public abstract class AbstractPortConstraintOptimizer extends Object implements IPortConstraintOptimizer
IPortConstraintOptimizer 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:
the hook
in which the custom port assignment should be done.
1.| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractPortConstraintOptimizer.SameLayerData
This static class provides information about the same-layer structures created by class
AbstractPortConstraintOptimizer. |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractPortConstraintOptimizer()
Creates a new
AbstractPortConstraintOptimizer instance with default settings. |
| Modifier and Type | Method and Description |
|---|---|
LayoutOrientation |
getLayoutOrientation()
Gets the layout orientation.
|
MirrorModes |
getMirrorMode()
Gets the mirror mask that defines which orientations should be mirrored.
|
protected AbstractPortConstraintOptimizer.SameLayerData |
insertSameLayerStructures(LayoutGraph graph,
ILayers layers,
ILayoutDataProvider ldp,
IItemFactory itemFactory)
Inserts a same-layer edge structure for each same-layer edge of the original graph.
|
abstract void |
optimizeAfterLayering(LayoutGraph graph,
ILayers layers,
ILayoutDataProvider ldp,
IItemFactory itemFactory)
Assigns new temporary port constraints after the nodes have been assigned to layers.
|
protected void |
optimizeAfterSequencing(Comparator<Object> inEdgeOrder,
Comparator<Object> outEdgeOrder,
LayoutGraph graph,
ILayers layers,
ILayoutDataProvider ldp,
IItemFactory itemFactory)
Assigns new temporary port constraints after the order of the nodes in each layer has been determined.
|
void |
optimizeAfterSequencing(LayoutGraph graph,
ILayers layers,
ILayoutDataProvider ldp,
IItemFactory itemFactory)
Assigns new temporary port constraints after the order of the nodes in each layer has been determined.
|
protected abstract void |
optimizeAfterSequencing(Node node,
Comparator<Object> inEdgeOrder,
Comparator<Object> outEdgeOrder,
LayoutGraph graph,
ILayoutDataProvider ldp,
IItemFactory 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,
ILayoutDataProvider ldp,
IItemFactory itemFactory)
Removes the same-layer edge structure created using
insertSameLayerStructures(LayoutGraph, ILayers, ILayoutDataProvider, IItemFactory). |
void |
setLayoutOrientation(LayoutOrientation value)
Sets the layout orientation.
|
void |
setMirrorMode(MirrorModes value)
Sets the mirror mask that defines which orientations should be mirrored.
|
protected AbstractPortConstraintOptimizer()
AbstractPortConstraintOptimizer instance with default settings.public LayoutOrientation getLayoutOrientation()
This setting is necessary to correctly interpret the values provided by the PortCandidates since the OrientationLayout
cannot automatically adjust these values.
LayoutOrientation.TOP_TO_BOTTOM. The layout orientation is top-to-bottom.MultiStageLayout.getLayoutOrientation(),
setLayoutOrientation(LayoutOrientation)public MirrorModes getMirrorMode()
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.
MirrorModes.BOTTOM_TO_TOP. Layout orientation LayoutOrientation.BOTTOM_TO_TOP will be mirrored at the
y-axis.OrientationLayout,
LayoutOrientation,
setMirrorMode(MirrorModes)protected AbstractPortConstraintOptimizer.SameLayerData insertSameLayerStructures(LayoutGraph graph, ILayers layers, ILayoutDataProvider ldp, IItemFactory itemFactory)
(s,t)
consists of a temporary node w and edges (s,w) and (t,w).graph - the input graphlayers - the given ILayers instance holding the layering informationldp - the ILayoutDataProvider implementation which provides access to the INodeData and IEdgeData
instancesitemFactory - the factory that sets the temporary port constraintsIItemFactory.setTemporaryPortConstraint(Edge, boolean, com.yworks.yfiles.layout.PortConstraint)public abstract void optimizeAfterLayering(LayoutGraph graph, ILayers layers, ILayoutDataProvider ldp, IItemFactory itemFactory)
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.
optimizeAfterLayering in interface IPortConstraintOptimizergraph - the input graphlayers - the given ILayers instance holding the layering informationldp - the ILayoutDataProvider implementation which provides access to the INodeData and IEdgeData
instancesitemFactory - the factory that sets the temporary port constraintsIItemFactory.setTemporaryPortConstraint(Edge, boolean, com.yworks.yfiles.layout.PortConstraint)protected void optimizeAfterSequencing(Comparator<Object> inEdgeOrder, Comparator<Object> outEdgeOrder, LayoutGraph graph, ILayers layers, ILayoutDataProvider ldp, IItemFactory itemFactory)
More precisely, it is called after the sequence of the nodes has been determined. It invokes optimizeAfterSequencing(Node, Comparator, Comparator, LayoutGraph, ILayoutDataProvider, IItemFactory)
for every node of the original layout graph and omits the nodes of the same-layer structures.
Incoming and outgoing edges are sorted using Comparator instances which define the preferred ordering of the
incoming and outgoing edges from left to right.
inEdgeOrder - a given Comparator instance for incoming edgesoutEdgeOrder - a given Comparator instance for outgoing edgesgraph - the input graphldp - the ILayoutDataProvider implementation which provides access to the INodeData and IEdgeData
instancesitemFactory - the factory that sets the temporary port constraintsoptimizeAfterSequencing(LayoutGraph, ILayers, ILayoutDataProvider, IItemFactory)public void optimizeAfterSequencing(LayoutGraph graph, ILayers layers, ILayoutDataProvider ldp, IItemFactory itemFactory)
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.
optimizeAfterSequencing in interface IPortConstraintOptimizergraph - the input graphlayers - the given ILayers instance holding the layering informationldp - the ILayoutDataProvider implementation which provides access to the INodeData and IEdgeData
instancesitemFactory - the factory that sets the temporary port constraintsinsertSameLayerStructures(LayoutGraph, ILayers, ILayoutDataProvider, IItemFactory),
optimizeAfterSequencing(LayoutGraph, ILayers, ILayoutDataProvider, IItemFactory),
removeSameLayerStructures(SameLayerData, LayoutGraph, ILayoutDataProvider, IItemFactory)protected abstract void optimizeAfterSequencing(Node node, Comparator<Object> inEdgeOrder, Comparator<Object> outEdgeOrder, LayoutGraph graph, ILayoutDataProvider ldp, IItemFactory itemFactory)
More precisely, it is called after the sequence of the nodes has been determined.
Incoming and outgoing edges are sorted using Comparator instances which define the preferred ordering of the
incoming and outgoing edges from left to right.
node - the original node to set temporary port constraintsinEdgeOrder - a given Comparator instance for incoming edgesoutEdgeOrder - a given Comparator instance for outgoing edgesgraph - the input graphldp - the ILayoutDataProvider implementation which provides access to the INodeData and IEdgeData
instancesitemFactory - the factory that sets the temporary port constraintsoptimizeAfterSequencing(LayoutGraph, ILayers, ILayoutDataProvider, IItemFactory)protected void removeSameLayerStructures(AbstractPortConstraintOptimizer.SameLayerData sameLayerData, LayoutGraph graph, ILayoutDataProvider ldp, IItemFactory itemFactory)
insertSameLayerStructures(LayoutGraph, ILayers, ILayoutDataProvider, IItemFactory).sameLayerData - a given AbstractPortConstraintOptimizer.SameLayerData instance holding the information about the same-layer structures.graph - the input graphldp - the ILayoutDataProvider implementation which provides access to the INodeData and IEdgeData
instancesitemFactory - the factory that sets the temporary port constraintsIItemFactory.setTemporaryPortConstraint(Edge, boolean, com.yworks.yfiles.layout.PortConstraint)public void setLayoutOrientation(LayoutOrientation value)
This setting is necessary to correctly interpret the values provided by the PortCandidates since the OrientationLayout
cannot automatically adjust these values.
LayoutOrientation.TOP_TO_BOTTOM. The layout orientation is top-to-bottom.value - a predefined orientation constantMultiStageLayout.getLayoutOrientation(),
getLayoutOrientation()public void setMirrorMode(MirrorModes value)
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.
MirrorModes.BOTTOM_TO_TOP. Layout orientation LayoutOrientation.BOTTOM_TO_TOP will be mirrored at the
y-axis.value - one of the predefined mirror masksOrientationLayout,
LayoutOrientation,
getMirrorMode()