sub_arctic.input
Class event

java.lang.Object
  |
  +--sub_arctic.input.event

public class event
extends java.lang.Object

This class represents an input event. It is a wrapper around java.awt.AWTEvent. In general for each public instance variable "v" in the original Event class there are access methods "v()" and "set_v()" in this class. One exception is that the x and y fields have been renamed global_x and global_y to better reflect their meaning in subArctic. In addition, this class introduces fields to maintain position in an object's local coordinate system and to record the root top_level object along with methods to manipulate these.

See Also:
AWTEvent

Field Summary
protected  java.awt.AWTEvent _awt_event
          The AWT event object being wrapped
protected  int _local_x
          X position in local coordinates of the object it is delivered to.
protected  int _local_y
          Y position in local coordinates of the object it is delivered to.
protected  top_level _root_interactor
          Top level interactor that this event occured in.
static int ACTION_PERFORMED
           
static int ALT_MASK
           
static int CHAR_UNDEFINED
           
static int CTRL_MASK
           
static int DOWN
           
static int END
           
static int F1
           
static int F10
           
static int F11
           
static int F12
           
static int F2
           
static int F3
           
static int F4
           
static int F5
           
static int F6
           
static int F7
           
static int F8
           
static int F9
           
static int FOCUS_GAINED
           
static int FOCUS_LOST
           
static int HOME
           
static int KEY_PRESSED
           
static int KEY_RELEASED
           
static int KEY_TYPED
           
static int LEFT
           
static int META_MASK
           
static int MOUSE_DRAGGED
           
static int MOUSE_ENTERED
           
static int MOUSE_EXITED
           
static int MOUSE_MOVED
           
static int MOUSE_PRESSED
           
static int MOUSE_RELEASED
           
static int PAGE_DOWN
           
static int PAGE_UP
           
static int RIGHT
           
static int SHIFT_MASK
           
static int UP
           
static int VK_0
           
static int VK_1
           
static int VK_2
           
static int VK_3
           
static int VK_4
           
static int VK_5
           
static int VK_6
           
static int VK_7
           
static int VK_8
           
static int VK_9
           
static int VK_A
           
static int VK_ACCEPT
           
static int VK_ADD
           
static int VK_ALT
           
static int VK_B
           
static int VK_BACK_QUOTE
           
static int VK_BACK_SLASH
           
static int VK_BACK_SPACE
           
static int VK_C
           
static int VK_CANCEL
           
static int VK_CAPS_LOCK
           
static int VK_CLEAR
           
static int VK_CLOSE_BRACKET
           
static int VK_COMMA
           
static int VK_CONTROL
           
static int VK_CONVERT
           
static int VK_D
           
static int VK_DECIMAL
           
static int VK_DELETE
           
static int VK_DIVIDE
           
static int VK_DOWN
           
static int VK_E
           
static int VK_END
           
static int VK_ENTER
           
static int VK_EQUALS
           
static int VK_ESCAPE
           
static int VK_F
           
static int VK_F1
           
static int VK_F10
           
static int VK_F11
           
static int VK_F12
           
static int VK_F2
           
static int VK_F3
           
static int VK_F4
           
static int VK_F5
           
static int VK_F6
           
static int VK_F7
           
static int VK_F8
           
static int VK_F9
           
static int VK_FINAL
           
static int VK_G
           
static int VK_H
           
static int VK_HELP
           
static int VK_HOME
           
static int VK_I
           
static int VK_INSERT
           
static int VK_J
           
static int VK_K
           
static int VK_KANA
           
static int VK_KANJI
           
static int VK_L
           
static int VK_LEFT
           
static int VK_M
           
static int VK_META
           
static int VK_MODECHANGE
           
static int VK_MULTIPLY
           
static int VK_N
           
static int VK_NONCONVERT
           
static int VK_NUM_LOCK
           
static int VK_NUMPAD0
           
static int VK_NUMPAD1
           
static int VK_NUMPAD2
           
static int VK_NUMPAD3
           
static int VK_NUMPAD4
           
static int VK_NUMPAD5
           
static int VK_NUMPAD6
           
static int VK_NUMPAD7
           
static int VK_NUMPAD8
           
static int VK_NUMPAD9
           
static int VK_O
           
static int VK_OPEN_BRACKET
           
static int VK_P
           
static int VK_PAGE_DOWN
           
static int VK_PAGE_UP
           
static int VK_PAUSE
           
static int VK_PERIOD
           
static int VK_PRINTSCREEN
           
static int VK_Q
           
static int VK_QUOTE
           
static int VK_R
           
static int VK_RIGHT
           
static int VK_S
           
static int VK_SCROLL_LOCK
           
static int VK_SEMICOLON
           
static int VK_SEPARATER
           
static int VK_SHIFT
           
static int VK_SLASH
           
static int VK_SPACE
           
static int VK_SUBTRACT
           
static int VK_T
           
static int VK_TAB
           
static int VK_U
           
static int VK_UNDEFINED
           
static int VK_UP
           
static int VK_V
           
static int VK_W
           
static int VK_X
           
static int VK_Y
           
static int VK_Z
           
static int WINDOW_ACTIVATED
           
static int WINDOW_CLOSED
           
static int WINDOW_CLOSING
           
static int WINDOW_DEACTIVATED
           
static int WINDOW_DEICONIFIED
           
static int WINDOW_ICONIFIED
           
static int WINDOW_OPENED
           
 
Constructor Summary
event(java.awt.AWTEvent other, top_level root)
          Construct one of these events from a normal AWT event.
event(event other)
          Copy constructor.
 
Method Summary
 java.awt.AWTEvent awt_event()
          Return the raw AWT event from within the sub_arctic event.
 int click_count()
          Alias for clickCount() using subArctic style name.
 int clickCount()
          AWT method: The number of consecutive clicks.
 boolean controlDown()
          AWT method: Checks if the control key is down.This call returns false if the underlying event doesn't know about the state of the modifiers.
 void global_to_local(interactor of_obj)
          Put event into the given object's local coordinates regardless of what coordinates it is in now.
 int global_x()
          AWT method: x coordinate of the event.
 int global_y()
          AWT method: x coordinate of the event.
static java.lang.String id_string(int id)
          Create a human readable string corresponding to an event id code.
 int id()
          AWT method: type of this event.
 void into_local(interactor of_obj)
          Change event which is currently placed in coords of the parent of the given object into one placed in the local coords of the given object.
 void into_parents(interactor of_obj)
          Change event which is currently placed in the given object's local coords into one placed in the coords of its parent.
 boolean is_action_key()
          Indicate wether the given event is an "action" keyboard event such as an arrow key.
 int key_code()
          Retrieve the key code for a keyboard event.
static java.lang.String key_string(int key)
          Create a human readable string corresponding to an event key code.
 int key()
          The character corresponding to the key that was pressed for a (non-action) keyboard event (or CHAR_UNDEFINED) if there is no corresponding character.
 int local_x()
          X position in local coordinates of the object it is delivered to.
 int local_y()
          Y position in local coordinates of the object it is delivered to.
 boolean metaDown()
          AWT method: Checks if the meta key is down.This call returns false if the underlying event doesn't know about the state of the modifiers.
static java.lang.String mod_string(int mod)
          Create a human readable string corresponding to an event modifier mask.
 int modifiers()
          AWT method: state of the modifier keys.
 void reset_to_global()
          Force event back into global coordinates
 top_level root_interactor()
          Top level interactor that this event occured in.
 void set_key(int k)
          Set the character corresponding to key that was pressed for a keyboard event.
 void set_local_x(int x)
          Set the X position in local coordinates of the object it is delivered to.
 void set_local_y(int y)
          Set the Y position in local coordinates of the object it is delivered to.
 void set_modifiers(int m)
          Set AWT field: This method sets the modifier mask.
 void set_root_interactor(top_level t)
          Set the top level interactor that this event occured in.
 boolean shiftDown()
          AWT method: Checks if the shift key is down.
 java.lang.Object source()
          AWT method
 java.lang.String toString()
          Convert event to a human readable string which describes it.
 void translatePoint(int x, int y)
          AWT method: Translates an event relative to the given component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_awt_event

protected java.awt.AWTEvent _awt_event
The AWT event object being wrapped

_local_x

protected int _local_x
X position in local coordinates of the object it is delivered to. The global_x field will retain the global coordinate value.

_local_y

protected int _local_y
Y position in local coordinates of the object it is delivered to. The global_y field will retain the global coordinate value.

_root_interactor

protected top_level _root_interactor
Top level interactor that this event occured in. Global coordinates are with respect to the origin of that object.

SHIFT_MASK

public static final int SHIFT_MASK

CTRL_MASK

public static final int CTRL_MASK

META_MASK

public static final int META_MASK

ALT_MASK

public static final int ALT_MASK

HOME

public static final int HOME

END

public static final int END

PAGE_UP

public static final int PAGE_UP

PAGE_DOWN

public static final int PAGE_DOWN

UP

public static final int UP

DOWN

public static final int DOWN

LEFT

public static final int LEFT

RIGHT

public static final int RIGHT

F1

public static final int F1

F2

public static final int F2

F3

public static final int F3

F4

public static final int F4

F5

public static final int F5

F6

public static final int F6

F7

public static final int F7

F8

public static final int F8

F9

public static final int F9

F10

public static final int F10

F11

public static final int F11

F12

public static final int F12

ACTION_PERFORMED

public static final int ACTION_PERFORMED

FOCUS_GAINED

public static final int FOCUS_GAINED

FOCUS_LOST

public static final int FOCUS_LOST

KEY_PRESSED

public static final int KEY_PRESSED

KEY_RELEASED

public static final int KEY_RELEASED

KEY_TYPED

public static final int KEY_TYPED

MOUSE_PRESSED

public static final int MOUSE_PRESSED

MOUSE_DRAGGED

public static final int MOUSE_DRAGGED

MOUSE_ENTERED

public static final int MOUSE_ENTERED

MOUSE_EXITED

public static final int MOUSE_EXITED

MOUSE_MOVED

public static final int MOUSE_MOVED

MOUSE_RELEASED

public static final int MOUSE_RELEASED

WINDOW_ACTIVATED

public static final int WINDOW_ACTIVATED

WINDOW_CLOSED

public static final int WINDOW_CLOSED

WINDOW_CLOSING

public static final int WINDOW_CLOSING

WINDOW_DEACTIVATED

public static final int WINDOW_DEACTIVATED

WINDOW_DEICONIFIED

public static final int WINDOW_DEICONIFIED

WINDOW_ICONIFIED

public static final int WINDOW_ICONIFIED

WINDOW_OPENED

public static final int WINDOW_OPENED

CHAR_UNDEFINED

public static final int CHAR_UNDEFINED

VK_0

public static final int VK_0

VK_1

public static final int VK_1

VK_2

public static final int VK_2

VK_3

public static final int VK_3

VK_4

public static final int VK_4

VK_5

public static final int VK_5

VK_6

public static final int VK_6

VK_7

public static final int VK_7

VK_8

public static final int VK_8

VK_9

public static final int VK_9

VK_A

public static final int VK_A

VK_ACCEPT

public static final int VK_ACCEPT

VK_ADD

public static final int VK_ADD

VK_ALT

public static final int VK_ALT

VK_B

public static final int VK_B

VK_BACK_QUOTE

public static final int VK_BACK_QUOTE

VK_BACK_SLASH

public static final int VK_BACK_SLASH

VK_BACK_SPACE

public static final int VK_BACK_SPACE

VK_C

public static final int VK_C

VK_CANCEL

public static final int VK_CANCEL

VK_CAPS_LOCK

public static final int VK_CAPS_LOCK

VK_CLEAR

public static final int VK_CLEAR

VK_CLOSE_BRACKET

public static final int VK_CLOSE_BRACKET

VK_COMMA

public static final int VK_COMMA

VK_CONTROL

public static final int VK_CONTROL

VK_CONVERT

public static final int VK_CONVERT

VK_D

public static final int VK_D

VK_DECIMAL

public static final int VK_DECIMAL

VK_DELETE

public static final int VK_DELETE

VK_DIVIDE

public static final int VK_DIVIDE

VK_DOWN

public static final int VK_DOWN

VK_E

public static final int VK_E

VK_END

public static final int VK_END

VK_ENTER

public static final int VK_ENTER

VK_EQUALS

public static final int VK_EQUALS

VK_ESCAPE

public static final int VK_ESCAPE

VK_F

public static final int VK_F

VK_F1

public static final int VK_F1

VK_F10

public static final int VK_F10

VK_F11

public static final int VK_F11

VK_F12

public static final int VK_F12

VK_F2

public static final int VK_F2

VK_F3

public static final int VK_F3

VK_F4

public static final int VK_F4

VK_F5

public static final int VK_F5

VK_F6

public static final int VK_F6

VK_F7

public static final int VK_F7

VK_F8

public static final int VK_F8

VK_F9

public static final int VK_F9

VK_FINAL

public static final int VK_FINAL

VK_G

public static final int VK_G

VK_H

public static final int VK_H

VK_HELP

public static final int VK_HELP

VK_HOME

public static final int VK_HOME

VK_I

public static final int VK_I

VK_INSERT

public static final int VK_INSERT

VK_J

public static final int VK_J

VK_K

public static final int VK_K

VK_KANA

public static final int VK_KANA

VK_KANJI

public static final int VK_KANJI

VK_L

public static final int VK_L

VK_LEFT

public static final int VK_LEFT

VK_M

public static final int VK_M

VK_META

public static final int VK_META

VK_MODECHANGE

public static final int VK_MODECHANGE

VK_MULTIPLY

public static final int VK_MULTIPLY

VK_N

public static final int VK_N

VK_NONCONVERT

public static final int VK_NONCONVERT

VK_NUM_LOCK

public static final int VK_NUM_LOCK

VK_NUMPAD0

public static final int VK_NUMPAD0

VK_NUMPAD1

public static final int VK_NUMPAD1

VK_NUMPAD2

public static final int VK_NUMPAD2

VK_NUMPAD3

public static final int VK_NUMPAD3

VK_NUMPAD4

public static final int VK_NUMPAD4

VK_NUMPAD5

public static final int VK_NUMPAD5

VK_NUMPAD6

public static final int VK_NUMPAD6

VK_NUMPAD7

public static final int VK_NUMPAD7

VK_NUMPAD8

public static final int VK_NUMPAD8

VK_NUMPAD9

public static final int VK_NUMPAD9

VK_O

public static final int VK_O

VK_OPEN_BRACKET

public static final int VK_OPEN_BRACKET

VK_P

public static final int VK_P

VK_PAGE_DOWN

public static final int VK_PAGE_DOWN

VK_PAGE_UP

public static final int VK_PAGE_UP

VK_PAUSE

public static final int VK_PAUSE

VK_PERIOD

public static final int VK_PERIOD

VK_PRINTSCREEN

public static final int VK_PRINTSCREEN

VK_Q

public static final int VK_Q

VK_QUOTE

public static final int VK_QUOTE

VK_R

public static final int VK_R

VK_RIGHT

public static final int VK_RIGHT

VK_S

public static final int VK_S

VK_SCROLL_LOCK

public static final int VK_SCROLL_LOCK

VK_SEMICOLON

public static final int VK_SEMICOLON

VK_SEPARATER

public static final int VK_SEPARATER

VK_SHIFT

public static final int VK_SHIFT

VK_SLASH

public static final int VK_SLASH

VK_SPACE

public static final int VK_SPACE

VK_SUBTRACT

public static final int VK_SUBTRACT

VK_T

public static final int VK_T

VK_TAB

public static final int VK_TAB

VK_U

public static final int VK_U

VK_UP

public static final int VK_UP

VK_V

public static final int VK_V

VK_W

public static final int VK_W

VK_X

public static final int VK_X

VK_Y

public static final int VK_Y

VK_Z

public static final int VK_Z

VK_UNDEFINED

public static final int VK_UNDEFINED
Constructor Detail

event

public event(java.awt.AWTEvent other,
             top_level root)
Construct one of these events from a normal AWT event.
Parameters:
AWTEvent - other the AWT event we are creating this from.
top_level - root the subArctic root object that this event is associated with (this provides its global coordinate system).

event

public event(event other)
Copy constructor.
Parameters:
event - other the event we are making a copy of.
Method Detail

awt_event

public java.awt.AWTEvent awt_event()
Return the raw AWT event from within the sub_arctic event. This is probably only useful if you have your own AWTEvent subtypes that you are wrapping in a sub_arctic event.
Returns:
AWTEvent the AWT event that the sub arctic event was derived from

source

public java.lang.Object source()
AWT method

id

public int id()
AWT method: type of this event.

global_x

public int global_x()
AWT method: x coordinate of the event. In our case this is the global position (position in the top_level root object). In cases where the event doesn't have any X coordinate (i.e. key events or other non-mouse events) we just return 0.

global_y

public int global_y()
AWT method: x coordinate of the event. In our case this is the global position (position in the top_level root object). In cases where the event doesn't have any X coordinate (i.e. key events or other non-mouse events) we just return 0.

key

public int key()
The character corresponding to the key that was pressed for a (non-action) keyboard event (or CHAR_UNDEFINED) if there is no corresponding character. Note: this is equivalent to the AWT call getKeyChar() cast to an int.

Backward compatability note: it used to be the case that "action keys" such as the arrow keys would return a special value (outside the unicode range) here. Now they return CHAR_UNDEFINED here (since the AWT codes for those keys are no longer disjoint from unicode characters). You must now use is_action_key() to determine if the event is an action key, and if it is, retrieve its code with key_code().


set_key

public void set_key(int k)
Set the character corresponding to key that was pressed for a keyboard event. This corresponds to the AWT method setKeyChar() with the integer argument cast to a char. If you call this method on an event which is not a keyboard event, it is ignored.

is_action_key

public boolean is_action_key()
Indicate wether the given event is an "action" keyboard event such as an arrow key. This is equivalent to the AWTEvent method isActionKey().

key_code

public int key_code()
Retrieve the key code for a keyboard event. This is equivalent to the AWTEvent method getKeyCode(). This returns VK_UNDEFINED if the event is not a keyboard event.

modifiers

public int modifiers()
AWT method: state of the modifier keys. If you call this on an event for which the modifiers are not reported you get a zero return value. Be aware that events in AWT other than things which are instances of InputEvent (or subclasses of it) or ActionEvent don't have a modifier state. Further, some subarctic events also don't have a modifier state (most notably animation events).

set_modifiers

public void set_modifiers(int m)
Set AWT field: This method sets the modifier mask. This call will only work on things which are KeyEvents. You can not set the modifiers on MouseEvents, even though they are subclasses of the InputEvent class. If you call this method on an event for which it doesn't make sense, it is ignored.

clickCount

public int clickCount()
AWT method: The number of consecutive clicks. This field is relevant only for MOUSE_PRESSED events. If the field isn't set it will be 0. Otherwise, it will be 1 for single-clicks, 2 for double-clicks, and so on. If you call this on a non mouse event, you will get a return value of 0.

click_count

public int click_count()
Alias for clickCount() using subArctic style name.

local_x

public int local_x()
X position in local coordinates of the object it is delivered to. The global_x field will retain the global coordinate value. If you call this method on an event which is not a mouse event, you'll get the coordinate 0 translated into the local coordinate system. I.e. all events which don't have an X coordinate are assumed to have occurred at a global position of 0.

set_local_x

public void set_local_x(int x)
Set the X position in local coordinates of the object it is delivered to. The global_x field will retain the global coordinate value.

local_y

public int local_y()
Y position in local coordinates of the object it is delivered to. The global_y field will retain the global coordinate value.If you call this method on an event which is not a mouse event, you'll get the coordinate 0 translated into the local coordinate system. I.e. all events which don't have an Y coordinate are assumed to have occurred at a global position of 0.

set_local_y

public void set_local_y(int y)
Set the Y position in local coordinates of the object it is delivered to. The global_y field will retain the global coordinate value.

root_interactor

public top_level root_interactor()
Top level interactor that this event occured in. Global coordinates are with respect to the origin of that object.

set_root_interactor

public void set_root_interactor(top_level t)
Set the top level interactor that this event occured in. Global coordinates are with respect to the origin of that object. Note, this does not update coordinates for you and in general needs to be used with great care.

into_local

public void into_local(interactor of_obj)
Change event which is currently placed in coords of the parent of the given object into one placed in the local coords of the given object. This only works if we know the coordinate system of the event in advance. If this is now know, use global_to_local() instead.

See Also:
global_to_local(sub_arctic.lib.interactor)

into_parents

public void into_parents(interactor of_obj)
Change event which is currently placed in the given object's local coords into one placed in the coords of its parent. This only works if we know the coordinate system of the event in advance. If this is not know, use reset_to_global() to get the event into a known coordinate system.

See Also:
into_local(sub_arctic.lib.interactor), global_to_local(sub_arctic.lib.interactor), reset_to_global()

global_to_local

public void global_to_local(interactor of_obj)
Put event into the given object's local coordinates regardless of what coordinates it is in now.

reset_to_global

public void reset_to_global()
Force event back into global coordinates

id_string

public static java.lang.String id_string(int id)
Create a human readable string corresponding to an event id code.
Parameters:
int - id the event id code.
Returns:
String a string with the human readable name of the event type.

key_string

public static java.lang.String key_string(int key)
Create a human readable string corresponding to an event key code.
Parameters:
int - key the key code.
Returns:
String a string with the human readable name of the key code.

mod_string

public static java.lang.String mod_string(int mod)
Create a human readable string corresponding to an event modifier mask.
Parameters:
int - mod the modifier mask.
Returns:
String a string with the human readable dump of the modifier mask.

toString

public java.lang.String toString()
Convert event to a human readable string which describes it.
Overrides:
toString in class java.lang.Object

translatePoint

public void translatePoint(int x,
                           int y)
AWT method: Translates an event relative to the given component. This involves at a minimum translating the coordinates so they make sense within the given component. It may also involve translating a region in the case of an expose event. This event has no effect if the underlying AWT event cannot be translated. At the present time, only MouseEvent can be translated.
For subArctic this affects the global position of the event. (You rarely want or need to do this). The local position is adjusted accordingly.
Parameters:
x - the x coordinate
y - the y coordinate

shiftDown

public boolean shiftDown()
AWT method: Checks if the shift key is down. This call returns false if the underlying event doesn't know about the state of the modifiers.
See Also:
modifiers(), controlDown(), metaDown()

controlDown

public boolean controlDown()
AWT method: Checks if the control key is down.This call returns false if the underlying event doesn't know about the state of the modifiers.
See Also:
modifiers(), shiftDown(), metaDown()

metaDown

public boolean metaDown()
AWT method: Checks if the meta key is down.This call returns false if the underlying event doesn't know about the state of the modifiers.
See Also:
modifiers(), shiftDown(), controlDown()