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

java.lang.Object
  extended by edu.uci.ics.jung.algorithms.layout.AggregateLayout<V,E>
Type Parameters:
V - the vertex type
E - the edge type
All Implemented Interfaces:
Layout<V,E>, IterativeContext, org.apache.commons.collections15.Transformer<V,Point2D>

public class AggregateLayout<V,E>
extends Object
implements Layout<V,E>, IterativeContext

A Layout implementation that combines multiple other layouts so that they may be manipulated as one layout. The relaxer thread will step each layout in sequence.

Author:
Tom Nelson - tomnelson@dev.java.net

Field Summary
protected  Layout<V,E> delegate
           
protected  Map<Layout<V,E>,Point2D> layouts
           
 
Constructor Summary
AggregateLayout(Layout<V,E> delegate)
          Creates an instance backed by the specified delegate.
 
Method Summary
 boolean done()
          Check all sublayouts.keySet() and the delegate layout, returning done == true iff all are done.
 Point2D get(Layout<V,E> layout)
          Returns the center of the passed layout.
 Layout<V,E> getDelegate()
           
 Graph<V,E> getGraph()
          Returns the graph for which this layout is defined.
 Map<Layout<V,E>,Point2D> getLayouts()
          Returns a map from each Layout instance to its center point.
 Dimension getSize()
          Returns the size of the underlying layout.
 void initialize()
          Initializes fields in the node that may not have been set during the constructor.
 boolean isLocked(V v)
          Override to test if the passed vertex is locked in any of the layouts.
 void lock(V v, boolean state)
          override to lock or unlock this vertex in any layout with a subgraph containing it
 void put(Layout<V,E> layout, Point2D center)
          adds the passed layout as a sublayout, also specifying the center of where this sublayout should appear
 void remove(Layout<V,E> layout)
          Removes layout from this instance.
 void removeAll()
          Removes all layouts from this instance.
 void reset()
           
 void setDelegate(Layout<V,E> delegate)
           
 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 d)
           
 void step()
          call step on any sublayout that is also an IterativeContext and is not done
 Point2D transform(V v)
          Returns the location of the vertex.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delegate

protected Layout<V,E> delegate

layouts

protected Map<Layout<V,E>,Point2D> layouts
Constructor Detail

AggregateLayout

public AggregateLayout(Layout<V,E> delegate)
Creates an instance backed by the specified delegate.

Parameters:
delegate -
Method Detail

getDelegate

public Layout<V,E> getDelegate()
Returns:
the delegate

setDelegate

public void setDelegate(Layout<V,E> delegate)
Parameters:
delegate - the delegate to set

put

public void put(Layout<V,E> layout,
                Point2D center)
adds the passed layout as a sublayout, also specifying the center of where this sublayout should appear

Parameters:
layout -
center -

get

public Point2D get(Layout<V,E> layout)
Returns the center of the passed layout.

Parameters:
layout -
Returns:
the center of the passed layout

remove

public void remove(Layout<V,E> layout)
Removes layout from this instance.


removeAll

public void removeAll()
Removes all layouts from this instance.


getGraph

public Graph<V,E> getGraph()
Returns the graph for which this layout is defined.

Specified by:
getGraph in interface Layout<V,E>
Returns:
the graph for which this layout is defined
See Also:
Layout.getGraph()

getSize

public Dimension getSize()
Returns the size of the underlying layout.

Specified by:
getSize in interface Layout<V,E>
Returns:
the size of the underlying layout
See Also:
Layout.getSize()

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>
See Also:
Layout.initialize()

isLocked

public boolean isLocked(V v)
Override to test if the passed vertex is locked in any of the layouts.

Specified by:
isLocked in interface Layout<V,E>
Parameters:
v -
Returns:
true if v is locked in any of the layouts, and false otherwise
See Also:
Layout.isLocked(java.lang.Object)

lock

public void lock(V v,
                 boolean state)
override to lock or unlock this vertex in any layout with a subgraph containing it

Specified by:
lock in interface Layout<V,E>
Parameters:
v -
state -
See Also:
Layout.lock(java.lang.Object, boolean)

reset

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

setGraph

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

Specified by:
setGraph in interface Layout<V,E>
Parameters:
graph -
See Also:
Layout.setGraph(edu.uci.ics.jung.graph.Graph)

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>
Parameters:
initializer -
See Also:
Layout.setInitializer(org.apache.commons.collections15.Transformer)

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>
Parameters:
v -
location -
See Also:
Layout.setLocation(java.lang.Object, java.awt.geom.Point2D)

setSize

public void setSize(Dimension d)
Specified by:
setSize in interface Layout<V,E>
Parameters:
d -
See Also:
Layout.setSize(java.awt.Dimension)

getLayouts

public Map<Layout<V,E>,Point2D> getLayouts()
Returns a map from each Layout instance to its center point.


transform

public Point2D transform(V v)
Returns the location of the vertex. The location is specified first by the sublayouts, and then by the base layout if no sublayouts operate on this vertex.

Specified by:
transform in interface org.apache.commons.collections15.Transformer<V,Point2D>
Returns:
the location of the vertex
See Also:
Transformer.transform(java.lang.Object)

done

public boolean done()
Check all sublayouts.keySet() and the delegate layout, returning done == true iff all are done.

Specified by:
done in interface IterativeContext

step

public void step()
call step on any sublayout that is also an IterativeContext and is not done

Specified by:
step in interface IterativeContext


Copyright © 2009. All Rights Reserved.