public abstract class AbstractLayoutContext extends java.lang.Object implements ILayoutContext
AbstractLayoutContext is an abstract ILayoutContext
implementation which supports the (un-)registration of
PropertyChangeListeners and firing of events, the (un-)registration
of any layout listeners and firing of events, the handling and execution of
pre and post Runnables, 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
PropertyChangeListeners 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
Runnables (previously added by
schedulePostLayoutPass(Runnable). |
void |
fireBackgroundEnableChangedEvent()
Notifies all previously registered
IContextListeners about the
state of the background layout flag. |
void |
fireBoundsChangedEvent()
Notifies all previously registered
IContextListeners about the
bounds change. |
void |
fireConnectionAddedEvent(IConnectionLayout connection)
Notifies all previously registered
IGraphStructureListeners about
the newly added connection. |
void |
fireConnectionRemovedEvent(IConnectionLayout connection)
Notifies all previously registered
IGraphStructureListeners about
the removed connection. |
void |
fireNodeAddedEvent(INodeLayout node)
Notifies all previously registered
IGraphStructureListeners about
the newly added node. |
void |
fireNodeMovedEvent(INodeLayout node)
Notifies all previously registered
ILayoutListeners about the
moved node. |
void |
fireNodeRemovedEvent(INodeLayout node)
Notifies all previously registered
IGraphStructureListeners about
the removed node. |
void |
fireNodeResizedEvent(INodeLayout node)
Notifies all previously registered
ILayoutListeners about the
resized node. |
void |
firePruningEnableChangedEvent()
Notifies all previously registered
IContextListeners about the
state of the pruning flag. |
void |
fireSubgraphMovedEvent(ISubgraphLayout subgraph)
Notifies all previously registered
ILayoutListeners about the
moved subgraph. |
void |
fireSubgraphResizedEvent(ISubgraphLayout subgraph)
Notifies all previously registered
ILayoutListeners 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 Runnables 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 Runnables
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, waitcreateSubgraph, getEntitiesprotected java.beans.PropertyChangeSupport pcs
PropertyChangeListeners and firing of events.protected org.eclipse.gef4.common.properties.PropertyStoreSupport pss
public void addContextListener(IContextListener listener)
ILayoutContextaddContextListener in interface ILayoutContextlistener - 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)
ILayoutContextaddGraphStructureListener in interface ILayoutContextlistener - listener to addpublic void addLayoutFilter(ILayoutFilter layoutFilter)
ILayoutContextILayoutContext.addLayoutFilter in interface ILayoutContextlayoutFilter - The ILayoutFilter to add to this context.public void addLayoutListener(ILayoutListener listener)
ILayoutContextaddLayoutListener in interface ILayoutContextlistener - 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.IPropertyChangeNotifierpublic void addPruningListener(IPruningListener listener)
ILayoutContextaddPruningListener in interface ILayoutContextlistener - listener to addpublic void applyDynamicLayout(boolean clear)
ILayoutContextapplyDynamicLayout in interface ILayoutContextclear - true to indicate that the algorithm has to fully
re-compute the layout, otherwise false.public void applyStaticLayout(boolean clear)
ILayoutContextapplyStaticLayout in interface ILayoutContextclear - 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)
Runnables (previously added by
schedulePostLayoutPass(Runnable).animationHint - true to indicate that the changes should be
applied with an animation, otherwise false.public void fireBackgroundEnableChangedEvent()
ILayoutContextIContextListeners about the
state of the background layout flag.fireBackgroundEnableChangedEvent in interface ILayoutContextpublic void fireBoundsChangedEvent()
ILayoutContextIContextListeners about the
bounds change.fireBoundsChangedEvent in interface ILayoutContextpublic void fireConnectionAddedEvent(IConnectionLayout connection)
ILayoutContextIGraphStructureListeners about
the newly added connection.fireConnectionAddedEvent in interface ILayoutContextconnection - ConnectionLayout of newly added connectionpublic void fireConnectionRemovedEvent(IConnectionLayout connection)
ILayoutContextIGraphStructureListeners about
the removed connection.fireConnectionRemovedEvent in interface ILayoutContextconnection - ConnectionLayout of removed connectionpublic void fireNodeAddedEvent(INodeLayout node)
ILayoutContextIGraphStructureListeners about
the newly added node.fireNodeAddedEvent in interface ILayoutContextnode - NodeLayout of newly added nodepublic void fireNodeMovedEvent(INodeLayout node)
ILayoutContextILayoutListeners about the
moved node.fireNodeMovedEvent in interface ILayoutContextnode - NodeLayout of moved nodepublic void fireNodeRemovedEvent(INodeLayout node)
ILayoutContextIGraphStructureListeners about
the removed node.fireNodeRemovedEvent in interface ILayoutContextnode - NodeLayout of removed nodepublic void fireNodeResizedEvent(INodeLayout node)
ILayoutContextILayoutListeners about the
resized node.fireNodeResizedEvent in interface ILayoutContextnode - NodeLayout of resized nodepublic void firePruningEnableChangedEvent()
ILayoutContextIContextListeners about the
state of the pruning flag.firePruningEnableChangedEvent in interface ILayoutContextpublic void fireSubgraphMovedEvent(ISubgraphLayout subgraph)
ILayoutContextILayoutListeners about the
moved subgraph.fireSubgraphMovedEvent in interface ILayoutContextsubgraph - SubgraphLayout of moved subgraphpublic void fireSubgraphResizedEvent(ISubgraphLayout subgraph)
ILayoutContextILayoutListeners about the
resized subgraph.fireSubgraphResizedEvent in interface ILayoutContextsubgraph - SubgraphLayout of resized subgraphpublic void flushChanges(boolean animationHint)
ILayoutContextflushChanges in interface ILayoutContextanimationHint - a hint for display mechanism indicating whether changes are
major and should be animated (if true) or not.public IConnectionLayout[] getConnections()
ILayoutContextgetConnections in interface ILayoutContextpublic IConnectionLayout[] getConnections(IEntityLayout layoutEntity1, IEntityLayout layoutEntity2)
ILayoutContextgetConnections in interface ILayoutContextlayoutEntity1 - The source entity.layoutEntity2 - The target entity.public ILayoutAlgorithm getDynamicLayoutAlgorithm()
getDynamicLayoutAlgorithm in interface ILayoutContextILayoutContext.setDynamicLayoutAlgorithm(ILayoutAlgorithm) for details)public INodeLayout[] getNodes()
ILayoutContextgetNodes in interface ILayoutContextpublic java.lang.Object getProperty(java.lang.String name)
getProperty in interface org.eclipse.gef4.common.properties.IPropertyStorepublic ILayoutAlgorithm getStaticLayoutAlgorithm()
ILayoutContextgetStaticLayoutAlgorithm in interface ILayoutContextpublic ISubgraphLayout[] getSubgraphs()
ILayoutContextgetSubgraphs in interface ILayoutContextpublic boolean isLayoutIrrelevant(IConnectionLayout connLayout)
ILayoutContexttrue when the given IConnectionLayout is not
relevant for layout according to the configured layout filters. Otherwise returns false.isLayoutIrrelevant in interface ILayoutContextconnLayout - 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)
ILayoutContexttrue when the given INodeLayout is not
relevant for layout according to the configured layout filters. Otherwise returns false.isLayoutIrrelevant in interface ILayoutContextnodeLayout - 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)
ILayoutContextremoveContextListener in interface ILayoutContextlistener - 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)
ILayoutContextremoveGraphStructureListener in interface ILayoutContextlistener - listener to removepublic void removeLayoutFilter(ILayoutFilter layoutFilter)
ILayoutContextILayoutContext.removeLayoutFilter in interface ILayoutContextlayoutFilter - The ILayoutFilter to remove to this context.public void removeLayoutListener(ILayoutListener listener)
ILayoutContextremoveLayoutListener in interface ILayoutContextlistener - 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.IPropertyChangeNotifierpublic void removePruningListener(IPruningListener listener)
ILayoutContextremovePruningListener in interface ILayoutContextlistener - listener to removepublic void schedulePostLayoutPass(java.lang.Runnable runnable)
ILayoutContextRunnable 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 ILayoutContextrunnable - 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)
ILayoutContextRunnable to the list of Runnables which
are executed before applying a layout, i.e. before
ILayoutContext.applyDynamicLayout(boolean) or
ILayoutContext.applyStaticLayout(boolean).schedulePreLayoutPass in interface ILayoutContextrunnable - The Runnable to add to the list of Runnables
which are executed before applying a layout.public void setDynamicLayoutAlgorithm(ILayoutAlgorithm dynamicLayoutAlgorithm)
ILayoutContextILayoutAlgorithm.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 ILayoutContextdynamicLayoutAlgorithm - 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.IPropertyStorepublic void setStaticLayoutAlgorithm(ILayoutAlgorithm staticLayoutAlgorithm)
ILayoutContextsetStaticLayoutAlgorithm in interface ILayoutContextstaticLayoutAlgorithm - The new static ILayoutAlgorithm for this
ILayoutContext.public void unschedulePostLayoutPass(java.lang.Runnable runnable)
ILayoutContextRunnable 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 ILayoutContextrunnable - The Runnable that should no longer get called when
flushing changes.public void unschedulePreLayoutPass(java.lang.Runnable runnable)
ILayoutContextRunnable from the list of Runnables
which are executed before applying a layout, i.e. before
ILayoutContext.applyDynamicLayout(boolean) or
ILayoutContext.applyStaticLayout(boolean).unschedulePreLayoutPass in interface ILayoutContextrunnable - The Runnable to remove from the list of
Runnables which are executed before applying a layout.Copyright (c) 2014 itemis AG and others. All rights reserved.