|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gishur.gui2.DrawAtom | +--gishur.gui2.DrawObject | +--gishur.gui2.InputHandler
Base class for interactive DrawObjects
that can process
AWTEvents
.
Event processing with an InputHandler works in two ways:
First, every InputHandler that is inserted to an InputLayer
gets
all events occuring at the drawing surface (usally a DisplayManager
) -
that is the use InputHandler are made for. Via the
DrawObject.enableEvents(int)
, DrawObject.disableEvents(int)
methods,
it is possible to filter the events a InputHandler can get (this influences
also the 'internal generated' DrawEvent
s). If a InputHandler consumes
a consumable event, it will not be delivered to any other InputHandler same
hierachy (other InputHandlers inserted to different InputLayer
are not influenced by consumption). InputHandler can only get events, if they
are enabled.
The other way is to implement event listeners and register the InputHandler at
the watched DisplayObject
. In this case all enabled events of this
DisplayObject
were delivered to the InputHandler regardless of the
enabled-state of the InputHandler or of the enabled events mask (so this method
should only be used in a very restricted way).
Fields inherited from class gishur.gui2.DrawAtom |
BLOCK_REPAINT, MARK_RECALC, MARK_REPAINT, MARK_SIZE, REPAINT, UNBLOCK_REPAINT, USER_STATES_FIRST, USER_STATES_MASK |
Constructor Summary | |
protected |
InputHandler(java.lang.String property_prefix)
Constructs a new InputHandler which uses the given
prefix for all properties. |
Method Summary | |
boolean |
acceptConsumed()
Returns true , if this InputHandler accepts
consumed InputEvents (per default the setting is false ). |
static boolean |
allButtons(java.awt.event.MouseEvent e,
int buttonmask)
Returns true , if the modifiers of the given MouseEvent
contains all of the values of the given button mask. |
void |
disable()
Disables this InputHandler. |
protected void |
dispatchModifyEvent(int id,
int subtype,
java.lang.Object target)
Dispatches a new ModifyEvent . |
void |
enable()
Enables this InputHandler. |
boolean |
enabled()
Returns true , if the InputHandler is enabled and
ready to receive AWTEvents , otherwise false . |
protected void |
filterEvent(java.awt.AWTEvent e)
Filters events for this InputHandler and all of its members.
|
protected void |
onConsumedEvent(java.awt.event.InputEvent e)
Processes consumed InputEvents . |
static boolean |
oneButton(java.awt.event.MouseEvent e,
int buttonmask)
Returns true , if the modifiers of the given MouseEvent
contains one of the values of the given button mask. |
protected void |
preprocessEvent(int id,
DrawAtom sender)
Preprocesses the event specified via its id sent by the given source. |
protected void |
processActionEvent(java.awt.event.ActionEvent e)
Processes action events. |
protected void |
processAdjustmentEvent(java.awt.event.AdjustmentEvent e)
Processes adjustment events. |
protected void |
processComponentEvent(java.awt.event.ComponentEvent e)
Processes component events (other than mouse, key, focus, paint or window events). |
protected void |
processContainerEvent(java.awt.event.ContainerEvent e)
Processes container events. |
protected void |
processEvent(java.awt.AWTEvent e)
Processes events delivered to this InputHandler. |
protected void |
processFocusEvent(java.awt.event.FocusEvent e)
Processes focus events. |
protected void |
processItemEvent(java.awt.event.ItemEvent e)
Processes item events. |
protected void |
processKeyEvent(java.awt.event.KeyEvent e)
Processes key events. |
protected void |
processModifyEvent(ModifyEvent e)
Processes modification events. |
protected void |
processMouseEvent(java.awt.event.MouseEvent e)
Processes mouse events. |
protected void |
processMouseMotionEvent(java.awt.event.MouseEvent e)
Processes mouse motion events. |
protected void |
processPaintEvent(java.awt.event.PaintEvent e)
Processes paint events. |
protected void |
processTextEvent(java.awt.event.TextEvent e)
Processes text events. |
protected void |
processWindowEvent(java.awt.event.WindowEvent e)
Processes window events. |
protected void |
recalculate(RenderContext context,
PropertyStatusReader properties)
Forces the DrawObject to recalculate its representation.
|
void |
removeCursor()
Removes the mouse cursor. |
protected void |
sendEvent(java.awt.AWTEvent e)
Sends the given event to this InputHandler and to
all of its members. |
protected boolean |
setAcceptConsumed(boolean cons)
Sets the acceptance of consumed InputEvents (per default the setting is false ). |
void |
setCursor(java.awt.Cursor cursor)
Sets the mouse cursor to the given cursor. |
void |
setCursor(int cursor)
Sets the mouse cursor to the given cursor. |
Methods inherited from class gishur.gui2.DrawObject |
addDrawDependency, addPainter, blockRepaint, checkState, checkStateCleared, child, clear, clearCache, clearState, dependency, dirty, disableEvents, draw, draw, enableEvents, ensureRecalculate, findPainter, firstPainter, fullscreen, hide, hide, insert, levelMask, levelUsed, locate, makeDirty, makeDirty, next, next, nextPainter, parent, prepeareRenderContext, prev, prev, processDrawEvent, propertyReader, recalculate, remove, removeDrawDependency, repaint, screenTransformation, setFullscreen, setPaintBeforeMembers, setScreenTransformation, setState, show, show, state, state, unblockRepaint, unblockRepaint, visible |
Methods inherited from class gishur.gui2.DrawAtom |
addProperties, collectHits, dispatchEvent, displayManager, drawComponent, getBounds, getLocalProperty, getProperty, getProperty, getRequiredProperty, processMessage, properties, removeProperty, sendEvent, sendMessage, setBounds, setPropertiesTo, setProperty, setProperty, setProperty, setProperty, toString, toString, toStringDetail, toTreeString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
protected InputHandler(java.lang.String property_prefix)
InputHandler
which uses the given
prefix for all properties.property_prefix
- the prefix string used for all read
propertiesMethod Detail |
protected void recalculate(RenderContext context, PropertyStatusReader properties)
DrawObject
to recalculate its representation.
This method will only be called, if it became dirty via a call
to the DrawObject.makeDirty(boolean)
method or something has happened, that
causes all DrawAtoms
to recalculate their
representation.
This method should only be called by the render system.recalculate
in class DrawObject
context
- the RenderContext
to useproperties
- the PropertyStatusReader
to use for
reading propertiespublic final boolean enabled()
true
, if the InputHandler is enabled and
ready to receive AWTEvents
, otherwise false
.true
, if the InputHandler is enabled,
otherwise false
.public final void enable()
this
InputHandler. Only enabled InputHandler
can receive AWTEvents
and post them to their members.public final void disable()
this
InputHandler. So it no longer receives
AWTEvents
, neither its members.public final boolean acceptConsumed()
true
, if this
InputHandler
accepts
consumed InputEvents (per default the setting is false
).true
, if accepts consumed InputEvents.protected final boolean setAcceptConsumed(boolean cons)
false
).cons
- if true
, consumed InputEvents will be accepted.public static final boolean oneButton(java.awt.event.MouseEvent e, int buttonmask)
true
, if the modifiers of the given MouseEvent
contains one of the values of the given button mask.e
- the MouseEvent
with modifiers to testbuttonmask
- a mask of mouse buttons to testtrue
, if modifiers contains one of buttonmask
public static final boolean allButtons(java.awt.event.MouseEvent e, int buttonmask)
true
, if the modifiers of the given MouseEvent
contains all of the values of the given button mask.e
- the MouseEvent
with modifiers to testbuttonmask
- a mask of mouse buttons to testtrue
, if modifiers contains all of buttonmask
public void setCursor(java.awt.Cursor cursor)
cursor
- the java.awt.Cursor
to setpublic void setCursor(int cursor)
cursor
- the cursor-id to setpublic void removeCursor()
protected void dispatchModifyEvent(int id, int subtype, java.lang.Object target)
ModifyEvent
. The ModifyEvent
will have
this
InputHandler
as source.id
- type of the eventsubtype
- sub-type of the eventtarget
- target object that was modifiedprotected void preprocessEvent(int id, DrawAtom sender)
DrawAtom
itself
and by DrawAtom
where this
depends from. The method
will be called before events are filtered out.preprocessEvent
in class DrawAtom
id
- the event idsender
- the source of the eventDrawEvent
protected final void sendEvent(java.awt.AWTEvent e)
this
InputHandler
and to
all of its members. This method should only be called by the
filterEvent(java.awt.AWTEvent)
method.e
- the event to sendprotected void onConsumedEvent(java.awt.event.InputEvent e)
InputEvents
. In order to process the events
further, call sendEvent(java.awt.AWTEvent)
.e
- consumed InputEvent
.protected void filterEvent(java.awt.AWTEvent e)
this
InputHandler and all of its members.
This method should call sendEvent(java.awt.AWTEvent)
in order to process events
through this
InputHandler
and all of its members.e
- the source event. The event mask must be enabled in order to filter
that type of eventsprotected void processEvent(java.awt.AWTEvent e)
process<event type>Event
method for the given class of event.
The checking for enabled events will be done before the
call of this method.processEvent
in class DrawObject
e
- the event.DrawObject.processDrawEvent(gishur.gui2.event.DrawEvent)
,
processModifyEvent(gishur.core.event.ModifyEvent)
,
processMouseEvent(java.awt.event.MouseEvent)
,
processMouseMotionEvent(java.awt.event.MouseEvent)
,
processKeyEvent(java.awt.event.KeyEvent)
,
processContainerEvent(java.awt.event.ContainerEvent)
,
processFocusEvent(java.awt.event.FocusEvent)
,
processPaintEvent(java.awt.event.PaintEvent)
,
processWindowEvent(java.awt.event.WindowEvent)
,
processComponentEvent(java.awt.event.ComponentEvent)
,
processActionEvent(java.awt.event.ActionEvent)
,
processAdjustmentEvent(java.awt.event.AdjustmentEvent)
,
processItemEvent(java.awt.event.ItemEvent)
,
processTextEvent(java.awt.event.TextEvent)
protected void processModifyEvent(ModifyEvent e)
ModifyListener
, if this implements this
listener.
- Parameters:
e
- the event.
protected void processMouseEvent(java.awt.event.MouseEvent e)
MouseListener
, if this implements this
listener.
If the given element is already consumed, this method does nothing.
- Parameters:
e
- the event.
protected void processMouseMotionEvent(java.awt.event.MouseEvent e)
MouseMotionListener
, if this implements this
listener.
If the given element is already consumed, this method does nothing.
- Parameters:
e
- the event.
protected void processKeyEvent(java.awt.event.KeyEvent e)
KeyListener
, if this implements this
listener.
If the given element is already consumed, this method does nothing.
- Parameters:
e
- the event.
protected void processContainerEvent(java.awt.event.ContainerEvent e)
ContainerListener
, if this implements this
listener.
- Parameters:
e
- the event.
protected void processFocusEvent(java.awt.event.FocusEvent e)
FocusListener
, if this implements this
listener.
- Parameters:
e
- the event.
protected void processPaintEvent(java.awt.event.PaintEvent e)
e
- the event.protected void processWindowEvent(java.awt.event.WindowEvent e)
WindowListener
, if this
implements this
listener.e
- the event.protected void processComponentEvent(java.awt.event.ComponentEvent e)
ComponentListener
, if this implements this
listener.
- Parameters:
e
- the event.
protected void processActionEvent(java.awt.event.ActionEvent e)
ActionListener
, if this implements this
listener.
- Parameters:
e
- the event.
protected void processAdjustmentEvent(java.awt.event.AdjustmentEvent e)
AdjustmentListener
, if this implements this
listener.
- Parameters:
e
- the event.
protected void processItemEvent(java.awt.event.ItemEvent e)
ItemListener
, if this implements this
listener.
- Parameters:
e
- the event.
protected void processTextEvent(java.awt.event.TextEvent e)
TextListener
, if this implements this
listener.
- Parameters:
e
- the event.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |