Class AggregateLayoutModel<V>
- java.lang.Object
-
- org.jungrapht.visualization.layout.model.AggregateLayoutModel<V>
-
- Type Parameters:
V
- the vertex type
- All Implemented Interfaces:
Function<V,Point>
,LayoutSizeChange.Producer<V>
,LayoutStateChange.Producer
,LayoutVertexPositionChange.Listener<V>
,LayoutVertexPositionChange.Producer<V>
,ModelChange.Producer
,ViewChange.Producer
,LayoutModel<V>
public class AggregateLayoutModel<V> extends Object implements LayoutModel<V>
ALayoutModel
implementation that combines multiple other layoutModels so that they may be manipulated as one layoutModel. The relaxer thread will step each layoutmodel's algorithm in sequence.- Author:
- Tom Nelson
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jungrapht.visualization.layout.model.LayoutModel
LayoutModel.Builder<V,T extends DefaultLayoutModel<V>,B extends LayoutModel.Builder<V,T,B>>
-
-
Field Summary
Fields Modifier and Type Field Description protected LayoutModel<V>
delegate
protected Map<LayoutModel<V>,Point>
layouts
-
Constructor Summary
Constructors Constructor Description AggregateLayoutModel(LayoutModel<V> delegate)
Creates an instance backed by the specifieddelegate
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(LayoutAlgorithm<V> layoutAlgorithm)
allow the passed LayoutAlgorithm to operate on this LayoutModelvoid
appendLayoutModel(LayoutModel<V> layoutModel)
Point
apply(V vertex)
Returns the location of the vertex.Point
get(LayoutModel<V> layout)
Point
get(V vertex)
<E> org.jgrapht.Graph<V,E>
getGraph()
int
getHeight()
LayoutSizeChange.Support<V>
getLayoutSizeChangeSupport()
LayoutStateChange.Support
getLayoutStateChangeSupport()
LayoutVertexPositionChange.Support<V>
getLayoutVertexPositionSupport()
Map<V,Point>
getLocations()
ModelChange.Support
getModelChangeSupport()
int
getPreferredHeight()
int
getPreferredWidth()
ViewChange.Support
getViewChangeSupport()
int
getWidth()
boolean
isLocked()
boolean
isLocked(V vertex)
boolean
isRelaxing()
indicates that there is a relaxer thread operating on this LayoutModelvoid
layoutVertexPositionChanged(LayoutVertexPositionChange.Event<V> evt)
void
layoutVertexPositionChanged(LayoutVertexPositionChange.GraphEvent<V> evt)
void
lock(boolean locked)
void
lock(V vertex, boolean state)
Locks this vertex in the main layout and in any sublayouts whose graph contains this vertex.void
put(LayoutModel<V> layoutModel, Point center)
Adds the passed layout as a sublayout, and specifies the center of where this sublayout should appear.void
remove(LayoutModel<V> layout)
Removeslayout
from this instance.void
removeAll()
Removes all layouts from this instance.void
resizeToSurroundingRectangle()
void
set(V vertex, double x, double y)
Changes the layout coordinates ofvertex
tox, y
.void
set(V vertex, Point location)
Changes the layout coordinates ofvertex
tolocation
.void
setGraph(org.jgrapht.Graph<V,?> graph)
void
setInitialDimensionFunction(Function<org.jgrapht.Graph<V,?>,Pair<Integer>> initialDimensionFunction)
The initialDimensionFunction sets the layout area bounds by evaluating theGraph
void
setInitializer(Function<V,Point> initializer)
void
setPreferredSize(int width, int height)
void
setRelaxing(boolean relaxing)
indicates that there is a relaxer thread operating on this LayoutModelvoid
setSize(int width, int height)
void
stop()
stop a relaxer Thread from continuing to operate-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jungrapht.visualization.layout.model.LayoutModel
getCenter, setFireEvents
-
-
-
-
Field Detail
-
delegate
protected final LayoutModel<V> delegate
-
layouts
protected Map<LayoutModel<V>,Point> layouts
-
-
Constructor Detail
-
AggregateLayoutModel
public AggregateLayoutModel(LayoutModel<V> delegate)
Creates an instance backed by the specifieddelegate
.- Parameters:
delegate
- the layout to which this instance is delegating
-
-
Method Detail
-
put
public void put(LayoutModel<V> layoutModel, Point center)
Adds the passed layout as a sublayout, and specifies the center of where this sublayout should appear.- Parameters:
layoutModel
- the layout model to use as a sublayoutcenter
- the center of the coordinates for the sublayout model
-
get
public Point get(LayoutModel<V> layout)
- Parameters:
layout
- the layout whose center is to be returned- Returns:
- the center of the passed layout
-
accept
public void accept(LayoutAlgorithm<V> layoutAlgorithm)
Description copied from interface:LayoutModel
allow the passed LayoutAlgorithm to operate on this LayoutModel- Specified by:
accept
in interfaceLayoutModel<V>
- Parameters:
layoutAlgorithm
- the algorithm to apply to this model's Points
-
getLocations
public Map<V,Point> getLocations()
- Specified by:
getLocations
in interfaceLayoutModel<V>
- Returns:
- a mapping of Vertices to Point locations
-
setInitialDimensionFunction
public void setInitialDimensionFunction(Function<org.jgrapht.Graph<V,?>,Pair<Integer>> initialDimensionFunction)
Description copied from interface:LayoutModel
The initialDimensionFunction sets the layout area bounds by evaluating theGraph
- Specified by:
setInitialDimensionFunction
in interfaceLayoutModel<V>
-
setSize
public void setSize(int width, int height)
- Specified by:
setSize
in interfaceLayoutModel<V>
- Parameters:
width
- to setheight
- to set
-
setPreferredSize
public void setPreferredSize(int width, int height)
- Specified by:
setPreferredSize
in interfaceLayoutModel<V>
- Parameters:
width
- to setheight
- to set
-
stop
public void stop()
Description copied from interface:LayoutModel
stop a relaxer Thread from continuing to operate- Specified by:
stop
in interfaceLayoutModel<V>
-
setRelaxing
public void setRelaxing(boolean relaxing)
Description copied from interface:LayoutModel
indicates that there is a relaxer thread operating on this LayoutModel- Specified by:
setRelaxing
in interfaceLayoutModel<V>
- Parameters:
relaxing
- whether there is a relaxer thread
-
isRelaxing
public boolean isRelaxing()
Description copied from interface:LayoutModel
indicates that there is a relaxer thread operating on this LayoutModel- Specified by:
isRelaxing
in interfaceLayoutModel<V>
- Returns:
- relaxing
-
set
public void set(V vertex, Point location)
Description copied from interface:LayoutModel
Changes the layout coordinates ofvertex
tolocation
.- Specified by:
set
in interfaceLayoutModel<V>
- Parameters:
vertex
- the vertex whose location is to be specifiedlocation
- the coordinates of the specified location
-
set
public void set(V vertex, double x, double y)
Description copied from interface:LayoutModel
Changes the layout coordinates ofvertex
tox, y
.- Specified by:
set
in interfaceLayoutModel<V>
- Parameters:
vertex
- the vertex to set location forx
- coordinate to sety
- coordinate to set
-
get
public Point get(V vertex)
- Specified by:
get
in interfaceLayoutModel<V>
- Parameters:
vertex
- the vertex of interest- Returns:
- the Point location for vertex
-
getGraph
public <E> org.jgrapht.Graph<V,E> getGraph()
- Specified by:
getGraph
in interfaceLayoutModel<V>
- Returns:
- the
Graph
that this model is mediating
-
setGraph
public void setGraph(org.jgrapht.Graph<V,?> graph)
- Specified by:
setGraph
in interfaceLayoutModel<V>
- Parameters:
graph
- theGraph
to set
-
remove
public void remove(LayoutModel<V> layout)
Removeslayout
from this instance.- Parameters:
layout
- the layout to remove
-
removeAll
public void removeAll()
Removes all layouts from this instance.
-
getWidth
public int getWidth()
- Specified by:
getWidth
in interfaceLayoutModel<V>
- Returns:
- the width of the layout area
-
getHeight
public int getHeight()
- Specified by:
getHeight
in interfaceLayoutModel<V>
- Returns:
- the height of the layout area
-
getPreferredWidth
public int getPreferredWidth()
- Specified by:
getPreferredWidth
in interfaceLayoutModel<V>
-
getPreferredHeight
public int getPreferredHeight()
- Specified by:
getPreferredHeight
in interfaceLayoutModel<V>
-
isLocked
public boolean isLocked(V vertex)
- Specified by:
isLocked
in interfaceLayoutModel<V>
- Parameters:
vertex
- the vertex whose locked state is to be returned- Returns:
- true if v is locked in any of the layouts, and false otherwise
-
lock
public void lock(V vertex, boolean state)
Locks this vertex in the main layout and in any sublayouts whose graph contains this vertex.- Specified by:
lock
in interfaceLayoutModel<V>
- Parameters:
vertex
- the vertex whose locked state is to be setstate
-true
if the vertex is to be locked, andfalse
if unlocked
-
lock
public void lock(boolean locked)
- Specified by:
lock
in interfaceLayoutModel<V>
-
isLocked
public boolean isLocked()
- Specified by:
isLocked
in interfaceLayoutModel<V>
-
setInitializer
public void setInitializer(Function<V,Point> initializer)
- Specified by:
setInitializer
in interfaceLayoutModel<V>
-
resizeToSurroundingRectangle
public void resizeToSurroundingRectangle()
- Specified by:
resizeToSurroundingRectangle
in interfaceLayoutModel<V>
-
getLayoutStateChangeSupport
public LayoutStateChange.Support getLayoutStateChangeSupport()
- Specified by:
getLayoutStateChangeSupport
in interfaceLayoutStateChange.Producer
-
getLayoutSizeChangeSupport
public LayoutSizeChange.Support<V> getLayoutSizeChangeSupport()
- Specified by:
getLayoutSizeChangeSupport
in interfaceLayoutSizeChange.Producer<V>
-
apply
public Point apply(V vertex)
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.
-
getModelChangeSupport
public ModelChange.Support getModelChangeSupport()
- Specified by:
getModelChangeSupport
in interfaceModelChange.Producer
-
getViewChangeSupport
public ViewChange.Support getViewChangeSupport()
- Specified by:
getViewChangeSupport
in interfaceViewChange.Producer
-
getLayoutVertexPositionSupport
public LayoutVertexPositionChange.Support<V> getLayoutVertexPositionSupport()
- Specified by:
getLayoutVertexPositionSupport
in interfaceLayoutVertexPositionChange.Producer<V>
-
layoutVertexPositionChanged
public void layoutVertexPositionChanged(LayoutVertexPositionChange.Event<V> evt)
- Specified by:
layoutVertexPositionChanged
in interfaceLayoutVertexPositionChange.Listener<V>
-
layoutVertexPositionChanged
public void layoutVertexPositionChanged(LayoutVertexPositionChange.GraphEvent<V> evt)
- Specified by:
layoutVertexPositionChanged
in interfaceLayoutVertexPositionChange.Listener<V>
-
appendLayoutModel
public void appendLayoutModel(LayoutModel<V> layoutModel)
- Specified by:
appendLayoutModel
in interfaceLayoutModel<V>
-
-