gishur.gui2
Class InputLayer

java.lang.Object
  |
  +--gishur.gui2.DrawAtom
        |
        +--gishur.gui2.InputLayer

public class InputLayer
extends DrawAtom

An InputLayer is a special layer which accepts only InputHandler as members. An InputLayer delivers all events dispatched at the drawing surface (the component, it must be an DisplayManager, where the parent DrawManager paints all objects on) to its members if they implement the corresponding Listener interface.

Version:
1.0
Author:
Thomas Wolf

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
InputLayer()
          Default constructor.
 
Method Summary
 void add(InputHandler drw)
          Adds the InputHandler drw at the end of the layer.
 void add(InputHandler drw, boolean enable)
          Adds the InputHandler drw at the end of the layer.
 void clear()
          Removes all member DrawObjects from this layer.
 void disable()
          Disables this InputLayer.
protected  void draw(java.awt.Graphics g, RenderContext context)
          Draws this DrawAtom to the given Graphics g.
 void enable()
          Enables this InputLayer.
 boolean enabled()
          Returns true, if the InputLayer is enabled, otherwise false.
 boolean eventProcessThread()
          Returns true, if the InputLayer uses an extra event thread for event processing.
 InputHandler first()
          Returns the first element of the input layer.
 void hide()
          Hides the Layer (visible()()==false).
 void insert(InputHandler p, InputHandler drw)
          Inserts the InputHandler drw in the layer before p.
 void insert(InputHandler p, InputHandler drw, boolean enable)
          Inserts the InputHandler drw in the layer before p.
 InputHandler last()
          Returns the last element of the input layer.
protected  void preprocessEvent(int id, DrawAtom sender)
          Preprocesses the event specified via its id sent by the given source.
protected  void recalculate(RenderContext context)
          Forces the DrawAtom to recalculate its representation.
 void remove(InputHandler drw)
          Removes the given InputHandler from this layer.
 void setEventProcessThread(boolean thread)
          Enables the InputLayer to use an extra event thread.
 void setEventThreadPriority(int priority)
          Sets the priority of the thread that processes incoming events throughout the layer.
 void setScreenTransformation(ScreenTransformation transform)
          Sets the screen transformation for this Layer.
 void show()
          Shows the Layer (visible()()==true).
 boolean visible()
          Returns true, if the Layer is visible.
 
Methods inherited from class gishur.gui2.DrawAtom
addProperties, collectHits, dispatchEvent, displayManager, drawComponent, getBounds, getLocalProperty, getProperty, getProperty, getRequiredProperty, locate, prepeareRenderContext, 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

InputLayer

public InputLayer()
Default constructor.
Method Detail

setScreenTransformation

public final void setScreenTransformation(ScreenTransformation transform)
Sets the screen transformation for this Layer. The transformation will be stored under the key "screen_transformation" in this layers properties list. To initialize the ScreenTransformation correctly, use this method instead of DrawAtom.setProperty(java.lang.String, java.lang.Object).
Parameters:
transform - the new ScreenTransformation

eventProcessThread

public boolean eventProcessThread()
Returns true, if the InputLayer uses an extra event thread for event processing.
Returns:
true, if the InputLayer uses an extra event thread for event processing.

setEventProcessThread

public void setEventProcessThread(boolean thread)
Enables the InputLayer to use an extra event thread.
Parameters:
thread - if true, use extra event thread

setEventThreadPriority

public void setEventThreadPriority(int priority)
Sets the priority of the thread that processes incoming events throughout the layer. The priority must be in the range Thread.MIN_PRIORITY to Thread.MAX_PRIORITY.
Parameters:
priority - the new priority for the event processing thread

first

public InputHandler first()
Returns the first element of the input layer.
Returns:
first element

last

public InputHandler last()
Returns the last element of the input layer.
Returns:
last element

add

public void add(InputHandler drw)
Adds the InputHandler drw at the end of the layer.
Parameters:
drw - InputHandler to add

insert

public void insert(InputHandler p,
                   InputHandler drw)
Inserts the InputHandler drw in the layer before p.
Parameters:
p - group member to insert before or null to add at the end of the layer
drw - InputHandler to insert

add

public void add(InputHandler drw,
                boolean enable)
Adds the InputHandler drw at the end of the layer.
Parameters:
drw - InputHandler to add
enable - if true, the element will be enabled via InputHandler.enable() else it will be disabled via InputHandler.disable()

insert

public void insert(InputHandler p,
                   InputHandler drw,
                   boolean enable)
Inserts the InputHandler drw in the layer before p.
Parameters:
p - layer member to insert before or null to add at the end of the layer
drw - InputHandler to insert
enable - if true, the element will be enabled via InputHandler.enable() else it will be disabled via InputHandler.disable()

remove

public void remove(InputHandler drw)
Removes the given InputHandler from this layer. If the specified InputHandler has members, all members were removed first. Insertion of the InputHandler inserts only the InputHandler - without its members.
Parameters:
drw - InputHandler to remove

clear

public void clear()
Removes all member DrawObjects from this layer.

visible

public boolean visible()
Returns true, if the Layer is visible.
Returns:
true, if visible

hide

public void hide()
Hides the Layer (visible()()==false).

show

public void show()
Shows the Layer (visible()()==true).

enabled

public final boolean enabled()
Returns true, if the InputLayer is enabled, otherwise false.
Returns:
true, if the InputLayer is enabled, otherwise false.

enable

public final void enable()
Enables this InputLayer. Only if the InputLayer is enabled, it can post events to its members.

disable

public final void disable()
Disables this InputLayer. So it no longer posts AWTEvents to its members.

preprocessEvent

protected void preprocessEvent(int id,
                               DrawAtom sender)
Preprocesses the event specified via its id sent by the given source. This method will be called by events produced by the DrawAtom itself and by DrawAtom where this depends from. The method will be called before events are filtered out.
Overrides:
preprocessEvent in class DrawAtom
Parameters:
id - the event id
sender - the source of the event
See Also:
DrawEvent

recalculate

protected void recalculate(RenderContext context)
Forces the DrawAtom to recalculate its representation. This method will only be called, if it became dirty via a call to the #makeDirty method or something has happened, that causes all DrawAtoms to recalculate their representation. This method should only be called by the render system.
Overrides:
recalculate in class DrawAtom
Parameters:
context - the RenderContext to use

draw

protected void draw(java.awt.Graphics g,
                    RenderContext context)
Draws this DrawAtom to the given Graphics g. This method should only be called by the render system.
Overrides:
draw in class DrawAtom
Parameters:
g - Graphics for drawing
context - the RenderContext to use
Throws:
DrawException - if invalid call to this method