uci.gef
Class LayerDiagram

java.lang.Object
  |
  +--uci.gef.Layer
        |
        +--uci.gef.LayerDiagram
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  Vector _contents
          The Fig's that are contained in this layer.
protected static int _nextLayerNumbered
          A counter so that layers have default names like 'One', 'Two', ...
 
Fields inherited from class uci.gef.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(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.
 Enumeration elements()
          Enumerate over all Fig's in this layer.
 Vector getContents()
          Reply the contents of this layer.
 FigNode getPortFig(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(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 String numberWordFor(int n)
          A utility function to give the spelled-out word for numbers.
 void paintContents(Graphics g)
          Paint all the Fig's that belong to this layer.
 void postLoad()
           
 void postSave()
           
 void preSave()
           
 int presentationCountFor(Object obj)
           
 Fig presentationFor(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 uci.gef.Layer
addEditor, adjust, damaged, deleted, elementsIn, fetHidden, findLayerNamed, getContentsEdgesOnly, getContentsNoEdges, getEditors, getGrayed, getLocked, getName, getOnMenu, getPerspectiveType, nodesIn, paint, paintGrayContents, print, refreshEditors, removeEditor, setGrayed, setHidden, setLocked, setName, setOnMenu, setPerspectiveType, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_contents

protected Vector _contents
The Fig's that are contained in this layer.

_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(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

numberWordFor

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

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.

indexOf

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

remove

public void remove(Fig f)
Remove the given Fig from this layer.
Overrides:
remove in class Layer

elements

public Enumeration elements()
Enumerate over all Fig's in this layer.
Overrides:
elements in class Layer

getContents

public Vector getContents()
Reply the contents of this layer. Do I really want to do this?
Overrides:
getContents in class Layer

hit

public Fig hit(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(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(Object obj)
Find the Fig that visualized the given NetNode in this layer, or null if there is none.
Overrides:
presentationFor in class Layer

presentationCountFor

public int presentationCountFor(Object obj)

paintContents

public void paintContents(Graphics g)
Paint all the Fig's that belong to this layer.
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