org.tigris.gef.base
Class LayerManager

java.lang.Object
  extended by org.tigris.gef.base.LayerManager
All Implemented Interfaces:
java.io.Serializable

public class LayerManager
extends java.lang.Object
implements java.io.Serializable

This class implements a kind of Layer that contains other Layers. Layer's can be nested in an is-part-of tree. That tree can be walked to paint the contents of the view, find what the user clicked on, find a layer by name, save the contents to a file, etc.

See Also:
Serialized Form

Field Summary
protected  Layer _activeLayer
          In most editors one Layer is the active layer and all mouse clicks go to the contents of that layer.
 Editor _editor
           
protected  java.util.List _layers
          The Layer's contained within this LayerManager.
 
Constructor Summary
LayerManager(Editor editor)
          Construct a new LayerManager with no sublayers.
 
Method Summary
 void add(Fig f)
          When the user tries to add a new Fig to a LayerManager, pass that addition along to my active layer.
 void addLayer(Layer lay)
           
 void addLayer(Layer lay, boolean makeActive)
          Add a sublayer to this layer.
 void bringForward(Fig f)
          See comments above, this message is passed to my active layer.
 void bringToFront(Fig f)
          See comments above, this message is passed to my active layer.
 java.util.Enumeration elements()
          See comments above, this message is passed to my active layer.
 Layer findLayerNamed(java.lang.String aName)
          Find a layer with the given name somewhere in the layer tree.
 Layer getActiveLayer()
          Reply which layer is the active one.
 java.util.Collection getContents(java.util.Collection c)
          When an editor or some tool wants to look at all the Figs that are contained in this layer, reply the contents of my active layer.
 Editor getEditor()
           
 boolean getPaintActiveOnly()
           
 boolean getPaintLayers()
           
 Fig hit(java.awt.Rectangle r)
          See comments above, this message is passed to my active layer.
 void paint(java.awt.Graphics g)
          Paint the contents of this LayerManager by painting all layers.
 void paint(java.awt.Graphics g, FigPainter painter)
          Paint the contents of this LayerManager using a given painter by painting all layers.
 void postLoad()
           
 void postSave()
           
 void preSave()
           
 Fig presentationFor(java.lang.Object obj)
          Try to find a FigNode instance that presents the given Net-level object.
 void remove(Fig f)
          When the user tries to remove a new Fig from a LayerManager, pass that removal along to my active layer.
 void removeAll()
          See comments above, this message is passed to my active layer.
 void removeAllLayers()
           
 void removeLayer(Layer lay)
          Remove a sublayer to this layer.
 void reorder(Fig f, int function)
          See comments above, this message is passed to my active layer.
 void replaceActiveLayer(Layer layer)
           
 void replaceLayer(Layer oldLayer, Layer newLayer)
           
 void sendBackward(Fig f)
          See comments above, this message is passed to my active layer.
 void sendToBack(Fig f)
          See comments above, this message is passed to my active layer.
 void setActiveLayer(Layer lay)
          Make one of my layers the active one.
 void setEditor(Editor ed)
           
 void setPaintActiveOnly(boolean activeOnly)
           
 void setPaintLayers(boolean paintLayers)
           
 void setScale(double scale)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_layers

protected java.util.List _layers
The Layer's contained within this LayerManager.


_activeLayer

protected Layer _activeLayer
In most editors one Layer is the active layer and all mouse clicks go to the contents of that layer. For now I assume this, but I would like to avoid this assumption in the future.


_editor

public Editor _editor
Constructor Detail

LayerManager

public LayerManager(Editor editor)
Construct a new LayerManager with no sublayers.

Method Detail

addLayer

public void addLayer(Layer lay,
                     boolean makeActive)
Add a sublayer to this layer.


addLayer

public void addLayer(Layer lay)

removeAllLayers

public void removeAllLayers()

replaceLayer

public void replaceLayer(Layer oldLayer,
                         Layer newLayer)

replaceActiveLayer

public void replaceActiveLayer(Layer layer)

removeLayer

public void removeLayer(Layer lay)
Remove a sublayer to this layer.


findLayerNamed

public Layer findLayerNamed(java.lang.String aName)
Find a layer with the given name somewhere in the layer tree.


setActiveLayer

public void setActiveLayer(Layer lay)
Make one of my layers the active one.


getActiveLayer

public Layer getActiveLayer()
Reply which layer is the active one. In case LayerManager's are nested, this works recursively.


getContents

public java.util.Collection getContents(java.util.Collection c)
When an editor or some tool wants to look at all the Figs that are contained in this layer, reply the contents of my active layer. Maybe this should really reply _all_ the contents of all layers.


paint

public void paint(java.awt.Graphics g)
Paint the contents of this LayerManager by painting all layers.


paint

public void paint(java.awt.Graphics g,
                  FigPainter painter)
Paint the contents of this LayerManager using a given painter by painting all layers.


add

public void add(Fig f)
When the user tries to add a new Fig to a LayerManager, pass that addition along to my active layer.


remove

public void remove(Fig f)
When the user tries to remove a new Fig from a LayerManager, pass that removal along to my active layer.


removeAll

public void removeAll()
See comments above, this message is passed to my active layer.


elements

public java.util.Enumeration elements()
See comments above, this message is passed to my active layer.


hit

public Fig hit(java.awt.Rectangle r)
See comments above, this message is passed to my active layer.


presentationFor

public Fig presentationFor(java.lang.Object obj)
Try to find a FigNode instance that presents the given Net-level object.


sendToBack

public void sendToBack(Fig f)
See comments above, this message is passed to my active layer.


bringForward

public void bringForward(Fig f)
See comments above, this message is passed to my active layer.


sendBackward

public void sendBackward(Fig f)
See comments above, this message is passed to my active layer.


bringToFront

public void bringToFront(Fig f)
See comments above, this message is passed to my active layer.


reorder

public void reorder(Fig f,
                    int function)
See comments above, this message is passed to my active layer.


setEditor

public void setEditor(Editor ed)

getEditor

public Editor getEditor()

preSave

public void preSave()

postSave

public void postSave()

postLoad

public void postLoad()

setPaintActiveOnly

public void setPaintActiveOnly(boolean activeOnly)

getPaintActiveOnly

public boolean getPaintActiveOnly()

setPaintLayers

public void setPaintLayers(boolean paintLayers)

getPaintLayers

public boolean getPaintLayers()

setScale

public void setScale(double scale)