gishur.gui2
Class DrawAtom

java.lang.Object
  |
  +--gishur.gui2.DrawAtom
Direct Known Subclasses:
BackgroundLayer, DrawManager, DrawObject, DrawShadow, InputLayer, Layer

public abstract class DrawAtom
extends java.lang.Object

DrawAtom is the basis class for all classes in the rendering hierachy. DrawAtoms can be used to build a hierachy. The following points yield for parent DrawAtoms and their members:

Version:
2.0
Author:
Thomas Wolf

Field Summary
protected static java.lang.String BLOCK_REPAINT
           
protected static java.lang.String MARK_RECALC
           
protected static java.lang.String MARK_REPAINT
           
protected static java.lang.String MARK_SIZE
           
protected static java.lang.String REPAINT
           
protected static java.lang.String UNBLOCK_REPAINT
           
static int USER_STATES_FIRST
          The first bit in the user states mask.
static int USER_STATES_MASK
          Mask of users states.
 
Method Summary
 void addProperties(DrawProperties properties)
          Adds the given properties list to this DrawAtoms properties list.
 List collectHits(int x, int y, List l)
          Collects all DrawAtoms rekursively that were hitted by the point (x,y) and stores them together with their locate(int, int)-value in the List l.
protected  void dispatchEvent(java.awt.AWTEvent e)
          Dispatches the given event e. {
protected  DisplayManager displayManager()
          Returns the DisplayManager that manages the redrawing.
protected abstract  void draw(java.awt.Graphics g, RenderContext context)
          Draws this DrawAtom to the given Graphics g.
 java.awt.Component drawComponent()
          Returns the component where all DrawAtoms draw on.
protected  RectangleShape getBounds()
          Returns the bounds of the DrawAtom in absolute screen coordinates.
 java.lang.Object getLocalProperty(java.lang.String key)
          Returns the value to which the specified key is mapped in the properties list of this DrawAtom.
 java.lang.Object getProperty(java.lang.String key)
          Returns the value to which the specified key is mapped in the properties list of this DrawAtom or (if no properties list is assigned or the key is not contained) of the parent DrawAtom.
 java.lang.Object getProperty(java.lang.String key, java.lang.Object default_value)
          Returns the value to which the specified key is mapped in the properties list of this DrawAtom or (if no properties list is assigned or the key is not contained) of the parent DrawAtom.
 java.lang.Object getRequiredProperty(java.lang.String key)
          Returns the value to which the specified key is mapped in the properties list of this DrawAtom or (if no properties list is assigned or the key is not contained) of the parent DrawAtom.
 java.lang.String locate(int x, int y)
          Locates the point (x,y).
protected  void prepeareRenderContext(RenderContext context)
          Prepeares the RenderContext before recalulation or drawing via a call to recalculate(gishur.gui2.RenderContext)/draw(Graphics,RenderContext).
protected  void preprocessEvent(int id, DrawAtom sender)
          Preprocesses the event specified via its id sent by the given source.
protected  java.lang.Object processMessage(java.lang.String id_string, java.lang.Object argument)
          Processes a given message.
 DrawProperties properties()
          Returns the DrawProperties object of this DrawAtom.
protected abstract  void recalculate(RenderContext context)
          Forces the DrawAtom to recalculate its representation.
 java.lang.Object removeProperty(java.lang.String key)
          Removes the key (and its corresponding value) from this DrawAtom's properties lies.
protected  void sendEvent(int id)
          Sends an event to all dependend DrawAtoms.
protected  java.lang.Object sendMessage(java.lang.String id_string, java.lang.Object argument)
          Sends a message with a given id-string up the drawing hierachy.
protected  void setBounds(int x, int y, int w, int h)
          Sets the bounds of the DrawAtom in absolute screen coordinates.
 void setPropertiesTo(DrawProperties properties)
          Sets the DrawProperties object for this DrawAtom.
 void setProperty(java.lang.String key, boolean value)
          Maps the specified key to the specified value in this DrawAtom's properties list.
 void setProperty(java.lang.String key, double value)
          Maps the specified key to the specified value in this DrawAtom's properties list.
 void setProperty(java.lang.String key, int value)
          Maps the specified key to the specified value in this DrawAtom's properties list.
 java.lang.Object setProperty(java.lang.String key, java.lang.Object value)
          Maps the specified key to the specified value in this DrawAtom's properties list.
 java.lang.String toString()
          Returns a string representation of the object.
 java.lang.String toString(boolean ddata, boolean odata, boolean pdata, int level)
          Returns a string representation of the object.
 java.lang.String toStringDetail()
          Returns a string representation of the object, excluding class name and details of the base DrawAtom (like properties or members list).
 java.lang.String toTreeString()
          Returns a String-Representation of the drawing hierachy rooted by this DrawAtom (for debugging reasons).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MARK_RECALC

protected static final java.lang.String MARK_RECALC

MARK_REPAINT

protected static final java.lang.String MARK_REPAINT

MARK_SIZE

protected static final java.lang.String MARK_SIZE

REPAINT

protected static final java.lang.String REPAINT

BLOCK_REPAINT

protected static final java.lang.String BLOCK_REPAINT

UNBLOCK_REPAINT

protected static final java.lang.String UNBLOCK_REPAINT

USER_STATES_MASK

public static final int USER_STATES_MASK
Mask of users states.

USER_STATES_FIRST

public static final int USER_STATES_FIRST
The first bit in the user states mask.
Method Detail

toString

public java.lang.String toString()
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object.
Overrides:
toString in class java.lang.Object
Returns:
a string representation of the object.

toString

public java.lang.String toString(boolean ddata,
                                 boolean odata,
                                 boolean pdata,
                                 int level)
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object.
Parameters:
ddata - return detailed data of this object
odata - return basic data of this object
pdata - return properties data of this object
level - member level (<0 for all members, ==0 for no members)
Returns:
a string representation of the object.

toStringDetail

public java.lang.String toStringDetail()
Returns a string representation of the object, excluding class name and details of the base DrawAtom (like properties or members list). This method will be called by #toString(boolean,boolean,int) and toString().
Returns:
string representation of class details

toTreeString

public java.lang.String toTreeString()
Returns a String-Representation of the drawing hierachy rooted by this DrawAtom (for debugging reasons).
Returns:
String-Representation of the drawing hierachy

sendMessage

protected final java.lang.Object sendMessage(java.lang.String id_string,
                                             java.lang.Object argument)
Sends a message with a given id-string up the drawing hierachy. On its way, processMessage(java.lang.String, java.lang.Object) will be called. If this method returns true, the message will be consumed andno longer propagated along the drawing hierachy.
Parameters:
id_string - the id String
argument - the message argument
Returns:
the response to the message, if the message was consumed by some object in the drawing hierachy.

processMessage

protected java.lang.Object processMessage(java.lang.String id_string,
                                          java.lang.Object argument)
Processes a given message. This method will be called via sendMessage(java.lang.String, java.lang.Object). If the returned value is not null, the message will be consumed and no longer send up the drawing hierachy.
Parameters:
id_string - the id String
argument - the message argument
Returns:
if !=null, the object will be sent back as response

sendEvent

protected final void sendEvent(int id)
Sends an event to all dependend DrawAtoms.
Parameters:
id - the event id
See Also:
DrawEvent

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. This implementation of the method answers to the events DrawEvent.DIRTY,DrawEvent.HIDE,DrawEvent.SHOW sent by other DrawAtoms with the appropriate action on this DrawAtom. To avoid that, simply overwrite this method.
Parameters:
id - the event id
sender - the source of the event
See Also:
DrawEvent

dispatchEvent

protected void dispatchEvent(java.awt.AWTEvent e)
Dispatches the given event e. DrawAtoms deliver their events simply to their parent DrawAtoms
Parameters:
e - event to dispatch

getBounds

protected final RectangleShape getBounds()
Returns the bounds of the DrawAtom in absolute screen coordinates.
Returns:
bounds of the DrawAtom.

setBounds

protected final void setBounds(int x,
                               int y,
                               int w,
                               int h)
Sets the bounds of the DrawAtom in absolute screen coordinates. If the area is empty or negative, the DrawAtom will have no

recalculate

protected abstract 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_int method (and #repaint) or something has happened, that causes all DrawAtoms to recalculate their representation. This method should only be called by the render system.
Parameters:
context - the RenderContext to use

prepeareRenderContext

protected void prepeareRenderContext(RenderContext context)
Prepeares the RenderContext before recalulation or drawing via a call to recalculate(gishur.gui2.RenderContext)/draw(Graphics,RenderContext).
Parameters:
context - RenderContext to prepeare

draw

protected abstract 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.
Parameters:
g - Graphics for drawing
context - the RenderContext to use
Throws:
DrawException - if invalid call to this method

locate

public java.lang.String locate(int x,
                               int y)
Locates the point (x,y). If the point lies outside of the DrawAtom's bounds null will be returned, otherwise a String value will be returned that identifies the part that hits the given point. In this implementation of locate, simply a non-null String will be returned if the point lies inside the boundaries of the object. Overwrite this method in order to get more useful resultats.
Parameters:
x,y - point to locate
Returns:
null for no hit, otherwise the name of the element that hits the point.

collectHits

public final List collectHits(int x,
                              int y,
                              List l)
Collects all DrawAtoms rekursively that were hitted by the point (x,y) and stores them together with their locate(int, int)-value in the List l. The order in the list represents the visibility order (the last painted object on top).
Parameters:
x,y - point to test
l - List where to store hitted DrawAtoms (and their locate value)
Returns:
the List l

drawComponent

public java.awt.Component drawComponent()
Returns the component where all DrawAtoms draw on.
Returns:
Component where all DrawAtoms draw onto.

displayManager

protected DisplayManager displayManager()
Returns the DisplayManager that manages the redrawing.
Returns:
DisplayManager.

properties

public final DrawProperties properties()
Returns the DrawProperties object of this DrawAtom.
Returns:
Properties list of this DrawAtom.

setPropertiesTo

public final void setPropertiesTo(DrawProperties properties)
Sets the DrawProperties object for this DrawAtom.
Parameters:
properties - the new properties list for this DrawAtom

addProperties

public final void addProperties(DrawProperties properties)
Adds the given properties list to this DrawAtoms properties list. Already defined key were overwritten by this operation.
Parameters:
properties - the properties list to add to this DrawAtom

getProperty

public final java.lang.Object getProperty(java.lang.String key)
Returns the value to which the specified key is mapped in the properties list of this DrawAtom or (if no properties list is assigned or the key is not contained) of the parent DrawAtom.
Parameters:
key - a key in the properties list
Returns:
the value to which the key is mapped in a properties list; null if the key is not mapped to any value in the properties lists of this object and parent object(s).

getProperty

public final java.lang.Object getProperty(java.lang.String key,
                                          java.lang.Object default_value)
Returns the value to which the specified key is mapped in the properties list of this DrawAtom or (if no properties list is assigned or the key is not contained) of the parent DrawAtom. If this properties is not set (on this DrawAtom and all of its parents), the specified default value for that property will be returned.
Parameters:
key - a key in the properties list
default_value - the default value for the property that will be returned if the key is not mapped to a value
Returns:
the value to which the key is mapped in a properties list; default_value if the key is not mapped to any value in the properties lists of this object and parent object(s).

getRequiredProperty

public final java.lang.Object getRequiredProperty(java.lang.String key)
Returns the value to which the specified key is mapped in the properties list of this DrawAtom or (if no properties list is assigned or the key is not contained) of the parent DrawAtom. If the key was not found in any of the properties lists, a DrawException will be thrown.
Parameters:
key - a key in the properties list
Returns:
the value to which the key is mapped in a properties list
Throws:
DrawException - if key not found

getLocalProperty

public final java.lang.Object getLocalProperty(java.lang.String key)
Returns the value to which the specified key is mapped in the properties list of this DrawAtom. If this DrawAtom has no properties list or the specified key is not contained, null will be returned.
Parameters:
key - a key in the properties list
Returns:
the value to which the key is mapped in a properties list; null if the key is not mapped to any value in this DrawAtoms properties list.

setProperty

public final java.lang.Object setProperty(java.lang.String key,
                                          java.lang.Object value)
Maps the specified key to the specified value in this DrawAtom's properties list. Neither the key nor the value can be null. If this DrawAtom has no properties list, a new properties list will be created.
Parameters:
key - the properties key
value - the value
Returns:
the previous value of the specified key in this properties list, or null if it did not have one.

removeProperty

public java.lang.Object removeProperty(java.lang.String key)
Removes the key (and its corresponding value) from this DrawAtom's properties lies. This method does nothing if the key is not in this DrawAtom's properties list.
Parameters:
key - the key that needs to be removed
Returns:
the value to which the key had been mapped in this properties list, or null if the key did not have a mapping

setProperty

public final void setProperty(java.lang.String key,
                              boolean value)
Maps the specified key to the specified value in this DrawAtom's properties list. The key can not be null. If this DrawAtom has no properties list, a new properties list will be created.
Parameters:
key - the properties key
value - the value

setProperty

public final void setProperty(java.lang.String key,
                              int value)
Maps the specified key to the specified value in this DrawAtom's properties list. The key can not be null. If this DrawAtom has no properties list, a new properties list will be created.
Parameters:
key - the properties key
value - the value

setProperty

public final void setProperty(java.lang.String key,
                              double value)
Maps the specified key to the specified value in this DrawAtom's properties list. The key can not be null. If this DrawAtom has no properties list, a new properties list will be created.
Parameters:
key - the properties key
value - the value