edu.uci.ics.jung.algorithms.layout3d
Class AbstractLayout<V,E>

java.lang.Object
  extended by edu.uci.ics.jung.algorithms.layout3d.AbstractLayout<V,E>
Type Parameters:
V -
All Implemented Interfaces:
Layout<V,E>, org.apache.commons.collections15.Transformer<V,javax.vecmath.Point3f>
Direct Known Subclasses:
FRLayout, ISOMLayout, SpringLayout

public abstract class AbstractLayout<V,E>
extends Object
implements Layout<V,E>

Implements some of the dirty work of writing a layout algorithm, allowing the user to express their major intent more simply. When writing a Layout, there are many shared tasks: handling tracking locked nodes, applying filters, and tracing nearby vertices. This package automates all of those.

Author:
Danyel Fisher, Scott White

Field Summary
protected  Map<V,javax.vecmath.Point3f> locations
           
 
Constructor Summary
protected AbstractLayout(Graph<V,E> graph)
          Constructor.
protected AbstractLayout(Graph<V,E> graph, javax.media.j3d.BoundingSphere size)
           
protected AbstractLayout(Graph<V,E> graph, org.apache.commons.collections15.Transformer<V,javax.vecmath.Point3f> initializer)
           
protected AbstractLayout(Graph<V,E> graph, org.apache.commons.collections15.Transformer<V,javax.vecmath.Point3f> initializer, javax.media.j3d.BoundingSphere size)
           
 
Method Summary
 Graph<V,E> getGraph()
          Accessor for the graph that represets all vertices.
 javax.media.j3d.BoundingSphere getSize()
          Returns the current size of the visualization space, accoring to the last call to resize().
 Collection<V> getVertices()
           
 double getX(V v)
          Returns the x coordinate of the vertex from the Coordinates object.
 double getY(V v)
          Returns the y coordinate of the vertex from the Coordinates object.
abstract  void initialize()
          Initializer, calls intialize_local and initializeLocations to start construction process.
 boolean isLocked(V v)
          Returns true if the position of vertex v is locked.
 void lock(boolean lock)
           
 void lock(V v, boolean state)
          Adds the vertex to the DontMove list
protected  void offsetVertex(V v, float xOffset, float yOffset, float zOffset)
           
 void setGraph(Graph<V,E> graph)
          setter for graph
 void setInitializer(org.apache.commons.collections15.Transformer<V,javax.vecmath.Point3f> initializer)
          provides initial locations for all vertices.
 void setLocation(V picked, float x, float y, float z)
          Forcibly moves a vertex to the (x,y) location by setting its x and y locations to the inputted location.
 void setLocation(V picked, javax.vecmath.Point3f p)
          set the location of a vertex
 void setSize(javax.media.j3d.BoundingSphere size)
          When a visualization is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data.
 javax.vecmath.Point3f transform(V v)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.uci.ics.jung.algorithms.layout3d.Layout
reset
 

Field Detail

locations

protected Map<V,javax.vecmath.Point3f> locations
Constructor Detail

AbstractLayout

protected AbstractLayout(Graph<V,E> graph)
Constructor. Initializes the current size to be 100x100, both the graph and the showing graph to the argument, and creates the dontmove set.

Parameters:
g -

AbstractLayout

protected AbstractLayout(Graph<V,E> graph,
                         org.apache.commons.collections15.Transformer<V,javax.vecmath.Point3f> initializer)

AbstractLayout

protected AbstractLayout(Graph<V,E> graph,
                         javax.media.j3d.BoundingSphere size)

AbstractLayout

protected AbstractLayout(Graph<V,E> graph,
                         org.apache.commons.collections15.Transformer<V,javax.vecmath.Point3f> initializer,
                         javax.media.j3d.BoundingSphere size)
Method Detail

setGraph

public void setGraph(Graph<V,E> graph)
Description copied from interface: Layout
setter for graph

Specified by:
setGraph in interface Layout<V,E>

setSize

public void setSize(javax.media.j3d.BoundingSphere size)
When a visualization is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data. The current method calls initializeLocations followed by initialize_local. TODO: A better implementation wouldn't destroy the current information, but would either scale the current visualization, or move the nodes toward the new center.

Specified by:
setSize in interface Layout<V,E>

isLocked

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

Specified by:
isLocked in interface Layout<V,E>

getVertices

public Collection<V> getVertices()

initialize

public abstract void initialize()
Initializer, calls intialize_local and initializeLocations to start construction process.

Specified by:
initialize in interface Layout<V,E>

setInitializer

public void setInitializer(org.apache.commons.collections15.Transformer<V,javax.vecmath.Point3f> initializer)
Description copied from interface: Layout
provides initial locations for all vertices.

Specified by:
setInitializer in interface Layout<V,E>

getSize

public javax.media.j3d.BoundingSphere getSize()
Returns the current size of the visualization space, accoring to the last call to resize().

Specified by:
getSize in interface Layout<V,E>
Returns:
the current size of the screen

transform

public javax.vecmath.Point3f transform(V v)
Specified by:
transform in interface org.apache.commons.collections15.Transformer<V,javax.vecmath.Point3f>

getX

public double getX(V v)
Returns the x coordinate of the vertex from the Coordinates object. in most cases you will be better off calling getLocation(Vertex v);

See Also:
edu.uci.ics.jung.visualization.layout.Layout#getX(edu.uci.ics.jung.graph.Vertex)

getY

public double getY(V v)
Returns the y coordinate of the vertex from the Coordinates object. In most cases you will be better off calling getLocation(Vertex v)

See Also:
edu.uci.ics.jung.visualization.layout.Layout#getX(edu.uci.ics.jung.graph.Vertex)

offsetVertex

protected void offsetVertex(V v,
                            float xOffset,
                            float yOffset,
                            float zOffset)
Parameters:
v -
xOffset -
yOffset -

getGraph

public Graph<V,E> getGraph()
Accessor for the graph that represets all vertices.

Specified by:
getGraph in interface Layout<V,E>
Returns:
the graph that contains all vertices.

setLocation

public void setLocation(V picked,
                        float x,
                        float y,
                        float z)
Forcibly moves a vertex to the (x,y) location by setting its x and y locations to the inputted location. Does not add the vertex to the "dontmove" list, and (in the default implementation) does not make any adjustments to the rest of the graph.


setLocation

public void setLocation(V picked,
                        javax.vecmath.Point3f p)
Description copied from interface: Layout
set the location of a vertex

Specified by:
setLocation in interface Layout<V,E>

lock

public void lock(V v,
                 boolean state)
Adds the vertex to the DontMove list

Specified by:
lock in interface Layout<V,E>
Parameters:
v - vertex

lock

public void lock(boolean lock)


Copyright © 2009. All Rights Reserved.