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 Object
implements PortConstraintOptimizer

A partial implementation of the PortConstraintOptimizer interface to minimize the effort required to modify the port assignment after the sequencing phase. In this class, the callback method invoked after sequencing temporarily restores all same layer edges which, otherwise, wouldn't be present in the layout graph at this time of the algorithm, then invokes the hook in which the custom port assignment should be done, and finally takes care to restore the original state of the layout graph by removing the temporary edges.


Nested Class Summary
static class AbstractPortConstraintOptimizer.SameLayerData
          Provides information about the same layer structures created by class AbstractPortConstraintOptimizer.
 
Constructor Summary
protected AbstractPortConstraintOptimizer()
          Creates a new AbstractPortConstraintOptimizer.
 
Method Summary
 byte getLayoutOrientation()
          Returns the currently set layout orientation for this class.
 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)
          Called after the layering information has been determined.
protected  void optimizeAfterSequencing(Comparator inEdgeOrder, Comparator outEdgeOrder, LayoutGraph graph, Layers layers, LayoutDataProvider ldp, ItemFactory itemFactory)
          Called after the sequence of the nodes has been determined to assign new temporary port constraints to all nodes.
 void optimizeAfterSequencing(LayoutGraph graph, Layers layers, LayoutDataProvider ldp, ItemFactory itemFactory)
          Called after the sequence of the nodes has been determined to assign new temporary port constraints.
protected abstract  void optimizeAfterSequencing(Node node, Comparator inEdgeOrder, Comparator outEdgeOrder, LayoutGraph graph, LayoutDataProvider ldp, ItemFactory itemFactory)
          Called after the sequence of the nodes has been determined to assign new temporary port constraints to each original node.
protected  void removeSameLayerStructures(AbstractPortConstraintOptimizer.SameLayerData sameLayerData, LayoutGraph graph, LayoutDataProvider ldp, ItemFactory itemFactory)
          Removes the same layer edge structure created in insertSameLayerStructures(y.layout.LayoutGraph, y.layout.hierarchic.incremental.Layers, y.layout.hierarchic.incremental.LayoutDataProvider, y.layout.hierarchic.incremental.ItemFactory).
 void setLayoutOrientation(byte layoutOrientation)
          Sets the layout orientation that is used by this class.
 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.

Method Detail

getMirrorMask

public int getMirrorMask()
Returns the mirror mask that defines which orientations should be mirrored. Setting a layout orientation can be seen as rotating the graph 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).

By default a mirror mask is set, where LayoutOrientation.BOTTOM_TO_TOP will be mirrored at the y-Axis.

Returns:
a mirror mask, that determines for which layout orientation the graph will be mirrored.
See Also:
OrientationLayouter.MIRROR_BOTTOM_TO_TOP, OrientationLayouter.MIRROR_LEFT_TO_RIGHT, OrientationLayouter.MIRROR_RIGHT_TO_LEFT, OrientationLayouter.MIRROR_TOP_TO_BOTTOM, 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 seen as rotating the graph 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.

By default a mirror mask is set, where LayoutOrientation.BOTTOM_TO_TOP will be mirrored at the y-Axis.

Parameters:
mirrorMask - the mask, that determines which layout orientations shall be mirrored.
See Also:
OrientationLayouter.MIRROR_BOTTOM_TO_TOP, OrientationLayouter.MIRROR_LEFT_TO_RIGHT, OrientationLayouter.MIRROR_RIGHT_TO_LEFT, OrientationLayouter.MIRROR_TOP_TO_BOTTOM, getMirrorMask()

setLayoutOrientation

public void setLayoutOrientation(byte layoutOrientation)
Sets the layout orientation that is used by this class. This setting is necessary to correctly interpret the values provided in the PortCandidates since the OrientationLayouter cannot automatically adjust these values.

Parameters:
layoutOrientation - a orientation constant as defined in OrientationLayouter.
See Also:
CanonicMultiStageLayouter.getLayoutOrientation(), getLayoutOrientation()

getLayoutOrientation

public byte getLayoutOrientation()
Returns the currently set layout orientation for this class.

See Also:
setLayoutOrientation(byte)

optimizeAfterLayering

public abstract void optimizeAfterLayering(LayoutGraph graph,
                                           Layers layers,
                                           LayoutDataProvider ldp,
                                           ItemFactory itemFactory)
Called after the layering information has been determined. This method can be used to assign new temporary port constraints for the next phases of the algorithm. In this phase, it is possible to create back-loops by assigning in-edges to the south side or out-edges to the north side, respectively.

Specified by:
optimizeAfterLayering in interface PortConstraintOptimizer
Parameters:
graph - the graph to work on
layers - the layering information
ldp - the implementation which provides access to the NodeData and EdgeData instances
itemFactory - the factory to set the temporary port constraints with
See Also:
ItemFactory.setTemporaryPortConstraint(y.base.Edge, boolean, y.layout.PortConstraint)

optimizeAfterSequencing

public void optimizeAfterSequencing(LayoutGraph graph,
                                    Layers layers,
                                    LayoutDataProvider ldp,
                                    ItemFactory itemFactory)
Called after the sequence of the nodes has been determined to assign new temporary port constraints. This method inserts the same layer strucutres, invokes the hook in which the custom port assignment should be done, and finally takes care to restore the original state of the layout graph by removing the temporary edges.

Specified by:
optimizeAfterSequencing in interface PortConstraintOptimizer
Parameters:
graph - the graph to work on.
layers - the layering information.
ldp - the LayoutDataProvider which provides access to the NodeData and EdgeData.
itemFactory - the factory which can set the temporary port constraints.
See Also:
ItemFactory.setTemporaryPortConstraint(y.base.Edge, boolean, y.layout.PortConstraint)

optimizeAfterSequencing

protected void optimizeAfterSequencing(Comparator inEdgeOrder,
                                       Comparator outEdgeOrder,
                                       LayoutGraph graph,
                                       Layers layers,
                                       LayoutDataProvider ldp,
                                       ItemFactory itemFactory)
Called after the sequence of the nodes has been determined to assign new temporary port constraints to all nodes. This method 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.

Note that, in this phase, it's not allowed to create back-loops, that is, in-edges must not connect to the south side and out-edges must not connect to the north side.

Parameters:
inEdgeOrder - a Comparators.PartialOrder which defines the preferred ordering of the in-edges from left to right. Note: to sort collections according to a PartialOrder, an appropriate method like Comparators.sort(java.util.List, java.util.Comparator) or YList.sort(java.util.Comparator) must be used.
outEdgeOrder - a Comparators.PartialOrder which defines the preferred ordering of the out-edges from left to right. Note: to sort collections according to a PartialOrder, an appropriate method like Comparators.sort(java.util.List, java.util.Comparator) or YList.sort(java.util.Comparator) must be used.
graph - the graph to work on.
ldp - the LayoutDataProvider which provides access to the NodeData and EdgeData.
itemFactory - the factory which can set the temporary port constraints.
See Also:
optimizeAfterSequencing(y.layout.LayoutGraph, Layers, LayoutDataProvider, ItemFactory)

optimizeAfterSequencing

protected abstract void optimizeAfterSequencing(Node node,
                                                Comparator inEdgeOrder,
                                                Comparator outEdgeOrder,
                                                LayoutGraph graph,
                                                LayoutDataProvider ldp,
                                                ItemFactory itemFactory)
Called after the sequence of the nodes has been determined to assign new temporary port constraints to each original node.

Note that, in this phase, it's not allowed to create back-loops, that is, in-edges must not connect to the south side and out-edges must not connect to the north side.

Parameters:
node - the original node to set temporary port constraints at.
inEdgeOrder - a Comparators.PartialOrder which defines the preferred ordering of the in-edges from left to right. Note: to sort collections according to a PartialOrder, an appropriate method like Comparators.sort(java.util.List, java.util.Comparator) or YList.sort(java.util.Comparator) must be used.
outEdgeOrder - a Comparators.PartialOrder which defines the preferred ordering of the out-edges from left to right. Note: to sort collections according to a PartialOrder, an appropriate method like Comparators.sort(java.util.List, java.util.Comparator) or YList.sort(java.util.Comparator) must be used.
graph - the graph to work on.
ldp - the LayoutDataProvider which provides access to the NodeData and EdgeData.
itemFactory - the factory which can set 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. Note that, in this phase of the layout, the graph does not contain any same layer edges. The structure for a same layer edge (s,t) consists of a temporary node w and the edges (s,w) and (t,w).

Parameters:
graph - the graph to work on.
layers - the layering information.
ldp - the LayoutDataProvider which provides access to the NodeData and EdgeData.
itemFactory - the factory which can set 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 in insertSameLayerStructures(y.layout.LayoutGraph, y.layout.hierarchic.incremental.Layers, y.layout.hierarchic.incremental.LayoutDataProvider, y.layout.hierarchic.incremental.ItemFactory).

Parameters:
sameLayerData - the information about the same layer structures.
graph - the graph to work on.
ldp - the LayoutDataProvider which provides access to the NodeData and EdgeData.
itemFactory - the factory which can set the temporary port constraints.
See Also:
ItemFactory.setTemporaryPortConstraint(y.base.Edge, boolean, y.layout.PortConstraint)

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