Search this API

y.layout
Class PortCandidateAssignmentStage

java.lang.Object
  extended by y.layout.AbstractLayoutStage
      extended by y.layout.PortCandidateAssignmentStage
All Implemented Interfaces:
Layouter, LayoutStage

public class PortCandidateAssignmentStage
extends AbstractLayoutStage

The PortCandidateAssignmentStage assigns edges to the ports specified by PortConstraints or PortCandidates after calling the core layout algorithm. It can be used for adjusting ports for layout algorithms that cannot handle PortConstraints.

If PortCandidates are assigned for edges and nodes, this stage tries to match them. When there is no match, the PortCandidate with the lowest costs specified for the edge is chosen. While PortConstraints are also matched to PortCandidates at nodes and edges, it is not recommended to mix them because they belong to different concepts.

This stage also considers port groups (see PortConstraintKeys.SOURCE_PORT_GROUP_ID_DPKEY and PortConstraintKeys.TARGET_PORT_GROUP_ID_DPKEY). It assigns the same port to edges that are port-grouped at a common node. Importantly, port grouping is prioritized over other constraints, for example, if two port-grouped edges do not have at least one common PortCandidate or the same PortConstraint, then the port of one of the edges will be chosen for both, violating the constraint of the other edge.

Furthermore, option setPathCorrectionEnabled(boolean) allows to specify whether the edge path should be corrected after correcting a port.

It is recommended that the PortCandidateAssignmentStage is prepended to the core layout algorithm in order to be able to process all the edges and especially, self-loops and parallel edges. Note that edges that might be hidden by other LayoutStages cannot be handled by PortCandidateAssignmentStage.

 
This stage can not properly deal with the case that the current ports are outside of the bounds of the adjacent nodes. The current ports are expected to be on the border or inside the node (e.g. center).
See Also:
PortConstraint, PortCandidate, PortCandidateSet, setPathCorrectionEnabled(boolean)
 

Field Summary
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
PortCandidateAssignmentStage()
          Creates a new PortCandidateAssignmentStage instance with default settings.
PortCandidateAssignmentStage(Layouter coreLayouter)
          Creates a new PortCandidateAssignmentStage instance using the given core layout algorithm.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Accepts all graphs that can be handled by the core layout algorithm.
 void doLayout(LayoutGraph graph)
          Corrects the ports of the edges considering PortConstraints and PortCandidates.
 boolean isPathCorrectionEnabled()
          Returns whether or not this LayoutStage corrects the edge paths after moving the port to the location specified by a PortConstraint or PortCandidates.
 void setPathCorrectionEnabled(boolean pathCorrectionEnabled)
          Specifies whether or not this LayoutStage corrects the edge paths after moving the port to the location specified by a PortConstraint or PortCandidates.
 
Methods inherited from class y.layout.AbstractLayoutStage
canLayoutCore, doLayoutCore, getCoreLayouter, setCoreLayouter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PortCandidateAssignmentStage

public PortCandidateAssignmentStage()
Creates a new PortCandidateAssignmentStage instance with default settings.


PortCandidateAssignmentStage

public PortCandidateAssignmentStage(Layouter coreLayouter)
Creates a new PortCandidateAssignmentStage instance using the given core layout algorithm.

Parameters:
coreLayouter - the core layout routine
Method Detail

canLayout

public boolean canLayout(LayoutGraph graph)
Accepts all graphs that can be handled by the core layout algorithm.

If there is no core layout algorithm, all graphs are accepted.

Parameters:
graph - the input graph
Returns:
true if there is no core layout algorithm or the core layout algorithm accepts the graph, false otherwise
See Also:
Layouter.doLayout(LayoutGraph)

doLayout

public void doLayout(LayoutGraph graph)
Corrects the ports of the edges considering PortConstraints and PortCandidates.

Parameters:
graph - the input graph
See Also:
Layouter.canLayout(LayoutGraph)

isPathCorrectionEnabled

public boolean isPathCorrectionEnabled()
Returns whether or not this LayoutStage corrects the edge paths after moving the port to the location specified by a PortConstraint or PortCandidates.

If path correction is enabled, the edge will be rerouted within a specific area around its source/target node. Outside this area, it will keep the route that was calculated by the core layout algorithm. If this feature is disabled, only the ports are moved which may be more suitable for initially straight edges.

 
The path correction uses a simple orthogonal routing strategy that is fast but may produce overlapping edge segments as well as edge-node intersections.
Returns:
true if edge paths are corrected, false otherwise
See Also:
setPathCorrectionEnabled(boolean)

setPathCorrectionEnabled

public void setPathCorrectionEnabled(boolean pathCorrectionEnabled)
Specifies whether or not this LayoutStage corrects the edge paths after moving the port to the location specified by a PortConstraint or PortCandidates.

If path correction is enabled, the edge will be rerouted within a specific area around its source/target node. Outside this area, it will keep the route that was calculated by the core layout algorithm. If this feature is disabled, only the ports are moved which may be more suitable for initially straight edges.

 
The path correction uses a simple orthogonal routing strategy that is fast but may produce overlapping edge segments as well as edge-node intersections.
Default Value:
The default value is false. Edge paths are not orthogonally corrected.
Parameters:
pathCorrectionEnabled - true if edge paths should be corrected, false otherwise
Sample Graphs:

false

true

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