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

java.lang.Object
  extended by edu.uci.ics.jung.algorithms.layout.AbstractLayout<V,E>
Type Parameters:
V - the vertex type
E - the edge type
All Implemented Interfaces:
Layout<V,E>, org.apache.commons.collections15.Transformer<V,Point2D>
Direct Known Subclasses:
CircleLayout, FRLayout, FRLayout2, ISOMLayout, KKLayout, SpringLayout, StaticLayout

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

Abstract class for implementations of Layout. It handles some of the basic functions: storing coordinates, maintaining the dimensions, initializing the locations, maintaining locked vertices.

Author:
Danyel Fisher, Scott White, Tom Nelson - converted to jung2

Field Summary
protected  Graph<V,E> graph
           
protected  boolean initialized
           
protected  Map<V,Point2D> locations
           
protected  Dimension size
           
 
Constructor Summary
protected AbstractLayout(Graph<V,E> graph)
          Creates an instance which does not initialize the vertex locations.
protected AbstractLayout(Graph<V,E> graph, Dimension size)
           
protected AbstractLayout(Graph<V,E> graph, org.apache.commons.collections15.Transformer<V,Point2D> initializer)
           
protected AbstractLayout(Graph<V,E> graph, org.apache.commons.collections15.Transformer<V,Point2D> initializer, Dimension size)
           
 
Method Summary
 Graph<V,E> getGraph()
          Accessor for the graph that represets all vertices.
 Dimension getSize()
          Returns the current size of the visualization space, accoring to the last call to resize().
 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.
 boolean isLocked(V v)
          Returns true if the position of vertex v is locked.
 void lock(boolean lock)
          Locks all vertices in place if lock is true, otherwise unlocks all vertices.
 void lock(V v, boolean state)
          Locks v in place if state is true, otherwise unlocks it.
protected  void offsetVertex(V v, double xOffset, double yOffset)
           
 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 picked, double x, double y)
          Forcibly moves a vertex to the (x,y) location by setting its x and y locations to the inputted location.
 void setLocation(V picked, Point2D p)
          set the location of a vertex
 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.
 Point2D 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.layout.Layout
initialize, reset
 

Field Detail

size

protected Dimension size

graph

protected Graph<V,E> graph

initialized

protected boolean initialized

locations

protected Map<V,Point2D> locations
Constructor Detail

AbstractLayout

protected AbstractLayout(Graph<V,E> graph)
Creates an instance which does not initialize the vertex locations.

Parameters:
graph - the graph for which the layout algorithm is to be created.

AbstractLayout

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

AbstractLayout

protected AbstractLayout(Graph<V,E> graph,
                         Dimension size)

AbstractLayout

protected AbstractLayout(Graph<V,E> graph,
                         org.apache.commons.collections15.Transformer<V,Point2D> initializer,
                         Dimension 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(Dimension 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.

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>

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>

getSize

public Dimension 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 Point2D transform(V v)
Specified by:
transform in interface org.apache.commons.collections15.Transformer<V,Point2D>

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 transform(v).


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 transform(v).


offsetVertex

protected void offsetVertex(V v,
                            double xOffset,
                            double yOffset)
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,
                        double x,
                        double y)
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,
                        Point2D 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)
Locks v in place if state is true, otherwise unlocks it.

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

lock

public void lock(boolean lock)
Locks all vertices in place if lock is true, otherwise unlocks all vertices.



Copyright © 2009. All Rights Reserved.