edu.uci.ics.jung.algorithms.layout
Class SpringLayout2<V,E>

java.lang.Object
  extended by edu.uci.ics.jung.algorithms.layout.AbstractLayout<V,E>
      extended by edu.uci.ics.jung.algorithms.layout.SpringLayout2<V,E>
All Implemented Interfaces:
Layout<V,E>, IterativeContext

public class SpringLayout2<V,E>
extends AbstractLayout<V,E>
implements IterativeContext

The SpringLayout package represents a visualization of a set of nodes. The SpringLayout, which is initialized with a Graph, assigns X/Y locations to each node. When called relax(), the SpringLayout moves the visualization forward one step.

Author:
Danyel Fisher, Joshua O'Madadhain

Nested Class Summary
static interface SpringLayout2.LengthFunction<E>
          If the edge is weighted, then override this method to show what the visualized length is.
 class SpringLayout2.SpringDimensionChecker
           
protected static class SpringLayout2.SpringEdgeData<E>
           
protected static class SpringLayout2.SpringVertexData
           
static class SpringLayout2.UnitLengthFunction<E>
          Returns all edges as the same length: the input value
 
Field Summary
protected  int averageCounter
           
protected  Point2D averageDelta
           
protected  int currentIteration
           
protected  boolean done
           
protected  double force_multiplier
           
protected  SpringLayout2.LengthFunction<E> lengthFunction
           
protected  int loopCountMax
           
protected  int repulsion_range
           
protected  double stretch
           
static SpringLayout2.LengthFunction UNITLENGTHFUNCTION
           
 
Fields inherited from class edu.uci.ics.jung.algorithms.layout.AbstractLayout
initialized, locations
 
Constructor Summary
SpringLayout2(Graph<V,E> g)
          Constructor for a SpringLayout for a raw graph with associated dimension--the input knows how big the graph is.
SpringLayout2(Graph<V,E> g, SpringLayout2.LengthFunction<E> f)
          Constructor for a SpringLayout for a raw graph with associated component.
 
Method Summary
protected  void calcEdgeLength(SpringLayout2.SpringEdgeData<E> sed, SpringLayout2.LengthFunction<E> f)
           
protected  void calculateRepulsion()
           
 boolean done()
          For now, we pretend it never finishes.
protected  V getAVertex(E e)
           
 double getForceMultiplier()
           
 double getLength(E e)
           
 int getRepulsionRange()
           
 SpringLayout2.SpringEdgeData<E> getSpringData(E e)
           
 SpringLayout2.SpringVertexData getSpringData(V v)
           
 double getStretch()
           
 void initialize()
          Initializes fields in the node that may not have been set during the constructor.
 boolean isIncremental()
          This one is an incremental visualization
protected  void moveNodes()
           
protected  void relaxEdges()
           
 void reset()
           
 void setForceMultiplier(double force)
          Sets the force multiplier for this instance.
 void setRepulsionRange(int range)
          Sets the node repulsion range (in drawing area units) for this instance.
 void setSize(Dimension size)
          When a visualization is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data.
 void setStretch(double stretch)
          Sets the stretch parameter for this instance.
 void step()
          Relaxation step.
 
Methods inherited from class edu.uci.ics.jung.algorithms.layout.AbstractLayout
getGraph, getSize, getVertices, getX, getY, isLocked, lock, lock, offsetVertex, setGraph, setInitializer, setLocation, setLocation, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stretch

protected double stretch

lengthFunction

protected SpringLayout2.LengthFunction<E> lengthFunction

repulsion_range

protected int repulsion_range

force_multiplier

protected double force_multiplier

currentIteration

protected int currentIteration

averageCounter

protected int averageCounter

loopCountMax

protected int loopCountMax

done

protected boolean done

averageDelta

protected Point2D averageDelta

UNITLENGTHFUNCTION

public static final SpringLayout2.LengthFunction UNITLENGTHFUNCTION
Constructor Detail

SpringLayout2

public SpringLayout2(Graph<V,E> g)
Constructor for a SpringLayout for a raw graph with associated dimension--the input knows how big the graph is. Defaults to the unit length function.


SpringLayout2

public SpringLayout2(Graph<V,E> g,
                     SpringLayout2.LengthFunction<E> f)
Constructor for a SpringLayout for a raw graph with associated component.

Parameters:
g - the input Graph
f - the length function
Method Detail

getStretch

public double getStretch()
Returns:
the current value for the stretch parameter
See Also:
setStretch(double)

setSize

public void setSize(Dimension size)
Description copied from class: AbstractLayout
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.

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

setStretch

public void setStretch(double stretch)

Sets the stretch parameter for this instance. This value specifies how much the degrees of an edge's incident vertices should influence how easily the endpoints of that edge can move (that is, that edge's tendency to change its length).

The default value is 0.70. Positive values less than 1 cause high-degree vertices to move less than low-degree vertices, and values > 1 cause high-degree vertices to move more than low-degree vertices. Negative values will have unpredictable and inconsistent results.

Parameters:
stretch -

getRepulsionRange

public int getRepulsionRange()
Returns:
the current value for the node repulsion range
See Also:
setRepulsionRange(int)

setRepulsionRange

public void setRepulsionRange(int range)
Sets the node repulsion range (in drawing area units) for this instance. Outside this range, nodes do not repel each other. The default value is 100. Negative values are treated as their positive equivalents.

Parameters:
range -

getForceMultiplier

public double getForceMultiplier()
Returns:
the current value for the edge length force multiplier
See Also:
setForceMultiplier(double)

setForceMultiplier

public void setForceMultiplier(double force)
Sets the force multiplier for this instance. This value is used to specify how strongly an edge "wants" to be its default length (higher values indicate a greater attraction for the default length), which affects how much its endpoints move at each timestep. The default value is 1/3. A value of 0 turns off any attempt by the layout to cause edges to conform to the default length. Negative values cause long edges to get longer and short edges to get shorter; use at your own risk.


initialize

public void initialize()
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<V,E>

calcEdgeLength

protected void calcEdgeLength(SpringLayout2.SpringEdgeData<E> sed,
                              SpringLayout2.LengthFunction<E> f)

step

public void step()
Relaxation step. Moves all nodes a smidge.

Specified by:
step in interface IterativeContext

getAVertex

protected V getAVertex(E e)

relaxEdges

protected void relaxEdges()

calculateRepulsion

protected void calculateRepulsion()

moveNodes

protected void moveNodes()

getSpringData

public SpringLayout2.SpringVertexData getSpringData(V v)

getSpringData

public SpringLayout2.SpringEdgeData<E> getSpringData(E e)

getLength

public double getLength(E e)

isIncremental

public boolean isIncremental()
This one is an incremental visualization


done

public boolean done()
For now, we pretend it never finishes.

Specified by:
done in interface IterativeContext

reset

public void reset()
Specified by:
reset in interface Layout<V,E>


Copyright © 2008 null. All Rights Reserved.