Search this API

y.layout
Class KeepStrongPortConstraintsStage

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

public class KeepStrongPortConstraintsStage
extends AbstractLayoutStage

KeepStrongPortConstraintsStage ensures that layout algorithms that cannot handle port constraints keep the ports of edges with strong PortConstraints. Without this stage, the port locations get lost.

For each edge with strong PortConstraints, this stage simply stores the original port and restores it after applying the core layout algorithm. Therefore, it either replaces the source/target port by the original port or adds the original port to the edge path calculated by the core layout algorithm (see method setKeepCalculatedPortsEnabled(boolean)).

 

Field Summary
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
KeepStrongPortConstraintsStage()
          Creates a new KeepStrongPortConstraintsStage instance with default settings.
KeepStrongPortConstraintsStage(Layouter coreLayouter)
          Creates a new KeepStrongPortConstraintsStage 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)
          Restores the locations of strong PortConstraints after invoking the core layout algorithm.
 boolean isKeepCalculatedPortsEnabled()
          Returns whether or not the final edge routes should contain the ports calculated by the core layout algorithm.
 void setKeepCalculatedPortsEnabled(boolean keepPorts)
          Specifies whether or not the final edge routes should contain the ports calculated by the core layout algorithm.
 
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

KeepStrongPortConstraintsStage

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


KeepStrongPortConstraintsStage

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

Parameters:
coreLayouter - the core layout routine
Method Detail

isKeepCalculatedPortsEnabled

public boolean isKeepCalculatedPortsEnabled()
Returns whether or not the final edge routes should contain the ports calculated by the core layout algorithm. If this option is disabled, this stage simply replaces the current source/target ports (calculated by the core layout algorithm) by the original ports (for strong ports only). Otherwise, the calculated ports are still contained in the edge paths.

 
For layout algorithms that produce non straight-line edge routes this option should always be enabled.
Returns:
true if the final edge route should contain the ports calculated by the core layout algorithm, false otherwise

setKeepCalculatedPortsEnabled

public void setKeepCalculatedPortsEnabled(boolean keepPorts)
Specifies whether or not the final edge routes should contain the ports calculated by the core layout algorithm. If this option is disabled, this stage simply replaces the current source/target ports (calculated by the core layout algorithm) by the original ports (for strong ports only). Otherwise, the calculated ports are still contained in the edge paths.

 
For layout algorithms that produce non straight-line edge routes this option should always be enabled.
Default Value:
The default value is true. The edge paths contain the port locations calculated by the core layout algorithm.
Parameters:
keepPorts - true if the final edge route should contain the ports calculated by the core layout algorithm, false otherwise
Sample Graphs:

false

true

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)
Restores the locations of strong PortConstraints after invoking the core layout algorithm.

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

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