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 -
All Implemented Interfaces:
Layout<V,E>
Direct Known Subclasses:
CircleLayout, FRLayout, FRLayout2, ISOMLayout, KKLayout, SpringLayout, SpringLayout2, StaticLayout

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, Tom Nelson - converted to jung2

Field Summary
protected  boolean initialized
           
protected  Map<V,Point2D> locations
           
 
Constructor Summary
protected AbstractLayout(Graph<V,E> graph)
          Creates an instance which does not initialize the vertex locations.
protected AbstractLayout(Graph<V,E> graph,  initializer)
           
protected AbstractLayout(Graph<V,E> graph,  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().
 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.
 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, double xOffset, double yOffset)
           
 void setGraph(Graph<V,E> graph)
          setter for graph
 void setInitializer( 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

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,
                          initializer)

AbstractLayout

protected AbstractLayout(Graph<V,E> graph,
                          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>

getVertices

public Collection<V> getVertices()

setInitializer

public void setInitializer( 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)

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)
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 © 2008 null. All Rights Reserved.