Search this API

y.view
Class Graph2DLayoutExecutor

java.lang.Object
  extended by y.view.Graph2DLayoutExecutor

public class Graph2DLayoutExecutor
extends java.lang.Object

Convenience class for executing or launching layouts on a graph. This class performs all commonly necessary preparation steps that are needed to calculate a layout for a Graph2D instance.
Several modes are available that cover the most common use-cases. Instances of this class can be configured and reused to perform multiple layout runs via one of the doLayout methods. The recommended way of calculating a layout for Graph2D instances is thus:
new Graph2DLayoutExecutor().doLayout(graph, layouter);
and if the graph is shown in a Graph2DView:
view.doLayout(layouter); // equivalent to new Graph2DLayoutExecutor(Graph2DLayoutExecutor.DIRECT).doLayout(view, layouter);

See Also:
doLayout(Graph2D, Layouter), doLayout(Graph2DView, Layouter), Graph2DView.applyLayout(Layouter), Graph2DView.applyLayoutAnimated(Layouter)
 

Nested Class Summary
static interface Graph2DLayoutExecutor.ExceptionListener
          Interface used to report Exceptions or Errors that happen during calls to doLayout(Graph2D, Layouter, Runnable, y.view.Graph2DLayoutExecutor.ExceptionListener).
static interface Graph2DLayoutExecutor.LayoutThreadHandle
          The interface of the handle that is returned by doLayout(Graph2DView, y.layout.Layouter, Runnable, y.view.Graph2DLayoutExecutor.ExceptionListener) that can be used to query the state of the layout calculation.
 
Field Summary
static byte ANIMATED
          Mode constant for use in setMode(byte) and getMode() that tells the executor to run a buffered layout and then morph the current graph to the newly calculated layout.
static byte ANIMATED_THREADED
          Mode constant for use in setMode(byte) and getMode() that tells the executor to run a buffered layout and then morph the current graph to the newly calculated layout.
static byte BUFFERED
          Mode constant for use in setMode(byte) and getMode() that tells the executor to run a buffered layout and then apply the calculated results to the graph.
static byte THREADED
          Mode constant for use in setMode(byte) and getMode() that tells the executor to run a buffered layout and then apply the calculated results to the graph.
static byte UNBUFFERED
          Mode constant for use in setMode(byte) and getMode() that tells the executor to run the layout directly on Graph2D instance without buffering.
 
Constructor Summary
Graph2DLayoutExecutor()
          Creates a new instance of Graph2DLayoutExecutor in ANIMATED mode.
Graph2DLayoutExecutor(byte mode)
          Creates a new instance of Graph2DLayoutExecutor in the provided mode.
 
Method Summary
protected  void applyGraphLayout(Graph2D graph, GraphLayout layout)
          Applies the specified layout to the given graph.
protected  void configureComponentLayouter(Graph2DView view, ComponentLayouter cl)
          Callback that configures the ComponentLayouter according to the view.
protected  AnimationObject createAnimation(Graph2DView view, Graph2D graph, GraphLayout graphLayout)
          Creates the AnimationObject that will be used after the layout has been calculated.
protected  AnimationPlayer createAnimationPlayer()
          Factory method used for the LayoutMorpher to play the animation.
protected  LayoutMorpher createLayoutMorpher()
          Factory method used to initialize the layout morpher used for the animation.
 void doLayout(Graph2D graph, Layouter layouter)
          Calculates a layout without animating it.
 void doLayout(Graph2D graph, Layouter layouter, java.lang.Runnable doneListener, Graph2DLayoutExecutor.ExceptionListener exceptionListener)
          Calculates a layout without animating it.
 void doLayout(Graph2DView view, Graph2D graph, Layouter layouter)
          Calculates a layout and applies it to the graph in the view.
 Graph2DLayoutExecutor.LayoutThreadHandle doLayout(Graph2DView view, Graph2D graph, Layouter layouter, java.lang.Runnable doneListener, Graph2DLayoutExecutor.ExceptionListener exceptionListener)
          Calculates a layout and applies it to the provided graph in the provided view.
 void doLayout(Graph2DView view, Layouter layouter)
          Calculates a layout and applies it to the graph in the view.
 Graph2DLayoutExecutor.LayoutThreadHandle doLayout(Graph2DView view, Layouter layouter, java.lang.Runnable doneListener, Graph2DLayoutExecutor.ExceptionListener exceptionListener)
          Calculates a layout and applies it to the graph in the view.
 AbortHandler getDefaultAbortHandler()
          Returns the default AbortHandler created for this Graph2DLayoutExecutor instance.
 LayoutMorpher getLayoutMorpher()
          Yields the LayoutMorpher instance that is used by this instance to perform the animation if this instance is in ANIMATED or ANIMATED_THREADED mode.
 byte getMode()
          Returns the mode this instance has been created for.
 NodePortLayoutConfigurator getNodePortConfigurator()
          Yields the NodePortLayoutConfigurator that is used by this instance to prepare the graph for the layout.
 TableLayoutConfigurator getTableLayoutConfigurator()
          Yields the TableLayoutConfigurator that is used by this instance to prepare the graph for the layout.
 boolean isAddingSelectedItemsProvider()
          Determines whether the Layouter.SELECTED_NODES and Layouter.SELECTED_EDGES data provider instances should be registered with the graph to pass the current selection state to the layout algorithm.
 boolean isBackupRealizersEnabled()
          Returns whether or not this layout executor will ask the given graph to backup all its realizers before it starts acting upon the graph.
 boolean isConfiguringComponentLayouter()
          Determines whether this instance uses method configureComponentLayouter(Graph2DView, y.layout.ComponentLayouter) to configure the current instance of the ComponentLayouter.
 boolean isConfiguringGrouping()
          Determines whether this instance uses the GroupLayoutConfigurator to prepare the graph for the calculation of a grouped Graph2D that has an associated HierarchyManager.
 boolean isConfiguringNodePorts()
          Determines whether or not this instance uses the NodePortLayoutConfigurator to prepare the node ports of the graph for layout calculation.
 boolean isConfiguringTableNodeRealizers()
          Determines whether this instance uses the TableLayoutConfigurator to prepare the graph for the calculation of PartitionGrids based on the information available in the TableGroupNodeRealizer instances.
 boolean isLockingView()
          Determines whether this mode should try to lock(y.view.Graph2DView, java.util.Map) and unlock(y.view.Graph2DView, java.util.Map) the Graph2DView during the calculation of the layout.
 boolean isPortIntersectionCalculatorEnabled()
          Determines whether a PortCalculator should be used to adjust port positions after the main layout to lie on the visible boundaries of the NodeRealizers.
protected  void lock(Graph2DView view, java.util.Map lockState)
          Called during one of the doLayout(Graph2DView, y.layout.Layouter) calls on the EDT to lock the Graph2DView from receiving further input.
protected  GroupLayoutConfigurator prepareGroupLayoutConfigurator(Graph2DView view, Graph2D graph, Layouter layouter)
          Callback method that creates a GroupLayoutConfigurator, and prepares the graph for the layout.
protected  NodePortLayoutConfigurator prepareNodePortConfigurator(Graph2DView view, Graph2D graph, Layouter layouter)
          Callback method that uses the NodePortConfigurator to prepare the graph for the layout.
protected  TableLayoutConfigurator prepareTableConfigurator(Graph2DView view, Graph2D graph, Layouter layouter)
          Callback method that uses the TableLayoutConfigurator to prepare the graph for the layout.
protected  void restoreGroupLayoutConfigurator(Graph2D graph, GroupLayoutConfigurator configurator)
          Callback that calls GroupLayoutConfigurator.restoreAll() after the layout is done.
protected  void restoreNodePortConfigurator(Graph2D graph, NodePortLayoutConfigurator configurator)
          Callback that calls NodePortLayoutConfigurator.restoreAll(Graph2D) after the layout is done.
protected  void restoreTableConfigurator(Graph2D graph, TableLayoutConfigurator tableConfigurator)
          Callback that calls TableLayoutConfigurator.restoreAll(Graph2D) after the layout is done.
 void setAddingSelectedItemsProvider(boolean addingSelectedItemsProvider)
          Determines whether the Layouter.SELECTED_NODES and Layouter.SELECTED_EDGES data provider instances should be registered with the graph to pass the current selection state to the layout algorithm.
 void setBackupRealizersEnabled(boolean enabled)
          Sets whether or not this layout executor will ask the given graph to backup all its realizers before it starts acting upon the graph.
 void setConfiguringComponentLayouter(boolean configuringComponentLayouter)
          Determines whether this instance uses method configureComponentLayouter(Graph2DView, y.layout.ComponentLayouter) to configure the current instance of the ComponentLayouter.
 void setConfiguringGrouping(boolean configuringGrouping)
          Determines whether this instance should use the GroupLayoutConfigurator to prepare the graph for the calculation of a grouped Graph2D that has an associated HierarchyManager.
 void setConfiguringNodePorts(boolean configuringNodePorts)
          Specifies whether or not this instance should use the NodePortLayoutConfigurator to prepare the node ports of the graph for layout calculation.
 void setConfiguringTableNodeRealizers(boolean configuringTableNodeRealizers)
          Determines whether this instance uses the TableLayoutConfigurator to prepare the graph for the calculation of PartitionGrids based on the information available in the TableGroupNodeRealizer instances.
 void setLayoutMorpher(LayoutMorpher layoutMorpher)
          Sets a new instance of LayoutMorpher that is used by this instance to perform the animation if this instance is in ANIMATED or ANIMATED_THREADED mode.
 void setLockingView(boolean lockingView)
          Determines whether this mode should try to lock(y.view.Graph2DView, java.util.Map) and unlock(y.view.Graph2DView, java.util.Map) the Graph2DView during the calculation of the layout.
 void setMode(byte mode)
          Sets the mode to use for this instance and the upcoming doLayout calls.
 void setNodePortConfigurator(NodePortLayoutConfigurator configurator)
          Sets the NodePortLayoutConfigurator that is used by this instance to prepare the graph for the layout.
 void setPortIntersectionCalculatorEnabled(boolean enabled)
          Sets whether or not layout stage PortCalculator should be automatically executed after the main layouter.
 void setTableLayoutConfigurator(TableLayoutConfigurator tableLayoutConfigurator)
          Sets the TableLayoutConfigurator that is used by this instance to prepare the graph for the layout.
protected  void startThread(java.lang.Runnable runnable)
          Callback method that creates and starts the thread for the execution of the ANIMATED_THREADED or THREADED layout.
protected  void unlock(Graph2DView view, java.util.Map lockState)
          This method will unlock a previously locked view after the layout has been calculated.
protected  boolean useEventDispatchThread(Graph2DView view)
          Determines whether to use the EDT for the calculations that should be performed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNBUFFERED

public static final byte UNBUFFERED
Mode constant for use in setMode(byte) and getMode() that tells the executor to run the layout directly on Graph2D instance without buffering. This is not recommended. Use BUFFERED instead.

See Also:
Graph2DLayoutExecutor(byte), Constant Field Values

ANIMATED

public static final byte ANIMATED
Mode constant for use in setMode(byte) and getMode() that tells the executor to run a buffered layout and then morph the current graph to the newly calculated layout. This is the default mode for this class.

See Also:
Graph2DLayoutExecutor(byte), getLayoutMorpher(), Constant Field Values

BUFFERED

public static final byte BUFFERED
Mode constant for use in setMode(byte) and getMode() that tells the executor to run a buffered layout and then apply the calculated results to the graph. This prevents the original graph from being corrupted if an exception happens during layout calculation.

See Also:
Graph2DLayoutExecutor(byte), Constant Field Values

ANIMATED_THREADED

public static final byte ANIMATED_THREADED
Mode constant for use in setMode(byte) and getMode() that tells the executor to run a buffered layout and then morph the current graph to the newly calculated layout. All of the calculations and the animation is performed on a separate thread so the doLayout calls are non-blocking.

See Also:
Graph2DLayoutExecutor(byte), getLayoutMorpher(), doLayout(Graph2D, Layouter, Runnable, y.view.Graph2DLayoutExecutor.ExceptionListener), doLayout(Graph2DView, Layouter, Runnable, y.view.Graph2DLayoutExecutor.ExceptionListener), startThread(Runnable), Constant Field Values

THREADED

public static final byte THREADED
Mode constant for use in setMode(byte) and getMode() that tells the executor to run a buffered layout and then apply the calculated results to the graph. This prevents the original graph from being corrupted if an exception happens during layout calculation. All of the calculations are performed on a separate thread so the doLayout calls are non-blocking.

See Also:
Graph2DLayoutExecutor(byte), doLayout(Graph2D, Layouter, Runnable, y.view.Graph2DLayoutExecutor.ExceptionListener), doLayout(Graph2DView, Layouter, Runnable, y.view.Graph2DLayoutExecutor.ExceptionListener), startThread(Runnable), Constant Field Values
Constructor Detail

Graph2DLayoutExecutor

public Graph2DLayoutExecutor()
Creates a new instance of Graph2DLayoutExecutor in ANIMATED mode.

See Also:
setMode(byte)

Graph2DLayoutExecutor

public Graph2DLayoutExecutor(byte mode)
Creates a new instance of Graph2DLayoutExecutor in the provided mode.

Parameters:
mode - one of BUFFERED, ANIMATED, THREADED, ANIMATED_THREADED, or UNBUFFERED.
Throws:
java.lang.IllegalArgumentException - if the argument is out of the range of possible values.
Method Detail

getMode

public byte getMode()
Returns the mode this instance has been created for. This is one of BUFFERED, ANIMATED, THREADED, ANIMATED_THREADED, or UNBUFFERED.

Returns:
One of BUFFERED, ANIMATED, THREADED, ANIMATED_THREADED, or UNBUFFERED.
See Also:
setMode(byte)

setMode

public void setMode(byte mode)
Sets the mode to use for this instance and the upcoming doLayout calls.

Parameters:
mode - One of BUFFERED, ANIMATED, THREADED, ANIMATED_THREADED, or UNBUFFERED.
Throws:
java.lang.IllegalArgumentException - If the argument is not one of the valid values.

isLockingView

public boolean isLockingView()
Determines whether this mode should try to lock(y.view.Graph2DView, java.util.Map) and unlock(y.view.Graph2DView, java.util.Map) the Graph2DView during the calculation of the layout. By default this feature is turned off.

Returns:
whether the view should be locked during layout calculation.

setLockingView

public void setLockingView(boolean lockingView)
Determines whether this mode should try to lock(y.view.Graph2DView, java.util.Map) and unlock(y.view.Graph2DView, java.util.Map) the Graph2DView during the calculation of the layout. By default this feature is turned off. The view will only be locked, if the doLayout variants are used that take a view argument.

Parameters:
lockingView - whether the view should be locked during layout calculation.

getTableLayoutConfigurator

public TableLayoutConfigurator getTableLayoutConfigurator()
Yields the TableLayoutConfigurator that is used by this instance to prepare the graph for the layout. The reference can be used to fine-tune the settings available in the TableLayoutConfigurator class.

Returns:
The instance that will be used.

setTableLayoutConfigurator

public void setTableLayoutConfigurator(TableLayoutConfigurator tableLayoutConfigurator)
Sets the TableLayoutConfigurator that is used by this instance to prepare the graph for the layout.

Parameters:
tableLayoutConfigurator - The new configurator instance to use.

getNodePortConfigurator

public NodePortLayoutConfigurator getNodePortConfigurator()
Yields the NodePortLayoutConfigurator that is used by this instance to prepare the graph for the layout. The reference can be used to fine-tune the settings available in the NodePortLayoutConfigurator class.

Returns:
The instance that will be used.

setNodePortConfigurator

public void setNodePortConfigurator(NodePortLayoutConfigurator configurator)
Sets the NodePortLayoutConfigurator that is used by this instance to prepare the graph for the layout.

Parameters:
configurator - The new configurator instance to use.

getLayoutMorpher

public LayoutMorpher getLayoutMorpher()
Yields the LayoutMorpher instance that is used by this instance to perform the animation if this instance is in ANIMATED or ANIMATED_THREADED mode. The reference can be used to fine-tune the settings available in the LayoutMorpher class.

Returns:
The morpher instance that will be used by this instance.
See Also:
createLayoutMorpher()

setLayoutMorpher

public void setLayoutMorpher(LayoutMorpher layoutMorpher)
Sets a new instance of LayoutMorpher that is used by this instance to perform the animation if this instance is in ANIMATED or ANIMATED_THREADED mode.

Parameters:
layoutMorpher - The new instance to use for the upcoming doLayout runs.
See Also:
getLayoutMorpher()

isConfiguringGrouping

public boolean isConfiguringGrouping()
Determines whether this instance uses the GroupLayoutConfigurator to prepare the graph for the calculation of a grouped Graph2D that has an associated HierarchyManager. By default this features is enabled.

Returns:
whether the GroupLayoutConfigurator will be used for the layout.

setConfiguringGrouping

public void setConfiguringGrouping(boolean configuringGrouping)
Determines whether this instance should use the GroupLayoutConfigurator to prepare the graph for the calculation of a grouped Graph2D that has an associated HierarchyManager. By default this features is enabled.

Parameters:
configuringGrouping - whether the GroupLayoutConfigurator will be used for the layout.

isConfiguringComponentLayouter

public boolean isConfiguringComponentLayouter()
Determines whether this instance uses method configureComponentLayouter(Graph2DView, y.layout.ComponentLayouter) to configure the current instance of the ComponentLayouter. By default this feature is enabled. Note: enabling this option has no impact if the used layouter is not of type CanonicMultiStageLayouter.

Returns:
whether to configure the ComponentLayouter that will be used for the layout.
See Also:
configureComponentLayouter(Graph2DView, y.layout.ComponentLayouter)

setConfiguringComponentLayouter

public void setConfiguringComponentLayouter(boolean configuringComponentLayouter)
Determines whether this instance uses method configureComponentLayouter(Graph2DView, y.layout.ComponentLayouter) to configure the current instance of the ComponentLayouter. By default this feature is enabled. Note: enabling this option has no impact if the used layouter is not of type CanonicMultiStageLayouter.

Parameters:
configuringComponentLayouter - whether to configure the ComponentLayouter that will be used for the layout.
See Also:
configureComponentLayouter(Graph2DView, y.layout.ComponentLayouter)

isAddingSelectedItemsProvider

public boolean isAddingSelectedItemsProvider()
Determines whether the Layouter.SELECTED_NODES and Layouter.SELECTED_EDGES data provider instances should be registered with the graph to pass the current selection state to the layout algorithm. By default this feature is enabled when there is no DataProvider with the same key registered with the graph at the same time.

Returns:
Whether the providers should be registered.
See Also:
Selections.createSelectionNodeMap(Graph2D), Selections.createSelectionEdgeMap(Graph2D)

setAddingSelectedItemsProvider

public void setAddingSelectedItemsProvider(boolean addingSelectedItemsProvider)
Determines whether the Layouter.SELECTED_NODES and Layouter.SELECTED_EDGES data provider instances should be registered with the graph to pass the current selection state to the layout algorithm. By default this feature is enabled when there is no DataProvider with the same key registered with the graph at the same time.

Parameters:
addingSelectedItemsProvider - whether the providers should be registered.
See Also:
Selections.createSelectionNodeMap(Graph2D), Selections.createSelectionEdgeMap(Graph2D)

isConfiguringTableNodeRealizers

public boolean isConfiguringTableNodeRealizers()
Determines whether this instance uses the TableLayoutConfigurator to prepare the graph for the calculation of PartitionGrids based on the information available in the TableGroupNodeRealizer instances. By default this features is disabled.

Returns:
whether the TableLayoutConfigurator will be used for the layout.

setConfiguringTableNodeRealizers

public void setConfiguringTableNodeRealizers(boolean configuringTableNodeRealizers)
Determines whether this instance uses the TableLayoutConfigurator to prepare the graph for the calculation of PartitionGrids based on the information available in the TableGroupNodeRealizer instances. By default this features is disabled.

Parameters:
configuringTableNodeRealizers - whether the TableLayoutConfigurator should be used for the layout.

isConfiguringNodePorts

public boolean isConfiguringNodePorts()
Determines whether or not this instance uses the NodePortLayoutConfigurator to prepare the node ports of the graph for layout calculation.

By default, this feature is enabled. This feature should be disabled if port constraints or edge groups for edges connecting to node ports are explicitly given by PortConstraintKeys data providers.

Returns:
true if node ports are automatically prepared for layout calculation and false otherwise.
See Also:
setConfiguringNodePorts(boolean)

setConfiguringNodePorts

public void setConfiguringNodePorts(boolean configuringNodePorts)
Specifies whether or not this instance should use the NodePortLayoutConfigurator to prepare the node ports of the graph for layout calculation.

By default, this feature is enabled. This feature should be disabled if port constraints or edge groups for edges connecting to node ports are explicitly given by PortConstraintKeys data providers.

Parameters:
configuringNodePorts - if true node ports are automatically prepared for layout calculation
See Also:
isConfiguringNodePorts()

isBackupRealizersEnabled

public boolean isBackupRealizersEnabled()
Returns whether or not this layout executor will ask the given graph to backup all its realizers before it starts acting upon the graph. By default, this feature is enabled.

See Also:
setBackupRealizersEnabled(boolean), setBackupRealizersEnabled(boolean)

setBackupRealizersEnabled

public void setBackupRealizersEnabled(boolean enabled)
Sets whether or not this layout executor will ask the given graph to backup all its realizers before it starts acting upon the graph. By default, this feature is enabled.

See Also:
isBackupRealizersEnabled(), Graph2D.backupRealizers()

getDefaultAbortHandler

public AbortHandler getDefaultAbortHandler()
Returns the default AbortHandler created for this Graph2DLayoutExecutor instance. If no AbortHandler was assigned to the graph for which a layout is calculated, the Graph2DLayoutExecutor will use this AbortHandler to provide early termination of the layouter.

Note: If there is already an AbortHandler associated with the graph, the instance that is returned here won't be the same as the one that is provided by the LayoutThreadHandle which is returned when running Graph2DLayoutExecutor in a multi-threaded mode.

Returns:
The default abort handler.
See Also:
doLayout(Graph2DView, y.layout.Layouter, Runnable, y.view.Graph2DLayoutExecutor.ExceptionListener), doLayout(Graph2DView, Graph2D, y.layout.Layouter, Runnable, y.view.Graph2DLayoutExecutor.ExceptionListener)

prepareGroupLayoutConfigurator

protected GroupLayoutConfigurator prepareGroupLayoutConfigurator(Graph2DView view,
                                                                 Graph2D graph,
                                                                 Layouter layouter)
Callback method that creates a GroupLayoutConfigurator, and prepares the graph for the layout.

Parameters:
view - The view that has been passed to doLayout(Graph2DView, Layouter) or null.
graph - The graph that should be prepared.
layouter - The layouter for which the layout will be executed.
Returns:
The instance that will later be passed to restoreGroupLayoutConfigurator(Graph2D, GroupLayoutConfigurator)

prepareTableConfigurator

protected TableLayoutConfigurator prepareTableConfigurator(Graph2DView view,
                                                           Graph2D graph,
                                                           Layouter layouter)
Callback method that uses the TableLayoutConfigurator to prepare the graph for the layout.

Parameters:
view - The view that has been passed to doLayout(Graph2DView, Layouter) or null.
graph - The graph that should be prepared.
layouter - The layouter for which the layout will be executed.
Returns:
The instance that will later be passed to restoreTableConfigurator(Graph2D, y.view.tabular.TableLayoutConfigurator).

prepareNodePortConfigurator

protected NodePortLayoutConfigurator prepareNodePortConfigurator(Graph2DView view,
                                                                 Graph2D graph,
                                                                 Layouter layouter)
Callback method that uses the NodePortConfigurator to prepare the graph for the layout.

Parameters:
view - The view that has been passed to doLayout(Graph2DView, Layouter) or null.
graph - The graph that should be prepared.
layouter - The layouter for which the layout will be executed.
Returns:
The instance that will later be passed to restoreNodePortConfigurator(Graph2D, NodePortLayoutConfigurator).

restoreGroupLayoutConfigurator

protected void restoreGroupLayoutConfigurator(Graph2D graph,
                                              GroupLayoutConfigurator configurator)
Callback that calls GroupLayoutConfigurator.restoreAll() after the layout is done.

Parameters:
graph - The graph that had been prepared.
configurator - The configurator that has earlier been created in prepareGroupLayoutConfigurator(Graph2DView, Graph2D, Layouter)

restoreTableConfigurator

protected void restoreTableConfigurator(Graph2D graph,
                                        TableLayoutConfigurator tableConfigurator)
Callback that calls TableLayoutConfigurator.restoreAll(Graph2D) after the layout is done.

Parameters:
graph - The graph that had been prepared.
tableConfigurator - The configurator that has earlier been returned by prepareTableConfigurator(Graph2DView, Graph2D, Layouter).

restoreNodePortConfigurator

protected void restoreNodePortConfigurator(Graph2D graph,
                                           NodePortLayoutConfigurator configurator)
Callback that calls NodePortLayoutConfigurator.restoreAll(Graph2D) after the layout is done.

Parameters:
graph - The graph that had been prepared.
configurator - The configurator that has earlier been returned by prepareNodePortConfigurator(Graph2DView, Graph2D, y.layout.Layouter).

doLayout

public void doLayout(Graph2D graph,
                     Layouter layouter)
Calculates a layout without animating it. Even if this instance's mode is set to ANIMATED or ANIMATED_THREADED this call will perform no animation. Use the doLayout(Graph2DView, Layouter) or doLayout(Graph2DView, Graph2D, Layouter) methods for animations instead.

Parameters:
graph - The graph to calculate and apply a layout for.
layouter - The layouter instance to use.

doLayout

public void doLayout(Graph2DView view,
                     Layouter layouter)
Calculates a layout and applies it to the graph in the view.

Parameters:
view - the view with the graph to calculate and apply a layout for. May not be null.
layouter - The layouter instance to use. May not be null
Throws:
java.lang.IllegalArgumentException - if any of the required parameters is null.

doLayout

public void doLayout(Graph2DView view,
                     Graph2D graph,
                     Layouter layouter)
Calculates a layout and applies it to the graph in the view. Even if this instance's mode is set to ANIMATED or ANIMATED_THREADED this call will perform no animation if the view is null.

Parameters:
view - The view to run the animated layout in.
graph - The graph to calculate and apply a layout for. May not be null.
layouter - The layouter instance to use. May not be null
Throws:
java.lang.IllegalArgumentException - if any of the required parameters is null.

doLayout

public void doLayout(Graph2D graph,
                     Layouter layouter,
                     java.lang.Runnable doneListener,
                     Graph2DLayoutExecutor.ExceptionListener exceptionListener)
Calculates a layout without animating it. Even if this instance's mode is set to ANIMATED or ANIMATED_THREADED this call will perform no animation. Use the doLayout(Graph2DView, Layouter, Runnable, ExceptionListener) or doLayout(Graph2DView, Graph2D, Layouter, Runnable, ExceptionListener) methods for animations instead.

Parameters:
graph - The graph to calculate and apply a layout for. May not be null.
layouter - The layouter instance to use. May not be null
doneListener - if not null this listener will be Runnable.run() after the operation is complete.
exceptionListener - if not null this listener will be used to report asynchronous and synchronous caught exceptions.

doLayout

public Graph2DLayoutExecutor.LayoutThreadHandle doLayout(Graph2DView view,
                                                         Layouter layouter,
                                                         java.lang.Runnable doneListener,
                                                         Graph2DLayoutExecutor.ExceptionListener exceptionListener)
Calculates a layout and applies it to the graph in the view. Even if this instance's mode is set to ANIMATED or ANIMATED_THREADED this call will perform no animation if the view is null. Use the doLayout(Graph2DView, Layouter) or doLayout(Graph2DView, Graph2D, Layouter) methods instead. This method is useful for the ANIMATED_THREADED and THREADED modes and will return immediately to report progress via the doneListener and exceptionListener.

Parameters:
doneListener - if not null this listener will be Runnable.run() after the operation is complete.
exceptionListener - if not null this listener will be used to report asynchronous and synchronous caught exceptions.
view - The view to run the animated layout in.
layouter - The layouter instance to use. May not be null
Throws:
java.lang.IllegalArgumentException - if any of the required parameters is null.

doLayout

public Graph2DLayoutExecutor.LayoutThreadHandle doLayout(Graph2DView view,
                                                         Graph2D graph,
                                                         Layouter layouter,
                                                         java.lang.Runnable doneListener,
                                                         Graph2DLayoutExecutor.ExceptionListener exceptionListener)
Calculates a layout and applies it to the provided graph in the provided view. Even if this instance's mode is set to ANIMATED or ANIMATED_THREADED this call will perform no animation if the view is null. Use the doLayout(Graph2DView, Layouter) or doLayout(Graph2DView, Graph2D, Layouter) methods instead. This method is useful for the ANIMATED_THREADED and THREADED modes and will return immediately to report progress via the doneListener and exceptionListener.

Parameters:
doneListener - if not null this listener will be Runnable.run() after the operation is complete.
exceptionListener - if not null this listener will be used to report asynchronous and synchronous caught exceptions.
view - The view to run the animated layout in.
graph - The graph to calculate and apply a layout for. May not be null.
layouter - The layouter instance to use. May not be null
Throws:
java.lang.IllegalArgumentException - if any of the required parameters is null.

startThread

protected void startThread(java.lang.Runnable runnable)
Callback method that creates and starts the thread for the execution of the ANIMATED_THREADED or THREADED layout. This method needs to initiate the launch of the runnable. This implementation creates a new Thread and sets the daemon flag on it before starting it.

Parameters:
runnable - The runnable to execute.

lock

protected void lock(Graph2DView view,
                    java.util.Map lockState)
Called during one of the doLayout(Graph2DView, y.layout.Layouter) calls on the EDT to lock the Graph2DView from receiving further input. This implementation will set the wait cursor in the view and suppress input on it.

Parameters:
view - The view to be locked down
lockState - A map that can be used to store key value pairs that will later be provided to unlock(Graph2DView, java.util.Map).
See Also:
unlock(Graph2DView, java.util.Map)

unlock

protected void unlock(Graph2DView view,
                      java.util.Map lockState)
This method will unlock a previously locked view after the layout has been calculated.

Parameters:
view - The view to unlock.
lockState - The map that was passed to lock(Graph2DView, java.util.Map) previously.

configureComponentLayouter

protected void configureComponentLayouter(Graph2DView view,
                                          ComponentLayouter cl)
Callback that configures the ComponentLayouter according to the view.

If the size of the view is not specified at this point, ComponentLayouter will be configured with the preferred size of the view. If preferred size is not specified either, a default size of 400x400 is used.

Parameters:
view - The view the layout is run in.
cl - The ComponentLayouter to configure.

createAnimationPlayer

protected AnimationPlayer createAnimationPlayer()
Factory method used for the LayoutMorpher to play the animation.

Returns:
an AnimationPlayer that will be used to animate the LayoutMorpher

createLayoutMorpher

protected LayoutMorpher createLayoutMorpher()
Factory method used to initialize the layout morpher used for the animation.

Returns:
a readily configured LayoutMorpher instance

createAnimation

protected AnimationObject createAnimation(Graph2DView view,
                                          Graph2D graph,
                                          GraphLayout graphLayout)
Creates the AnimationObject that will be used after the layout has been calculated.

Parameters:
view - The view the animation will be used in.
graph - The graph that should be animated.
graphLayout - The target layout for the graph.
Returns:
The object to animate.

useEventDispatchThread

protected boolean useEventDispatchThread(Graph2DView view)
Determines whether to use the EDT for the calculations that should be performed. This implementation returns !SwingUtilities.isEventDispatchThread() && view != null && view.isShowing();

Parameters:
view - current view
Returns:
true, if the EDT should be used

applyGraphLayout

protected void applyGraphLayout(Graph2D graph,
                                GraphLayout layout)
Applies the specified layout to the given graph. This method is used to apply a newly calculated graph layout to the original graph when working with modes BUFFERED and THREADED or when the current graph should be morphed to the calculated layout but createAnimation(Graph2DView, Graph2D, y.layout.GraphLayout) returns null.

Parameters:
graph - the graph whose layout has to be updated.
layout - the new coordinates for the elements of the specified graph.

isPortIntersectionCalculatorEnabled

public boolean isPortIntersectionCalculatorEnabled()
Determines whether a PortCalculator should be used to adjust port positions after the main layout to lie on the visible boundaries of the NodeRealizers. By default this feature is turned off.

Returns:
true, if port intersection calculation is enabled
See Also:
setPortIntersectionCalculatorEnabled(boolean)

setPortIntersectionCalculatorEnabled

public void setPortIntersectionCalculatorEnabled(boolean enabled)
Sets whether or not layout stage PortCalculator should be automatically executed after the main layouter. If no IntersectionCalculator DataProviders are registered with the graph, this class will use DataProviders of type NodeRealizerIntersectionCalculator. By default this feature is disabled.

Parameters:
enabled - if true, port intersection calculation gets enabled and disabled otherwise

© Copyright 2000-2021,
yWorks GmbH.
All rights reserved.