gishur.gui2
Class Layer

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

public class Layer
extends DrawAtom

Layers are the top-level groups for DisplayObjects.

Version:
1.0
Author:
Thomas Wolf
See Also:
LayerManager, DisplayObject, DisplayGroup, DrawObject

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
Layer()
          Default Layer Constructor.
 
Method Summary
 void add(DrawObject drw)
          Adds the DrawObject drw at the end of the layer.
 void add(DrawObject drw, boolean visible)
          Adds the DrawObject drw at the end of the layer.
 void add(DrawShadow drw)
          Adds the DrawShadow drw at the end of the layer.
 void clear()
          Removes all member DrawObjects from this layer.
protected  void draw(java.awt.Graphics g, RenderContext context)
          Draws this DrawAtom to the given Graphics g.
 DrawObject first()
          Returns the first element of the layer.
 RectangleShape getVisibleObjectArea(RectangleShape rect)
          Calculates the area of all visible non-fullscreen DrawAtoms.
 void hide()
          Hides the Layer (visible()()==false).
 void insert(DrawAtom p, DrawObject drw)
          Inserts the DrawObject drw in the layer before p.
 void insert(DrawAtom p, DrawObject drw, boolean visible)
          Inserts the DrawObject drw in the layer before p.
 void insert(DrawAtom p, DrawShadow drw)
          Inserts the DrawShadow drw in the layer before p.
 DrawObject last()
          Returns the last element of the layer.
protected  void recalculate(RenderContext context)
          Forces the DrawAtom to recalculate its representation.
 void remove(DrawObject drw)
          Removes the given DrawObject from this layer.
 void remove(DrawShadow drw)
          Removes the given DrawShadow from this layer.
 ScreenTransformation screenTransformation()
          Returns the screen transformation for this 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, preprocessEvent, 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

Layer

public Layer()
Default Layer 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

screenTransformation

public final ScreenTransformation screenTransformation()
Returns the screen transformation for this Layer.
Returns:
the screen transformation for this Layer.

first

public DrawObject first()
Returns the first element of the layer.
Returns:
first element

last

public DrawObject last()
Returns the last element of the layer.
Returns:
last element

add

public void add(DrawObject drw)
Adds the DrawObject drw at the end of the layer. The inserted element will be made visible via DrawObject.show(boolean).
Parameters:
drw - DrawObject to add

insert

public void insert(DrawAtom p,
                   DrawObject drw)
Inserts the DrawObject drw in the layer before p. The inserted element will be made visible via DrawObject.show(boolean).
Parameters:
p - group member to insert before or null to add at the end of the layer
drw - DrawObject to insert

add

public void add(DrawObject drw,
                boolean visible)
Adds the DrawObject drw at the end of the layer.
Parameters:
drw - DrawObject to add
visible - if true, the element will be made visible via DrawObject.show(boolean) else it will be hidden

insert

public void insert(DrawAtom p,
                   DrawObject drw,
                   boolean visible)
Inserts the DrawObject drw in the layer before p.
Parameters:
p - layer member to insert before or null to add at the end of the layer
drw - DrawObject to insert
visible - if true, the element will be made visible via DrawObject.show(boolean) else it will be hidden

remove

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

clear

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

add

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

insert

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

remove

public void remove(DrawShadow drw)
Removes the given DrawShadow from this layer.
Parameters:
drw - DrawShadow to remove

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).

getVisibleObjectArea

public RectangleShape getVisibleObjectArea(RectangleShape rect)
Calculates the area of all visible non-fullscreen DrawAtoms.
Parameters:
rect - initial RectangleShape to unite with (or null).
Returns:
the area (using the given RectangleShape, if !=null)

recalculate

protected final 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 final 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