Package org.eclipse.gef.layout
Class LayoutContext
java.lang.Object
org.eclipse.gef.layout.LayoutContext
The
LayoutContext
provides the context in which to layout a
Graph
. It maintains an ILayoutAlgorithm
that can be applied,
supports the handling and execution of pre and post Runnable
s, and
filtering of layout objects using ILayoutFilter
.-
Property Summary
TypePropertyDescriptionjavafx.beans.property.ObjectProperty<ILayoutAlgorithm>
A property representing the layout algorithm used by thisLayoutContext
. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
AnLayoutContext
notifies registered listeners about changes to the layout algorithm using this property name. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addLayoutFilter
(ILayoutFilter layoutFilter) Adds the given ILayoutFilter to thisLayoutContext
.void
applyLayout
(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.Graph
getGraph()
Returns the graph that is to be layouted.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.boolean
isLayoutIrrelevant
(org.eclipse.gef.graph.Edge edge) Returnstrue
when the givenEdge
is not relevant for layout according to the configuredlayout filters
.boolean
isLayoutIrrelevant
(org.eclipse.gef.graph.Node nodeLayout) Returnstrue
when the givenNode
is not relevant for layout according to the configuredlayout filters
.javafx.beans.property.ObjectProperty<ILayoutAlgorithm>
A property representing the layout algorithm used by thisLayoutContext
.void
Initiated by the context or by anILayoutAlgorithm
to perform steps that are scheduled to be run after the layout pass.void
Initiated by the context or by anILayoutAlgorithm
to perform steps that are scheduled to be run before the layout pass.void
removeLayoutFilter
(ILayoutFilter layoutFilter) Removes the given ILayoutFilter from thisLayoutContext
.void
schedulePostLayoutPass
(Runnable runnable) Adds the givenRunnable
to the list of runnables which are called when thisLayoutContext
is asked to apply all changes made to its elements to the display.void
schedulePreLayoutPass
(Runnable runnable) Adds the givenRunnable
to the list ofRunnable
s which are executed before applying a layout, i.e. beforeapplyLayout(boolean)
.void
setGraph
(org.eclipse.gef.graph.Graph graph) Sets the graph that is to be layouted by this context.void
setLayoutAlgorithm
(ILayoutAlgorithm algorithm) Sets the layout algorithm for this context.void
unschedulePostLayoutPass
(Runnable runnable) Removes the givenRunnable
from the list of runnables which are called when thisLayoutContext
is asked to apply all changes made to its elements to the display.void
unschedulePreLayoutPass
(Runnable runnable) Removes the givenRunnable
from the list ofRunnable
s which are executed before applying a layout, i.e. beforeapplyLayout(boolean)
.
-
Property Details
-
layoutAlgorithm
A property representing the layout algorithm used by thisLayoutContext
.
-
-
Field Details
-
LAYOUT_ALGORITHM_PROPERTY
AnLayoutContext
notifies registered listeners about changes to the layout algorithm using this property name.- See Also:
-
-
Constructor Details
-
LayoutContext
public LayoutContext()
-
-
Method Details
-
addLayoutFilter
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
-true
to indicate that the algorithm has to fully re-compute the layout, otherwisefalse
.
-
postLayout
public void postLayout()Initiated by the context or by anILayoutAlgorithm
to 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 anILayoutAlgorithm
to 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
Graph
that 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
- TheGraph
to 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
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) Returnstrue
when the givenEdge
is not relevant for layout according to the configuredlayout filters
. Otherwise returnsfalse
.- Parameters:
edge
- TheEdge
in question.- Returns:
true
when the givenEdge
is not relevant for layout according to the configure layout filters, otherwisefalse
.
-
isLayoutIrrelevant
public boolean isLayoutIrrelevant(org.eclipse.gef.graph.Node nodeLayout) Returnstrue
when the givenNode
is not relevant for layout according to the configuredlayout filters
. Otherwise returnsfalse
.- Parameters:
nodeLayout
- TheNode
in question.- Returns:
true
when the givenNode
is not relevant for layout according to the configure layout filters, otherwisefalse
.
-
layoutAlgorithmProperty
A property representing the layout algorithm used by thisLayoutContext
. -
removeLayoutFilter
Removes the given ILayoutFilter from thisLayoutContext
.- Parameters:
layoutFilter
- The ILayoutFilter to remove to this context.
-
schedulePostLayoutPass
Adds the givenRunnable
to the list of runnables which are called when thisLayoutContext
is asked to apply all changes made to its elements to the display.- Parameters:
runnable
- ARunnable
called whenever this context is asked to apply all changes made to its elements to the display.
-
schedulePreLayoutPass
Adds the givenRunnable
to the list ofRunnable
s which are executed before applying a layout, i.e. beforeapplyLayout(boolean)
. -
setLayoutAlgorithm
Sets the layout algorithm for this context.- Parameters:
algorithm
- The newILayoutAlgorithm
for thisLayoutContext
.
-
unschedulePostLayoutPass
Removes the givenRunnable
from the list of runnables which are called when thisLayoutContext
is asked to apply all changes made to its elements to the display.- Parameters:
runnable
- TheRunnable
that should no longer get called when flushing changes.
-
unschedulePreLayoutPass
Removes the givenRunnable
from the list ofRunnable
s which are executed before applying a layout, i.e. beforeapplyLayout(boolean)
.
-