edu.uci.ics.jung.visualization
Interface Layout

All Known Subinterfaces:
LayoutMutable
All Known Implementing Classes:
AbstractLayout, FadingVertexLayout, FRLayout, SpringLayout

public interface Layout

A generalized interface is a mechanism for returning (x,y) coordinates from vertices. In general, most of these methods are used to both control and get information from the layout algorithm.

Some of the additional complexity comes from the desire to give allow users to click on particular nodes and "lock" them in place. Therefore, there are calls to query the nodes for the nearest to a particular location, and calls to label a node as locked.

Many layout algorithms are incremental, and place nodes based on their previous location. This system supports them; it progresses the visualization only if isIncremental is true.

The Layout concept is also prepared to deal with filtered subgraphs. Once the Layout was constructed with a Graph, it can accept calls to applyFilter(Graph), which set the set the current graph to a subset. The Layout is responsible for handling this new, smaller set by one of several strategies:

Author:
danyelf

Method Summary
 void advancePositions()
          Advances an incremental visualization.
 void applyFilter(Graph subgraph)
          Sets this filtered graph to be the applicable graph.
 void forceMove(Vertex picked, int x, int y)
          Forces a node to be moved to location x,y
 java.awt.Dimension getCurrentSize()
          Returns the current size of the visualization's space.
 Graph getGraph()
          Returns the full graph (the one that was passed in at construction time) that this Layout refers to.
 java.lang.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.
 java.util.Set getVisibleEdges()
          Returns all currently showing vertices
 java.util.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(java.awt.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.
 void lockVertex(Vertex v)
          Sets a flag which fixes this vertex in place.
 void resize(java.awt.Dimension d)
          Resets the size of the visualization.
 void restart()
          Resets the node positions to semi-random locations.
 void unlockVertex(Vertex v)
          Allows this vertex to be moved.
 

Method Detail

initialize

public void initialize(java.awt.Dimension currentSize)
Initializes fields in the node that may not have been set during the constructor. Must be called before the iterations begin.


getX

public double getX(Vertex v)
Returns the x coordinate of vertex v at this stage in the iteration.

Parameters:
v - The vertex being examined
Returns:
the x coordinate of that vertex

getY

public double getY(Vertex v)
Returns the y coordinate of vertex v at this stage in the iteration.

Parameters:
v - The vertex being examined
Returns:
the y coordinate of that vertex

applyFilter

public void applyFilter(Graph subgraph)
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.

Parameters:
subgraph - a filtered graph that is a subgraph of the Graph returned by getGraph

getStatus

public java.lang.String getStatus()
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.

Returns:
the status, as a string

restart

public void restart()
Resets the node positions to semi-random locations. Used to clean up visualizations.


getVertex

public Vertex getVertex(double x,
                        double y)
Finds the closest vertex to an input (x,y) coordinate. Useful for mouse clicks.

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.

getVertex

public Vertex getVertex(double x,
                        double y,
                        double maxDistance)
Finds the closest vertex to an input (x,y) coordinate. Useful for mouse clicks.

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.

getGraph

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


resize

public void resize(java.awt.Dimension d)
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() );
 

Parameters:
d -

advancePositions

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


isIncremental

public boolean isIncremental()
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.


incrementsAreDone

public boolean incrementsAreDone()
If this visualization is incremental, tells whether it has stabilized at a satisfactory spot yet.


lockVertex

public void lockVertex(Vertex v)
Sets a flag which fixes this vertex in place.

Parameters:
v - vertex
See Also:
unlockVertex(Vertex)

unlockVertex

public void unlockVertex(Vertex v)
Allows this vertex to be moved.

Parameters:
v - vertex
See Also:
lockVertex(Vertex)

forceMove

public void forceMove(Vertex picked,
                      int x,
                      int y)
Forces a node to be moved to location x,y

Parameters:
picked -
x -
y -

getVisibleEdges

public java.util.Set getVisibleEdges()
Returns all currently showing vertices


getVisibleVertices

public java.util.Set getVisibleVertices()
Returns all currently visible vertices


getCurrentSize

public java.awt.Dimension getCurrentSize()
Returns the current size of the visualization's space.