org.tigris.gef.base
Class LayerDiagram

java.lang.Object
  extended by org.tigris.gef.base.Layer
      extended by org.tigris.gef.base.LayerDiagram
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
LayerPerspective

public class LayerDiagram
extends Layer

A Layer like found in many drawing applications. It contains a collection of Fig's, ordered from back to front. Each LayerDiagram contains part of the overall picture that the user is drawing. Needs-More-Work: eventually add a "Layers" menu to the Editor. FEATURE: graph_visualization

See Also:
Serialized Form

Field Summary
protected static int _nextLayerNumbered
          A counter so that layers have default names like 'One', 'Two', ...
 
Fields inherited from class org.tigris.gef.base.Layer
_editors, _onMenu
 
Constructor Summary
LayerDiagram()
          Construct a new LayerDiagram with a default name and do not put it on the Layer's menu.
LayerDiagram(java.lang.String name)
          Construct a new LayerDiagram with the given name, and add it to the menu of layers.
 
Method Summary
 void add(Fig f)
          Add a Fig to the contents of this layer.
 void bringForward(Fig f)
          Reorder the given Fig in this layer.
 void bringInFrontOf(Fig f1, Fig f2)
          Reorder the given Fig in this layer.
 void bringToFront(Fig f)
          Reorder the given Fig in this layer.
 java.util.Enumeration elements()
           
 java.util.List getContents()
          Reply the contents of this layer.
 java.util.Collection getContents(java.util.Collection c)
          Reply the contents of this layer.
 FigNode getPortFig(java.lang.Object port)
          Find the FigNode that is being used to visualize the given NetPort, or null if there is none in this layer.
 Fig hit(java.awt.Rectangle r)
          Reply the 'top' Fig under the given (mouse) coordinates.
 int indexOf(Fig f)
          Add a Fig to the contents of this layer.
 void insertAt(Fig f, int index)
          Add a Fig to the contents of this layer.
protected static java.lang.String numberWordFor(int n)
          A utility function to give the spelled-out word for numbers.
 void paintContents(java.awt.Graphics g)
          Paint all the Fig's that belong to this layer.
 void paintContents(java.awt.Graphics g, FigPainter painter)
          Paint all the Fig's that belong to this layer using a given FigPainter.
 void postLoad()
           
 void postSave()
           
 void preSave()
           
 int presentationCountFor(java.lang.Object obj)
           
 Fig presentationFor(java.lang.Object obj)
          Find the Fig that visualized the given NetNode in this layer, or null if there is none.
 void remove(Fig f)
          Remove the given Fig from this layer.
 void removeAll()
          Delete all Fig's from this layer.
 void reorder(Fig f, int function)
          Reorder the given Fig in this layer.
 void sendBackward(Fig f)
          Reorder the given Fig in this layer.
 void sendToBack(Fig f)
          Reorder the given Fig in this layer.
 
Methods inherited from class org.tigris.gef.base.Layer
addEditor, adjust, calcDrawingArea, clone, damageAll, deleted, elementsIn, getContentsEdgesOnly, getContentsNoEdges, getEditors, getGrayed, getHidden, getLocked, getName, getOnMenu, getPerspectiveType, getScale, isAlwaysOnTop, nodesIn, paint, paint, paintGrayContents, print, refreshEditors, removeEditor, setAlwaysOnTop, setGrayed, setHidden, setLocked, setName, setOnMenu, setPerspectiveType, setScale, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_nextLayerNumbered

protected static int _nextLayerNumbered
A counter so that layers have default names like 'One', 'Two', ...

Constructor Detail

LayerDiagram

public LayerDiagram()
Construct a new LayerDiagram with a default name and do not put it on the Layer's menu.


LayerDiagram

public LayerDiagram(java.lang.String name)
Construct a new LayerDiagram with the given name, and add it to the menu of layers. Needs-More-Work: I have not implemented a menu of layers yet. I don't know if that is really the right user interface.

Method Detail

elements

public java.util.Enumeration elements()
Overrides:
elements in class Layer

numberWordFor

protected static java.lang.String numberWordFor(int n)
A utility function to give the spelled-out word for numbers.


add

public void add(Fig f)
Add a Fig to the contents of this layer. Items are added on top of all other items.

Overrides:
add in class Layer
Parameters:
f - the fig to add
Throws:
java.lang.IllegalArgumentException - if the fig is null
See Also:
LayerDiagram

insertAt

public void insertAt(Fig f,
                     int index)
Add a Fig to the contents of this layer. Items are added on top of all other items.

Parameters:
f - the fig to insert
Throws:
java.lang.IllegalArgumentException - if the fig is null

indexOf

public int indexOf(Fig f)
Add a Fig to the contents of this layer. Items are added on top of all other items.

Parameters:
f - the fig to insert
Throws:
java.lang.IllegalArgumentException - if the fig is null

remove

public void remove(Fig f)
Remove the given Fig from this layer.

Overrides:
remove in class Layer

getContents

public java.util.Collection getContents(java.util.Collection c)
Reply the contents of this layer. Do I really want to do this? If a collection is supplied then that collection is reused and added to. If no collection is supplied then I new collection object is created and returned.

Specified by:
getContents in class Layer
Parameters:
c - the collection in which to place the edges or null if a new collection should be created
Returns:
the figs

getContents

public java.util.List getContents()
Reply the contents of this layer. Do I really want to do this?

Overrides:
getContents in class Layer
Returns:
the figs

hit

public Fig hit(java.awt.Rectangle r)
Reply the 'top' Fig under the given (mouse) coordinates. Needs-More-Work: For now, just do a linear search. Later, optimize this routine using Quad Trees (or other) techniques.

Overrides:
hit in class Layer

removeAll

public void removeAll()
Delete all Fig's from this layer.

Overrides:
removeAll in class Layer

getPortFig

public FigNode getPortFig(java.lang.Object port)
Find the FigNode that is being used to visualize the given NetPort, or null if there is none in this layer.


presentationFor

public Fig presentationFor(java.lang.Object obj)
Find the Fig that visualized the given NetNode in this layer, or null if there is none.

Specified by:
presentationFor in class Layer

presentationCountFor

public int presentationCountFor(java.lang.Object obj)

paintContents

public void paintContents(java.awt.Graphics g)
Paint all the Fig's that belong to this layer.

Specified by:
paintContents in class Layer

paintContents

public void paintContents(java.awt.Graphics g,
                          FigPainter painter)
Paint all the Fig's that belong to this layer using a given FigPainter. If painter is null, the Fig's are painted directly.

Overrides:
paintContents in class Layer

sendToBack

public void sendToBack(Fig f)
Reorder the given Fig in this layer.

Overrides:
sendToBack in class Layer

bringToFront

public void bringToFront(Fig f)
Reorder the given Fig in this layer.

Overrides:
bringToFront in class Layer

sendBackward

public void sendBackward(Fig f)
Reorder the given Fig in this layer. Needs-more-work: Should come backward/forward until they change positions with an object they overlap. Maybe...

Overrides:
sendBackward in class Layer

bringForward

public void bringForward(Fig f)
Reorder the given Fig in this layer.

Overrides:
bringForward in class Layer

bringInFrontOf

public void bringInFrontOf(Fig f1,
                           Fig f2)
Reorder the given Fig in this layer.

Overrides:
bringInFrontOf in class Layer

reorder

public void reorder(Fig f,
                    int function)
Reorder the given Fig in this layer.

Overrides:
reorder in class Layer

preSave

public void preSave()
Overrides:
preSave in class Layer

postSave

public void postSave()
Overrides:
postSave in class Layer

postLoad

public void postLoad()
Overrides:
postLoad in class Layer