public abstract class AbstractLayoutContext extends java.lang.Object implements ILayoutContext
AbstractLayoutContext
is an abstract ILayoutContext
implementation which supports the (un-)registration of
PropertyChangeListener
s and firing of events, the (un-)registration
of any layout listeners and firing of events, the handling and execution of
pre and post Runnable
s, and filtering of layout objects using
ILayoutFilter
.Modifier and Type | Field and Description |
---|---|
protected java.beans.PropertyChangeSupport |
pcs
Support object for the (un-)registration of
PropertyChangeListener s and firing of events. |
protected org.eclipse.gef4.common.properties.PropertyStoreSupport |
pss
Support object for reading/writing general properties.
|
DYNAMIC_LAYOUT_ALGORITHM_PROPERTY, STATIC_LAYOUT_ALGORITHM_PROPERTY
Constructor and Description |
---|
AbstractLayoutContext() |
Modifier and Type | Method and Description |
---|---|
void |
addContextListener(IContextListener listener)
Adds a listener to the context that will be notified about changes
related to its configuration.
|
protected void |
addEdge(IConnectionLayout edge)
Adds the given
IConnectionLayout to the list of edges and fires a
corresponding connection-added-event. |
void |
addGraphStructureListener(IGraphStructureListener listener)
Adds a listener to the context that will be notified about changes in
graph structure, that is addition and removal of nodes and connections.
|
void |
addLayoutFilter(ILayoutFilter layoutFilter)
Adds the given ILayoutFilter to this
ILayoutContext . |
void |
addLayoutListener(ILayoutListener listener)
Adds a listener to the context that will be notified about changes in
this context's layout, that is movement and resizing of nodes /
subgraphs.
|
protected void |
addNode(INodeLayout node)
Adds the given
INodeLayout to the list of nodes and fires a
corresponding node-added-event. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener) |
void |
addPruningListener(IPruningListener listener)
Adds a listener to the context that will be notified about changes in
graph pruning, that is hiding and showing of nodes.
|
void |
applyDynamicLayout(boolean clear)
Applies the background layout algorithm of this LayoutContext.
|
void |
applyStaticLayout(boolean clear)
Applies the static layout algorithm of this LayoutContext.
|
protected void |
clearEdges()
Removes all edges from this context using individual
removeEdge(IConnectionLayout) calls. |
protected void |
clearNodes()
Removes all nodes from this context using individual
removeNode(INodeLayout) calls. |
protected void |
doFlushChanges(boolean animationHint)
Executes all scheduled post-layout
Runnable s (previously added by
schedulePostLayoutPass(Runnable) . |
void |
fireBackgroundEnableChangedEvent()
Notifies all previously registered
IContextListener s about the
state of the background layout flag. |
void |
fireBoundsChangedEvent()
Notifies all previously registered
IContextListener s about the
bounds change. |
void |
fireConnectionAddedEvent(IConnectionLayout connection)
Notifies all previously registered
IGraphStructureListener s about
the newly added connection. |
void |
fireConnectionRemovedEvent(IConnectionLayout connection)
Notifies all previously registered
IGraphStructureListener s about
the removed connection. |
void |
fireNodeAddedEvent(INodeLayout node)
Notifies all previously registered
IGraphStructureListener s about
the newly added node. |
void |
fireNodeMovedEvent(INodeLayout node)
Notifies all previously registered
ILayoutListener s about the
moved node. |
void |
fireNodeRemovedEvent(INodeLayout node)
Notifies all previously registered
IGraphStructureListener s about
the removed node. |
void |
fireNodeResizedEvent(INodeLayout node)
Notifies all previously registered
ILayoutListener s about the
resized node. |
void |
firePruningEnableChangedEvent()
Notifies all previously registered
IContextListener s about the
state of the pruning flag. |
void |
fireSubgraphMovedEvent(ISubgraphLayout subgraph)
Notifies all previously registered
ILayoutListener s about the
moved subgraph. |
void |
fireSubgraphResizedEvent(ISubgraphLayout subgraph)
Notifies all previously registered
ILayoutListener s about the
resized subgraph. |
void |
flushChanges(boolean animationHint)
Causes all the changes made to elements in this context to affect the
display.
|
IConnectionLayout[] |
getConnections()
Returns all the connections between nodes that should be laid out.
|
IConnectionLayout[] |
getConnections(IEntityLayout layoutEntity1,
IEntityLayout layoutEntity2)
Returns all the connections between given source and target entities.
|
ILayoutAlgorithm |
getDynamicLayoutAlgorithm() |
INodeLayout[] |
getNodes()
Returns all the nodes that should be laid out.
|
java.lang.Object |
getProperty(java.lang.String name) |
ILayoutAlgorithm |
getStaticLayoutAlgorithm()
Returns the static layout algorithm used to layout a newly initialized
graph or after heavy changes to it.
|
ISubgraphLayout[] |
getSubgraphs()
Returns all the subgraphs this context's nodes were pruned to.
|
boolean |
isLayoutIrrelevant(IConnectionLayout connLayout)
Returns
true when the given IConnectionLayout is not
relevant for layout according to the configured layout filters . |
boolean |
isLayoutIrrelevant(INodeLayout nodeLayout)
Returns
true when the given INodeLayout is not
relevant for layout according to the configured layout filters . |
void |
removeContextListener(IContextListener listener)
Removes a context listener from this context.
|
protected void |
removeEdge(IConnectionLayout edge)
Removes the given
IConnectionLayout from the list of edges and
fires a corresponding connection-removed-event. |
void |
removeGraphStructureListener(IGraphStructureListener listener)
Removes a graph structure listener from this context.
|
void |
removeLayoutFilter(ILayoutFilter layoutFilter)
Removes the given ILayoutFilter from this
ILayoutContext . |
void |
removeLayoutListener(ILayoutListener listener)
Removes a layout listener from this context.
|
protected void |
removeNode(INodeLayout node)
Removes the given
INodeLayout from the managed list of nodes and
fires a corresponding node-removed-event. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener) |
void |
removePruningListener(IPruningListener listener)
Removes a pruning structure listener from this context.
|
void |
schedulePostLayoutPass(java.lang.Runnable runnable)
Adds the given
Runnable to the list of runnables which are called
when this ILayoutContext is asked to apply all changes made to
its elements to the display, i.e. within ILayoutContext.flushChanges(boolean) . |
void |
schedulePreLayoutPass(java.lang.Runnable runnable)
Adds the given
Runnable to the list of Runnable s which
are executed before applying a layout, i.e. before
ILayoutContext.applyDynamicLayout(boolean) or
ILayoutContext.applyStaticLayout(boolean) . |
void |
setDynamicLayoutAlgorithm(ILayoutAlgorithm dynamicLayoutAlgorithm)
Sets the dynamic layout algorithm for this context.
|
void |
setProperty(java.lang.String name,
java.lang.Object value) |
void |
setStaticLayoutAlgorithm(ILayoutAlgorithm staticLayoutAlgorithm)
Sets the static layout algorithm for this context.
|
void |
unschedulePostLayoutPass(java.lang.Runnable runnable)
Removes the given
Runnable from the list of runnables which are
called when this ILayoutContext is asked to apply all changes
made to its elements to the display, i.e. within
ILayoutContext.flushChanges(boolean) . |
void |
unschedulePreLayoutPass(java.lang.Runnable runnable)
Removes the given
Runnable from the list of Runnable s
which are executed before applying a layout, i.e. before
ILayoutContext.applyDynamicLayout(boolean) or
ILayoutContext.applyStaticLayout(boolean) . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createSubgraph, getEntities
protected java.beans.PropertyChangeSupport pcs
PropertyChangeListener
s and firing of events.protected org.eclipse.gef4.common.properties.PropertyStoreSupport pss
public void addContextListener(IContextListener listener)
ILayoutContext
addContextListener
in interface ILayoutContext
listener
- listener to addprotected void addEdge(IConnectionLayout edge)
IConnectionLayout
to the list of edges and fires a
corresponding connection-added-event.edge
- IConnectionLayout
to addpublic void addGraphStructureListener(IGraphStructureListener listener)
ILayoutContext
addGraphStructureListener
in interface ILayoutContext
listener
- listener to addpublic void addLayoutFilter(ILayoutFilter layoutFilter)
ILayoutContext
ILayoutContext
.addLayoutFilter
in interface ILayoutContext
layoutFilter
- The ILayoutFilter to add to this context.public void addLayoutListener(ILayoutListener listener)
ILayoutContext
addLayoutListener
in interface ILayoutContext
listener
- listener to addprotected void addNode(INodeLayout node)
INodeLayout
to the list of nodes and fires a
corresponding node-added-event.node
- INodeLayout
to addpublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in interface org.eclipse.gef4.common.properties.IPropertyChangeNotifier
public void addPruningListener(IPruningListener listener)
ILayoutContext
addPruningListener
in interface ILayoutContext
listener
- listener to addpublic void applyDynamicLayout(boolean clear)
ILayoutContext
applyDynamicLayout
in interface ILayoutContext
clear
- true
to indicate that the algorithm has to fully
re-compute the layout, otherwise false
.public void applyStaticLayout(boolean clear)
ILayoutContext
applyStaticLayout
in interface ILayoutContext
clear
- true
to indicate that the algorithm has to fully
re-compute the layout, otherwise false
.protected void clearEdges()
removeEdge(IConnectionLayout)
calls.protected void clearNodes()
removeNode(INodeLayout)
calls.protected void doFlushChanges(boolean animationHint)
Runnable
s (previously added by
schedulePostLayoutPass(Runnable)
.animationHint
- true
to indicate that the changes should be
applied with an animation, otherwise false
.public void fireBackgroundEnableChangedEvent()
ILayoutContext
IContextListener
s about the
state of the background layout flag.fireBackgroundEnableChangedEvent
in interface ILayoutContext
public void fireBoundsChangedEvent()
ILayoutContext
IContextListener
s about the
bounds change.fireBoundsChangedEvent
in interface ILayoutContext
public void fireConnectionAddedEvent(IConnectionLayout connection)
ILayoutContext
IGraphStructureListener
s about
the newly added connection.fireConnectionAddedEvent
in interface ILayoutContext
connection
- ConnectionLayout of newly added connectionpublic void fireConnectionRemovedEvent(IConnectionLayout connection)
ILayoutContext
IGraphStructureListener
s about
the removed connection.fireConnectionRemovedEvent
in interface ILayoutContext
connection
- ConnectionLayout of removed connectionpublic void fireNodeAddedEvent(INodeLayout node)
ILayoutContext
IGraphStructureListener
s about
the newly added node.fireNodeAddedEvent
in interface ILayoutContext
node
- NodeLayout of newly added nodepublic void fireNodeMovedEvent(INodeLayout node)
ILayoutContext
ILayoutListener
s about the
moved node.fireNodeMovedEvent
in interface ILayoutContext
node
- NodeLayout of moved nodepublic void fireNodeRemovedEvent(INodeLayout node)
ILayoutContext
IGraphStructureListener
s about
the removed node.fireNodeRemovedEvent
in interface ILayoutContext
node
- NodeLayout of removed nodepublic void fireNodeResizedEvent(INodeLayout node)
ILayoutContext
ILayoutListener
s about the
resized node.fireNodeResizedEvent
in interface ILayoutContext
node
- NodeLayout of resized nodepublic void firePruningEnableChangedEvent()
ILayoutContext
IContextListener
s about the
state of the pruning flag.firePruningEnableChangedEvent
in interface ILayoutContext
public void fireSubgraphMovedEvent(ISubgraphLayout subgraph)
ILayoutContext
ILayoutListener
s about the
moved subgraph.fireSubgraphMovedEvent
in interface ILayoutContext
subgraph
- SubgraphLayout of moved subgraphpublic void fireSubgraphResizedEvent(ISubgraphLayout subgraph)
ILayoutContext
ILayoutListener
s about the
resized subgraph.fireSubgraphResizedEvent
in interface ILayoutContext
subgraph
- SubgraphLayout of resized subgraphpublic void flushChanges(boolean animationHint)
ILayoutContext
flushChanges
in interface ILayoutContext
animationHint
- a hint for display mechanism indicating whether changes are
major and should be animated (if true) or not.public IConnectionLayout[] getConnections()
ILayoutContext
getConnections
in interface ILayoutContext
public IConnectionLayout[] getConnections(IEntityLayout layoutEntity1, IEntityLayout layoutEntity2)
ILayoutContext
getConnections
in interface ILayoutContext
layoutEntity1
- The source entity.layoutEntity2
- The target entity.public ILayoutAlgorithm getDynamicLayoutAlgorithm()
getDynamicLayoutAlgorithm
in interface ILayoutContext
ILayoutContext.setDynamicLayoutAlgorithm(ILayoutAlgorithm)
for details)public INodeLayout[] getNodes()
ILayoutContext
getNodes
in interface ILayoutContext
public java.lang.Object getProperty(java.lang.String name)
getProperty
in interface org.eclipse.gef4.common.properties.IPropertyStore
public ILayoutAlgorithm getStaticLayoutAlgorithm()
ILayoutContext
getStaticLayoutAlgorithm
in interface ILayoutContext
public ISubgraphLayout[] getSubgraphs()
ILayoutContext
getSubgraphs
in interface ILayoutContext
public boolean isLayoutIrrelevant(IConnectionLayout connLayout)
ILayoutContext
true
when the given IConnectionLayout
is not
relevant for layout according to the configured layout filters
. Otherwise returns false
.isLayoutIrrelevant
in interface ILayoutContext
connLayout
- The IConnectionLayout
in question.true
when the given IConnectionLayout
is not
relevant for layout according to the configure layout filters,
otherwise false
.public boolean isLayoutIrrelevant(INodeLayout nodeLayout)
ILayoutContext
true
when the given INodeLayout
is not
relevant for layout according to the configured layout filters
. Otherwise returns false
.isLayoutIrrelevant
in interface ILayoutContext
nodeLayout
- The INodeLayout
in question.true
when the given INodeLayout
is not
relevant for layout according to the configure layout filters,
otherwise false
.public void removeContextListener(IContextListener listener)
ILayoutContext
removeContextListener
in interface ILayoutContext
listener
- listener to removeprotected void removeEdge(IConnectionLayout edge)
IConnectionLayout
from the list of edges and
fires a corresponding connection-removed-event.edge
- IConnectionLayout
to removepublic void removeGraphStructureListener(IGraphStructureListener listener)
ILayoutContext
removeGraphStructureListener
in interface ILayoutContext
listener
- listener to removepublic void removeLayoutFilter(ILayoutFilter layoutFilter)
ILayoutContext
ILayoutContext
.removeLayoutFilter
in interface ILayoutContext
layoutFilter
- The ILayoutFilter to remove to this context.public void removeLayoutListener(ILayoutListener listener)
ILayoutContext
removeLayoutListener
in interface ILayoutContext
listener
- listener to removeprotected void removeNode(INodeLayout node)
INodeLayout
from the managed list of nodes and
fires a corresponding node-removed-event.node
- INodeLayout
to removepublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in interface org.eclipse.gef4.common.properties.IPropertyChangeNotifier
public void removePruningListener(IPruningListener listener)
ILayoutContext
removePruningListener
in interface ILayoutContext
listener
- listener to removepublic void schedulePostLayoutPass(java.lang.Runnable runnable)
ILayoutContext
Runnable
to the list of runnables which are called
when this ILayoutContext
is asked to apply all changes made to
its elements to the display, i.e. within ILayoutContext.flushChanges(boolean)
.schedulePostLayoutPass
in interface ILayoutContext
runnable
- A Runnable
called whenever this context is asked to
apply all changes made to its elements to the display.public void schedulePreLayoutPass(java.lang.Runnable runnable)
ILayoutContext
Runnable
to the list of Runnable
s which
are executed before applying a layout, i.e. before
ILayoutContext.applyDynamicLayout(boolean)
or
ILayoutContext.applyStaticLayout(boolean)
.schedulePreLayoutPass
in interface ILayoutContext
runnable
- The Runnable
to add to the list of Runnable
s
which are executed before applying a layout.public void setDynamicLayoutAlgorithm(ILayoutAlgorithm dynamicLayoutAlgorithm)
ILayoutContext
ILayoutAlgorithm.applyLayout(boolean)
after every event that is
not intercepted by any listener when currently changes are not being
flushed and background layout is enabled. The clean flag for the
background layout algorithm can be set to false
by the
context when reacting to events.setDynamicLayoutAlgorithm
in interface ILayoutContext
dynamicLayoutAlgorithm
- The new dynamic ILayoutAlgorithm
for this
ILayoutContext
.public void setProperty(java.lang.String name, java.lang.Object value)
setProperty
in interface org.eclipse.gef4.common.properties.IPropertyStore
public void setStaticLayoutAlgorithm(ILayoutAlgorithm staticLayoutAlgorithm)
ILayoutContext
setStaticLayoutAlgorithm
in interface ILayoutContext
staticLayoutAlgorithm
- The new static ILayoutAlgorithm
for this
ILayoutContext
.public void unschedulePostLayoutPass(java.lang.Runnable runnable)
ILayoutContext
Runnable
from the list of runnables which are
called when this ILayoutContext
is asked to apply all changes
made to its elements to the display, i.e. within
ILayoutContext.flushChanges(boolean)
.unschedulePostLayoutPass
in interface ILayoutContext
runnable
- The Runnable
that should no longer get called when
flushing changes.public void unschedulePreLayoutPass(java.lang.Runnable runnable)
ILayoutContext
Runnable
from the list of Runnable
s
which are executed before applying a layout, i.e. before
ILayoutContext.applyDynamicLayout(boolean)
or
ILayoutContext.applyStaticLayout(boolean)
.unschedulePreLayoutPass
in interface ILayoutContext
runnable
- The Runnable
to remove from the list of
Runnable
s which are executed before applying a layout.Copyright (c) 2014 itemis AG and others. All rights reserved.