Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.uci.ics.jung.visualization
Class SpringLayout

    java.lang.Object
      edu.uci.ics.jung.visualization.AbstractLayout
          edu.uci.ics.jung.visualization.SpringLayout

All Implemented Interfaces:
  ChangeEventSupport, Layout, LayoutMutable, VertexLocationFunction

Direct Known Subclasses:
  DAGLayout

public class SpringLayout
extends AbstractLayout
implements LayoutMutable

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` | `SpringLayout.LengthFunction` If the edge is weighted, then override this method to show what the visualized length is.
`class` | `SpringLayout.SpringDimensionChecker`
`protected static class` | `SpringLayout.SpringEdgeData`
`protected static class` | `SpringLayout.SpringVertexData`
`static class` | `SpringLayout.UnitLengthFunction` Returns all edges as the same length: the input value

Field Summary
`protected double` | `force_multiplier`
`protected SpringLayout.LengthFunction` | `lengthFunction`
`protected int` | `repulsion_range`
`protected double` | `stretch`
`static SpringLayout.LengthFunction` | `UNITLENGTHFUNCTION`

Fields inherited from class edu.uci.ics.jung.visualization.AbstractLayout
`changeSupport, vertex_locations`

Constructor Summary
`SpringLayout(Graph g)` Constructor for a SpringLayout for a raw graph with associated dimension--the input knows how big the graph is.
`SpringLayout(Graph g, SpringLayout.LengthFunction f)` Constructor for a SpringLayout for a raw graph with associated component.

Method Summary
`void` | `advancePositions()` Relaxation step.
`protected void` | `calcEdgeLength(SpringLayout.SpringEdgeData sed, SpringLayout.LengthFunction f)`
`protected void` | `calculateRepulsion()`
`protected Vertex` | `getAVertex(Edge e)` Utility method, gets a single vertex from this edge.
`double` | `getForceMultiplier()`
`double` | `getLength(Edge e)`
`int` | `getRepulsionRange()`
`SpringLayout.SpringEdgeData` | `getSpringData(Edge e)`
`SpringLayout.SpringVertexData` | `getSpringData(Vertex v)`
`Object` | `getSpringKey()`
`String` | `getStatus()` Returns the status.
`double` | `getStretch()`
`boolean` | `incrementsAreDone()` For now, we pretend it never finishes.
`protected void` | `initialize_local_vertex(Vertex v)` (non-Javadoc)
`protected void` | `initialize_local()` Initializes all local information, and is called immediately within the `initialize()` process.
`boolean` | `isIncremental()` This one is an incremental visualization
`protected void` | `moveNodes()`
`protected void` | `relaxEdges()`
`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` | `setStretch(double stretch)` Sets the stretch parameter for this instance.
`void` | `update()`

Methods inherited from class edu.uci.ics.jung.visualization.AbstractLayout
`addChangeListener, applyFilter, dontMove, fireStateChanged, forceMove, getBaseKey, getChangeListeners, getCoordinates, getCurrentSize, getEdge, getEdge, getGraph, getLocation, getVertex, getVertex, getVertexIterator, getVisibleEdges, getVisibleGraph, getVisibleVertices, getX, getY, initialize, initialize, initializeLocation, initializeLocations, isLocked, lockVertex, offsetVertex, postInitialize, removeChangeListener, resize, restart, unlockVertex`

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.visualization.Layout
`applyFilter, forceMove, getCurrentSize, getGraph, getLocation, getVertex, getVertex, getVisibleEdges, getVisibleVertices, getX, getY, initialize, isLocked, lockVertex, resize, restart, unlockVertex`

Methods inherited from interface edu.uci.ics.jung.visualization.VertexLocationFunction
`getVertexIterator`

Field Detail

### stretch

    protected double stretch

### lengthFunction

    protected SpringLayout.LengthFunction lengthFunction

### repulsion_range

    protected int repulsion_range

### force_multiplier

    protected double force_multiplier

### UNITLENGTHFUNCTION

    public static final SpringLayout.LengthFunction UNITLENGTHFUNCTION

Constructor Detail

### SpringLayout

    public SpringLayout(Graph 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.

### SpringLayout

    public SpringLayout(Graph g,
                        SpringLayout.LengthFunction f)

  Constructor for a SpringLayout for a raw graph with associated component.

Parameters:
  `g` - the input Graph
  `f` - the length function

Method Detail

### getStatus

    public String getStatus()

  Returns the status.

  Specified by:
    `getStatus` in interface `Layout`
  Overrides:
    `getStatus` in class `AbstractLayout`

### getStretch

    public double getStretch()

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

### 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_local

    protected void initialize_local()

  Description copied from class: `AbstractLayout`
  Initializes all local information, and is called immediately within the `initialize()` process. The user is responsible for overriding this method to do any construction that may be necessary: for example, to initialize local per-edge or graph-wide data.

  Overrides:
    `initialize_local` in class `AbstractLayout`

### getSpringKey

    public Object getSpringKey()

### initialize_local_vertex

    protected void initialize_local_vertex(Vertex v)

  (non-Javadoc)

  Specified by:
    `initialize_local_vertex` in class `AbstractLayout`
  See Also:
    `AbstractLayout.initialize_local_vertex(edu.uci.ics.jung.graph.Vertex)`

### calcEdgeLength

    protected void calcEdgeLength(SpringLayout.SpringEdgeData sed,
                                  SpringLayout.LengthFunction f)

### advancePositions

    public void advancePositions()

  Relaxation step. Moves all nodes a smidge.

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

### getAVertex

    protected Vertex getAVertex(Edge e)

  Description copied from class: `AbstractLayout`
  Utility method, gets a single vertex from this edge. The utility's implementation is to get the iterator from the edge's `getIncidentVertices()` and then return the first element.

  Overrides:
    `getAVertex` in class `AbstractLayout`

### relaxEdges

    protected void relaxEdges()

### calculateRepulsion

    protected void calculateRepulsion()

### moveNodes

    protected void moveNodes()

### getSpringData

    public SpringLayout.SpringVertexData getSpringData(Vertex v)

### getSpringData

    public SpringLayout.SpringEdgeData getSpringData(Edge e)

### getLength

    public double getLength(Edge e)

### isIncremental

    public boolean isIncremental()

  This one is an incremental visualization

  Specified by:
    `isIncremental` in interface `Layout`

### incrementsAreDone

    public boolean incrementsAreDone()

  For now, we pretend it never finishes.

  Specified by:
    `incrementsAreDone` in interface `Layout`

### update

    public void update()

  Specified by:
    `update` in interface `LayoutMutable`
  See Also:
    `LayoutMutable.update()`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD