Package org.eclipse.gef.layout
Class LayoutContext
- java.lang.Object
-
- org.eclipse.gef.layout.LayoutContext
-
public class LayoutContext extends java.lang.ObjectTheLayoutContextprovides the context in which to layout aGraph. It maintains anILayoutAlgorithmthat can be applied, supports the handling and execution of pre and postRunnables, and filtering of layout objects usingILayoutFilter.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringLAYOUT_ALGORITHM_PROPERTYAnLayoutContextnotifies registered listeners about changes to the layout algorithm using this property name.
-
Constructor Summary
Constructors Constructor Description LayoutContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLayoutFilter(ILayoutFilter layoutFilter)Adds the given ILayoutFilter to thisLayoutContext.voidapplyLayout(boolean clear)Applies the layout algorithm of this LayoutContext.org.eclipse.gef.graph.Edge[]getEdges()Returns all the connections between nodes that should be laid out.org.eclipse.gef.graph.GraphgetGraph()Returns the graph that is to be layouted.ILayoutAlgorithmgetLayoutAlgorithm()Returns the static layout algorithm used to layout a newly initialized graph or after heavy changes to it.org.eclipse.gef.graph.Node[]getNodes()Returns all the nodes that should be laid out.booleanisLayoutIrrelevant(org.eclipse.gef.graph.Edge edge)Returnstruewhen the givenEdgeis not relevant for layout according to the configuredlayout filters.booleanisLayoutIrrelevant(org.eclipse.gef.graph.Node nodeLayout)Returnstruewhen the givenNodeis not relevant for layout according to the configuredlayout filters.javafx.beans.property.ObjectProperty<ILayoutAlgorithm>layoutAlgorithmProperty()A property representing the layout algorithm used by thisLayoutContext.voidpostLayout()Initiated by the context or by anILayoutAlgorithmto perform steps that are scheduled to be run after the layout pass.voidpreLayout()Initiated by the context or by anILayoutAlgorithmto perform steps that are scheduled to be run before the layout pass.voidremoveLayoutFilter(ILayoutFilter layoutFilter)Removes the given ILayoutFilter from thisLayoutContext.voidschedulePostLayoutPass(java.lang.Runnable runnable)Adds the givenRunnableto the list of runnables which are called when thisLayoutContextis asked to apply all changes made to its elements to the display.voidschedulePreLayoutPass(java.lang.Runnable runnable)Adds the givenRunnableto the list ofRunnables which are executed before applying a layout, i.e. beforeapplyLayout(boolean).voidsetGraph(org.eclipse.gef.graph.Graph graph)Sets the graph that is to be layouted by this context.voidsetLayoutAlgorithm(ILayoutAlgorithm algorithm)Sets the layout algorithm for this context.voidunschedulePostLayoutPass(java.lang.Runnable runnable)Removes the givenRunnablefrom the list of runnables which are called when thisLayoutContextis asked to apply all changes made to its elements to the display.voidunschedulePreLayoutPass(java.lang.Runnable runnable)Removes the givenRunnablefrom the list ofRunnables which are executed before applying a layout, i.e. beforeapplyLayout(boolean).
-
-
-
Field Detail
-
LAYOUT_ALGORITHM_PROPERTY
public static final java.lang.String LAYOUT_ALGORITHM_PROPERTY
AnLayoutContextnotifies registered listeners about changes to the layout algorithm using this property name.- See Also:
- Constant Field Values
-
-
Method Detail
-
addLayoutFilter
public void addLayoutFilter(ILayoutFilter layoutFilter)
Adds the given ILayoutFilter to thisLayoutContext.- Parameters:
layoutFilter- The ILayoutFilter to add to this context.
-
applyLayout
public void applyLayout(boolean clear)
Applies the layout algorithm of this LayoutContext. The clean flag is passed-in to the layout algorithm to indicate whether the context changed significantly since the last layout pass.- Parameters:
clear-trueto indicate that the algorithm has to fully re-compute the layout, otherwisefalse.
-
postLayout
public void postLayout()
Initiated by the context or by anILayoutAlgorithmto perform steps that are scheduled to be run after the layout pass. Should not be called by clients.
-
preLayout
public void preLayout()
Initiated by the context or by anILayoutAlgorithmto perform steps that are scheduled to be run before the layout pass. Should not be called by clients.
-
getGraph
public org.eclipse.gef.graph.Graph getGraph()
Returns the graph that is to be layouted.- Returns:
- The
Graphthat is to be layouted.
-
setGraph
public void setGraph(org.eclipse.gef.graph.Graph graph)
Sets the graph that is to be layouted by this context.- Parameters:
graph- TheGraphto layout.
-
getNodes
public org.eclipse.gef.graph.Node[] getNodes()
Returns all the nodes that should be laid out. Replacing elements in the returned array does not affect this context.- Returns:
- array of nodes to lay out
-
getEdges
public org.eclipse.gef.graph.Edge[] getEdges()
Returns all the connections between nodes that should be laid out. Replacing elements in the returned array does not affect this context.- Returns:
- array of connections between nodes
-
getLayoutAlgorithm
public ILayoutAlgorithm getLayoutAlgorithm()
Returns the static layout algorithm used to layout a newly initialized graph or after heavy changes to it.- Returns:
- The layout algorithm that is used by this
LayoutContext.
-
isLayoutIrrelevant
public boolean isLayoutIrrelevant(org.eclipse.gef.graph.Edge edge)
Returnstruewhen the givenEdgeis not relevant for layout according to the configuredlayout filters. Otherwise returnsfalse.- Parameters:
edge- TheEdgein question.- Returns:
truewhen the givenEdgeis not relevant for layout according to the configure layout filters, otherwisefalse.
-
isLayoutIrrelevant
public boolean isLayoutIrrelevant(org.eclipse.gef.graph.Node nodeLayout)
Returnstruewhen the givenNodeis not relevant for layout according to the configuredlayout filters. Otherwise returnsfalse.- Parameters:
nodeLayout- TheNodein question.- Returns:
truewhen the givenNodeis not relevant for layout according to the configure layout filters, otherwisefalse.
-
layoutAlgorithmProperty
public javafx.beans.property.ObjectProperty<ILayoutAlgorithm> layoutAlgorithmProperty()
A property representing the layout algorithm used by thisLayoutContext.- Returns:
- A property named
LAYOUT_ALGORITHM_PROPERTY. - See Also:
getLayoutAlgorithm(),setLayoutAlgorithm(ILayoutAlgorithm)
-
removeLayoutFilter
public void removeLayoutFilter(ILayoutFilter layoutFilter)
Removes the given ILayoutFilter from thisLayoutContext.- Parameters:
layoutFilter- The ILayoutFilter to remove to this context.
-
schedulePostLayoutPass
public void schedulePostLayoutPass(java.lang.Runnable runnable)
Adds the givenRunnableto the list of runnables which are called when thisLayoutContextis asked to apply all changes made to its elements to the display.- Parameters:
runnable- ARunnablecalled whenever this context is asked to apply all changes made to its elements to the display.
-
schedulePreLayoutPass
public void schedulePreLayoutPass(java.lang.Runnable runnable)
Adds the givenRunnableto the list ofRunnables which are executed before applying a layout, i.e. beforeapplyLayout(boolean).- Parameters:
runnable- TheRunnableto add to the list ofRunnables which are executed before applying a layout.
-
setLayoutAlgorithm
public void setLayoutAlgorithm(ILayoutAlgorithm algorithm)
Sets the layout algorithm for this context.- Parameters:
algorithm- The newILayoutAlgorithmfor thisLayoutContext.
-
unschedulePostLayoutPass
public void unschedulePostLayoutPass(java.lang.Runnable runnable)
Removes the givenRunnablefrom the list of runnables which are called when thisLayoutContextis asked to apply all changes made to its elements to the display.- Parameters:
runnable- TheRunnablethat should no longer get called when flushing changes.
-
unschedulePreLayoutPass
public void unschedulePreLayoutPass(java.lang.Runnable runnable)
Removes the givenRunnablefrom the list ofRunnables which are executed before applying a layout, i.e. beforeapplyLayout(boolean).- Parameters:
runnable- TheRunnableto remove from the list ofRunnables which are executed before applying a layout.
-
-