edu.uci.ics.jung.visualization
Class LayoutDecorator

java.lang.Object
  extended by edu.uci.ics.jung.visualization.LayoutDecorator
All Implemented Interfaces:
ChangeEventSupport, Layout, VertexLocationFunction
Direct Known Subclasses:
PersistentLayoutImpl, SubLayoutDecorator

public abstract class LayoutDecorator
extends Object
implements Layout, ChangeEventSupport

a pure decorator for the Layout interface. Intended to be overridden to provide specific behavior decoration

Author:
Tom Nelson - RABA Technologies
See Also:
PersistentLayoutImpl

Field Summary
protected  ChangeEventSupport changeSupport
           
protected  Layout delegate
           
 
Constructor Summary
LayoutDecorator(Layout delegate)
           
 
Method Summary
 void addChangeListener(ChangeListener l)
           
 void advancePositions()
          Advances an incremental visualization.
 void applyFilter(Graph subgraph)
          Sets this filtered graph to be the applicable graph.
 void fireStateChanged()
           
 void forceMove(Vertex picked, double x, double y)
          Forces a node to be moved to location x,y
 ChangeListener[] getChangeListeners()
          Returns an array of all the ChangeListeners added with addChangeListener().
 Dimension getCurrentSize()
          Returns the current size of the visualization's space.
 Layout getDelegate()
          getter for the delegate
 Graph getGraph()
          Returns the full graph (the one that was passed in at construction time) that this Layout refers to.
 Point2D getLocation(ArchetypeVertex v)
           
 String getStatus()
          Returns the current status of the sytem, or null if there is no particular status to report.
 Vertex getVertex(double x, double y)
          Finds the closest vertex to an input (x,y) coordinate.
 Vertex getVertex(double x, double y, double maxDistance)
          Finds the closest vertex to an input (x,y) coordinate.
 Iterator getVertexIterator()
           
 Set getVisibleEdges()
          Returns all currently showing edges
 Set getVisibleVertices()
          Returns all currently visible vertices
 double getX(Vertex v)
          Returns the x coordinate of vertex v at this stage in the iteration.
 double getY(Vertex v)
          Returns the y coordinate of vertex v at this stage in the iteration.
 boolean incrementsAreDone()
          If this visualization is incremental, tells whether it has stabilized at a satisfactory spot yet.
 void initialize(Dimension currentSize)
          Initializes fields in the node that may not have been set during the constructor.
 boolean isIncremental()
          Indicates whether this visualization has an incremental mode.
 boolean isLocked(Vertex v)
          Returns true if the position of vertex v is locked.
 void lockVertex(Vertex v)
          Sets a flag which fixes this vertex in place.
 void removeChangeListener(ChangeListener l)
          Removes a ChangeListener.
 void resize(Dimension d)
          Resets the size of the visualization.
 void restart()
          Resets the vertex positions to their initial locations.
 void setDelegate(Layout delegate)
          setter for the delegate
 void unlockVertex(Vertex v)
          Allows this vertex to be moved.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delegate

protected Layout delegate

changeSupport

protected ChangeEventSupport changeSupport
Constructor Detail

LayoutDecorator

public LayoutDecorator(Layout delegate)
Method Detail

getDelegate

public Layout getDelegate()
getter for the delegate

Returns:
the delegate

setDelegate

public void setDelegate(Layout delegate)
setter for the delegate

Parameters:
delegate - the new delegate

advancePositions

public void advancePositions()
Description copied from interface: Layout
Advances an incremental visualization. Many visualizations are incremental--that is, they get better over time and recalculations. This moves it forward one step.

Specified by:
advancePositions in interface Layout
See Also:
Layout.advancePositions()

applyFilter

public void applyFilter(Graph subgraph)
Description copied from interface: Layout
Sets this filtered graph to be the applicable graph. It is an error for the subgraph to not be a subgraph of the main graph.

Specified by:
applyFilter in interface Layout
Parameters:
subgraph - a filtered graph that is a subgraph of the Graph returned by getGraph
See Also:
Layout.applyFilter(edu.uci.ics.jung.graph.Graph)

forceMove

public void forceMove(Vertex picked,
                      double x,
                      double y)
Description copied from interface: Layout
Forces a node to be moved to location x,y

Specified by:
forceMove in interface Layout
See Also:
Layout.forceMove(edu.uci.ics.jung.graph.Vertex, double, double)

getCurrentSize

public Dimension getCurrentSize()
Description copied from interface: Layout
Returns the current size of the visualization's space.

Specified by:
getCurrentSize in interface Layout
See Also:
Layout.getCurrentSize()

getGraph

public Graph getGraph()
Description copied from interface: Layout
Returns the full graph (the one that was passed in at construction time) that this Layout refers to.

Specified by:
getGraph in interface Layout
See Also:
Layout.getGraph()

getLocation

public Point2D getLocation(ArchetypeVertex v)
Specified by:
getLocation in interface Layout
Specified by:
getLocation in interface VertexLocationFunction
See Also:
Layout.getLocation(edu.uci.ics.jung.graph.ArchetypeVertex)

getStatus

public String getStatus()
Description copied from interface: Layout
Returns the current status of the sytem, or null if there is no particular status to report. Useful for reporting things like number of iterations passed, temperature, and so on.

Specified by:
getStatus in interface Layout
Returns:
the status, as a string
See Also:
Layout.getStatus()

getVertex

public Vertex getVertex(double x,
                        double y,
                        double maxDistance)
Description copied from interface: Layout
Finds the closest vertex to an input (x,y) coordinate. Useful for mouse clicks.

Specified by:
getVertex in interface Layout
Parameters:
x - The x coordinate of the input
y - The y coordinate of the input
maxDistance - The maximum acceptable distance. Beyond this, vertices are ignored.
Returns:
The nearest vertex. It is up to the user to check if it is satisfactorily close.
See Also:
Layout.getVertex(double, double, double)

getVertex

public Vertex getVertex(double x,
                        double y)
Description copied from interface: Layout
Finds the closest vertex to an input (x,y) coordinate. Useful for mouse clicks.

Specified by:
getVertex in interface Layout
Parameters:
x - The x coordinate of the input
y - The y coordinate of the input
Returns:
The nearest vertex. It is up to the user to check if it is satisfactorily close.
See Also:
Layout.getVertex(double, double)

getVertexIterator

public Iterator getVertexIterator()
Specified by:
getVertexIterator in interface VertexLocationFunction
See Also:
VertexLocationFunction.getVertexIterator()

getVisibleEdges

public Set getVisibleEdges()
Description copied from interface: Layout
Returns all currently showing edges

Specified by:
getVisibleEdges in interface Layout
See Also:
Layout.getVisibleEdges()

getVisibleVertices

public Set getVisibleVertices()
Description copied from interface: Layout
Returns all currently visible vertices

Specified by:
getVisibleVertices in interface Layout
See Also:
Layout.getVisibleVertices()

getX

public double getX(Vertex v)
Description copied from interface: Layout
Returns the x coordinate of vertex v at this stage in the iteration.

Specified by:
getX in interface Layout
Parameters:
v - The vertex being examined
Returns:
the x coordinate of that vertex
See Also:
Layout.getX(edu.uci.ics.jung.graph.Vertex)

getY

public double getY(Vertex v)
Description copied from interface: Layout
Returns the y coordinate of vertex v at this stage in the iteration.

Specified by:
getY in interface Layout
Parameters:
v - The vertex being examined
Returns:
the y coordinate of that vertex
See Also:
Layout.getY(edu.uci.ics.jung.graph.Vertex)

incrementsAreDone

public boolean incrementsAreDone()
Description copied from interface: Layout
If this visualization is incremental, tells whether it has stabilized at a satisfactory spot yet.

Specified by:
incrementsAreDone in interface Layout
See Also:
Layout.incrementsAreDone()

initialize

public void initialize(Dimension currentSize)
Description copied from interface: Layout
Initializes fields in the node that may not have been set during the constructor. Must be called before the iterations begin.

Specified by:
initialize in interface Layout
See Also:
Layout.initialize(java.awt.Dimension)

isIncremental

public boolean isIncremental()
Description copied from interface: Layout
Indicates whether this visualization has an incremental mode. If so, it may be good to increment a bunch of times before showing. If not, the containing program may not wish to call increment.

Specified by:
isIncremental in interface Layout
See Also:
Layout.isIncremental()

lockVertex

public void lockVertex(Vertex v)
Description copied from interface: Layout
Sets a flag which fixes this vertex in place.

Specified by:
lockVertex in interface Layout
Parameters:
v - vertex
See Also:
Layout.lockVertex(edu.uci.ics.jung.graph.Vertex)

isLocked

public boolean isLocked(Vertex v)
Description copied from interface: Layout
Returns true if the position of vertex v is locked.

Specified by:
isLocked in interface Layout
See Also:
Layout.isLocked(Vertex)

resize

public void resize(Dimension d)
Description copied from interface: Layout
Resets the size of the visualization. One cannot count on a Visualizaton knowing its own size correctly until the following sequence has been called:
 Layout l = new XXXLayout( g )
 l.initialize();
 l.resize( this.getSize() );
 

Specified by:
resize in interface Layout
See Also:
Layout.resize(java.awt.Dimension)

restart

public void restart()
Description copied from interface: Layout
Resets the vertex positions to their initial locations.

Specified by:
restart in interface Layout
See Also:
Layout.restart()

unlockVertex

public void unlockVertex(Vertex v)
Description copied from interface: Layout
Allows this vertex to be moved.

Specified by:
unlockVertex in interface Layout
Parameters:
v - vertex
See Also:
Layout.unlockVertex(edu.uci.ics.jung.graph.Vertex)

addChangeListener

public void addChangeListener(ChangeListener l)
Specified by:
addChangeListener in interface ChangeEventSupport

removeChangeListener

public void removeChangeListener(ChangeListener l)
Description copied from interface: ChangeEventSupport
Removes a ChangeListener.

Specified by:
removeChangeListener in interface ChangeEventSupport
Parameters:
l - the listener to be removed

getChangeListeners

public ChangeListener[] getChangeListeners()
Description copied from interface: ChangeEventSupport
Returns an array of all the ChangeListeners added with addChangeListener().

Specified by:
getChangeListeners in interface ChangeEventSupport
Returns:
all of the ChangeListeners added or an empty array if no listeners have been added

fireStateChanged

public void fireStateChanged()
Specified by:
fireStateChanged in interface ChangeEventSupport