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>
ALayoutModelimplementation 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>delegateprotected 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 voidaccept(LayoutAlgorithm<V> layoutAlgorithm)allow the passed LayoutAlgorithm to operate on this LayoutModelvoidappendLayoutModel(LayoutModel<V> layoutModel)Pointapply(V vertex)Returns the location of the vertex.Pointget(LayoutModel<V> layout)Pointget(V vertex)<E> org.jgrapht.Graph<V,E>getGraph()intgetHeight()LayoutSizeChange.Support<V>getLayoutSizeChangeSupport()LayoutStateChange.SupportgetLayoutStateChangeSupport()LayoutVertexPositionChange.Support<V>getLayoutVertexPositionSupport()Map<V,Point>getLocations()ModelChange.SupportgetModelChangeSupport()intgetPreferredHeight()intgetPreferredWidth()ViewChange.SupportgetViewChangeSupport()intgetWidth()booleanisLocked()booleanisLocked(V vertex)booleanisRelaxing()indicates that there is a relaxer thread operating on this LayoutModelvoidlayoutVertexPositionChanged(LayoutVertexPositionChange.Event<V> evt)voidlayoutVertexPositionChanged(LayoutVertexPositionChange.GraphEvent<V> evt)voidlock(boolean locked)voidlock(V vertex, boolean state)Locks this vertex in the main layout and in any sublayouts whose graph contains this vertex.voidput(LayoutModel<V> layoutModel, Point center)Adds the passed layout as a sublayout, and specifies the center of where this sublayout should appear.voidremove(LayoutModel<V> layout)Removeslayoutfrom this instance.voidremoveAll()Removes all layouts from this instance.voidresizeToSurroundingRectangle()voidset(V vertex, double x, double y)Changes the layout coordinates ofvertextox, y.voidset(V vertex, Point location)Changes the layout coordinates ofvertextolocation.voidsetGraph(org.jgrapht.Graph<V,?> graph)voidsetInitialDimensionFunction(Function<org.jgrapht.Graph<V,?>,Pair<Integer>> initialDimensionFunction)The initialDimensionFunction sets the layout area bounds by evaluating theGraphvoidsetInitializer(Function<V,Point> initializer)voidsetPreferredSize(int width, int height)voidsetRelaxing(boolean relaxing)indicates that there is a relaxer thread operating on this LayoutModelvoidsetSize(int width, int height)voidstop()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:LayoutModelallow the passed LayoutAlgorithm to operate on this LayoutModel- Specified by:
acceptin interfaceLayoutModel<V>- Parameters:
layoutAlgorithm- the algorithm to apply to this model's Points
-
getLocations
public Map<V,Point> getLocations()
- Specified by:
getLocationsin 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:LayoutModelThe initialDimensionFunction sets the layout area bounds by evaluating theGraph- Specified by:
setInitialDimensionFunctionin interfaceLayoutModel<V>
-
setSize
public void setSize(int width, int height)- Specified by:
setSizein interfaceLayoutModel<V>- Parameters:
width- to setheight- to set
-
setPreferredSize
public void setPreferredSize(int width, int height)- Specified by:
setPreferredSizein interfaceLayoutModel<V>- Parameters:
width- to setheight- to set
-
stop
public void stop()
Description copied from interface:LayoutModelstop a relaxer Thread from continuing to operate- Specified by:
stopin interfaceLayoutModel<V>
-
setRelaxing
public void setRelaxing(boolean relaxing)
Description copied from interface:LayoutModelindicates that there is a relaxer thread operating on this LayoutModel- Specified by:
setRelaxingin interfaceLayoutModel<V>- Parameters:
relaxing- whether there is a relaxer thread
-
isRelaxing
public boolean isRelaxing()
Description copied from interface:LayoutModelindicates that there is a relaxer thread operating on this LayoutModel- Specified by:
isRelaxingin interfaceLayoutModel<V>- Returns:
- relaxing
-
set
public void set(V vertex, Point location)
Description copied from interface:LayoutModelChanges the layout coordinates ofvertextolocation.- Specified by:
setin 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:LayoutModelChanges the layout coordinates ofvertextox, y.- Specified by:
setin interfaceLayoutModel<V>- Parameters:
vertex- the vertex to set location forx- coordinate to sety- coordinate to set
-
get
public Point get(V vertex)
- Specified by:
getin 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:
getGraphin interfaceLayoutModel<V>- Returns:
- the
Graphthat this model is mediating
-
setGraph
public void setGraph(org.jgrapht.Graph<V,?> graph)
- Specified by:
setGraphin interfaceLayoutModel<V>- Parameters:
graph- theGraphto set
-
remove
public void remove(LayoutModel<V> layout)
Removeslayoutfrom this instance.- Parameters:
layout- the layout to remove
-
removeAll
public void removeAll()
Removes all layouts from this instance.
-
getWidth
public int getWidth()
- Specified by:
getWidthin interfaceLayoutModel<V>- Returns:
- the width of the layout area
-
getHeight
public int getHeight()
- Specified by:
getHeightin interfaceLayoutModel<V>- Returns:
- the height of the layout area
-
getPreferredWidth
public int getPreferredWidth()
- Specified by:
getPreferredWidthin interfaceLayoutModel<V>
-
getPreferredHeight
public int getPreferredHeight()
- Specified by:
getPreferredHeightin interfaceLayoutModel<V>
-
isLocked
public boolean isLocked(V vertex)
- Specified by:
isLockedin 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:
lockin interfaceLayoutModel<V>- Parameters:
vertex- the vertex whose locked state is to be setstate-trueif the vertex is to be locked, andfalseif unlocked
-
lock
public void lock(boolean locked)
- Specified by:
lockin interfaceLayoutModel<V>
-
isLocked
public boolean isLocked()
- Specified by:
isLockedin interfaceLayoutModel<V>
-
setInitializer
public void setInitializer(Function<V,Point> initializer)
- Specified by:
setInitializerin interfaceLayoutModel<V>
-
resizeToSurroundingRectangle
public void resizeToSurroundingRectangle()
- Specified by:
resizeToSurroundingRectanglein interfaceLayoutModel<V>
-
getLayoutStateChangeSupport
public LayoutStateChange.Support getLayoutStateChangeSupport()
- Specified by:
getLayoutStateChangeSupportin interfaceLayoutStateChange.Producer
-
getLayoutSizeChangeSupport
public LayoutSizeChange.Support<V> getLayoutSizeChangeSupport()
- Specified by:
getLayoutSizeChangeSupportin 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:
getModelChangeSupportin interfaceModelChange.Producer
-
getViewChangeSupport
public ViewChange.Support getViewChangeSupport()
- Specified by:
getViewChangeSupportin interfaceViewChange.Producer
-
getLayoutVertexPositionSupport
public LayoutVertexPositionChange.Support<V> getLayoutVertexPositionSupport()
- Specified by:
getLayoutVertexPositionSupportin interfaceLayoutVertexPositionChange.Producer<V>
-
layoutVertexPositionChanged
public void layoutVertexPositionChanged(LayoutVertexPositionChange.Event<V> evt)
- Specified by:
layoutVertexPositionChangedin interfaceLayoutVertexPositionChange.Listener<V>
-
layoutVertexPositionChanged
public void layoutVertexPositionChanged(LayoutVertexPositionChange.GraphEvent<V> evt)
- Specified by:
layoutVertexPositionChangedin interfaceLayoutVertexPositionChange.Listener<V>
-
appendLayoutModel
public void appendLayoutModel(LayoutModel<V> layoutModel)
- Specified by:
appendLayoutModelin interfaceLayoutModel<V>
-
-