Search this API

y.layout.hierarchic.incremental
Class AbstractPortConstraintOptimizer

java.lang.Object
  extended by y.layout.hierarchic.incremental.AbstractPortConstraintOptimizer
All Implemented Interfaces:
PortConstraintOptimizer
Direct Known Subclasses:
PCListOptimizer

public abstract class AbstractPortConstraintOptimizer
extends java.lang.Object
implements PortConstraintOptimizer

This class is an abstract implementation of the PortConstraintOptimizer interface that minimizes the effort required to modify the port assignment after the sequencing phase of hierarchic layout algorithm.

The callback method invoked after sequencing performs the following three steps:

  1. Restores temporarily all same-layer edges which are not currently present in the layout graph at this time of the layout algorithm.
  2. Invokes the hook in which the custom port assignment should be done.
  3. Restores the original state of the layout graph by removing the temporary same-layer edges added in Step 1.

 

Nested Class Summary
static class AbstractPortConstraintOptimizer.SameLayerData
          This static class provides information about the same-layer structures created by class AbstractPortConstraintOptimizer.
 
Constructor Summary
protected AbstractPortConstraintOptimizer()
          Creates a new AbstractPortConstraintOptimizer instance with default settings.
 
Method Summary
 byte getLayoutOrientation()
          Returns the layout orientation.
 int getMirrorMask()
          Returns the mirror mask that defines which orientations should be mirrored.
protected  AbstractPortConstraintOptimizer.SameLayerData insertSameLayerStructures(LayoutGraph graph, Layers layers, LayoutDataProvider ldp, ItemFactory itemFactory)
          Inserts a same-layer edge structure for each same-layer edge of the original graph.
abstract  void optimizeAfterLayering(LayoutGraph graph, Layers layers, LayoutDataProvider ldp, ItemFactory itemFactory)
          Assigns new temporary port constraints after the nodes have been assigned to layers.
protected  void optimizeAfterSequencing(java.util.Comparator inEdgeOrder, java.util.Comparator outEdgeOrder, LayoutGraph graph, Layers layers, LayoutDataProvider ldp, ItemFactory itemFactory)
          Assigns new temporary port constraints after the order of the nodes in each layer has been determined.
 void optimizeAfterSequencing(LayoutGraph graph, Layers layers, LayoutDataProvider ldp, ItemFactory itemFactory)
          Assigns new temporary port constraints after the order of the nodes in each layer has been determined.
protected abstract  void optimizeAfterSequencing(Node node, java.util.Comparator inEdgeOrder, java.util.Comparator outEdgeOrder, LayoutGraph graph, LayoutDataProvider ldp, ItemFactory itemFactory)
          Assigns new temporary port constraints to a given node of the graph after the order of the nodes in each layer has been determined.
protected  void removeSameLayerStructures(AbstractPortConstraintOptimizer.SameLayerData sameLayerData, LayoutGraph graph, LayoutDataProvider ldp, ItemFactory itemFactory)
          Removes the same-layer edge structure created using insertSameLayerStructures(LayoutGraph, Layers, LayoutDataProvider, ItemFactory).
 void setLayoutOrientation(byte layoutOrientation)
          Specifies the layout orientation.
 void setMirrorMask(int mirrorMask)
          Specifies the mirror mask that defines which orientations should be mirrored.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPortConstraintOptimizer

protected AbstractPortConstraintOptimizer()
Creates a new AbstractPortConstraintOptimizer instance with default settings.

Method Detail

getMirrorMask

public int getMirrorMask()
Returns the mirror mask that defines which orientations should be mirrored.

Setting a layout orientation can be considered as rotating the graph by 90, 180 or 270 degrees. Afterwards, the graph can be mirrored at the x-axis (for horizontal layout orientations) or y-axis (for vertical layout orientations). Which directions are mirrored can be defined by the given mask.

Returns:
one of the predefined mirror masks
See Also:
OrientationLayouter, LayoutOrientation, setMirrorMask(int)

setMirrorMask

public void setMirrorMask(int mirrorMask)
Specifies the mirror mask that defines which orientations should be mirrored.

Setting a layout orientation can be considered as rotating the graph by 90, 180 or 270 degrees. Afterwards, the graph can be mirrored at the x-axis (for horizontal layout orientations) or y-axis (for vertical layout orientations). Which directions are mirrored can be defined by the given mask.

Default Value:
The default value is OrientationLayouter.MIRROR_BOTTOM_TO_TOP. Layout orientation LayoutOrientation.BOTTOM_TO_TOP will be mirrored at the y-axis.
Parameters:
mirrorMask - one of the predefined mirror masks
See Also:
OrientationLayouter, LayoutOrientation

setLayoutOrientation

public void setLayoutOrientation(byte layoutOrientation)
Specifies the layout orientation.

This setting is necessary to correctly interpret the values provided by the PortCandidates since the OrientationLayouter cannot automatically adjust these values.

Default Value:
The default value is LayoutOrientation.TOP_TO_BOTTOM. The layout orientation is top-to-bottom.
Parameters:
layoutOrientation - a predefined orientation constant
See Also:
CanonicMultiStageLayouter.getLayoutOrientation()

getLayoutOrientation

public byte getLayoutOrientation()
Returns the layout orientation.

This setting is necessary to correctly interpret the values provided by the PortCandidates since the OrientationLayouter cannot automatically adjust these values.

Returns:
a predefined orientation constant
See Also:
CanonicMultiStageLayouter.getLayoutOrientation(), setLayoutOrientation(byte)

optimizeAfterLayering

public abstract void optimizeAfterLayering(LayoutGraph graph,
                                           Layers layers,
                                           LayoutDataProvider ldp,
                                           ItemFactory itemFactory)
Assigns new temporary port constraints after the nodes have been assigned to layers.

More precisely, it is called after the layering information has been determined. In this phase, it is possible to create back-loops by assigning incoming edges to the south (i.e. bottom) side or outgoing edges to the north (i.e. top) side, respectively.

Specified by:
optimizeAfterLayering in interface PortConstraintOptimizer
Parameters:
graph - the input graph
layers - the given Layers instance holding the layering information
ldp - the LayoutDataProvider implementation which provides access to the NodeData and EdgeData instances
itemFactory - the factory that sets the temporary port constraints
See Also:
ItemFactory.setTemporaryPortConstraint(y.base.Edge, boolean, y.layout.PortConstraint)

optimizeAfterSequencing

public void optimizeAfterSequencing(LayoutGraph graph,
                                    Layers layers,
                                    LayoutDataProvider ldp,
                                    ItemFactory itemFactory)
Assigns new temporary port constraints after the order of the nodes in each layer has been determined.

More precisely, it is called after the sequence of the nodes has been determined. It inserts the same-layer structures, invokes the hook in which the custom port assignment should be done, and finally restores the original state of the layout graph by removing the temporary edges.

Specified by:
optimizeAfterSequencing in interface PortConstraintOptimizer
Parameters:
graph - the input graph
layers - the given Layers instance holding the layering information
ldp - the LayoutDataProvider implementation which provides access to the NodeData and EdgeData instances
itemFactory - the factory that sets the temporary port constraints
See Also:
insertSameLayerStructures(LayoutGraph, Layers, LayoutDataProvider, ItemFactory), optimizeAfterSequencing(y.layout.LayoutGraph, Layers, LayoutDataProvider, ItemFactory), removeSameLayerStructures(y.layout.hierarchic.incremental.AbstractPortConstraintOptimizer.SameLayerData, y.layout.LayoutGraph, y.layout.hierarchic.incremental.LayoutDataProvider, y.layout.hierarchic.incremental.ItemFactory)

optimizeAfterSequencing

protected void optimizeAfterSequencing(java.util.Comparator inEdgeOrder,
                                       java.util.Comparator outEdgeOrder,
                                       LayoutGraph graph,
                                       Layers layers,
                                       LayoutDataProvider ldp,
                                       ItemFactory itemFactory)
Assigns new temporary port constraints after the order of the nodes in each layer has been determined.

More precisely, it is called after the sequence of the nodes has been determined. It invokes optimizeAfterSequencing(y.base.Node, java.util.Comparator, java.util.Comparator, y.layout.LayoutGraph, LayoutDataProvider, ItemFactory) for every node of the original layout graph and omits the nodes of the same-layer structures.

Incoming and outgoing edges are sorted using Comparators.PartialOrder instances which define the preferred ordering of the incoming and outgoing edges from left to right. To sort collections according to a Comparators.PartialOrder instance, an appropriate method like Comparators.sort(java.util.List, java.util.Comparator) or YList.sort(java.util.Comparator) must be used.

 
In this phase, it is not allowed to create back-loops, i.e., incoming edges must not connect to the south (i.e., bottom) side and outgoing edges must not connect to the north (i.e., top) side of a node.
Parameters:
inEdgeOrder - a given Comparators.PartialOrder instance for incoming edges
outEdgeOrder - a given Comparators.PartialOrder instance for outgoing edges
graph - the input graph
ldp - the LayoutDataProvider implementation which provides access to the NodeData and EdgeData instances
itemFactory - the factory that sets the temporary port constraints
See Also:
optimizeAfterSequencing(y.layout.LayoutGraph, Layers, LayoutDataProvider, ItemFactory)

optimizeAfterSequencing

protected abstract void optimizeAfterSequencing(Node node,
                                                java.util.Comparator inEdgeOrder,
                                                java.util.Comparator outEdgeOrder,
                                                LayoutGraph graph,
                                                LayoutDataProvider ldp,
                                                ItemFactory itemFactory)
Assigns new temporary port constraints to a given node of the graph after the order of the nodes in each layer has been determined.

More precisely, it is called after the sequence of the nodes has been determined.

Incoming and outgoing edges are sorted using Comparators.PartialOrder instances which define the preferred ordering of the incoming and outgoing edges from left to right. To sort collections according to a Comparators.PartialOrder instance, an appropriate method like Comparators.sort(java.util.List, java.util.Comparator) or YList.sort(java.util.Comparator) must be used.

 
In this phase, it is not allowed to create back-loops, i.e., incoming edges must not connect to the south (i.e., bottom) side and outgoing edges must not connect to the north (i.e., top) side of a node.
Parameters:
node - the original node to set temporary port constraints
inEdgeOrder - a given Comparators.PartialOrder instance for incoming edges
outEdgeOrder - a given Comparators.PartialOrder instance for outgoing edges
graph - the input graph
ldp - the LayoutDataProvider implementation which provides access to the NodeData and EdgeData instances
itemFactory - the factory that sets the temporary port constraints
See Also:
optimizeAfterSequencing(y.layout.LayoutGraph, Layers, LayoutDataProvider, ItemFactory)

insertSameLayerStructures

protected AbstractPortConstraintOptimizer.SameLayerData insertSameLayerStructures(LayoutGraph graph,
                                                                                  Layers layers,
                                                                                  LayoutDataProvider ldp,
                                                                                  ItemFactory itemFactory)
Inserts a same-layer edge structure for each same-layer edge of the original graph.

 
In this phase of the layout, the graph does not contain same-layer edges. The structure for a same-layer edge (s,t) consists of a temporary node w and edges (s,w) and (t,w).
Parameters:
graph - the input graph
layers - the given Layers instance holding the layering information
ldp - the LayoutDataProvider implementation which provides access to the NodeData and EdgeData instances
itemFactory - the factory that sets the temporary port constraints
See Also:
ItemFactory.setTemporaryPortConstraint(y.base.Edge, boolean, y.layout.PortConstraint)

removeSameLayerStructures

protected void removeSameLayerStructures(AbstractPortConstraintOptimizer.SameLayerData sameLayerData,
                                         LayoutGraph graph,
                                         LayoutDataProvider ldp,
                                         ItemFactory itemFactory)
Removes the same-layer edge structure created using insertSameLayerStructures(LayoutGraph, Layers, LayoutDataProvider, ItemFactory).

Parameters:
sameLayerData - a given AbstractPortConstraintOptimizer.SameLayerData instance holding the information about the same-layer structures.
graph - the input graph
ldp - the LayoutDataProvider implementation which provides access to the NodeData and EdgeData instances
itemFactory - the factory that sets the temporary port constraints
See Also:
ItemFactory.setTemporaryPortConstraint(y.base.Edge, boolean, y.layout.PortConstraint)

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