Class AbstractLayoutModel<V>
- java.lang.Object
 - 
- org.jungrapht.visualization.layout.model.AbstractLayoutModel<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>
- Direct Known Subclasses:
 DefaultLayoutModel
public abstract class AbstractLayoutModel<V> extends Object implements LayoutModel<V>
superclass for LayoutModels. Holds the required attributes for placing graph vertices in a visualization- Author:
 - Tom Nelson
 
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractLayoutModel.Builder<V,T extends AbstractLayoutModel<V>,B extends AbstractLayoutModel.Builder<V,T,B>> 
- 
Field Summary
Fields Modifier and Type Field Description protected intappendageCountprotected booleancreateVisRunnableprotected org.jgrapht.Graph<V,?>graphprotected intheightprotected Function<org.jgrapht.Graph<V,?>,Pair<Integer>>initialDimensionFunctionprotected LayoutSizeChange.SupportlayoutSizeChangeSupportprotected LayoutStateChange.SupportlayoutStateChangeSupportHandles events fired when the LayoutModel is actively being modified by a LayoutAlgorithmprotected LayoutVertexPositionChange.SupportlayoutVertexPositionSupportHandles events fired when vertex locations are changedprotected booleanlockedprotected Set<V>lockedVerticesprotected ModelChange.SupportmodelChangeSupportHandles events fired when the Graph is changedprotected intpreferredHeightprotected intpreferredWidthprotected booleanrelaxingprotected ViewChange.SupportviewChangeSupportprotected VisRunnablevisRunnableprotected intwidth 
- 
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractLayoutModel(org.jgrapht.Graph<V,?> graph, int width, int height)protectedAbstractLayoutModel(AbstractLayoutModel.Builder builder)protectedAbstractLayoutModel(LayoutModel<V> other) 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(LayoutAlgorithm<V> layoutAlgorithm)accept the visit of a LayoutAlgorithm.voidappendLayoutModel(LayoutModel<V> layoutModel)Append the supplied layoutModel to the right of this LayoutModel by increasing the width of this layoutModel by the width of the supplied LayoutModel, and by offsetting all locations in the new layoutModel by the previous width of this layoutModel<E> org.jgrapht.Graph<V,E>getGraph()intgetHeight()LayoutSizeChange.SupportgetLayoutSizeChangeSupport()LayoutStateChange.SupportgetLayoutStateChangeSupport()LayoutVertexPositionChange.Support<V>getLayoutVertexPositionSupport()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)lock the entire model (all vertices)voidlock(V vertex, boolean locked)set locked state for the provided vertexprotected voidoffsetvertex(V vertex, double xOffset, double yOffset)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 theGraphvoidsetPreferredSize(int preferredWidth, int preferredHeight)voidsetRelaxing(boolean relaxing)indicates that there is a relaxer thread operating on this LayoutModelvoidsetSize(int width, int height)voidsetSize(int width, int height, boolean adjustLocations)protected voidsetupVisRunner(IterativeLayoutAlgorithm iterativeContext)create and start a new VisRunner for the passed IterativeContextvoidstop()stop any running RelaxerStringtoString()- 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 
- 
Methods inherited from interface org.jungrapht.visualization.layout.model.LayoutModel
get, getCenter, getLocations, setFireEvents, setInitializer 
 - 
 
 - 
 
- 
- 
Field Detail
- 
locked
protected boolean locked
 
- 
width
protected int width
 
- 
height
protected int height
 
- 
preferredWidth
protected int preferredWidth
 
- 
preferredHeight
protected int preferredHeight
 
- 
createVisRunnable
protected boolean createVisRunnable
 
- 
graph
protected org.jgrapht.Graph<V,?> graph
 
- 
visRunnable
protected VisRunnable visRunnable
 
- 
relaxing
protected boolean relaxing
 
- 
layoutVertexPositionSupport
protected LayoutVertexPositionChange.Support layoutVertexPositionSupport
Handles events fired when vertex locations are changed 
- 
layoutStateChangeSupport
protected LayoutStateChange.Support layoutStateChangeSupport
Handles events fired when the LayoutModel is actively being modified by a LayoutAlgorithm 
- 
modelChangeSupport
protected ModelChange.Support modelChangeSupport
Handles events fired when the Graph is changed 
- 
viewChangeSupport
protected ViewChange.Support viewChangeSupport
 
- 
layoutSizeChangeSupport
protected LayoutSizeChange.Support layoutSizeChangeSupport
 
- 
appendageCount
protected int appendageCount
 
 - 
 
- 
Constructor Detail
- 
AbstractLayoutModel
protected AbstractLayoutModel(AbstractLayoutModel.Builder builder)
 
- 
AbstractLayoutModel
protected AbstractLayoutModel(LayoutModel<V> other)
 
- 
AbstractLayoutModel
protected AbstractLayoutModel(org.jgrapht.Graph<V,?> graph, int width, int height)
 
 - 
 
- 
Method Detail
- 
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>
 
- 
stop
public void stop()
stop any running Relaxer- Specified by:
 stopin interfaceLayoutModel<V>
 
- 
accept
public void accept(LayoutAlgorithm<V> layoutAlgorithm)
accept the visit of a LayoutAlgorithm. If it is an IterativeContext, create a VisRunner to run its relaxer in a new Thread. If there is a current VisRunner, stop it first.- set size to preferred width/height
 - fire LayoutStateChanged event
 - enable LayoutVertexPosition event firing
 - fire ModelChanged event
 - call the LayoutAlgorithm visit method to initiate the algorithm
 
- Specified by:
 acceptin interfaceLayoutModel<V>- Parameters:
 layoutAlgorithm- the algorithm to apply to the model vertex locations
 
- 
getLayoutStateChangeSupport
public LayoutStateChange.Support getLayoutStateChangeSupport()
- Specified by:
 getLayoutStateChangeSupportin interfaceLayoutStateChange.Producer
 
- 
getModelChangeSupport
public ModelChange.Support getModelChangeSupport()
- Specified by:
 getModelChangeSupportin interfaceModelChange.Producer
 
- 
getViewChangeSupport
public ViewChange.Support getViewChangeSupport()
- Specified by:
 getViewChangeSupportin interfaceViewChange.Producer
 
- 
setupVisRunner
protected void setupVisRunner(IterativeLayoutAlgorithm iterativeContext)
create and start a new VisRunner for the passed IterativeContext- Parameters:
 iterativeContext- the algorithm to run in a thread
 
- 
getGraph
public <E> org.jgrapht.Graph<V,E> getGraph()
- Specified by:
 getGraphin interfaceLayoutModel<V>- Returns:
 - the graph
 
 
- 
setGraph
public void setGraph(org.jgrapht.Graph<V,?> graph)
- Specified by:
 setGraphin interfaceLayoutModel<V>- Parameters:
 graph- theGraphto set
 
- 
lock
public void lock(V vertex, boolean locked)
set locked state for the provided vertex- Specified by:
 lockin interfaceLayoutModel<V>- Parameters:
 vertex- the vertex to affectlocked- to lock or not
 
- 
isLocked
public boolean isLocked(V vertex)
- Specified by:
 isLockedin interfaceLayoutModel<V>- Parameters:
 vertex- the vertex whose locked state is being queried- Returns:
 - whether the passed vertex is locked
 
 
- 
lock
public void lock(boolean locked)
lock the entire model (all vertices)- Specified by:
 lockin interfaceLayoutModel<V>- Parameters:
 locked- will prevent the vertices from being moved
 
- 
isLocked
public boolean isLocked()
- Specified by:
 isLockedin interfaceLayoutModel<V>- Returns:
 - whether this LayoutModel is locked for all vertices
 
 
- 
setSize
public void setSize(int width, int height)- Specified by:
 setSizein interfaceLayoutModel<V>- Parameters:
 width- to setheight- to set
 
- 
setPreferredSize
public void setPreferredSize(int preferredWidth, int preferredHeight)- Specified by:
 setPreferredSizein interfaceLayoutModel<V>- Parameters:
 preferredWidth- to setpreferredHeight- to set
 
- 
setSize
public void setSize(int width, int height, boolean adjustLocations) 
- 
getWidth
public int getWidth()
- Specified by:
 getWidthin interfaceLayoutModel<V>- Returns:
 - the width of the layout domain
 
 
- 
getHeight
public int getHeight()
- Specified by:
 getHeightin interfaceLayoutModel<V>- Returns:
 - the height of the layout domain
 
 
- 
getPreferredWidth
public int getPreferredWidth()
- Specified by:
 getPreferredWidthin interfaceLayoutModel<V>- Returns:
 - the width of the layout domain
 
 
- 
getPreferredHeight
public int getPreferredHeight()
- Specified by:
 getPreferredHeightin interfaceLayoutModel<V>- Returns:
 - the height of the layout domain
 
 
- 
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
 
- 
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
 
- 
offsetvertex
protected void offsetvertex(V vertex, double xOffset, double yOffset)
- Parameters:
 vertex- the vertex whose coordinates are to be offsetxOffset- the change to apply to this vertex's x coordinateyOffset- the change to apply to this vertex's y coordinate
 
- 
getLayoutVertexPositionSupport
public LayoutVertexPositionChange.Support<V> getLayoutVertexPositionSupport()
- Specified by:
 getLayoutVertexPositionSupportin interfaceLayoutVertexPositionChange.Producer<V>
 
- 
getLayoutSizeChangeSupport
public LayoutSizeChange.Support getLayoutSizeChangeSupport()
- Specified by:
 getLayoutSizeChangeSupportin interfaceLayoutSizeChange.Producer<V>
 
- 
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
 
 
- 
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
 
- 
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>
 
- 
resizeToSurroundingRectangle
public void resizeToSurroundingRectangle()
- Specified by:
 resizeToSurroundingRectanglein interfaceLayoutModel<V>
 
- 
appendLayoutModel
public void appendLayoutModel(LayoutModel<V> layoutModel)
Append the supplied layoutModel to the right of this LayoutModel by increasing the width of this layoutModel by the width of the supplied LayoutModel, and by offsetting all locations in the new layoutModel by the previous width of this layoutModel- Specified by:
 appendLayoutModelin interfaceLayoutModel<V>- Parameters:
 layoutModel- contains width and vertex locations to place
 
 - 
 
 -