bibliothek.gui.dock.control
Class ModifierMask

java.lang.Object
  extended by bibliothek.gui.dock.control.ModifierMask

public class ModifierMask
extends Object

A ModifierMask represents a pattern that tells what modifier keys are currently pressed. Modifier keys are keys like ctrl, shift or alt.
This class will be used to check the result of InputEvent.getModifiersEx().

Author:
Benjamin Sigg

Field Summary
static int KEY_MASK
          all the masks for which a ModifierMask looks out
 
Constructor Summary
ModifierMask(int mask)
          Creates a new mask which allows only modifiers that match exactly mask.
ModifierMask(int on, int off)
          Creates a new mask.
 
Method Summary
 boolean equals(Object obj)
           
 int getOffmask()
          Gets the mask of the modifiers which must not be pressed.
 int getOnmask()
          Gets the mask of modifiers which must be pressed in order to activate this.
 int hashCode()
           
 boolean matches(int modifiers)
          Tells whether this ModifierMask relates to modifiers or not.
 String onMaskToString()
          Creates a string that represents the on-mask.
 void setOffmask(int offmask)
          Sets the mask of the modifiers which must not be pressed in order to activate this mask.
 void setOnmask(int onmask)
          Sets the mask of the modifiers which must be pressed in order to activate this mask.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_MASK

public static int KEY_MASK
all the masks for which a ModifierMask looks out

Constructor Detail

ModifierMask

public ModifierMask(int mask)
Creates a new mask which allows only modifiers that match exactly mask.

Parameters:
mask - the mask to match

ModifierMask

public ModifierMask(int on,
                    int off)
Creates a new mask.

Parameters:
on - the keys that must be pressed
off - the keys that must not be pressed
Method Detail

onMaskToString

public String onMaskToString()
Creates a string that represents the on-mask.

Returns:
the string

matches

public boolean matches(int modifiers)
Tells whether this ModifierMask relates to modifiers or not. The modifiers have the same form as InputEvent.getModifiersEx() would have.

Parameters:
modifiers - the modifiers from an InputEvent
Returns:
true if this mask matches the modifiers

setOnmask

public void setOnmask(int onmask)
Sets the mask of the modifiers which must be pressed in order to activate this mask.

Parameters:
onmask - the modifiers that must be pressed

getOnmask

public int getOnmask()
Gets the mask of modifiers which must be pressed in order to activate this.

Returns:
the mask of active modifiers

setOffmask

public void setOffmask(int offmask)
Sets the mask of the modifiers which must not be pressed in order to activate this mask.

Parameters:
offmask - the modifiers that must not be pressed

getOffmask

public int getOffmask()
Gets the mask of the modifiers which must not be pressed.

Returns:
the mask of inactive modifiers

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object