edu.uci.ics.jung.visualization
Class FadingVertexLayout

java.lang.Object
  extended byedu.uci.ics.jung.visualization.FadingVertexLayout
All Implemented Interfaces:
Layout

public class FadingVertexLayout
extends java.lang.Object
implements Layout

Implements a pass-through visaulizer that fades out nodes that have been removed, and fades in nodes that have appeared. Adds a field FADINGNODEVIZ to the nodes, which directs the _Renderer to view those nodes as faded.

In order to use this class, create a FadingNodeLayout that takes as an arguemnt the Layout you actually wish to use:

 	Layout v= new FadingNodeLayout( 10, new SpringLayout( g ));
 
In order to operate, this implementation tracks the vertices that are visible before and after each call to applyFilte. Other nodes are not altered. However, each time that advancePositions is called, all nodes that are currently hidden have their fading level incremented.

In this documentaiton, code that is labelled as a passthrough has no functionality except to pass the data through to the contained layout.

Be sure to use a _Renderer that knows to pay attention to the Fading information. In particular, it must know that the FADINGNODEVIZ field gives information about the fade level.

Author:
danyelf

Nested Class Summary
 class FadingVertexLayout.FadingVertexLayoutData
           
 
Constructor Summary
FadingVertexLayout(int fadelevels, Layout layout)
          Adds user data to every vertex in the graph.
 
Method Summary
 void advancePositions()
          In addition to being a passthrough, this also advances the fade function by calling tick
 void applyFilter(Graph g_int)
          Tracks the changes in the set of visible vertices from the set of actual vertices.
 void forceMove(Vertex picked, int x, int y)
          Simply passes through the vertex.
 java.awt.Dimension getCurrentSize()
          Returns the current size of the visualization's space.
 int getFadeLevel(Vertex v)
          Static utility function returns the fade level of a given vertex.
 java.lang.Object getFadingKey()
           
 Graph getGraph()
          A pass-through.
 int getMaxLevel()
          Returns the number of levels that vertices fade through.
 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)
          A pass-through.
 Vertex getVertex(double x, double y, double maxDistance)
          A pass-through.
 java.util.Set getVisibleEdges()
          Returns *all* edges.
 java.util.Set getVisibleVertices()
          Returns both the visible and the hidden vertices.
 double getX(Vertex vert)
          Passthrough.
 double getY(Vertex vert)
          Passthrough.
 boolean incrementsAreDone()
          Passthrough.
 void initialize(java.awt.Dimension d)
          A pass-through to the contained Layout
 boolean isHidden(Vertex v)
          Static utility function returns the fade level of a given vertex.
 boolean isIncremental()
          Passthrough.
 void lockVertex(Vertex vert)
          Passthrough.
 void resize(java.awt.Dimension d)
          Passthrough.
 void restart()
          Passthrough.
 void unlockVertex(Vertex vert)
          Passthrough.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FadingVertexLayout

public FadingVertexLayout(int fadelevels,
                          Layout layout)
Adds user data to every vertex in the graph. Initially, no nodes are hidden.

Parameters:
fadelevels - The number of levels through which a vertex should fade once it is removed.
Method Detail

getCurrentSize

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

Specified by:
getCurrentSize in interface Layout

initialize

public void initialize(java.awt.Dimension d)
A pass-through to the contained Layout

Specified by:
initialize in interface Layout

getStatus

public java.lang.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

getVisibleEdges

public java.util.Set getVisibleEdges()
Returns *all* edges. Note that this is unusual: for example

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

getGraph

public Graph getGraph()
A pass-through.

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

getVertex

public Vertex getVertex(double x,
                        double y)
A pass-through.

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)

getVertex

public Vertex getVertex(double x,
                        double y,
                        double maxDistance)
A pass-through.

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)

advancePositions

public void advancePositions()
In addition to being a passthrough, this also advances the fade function by calling tick

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

getFadingKey

public java.lang.Object getFadingKey()

applyFilter

public void applyFilter(Graph g_int)
Tracks the changes in the set of visible vertices from the set of actual vertices.
Vertices that have been REMOVED will be faded out through FADELEVELS steps; vertices that have been ADDED will be faded in through FADELEVELS steps. All hidden vertices will be labelled as hidden; all showing vertices will be labeled as nonhidden.

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

resize

public void resize(java.awt.Dimension d)
Passthrough.

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

restart

public void restart()
Passthrough.

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

getX

public double getX(Vertex vert)
Passthrough. Note that you can't get X and Y of hidden nodes.

Specified by:
getX in interface Layout
Parameters:
vert - 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 vert)
Passthrough. Note that you can't get X and Y of hidden nodes.

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

getVisibleVertices

public java.util.Set getVisibleVertices()
Returns both the visible and the hidden vertices. This function is an exception to the usual behavior of getVisibleVertices. Where usually only visible vertices would be passed, this function also passes the hidden ones, and counts on the _Renderer (or other calling client) to know what to do with it appropriately. This is done in order to ensure that fading vertices are still shown.

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

getFadeLevel

public int getFadeLevel(Vertex v)
Static utility function returns the fade level of a given vertex. This vertex must be visaulized by a Fading Node Layout, or this function will throw an exception.

Parameters:
v -

isHidden

public boolean isHidden(Vertex v)
Static utility function returns the fade level of a given vertex. This vertex must be visaulized by a Fading Node Layout, or this function will throw an exception.

Parameters:
v -

lockVertex

public void lockVertex(Vertex vert)
Passthrough.

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

unlockVertex

public void unlockVertex(Vertex vert)
Passthrough.

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

forceMove

public void forceMove(Vertex picked,
                      int x,
                      int y)
Simply passes through the vertex.

Specified by:
forceMove in interface Layout
Parameters:
picked -
x -
y -
See Also:
Layout.forceMove(edu.uci.ics.jung.graph.Vertex, int, int)

getMaxLevel

public int getMaxLevel()
Returns the number of levels that vertices fade through.


isIncremental

public boolean isIncremental()
Passthrough.

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

incrementsAreDone

public boolean incrementsAreDone()
Passthrough.

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