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

java.lang.Object
  extended by edu.uci.ics.jung.algorithms.layout.TreeLayout<V,E>
All Implemented Interfaces:
Layout<V,E>, org.apache.commons.collections15.Transformer<V,Point2D>
Direct Known Subclasses:
BalloonLayout, RadialTreeLayout

public class TreeLayout<V,E>
extends Object
implements Layout<V,E>

Author:
Karlheinz Toni, Tom Nelson - converted to jung2

Field Summary
protected  Set<V> alreadyDone
           
protected  Map<V,Integer> basePositions
           
static int DEFAULT_DISTX
          The default horizontal vertex spacing.
static int DEFAULT_DISTY
          The default vertical vertex spacing.
protected  int distX
          The horizontal vertex spacing.
protected  int distY
          The vertical vertex spacing.
protected  Forest<V,E> graph
           
protected  Map<V,Point2D> locations
           
protected  Point m_currentPoint
           
protected  Dimension size
           
 
Constructor Summary
TreeLayout(Forest<V,E> g)
          Creates an instance for the specified graph with default X and Y distances.
TreeLayout(Forest<V,E> g, int distx)
          Creates an instance for the specified graph and X distance with default Y distance.
TreeLayout(Forest<V,E> g, int distx, int disty)
          Creates an instance for the specified graph, X distance, and Y distance.
 
Method Summary
protected  void buildTree()
           
protected  void buildTree(V v, int x)
           
 Point2D getCenter()
          Returns the center of this layout's area.
 Graph<V,E> getGraph()
          Returns the full graph (the one that was passed in at construction time) that this Layout refers to.
 Dimension getSize()
          Returns the current size of the visualization's space.
 void initialize()
          Initializes fields in the node that may not have been set during the constructor.
 boolean isLocked(V v)
          Returns true if the position of vertex v is locked.
 void lock(V v, boolean state)
          Sets a flag which fixes this vertex in place.
 void reset()
           
protected  void setCurrentPositionFor(V vertex)
           
 void setGraph(Graph<V,E> graph)
          setter for graph
 void setInitializer(org.apache.commons.collections15.Transformer<V,Point2D> initializer)
          provides initial locations for all vertices.
 void setLocation(V v, Point2D location)
          set the location of a vertex
 void setSize(Dimension size)
          This method is not supported by this class.
 Point2D transform(V v)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

size

protected Dimension size

graph

protected Forest<V,E> graph

basePositions

protected Map<V,Integer> basePositions

locations

protected Map<V,Point2D> locations

alreadyDone

protected transient Set<V> alreadyDone

DEFAULT_DISTX

public static int DEFAULT_DISTX
The default horizontal vertex spacing. Initialized to 50.


DEFAULT_DISTY

public static int DEFAULT_DISTY
The default vertical vertex spacing. Initialized to 50.


distX

protected int distX
The horizontal vertex spacing. Defaults to DEFAULT_XDIST.


distY

protected int distY
The vertical vertex spacing. Defaults to DEFAULT_YDIST.


m_currentPoint

protected transient Point m_currentPoint
Constructor Detail

TreeLayout

public TreeLayout(Forest<V,E> g)
Creates an instance for the specified graph with default X and Y distances.


TreeLayout

public TreeLayout(Forest<V,E> g,
                  int distx)
Creates an instance for the specified graph and X distance with default Y distance.


TreeLayout

public TreeLayout(Forest<V,E> g,
                  int distx,
                  int disty)
Creates an instance for the specified graph, X distance, and Y distance.

Method Detail

buildTree

protected void buildTree()

buildTree

protected void buildTree(V v,
                         int x)

setSize

public void setSize(Dimension size)
This method is not supported by this class. The size of the layout is determined by the topology of the tree, and by the horizontal and vertical spacing (optionally set by the constructor).

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

setCurrentPositionFor

protected void setCurrentPositionFor(V vertex)

getGraph

public Graph<V,E> getGraph()
Description copied from interface: Layout
Returns the full graph (the one that was passed in at construction time) that this Layout refers to.

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

getSize

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

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

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>

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>

lock

public void lock(V v,
                 boolean state)
Description copied from interface: Layout
Sets a flag which fixes this vertex in place.

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

reset

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

setGraph

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

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

setInitializer

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

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

getCenter

public Point2D getCenter()
Returns the center of this layout's area.


setLocation

public void setLocation(V v,
                        Point2D location)
Description copied from interface: Layout
set the location of a vertex

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

transform

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


Copyright © 2009. All Rights Reserved.