uci.gef
Class Layer

java.lang.Object
  |
  +--uci.gef.Layer
Direct Known Subclasses:
LayerDiagram, LayerGrid, LayerPageBreaks, LayerPolar

public abstract class Layer
extends Object
implements Serializable

A Layer is like a drawing layer in high-end drawing applications (e.g., MacDraw Pro). A Layer is like a sheet of clear plastic that can contain part of the picture being drawn and multiple layers are put on top of each other to make the overall picture. Different layers can be hidden, locked, or grayed out independently. In GEF the Layer class is more abstract than described above. LayerDiagram is a subclass of Layer that does what is described above. Other subclasses of Layer can provide functionality. For example the background drawing grid is a subclass of Layer that computes its display rather than displaying what is stored in a data structure. Generalizing the concept of a layer to handle grids and other computed display features gives more power and allows the framework to be extended in building various applications. For example an application that needs polar coordinates might use LayerPolar, and an application that used a world map might implement LayerMap. But since layers can be composed, the user could put a grid in front of or behind the map.

This approach to implementing drawing editors is similar to that described in a published paper: "Using the Multi-Layer Model for Building Interactive Graphical Applications" Fekete, et al. UIST'96. pp. 109-117. GEF might be improved by making it more like the system described in that paper: basically by moving some of the XXXManage functionality into Layers, or merging Layers and Modes.

See Also:
LayerDiagram, LayerPerspective, LayerGrid, LayerPolar, Serialized Form

Field Summary
 Vector _editors
          A Vector of the Editors that are displaying this Layer.
protected  boolean _onMenu
          Should the user be able to hide, lock, or gray this layer? Needs-More-Work.
 
Constructor Summary
Layer()
          Construct a new Layer.
Layer(String name)
          Construct a new layer with the given name.
Layer(String name, String type)
          Construct a new layer with the given name and type.
 
Method Summary
 void add(Fig f)
          Most Layers contain Fig, so I have empty implementations of add, remove, removeAll, elements, and hit.
 void addEditor(Editor ed)
          Add an Editor to the list of Editors showing this Layer.
 void adjust()
          Allow the user to edit the properties of this layer (not the properties of the contents of this layer).
 void bringForward(Fig f)
           
 void bringInFrontOf(Fig f1, Fig f2)
           
 void bringToFront(Fig f)
           
 void damaged(Fig f)
          A Fig in this Layer has changed state and needs to be redrawn.
 void deleted(Fig f)
          A Fig in this Layer has been deleted.
 Enumeration elements()
           
 Enumeration elementsIn(Rectangle r)
          Reply an enumeration of all the Figs in this Layer that intersect given Rectangle.
 boolean fetHidden()
           
 Layer findLayerNamed(String aName)
          If this layer has the given name then return 'this', else null
abstract  Vector getContents()
           
 Vector getContentsEdgesOnly()
           
 Vector getContentsNoEdges()
           
 Vector getEditors()
          Return the Vector of Editors that are showing this Layer.
 boolean getGrayed()
           
 boolean getLocked()
           
 String getName()
          Get and set methods
 boolean getOnMenu()
           
 String getPerspectiveType()
          Return a string that can be used to make some Layers show nodes in one way and other Layers show the same nodes in a different way.
 Fig hit(Rectangle r)
           
 Enumeration nodesIn(Rectangle r)
          Reply an enumeration of all the FigNodes in this Layer that intersect given Rectangle.
 void paint(Graphics g)
          Paint this Layer on the given Graphics.
abstract  void paintContents(Graphics g)
          Abactract method to paint the contents of this layer, subclasses must define this.
 void paintGrayContents(Graphics g)
          Paint the contents in a dimmed, demphasized way.
 void postLoad()
           
 void postSave()
           
 void preSave()
           
abstract  Fig presentationFor(Object obj)
          Given an object from the net-level model (e.g., NetNode or NetPort), reply the graphical depiction of that object in this layer, if there is one.
 void print(Graphics g)
          Draw the Layer on a PrintGraphics.
 void refreshEditors()
          Ask all Editors to completely redraw their display.
 void remove(Fig f)
           
 void removeAll()
           
 void removeEditor(Editor ed)
           
 void reorder(Fig f, int function)
           
 void sendBackward(Fig f)
           
 void sendToBack(Fig f)
          Most Layers will contain things in back to front order, so I define empty reordering functions here.
 void setGrayed(boolean b)
           
 void setHidden(boolean b)
           
 void setLocked(boolean b)
           
 void setName(String n)
           
 void setOnMenu(boolean b)
           
 void setPerspectiveType(String t)
           
 String toString()
          Reply a string useful for debugging
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_onMenu

protected boolean _onMenu
Should the user be able to hide, lock, or gray this layer? Needs-More-Work.

_editors

public transient Vector _editors
A Vector of the Editors that are displaying this Layer.
Constructor Detail

Layer

public Layer()
Construct a new Layer. This abstract class really does nothing in its constructor, but subclasses may have meaningful constructors.

Layer

public Layer(String name)
Construct a new layer with the given name.

Layer

public Layer(String name,
             String type)
Construct a new layer with the given name and type.
Method Detail

toString

public String toString()
Reply a string useful for debugging
Overrides:
toString in class Object

findLayerNamed

public Layer findLayerNamed(String aName)
If this layer has the given name then return 'this', else null

getName

public String getName()
Get and set methods

setName

public void setName(String n)

setHidden

public void setHidden(boolean b)

fetHidden

public boolean fetHidden()

setGrayed

public void setGrayed(boolean b)

getGrayed

public boolean getGrayed()

setLocked

public void setLocked(boolean b)

getLocked

public boolean getLocked()

setOnMenu

public void setOnMenu(boolean b)

getOnMenu

public boolean getOnMenu()

getContents

public abstract Vector getContents()

getContentsNoEdges

public Vector getContentsNoEdges()

getContentsEdgesOnly

public Vector getContentsEdgesOnly()

getEditors

public Vector getEditors()
Return the Vector of Editors that are showing this Layer.

add

public void add(Fig f)
Most Layers contain Fig, so I have empty implementations of add, remove, removeAll, elements, and hit.
See Also:
LayerDiagram

remove

public void remove(Fig f)

removeAll

public void removeAll()

elements

public Enumeration elements()

hit

public Fig hit(Rectangle r)

elementsIn

public Enumeration elementsIn(Rectangle r)
Reply an enumeration of all the Figs in this Layer that intersect given Rectangle.

nodesIn

public Enumeration nodesIn(Rectangle r)
Reply an enumeration of all the FigNodes in this Layer that intersect given Rectangle.

presentationFor

public abstract Fig presentationFor(Object obj)
Given an object from the net-level model (e.g., NetNode or NetPort), reply the graphical depiction of that object in this layer, if there is one. Otherwise reply null.

getPerspectiveType

public String getPerspectiveType()
Return a string that can be used to make some Layers show nodes in one way and other Layers show the same nodes in a different way. By default just use the name of the layer, but in general names are for users to specify as reminders to themselves and the perspectiveType controls what kinds of node FigNodes will be added to that view.

setPerspectiveType

public void setPerspectiveType(String t)

sendToBack

public void sendToBack(Fig f)
Most Layers will contain things in back to front order, so I define empty reordering functions here. Subclasses can implement these if appropriate.

bringForward

public void bringForward(Fig f)

sendBackward

public void sendBackward(Fig f)

bringToFront

public void bringToFront(Fig f)

bringInFrontOf

public void bringInFrontOf(Fig f1,
                           Fig f2)

reorder

public void reorder(Fig f,
                    int function)

print

public void print(Graphics g)
Draw the Layer on a PrintGraphics. By default, just calls paint(g).

paint

public void paint(Graphics g)
Paint this Layer on the given Graphics. Sublasses should define methods for paintContents, which is called from here if the Layer is not hidden.

paintContents

public abstract void paintContents(Graphics g)
Abactract method to paint the contents of this layer, subclasses must define this. For example, LayerDiagram paints itself by painting a list of Figs and LayerGrid paints itself by painting a lot lines.

paintGrayContents

public void paintGrayContents(Graphics g)
Paint the contents in a dimmed, demphasized way. Calls paintContents. Needs-More-Work: really needs a new kind of Graphics to work right.

damaged

public void damaged(Fig f)
A Fig in this Layer has changed state and needs to be redrawn. Notify all Editors showing this Layer that they should record the damage.

deleted

public void deleted(Fig f)
A Fig in this Layer has been deleted. Notify all Editors so that they can deselect the Fig.

refreshEditors

public void refreshEditors()
Ask all Editors to completely redraw their display.

addEditor

public void addEditor(Editor ed)
Add an Editor to the list of Editors showing this Layer.

removeEditor

public void removeEditor(Editor ed)

preSave

public void preSave()

postSave

public void postSave()

postLoad

public void postLoad()

adjust

public void adjust()
Allow the user to edit the properties of this layer (not the properties of the contents of this layer). For example, in LayerGrid this could set the grid size. By default, does nothing.
See Also:
LayerGrid