public abstract class GBoardInputHandler
extends java.lang.Object
An input handler class should inherit from this (abstract) class, call the constructor with the desired mask, and implement the run procedure. To activate input handler a pushInputHandler on the GBoard object is required.
invariant: validInputMask(mask())
This class follows DbC(tm) methodology. Where possible, contracts are implement with JML and native's Java assert.
Modifier and Type | Field and Description |
---|---|
static int |
gboardClosingMask |
static int |
keyEventType |
static int |
keyPressedMask |
static int |
keyReleasedMask |
static int |
keyTypedMask |
static int |
maxMaskValue |
static int |
mouseClickedMask |
static int |
mouseEventType |
static int |
mousePressedMask |
static int |
mouseReleasedMask |
static int |
windowEventType |
Constructor and Description |
---|
GBoardInputHandler(int mask)
Constructs a new GBoardInputHandler accepting the events defined by the mask.
|
Modifier and Type | Method and Description |
---|---|
boolean |
activated(int event)
Is current input handler object activated by event?
|
int |
mask()
The current mask value.
|
abstract void |
run(GBoard board,
int line,
int column,
int layer,
int type,
int code,
Gelem gelem)
Procedure to be automatically executed by
GBoard when
the input handler object is activated. |
void |
setMask(int mask)
Defines a new input mask.
|
boolean |
validEventType(int type) |
static boolean |
validInputMask(int mask)
Checks if input mask is valid.
|
public static final int keyPressedMask
public static final int keyReleasedMask
public static final int keyTypedMask
public static final int mousePressedMask
public static final int mouseReleasedMask
public static final int mouseClickedMask
public static final int gboardClosingMask
public static final int maxMaskValue
public static final int keyEventType
public static final int mouseEventType
public static final int windowEventType
public GBoardInputHandler(int mask)
requires: validInputMask(mask)
ensures: mask() == mask
mask
- the desired maskpublic static boolean validInputMask(int mask)
mask
- the maskboolean
true if mask okpublic boolean validEventType(int type)
public int mask()
int
maskpublic void setMask(int mask)
requires: validInputMask(mask)
ensures: mask() == mask
mask
- the new maskpublic boolean activated(int event)
event
- the event mask valueboolean
true if activated, false otherwisepublic abstract void run(GBoard board, int line, int column, int layer, int type, int code, Gelem gelem)
GBoard
when
the input handler object is activated.board
- GBoard objectline
- the line numbercolumn
- the column numberlayer
- the layer numbertype
- the event type (keyEventType or mouseEventType or windowEventType)code
- the event code (KeyEvent.getKeyCode() or MouseEvent.getButton() or WindowEvent.WINDOW_CLOSED)gelem
- object