Search this API

y.view
Class NodePortLayoutConfigurator

java.lang.Object
  extended by y.view.NodePortLayoutConfigurator

public class NodePortLayoutConfigurator
extends Object

Convenience class that adjusts NodePort positions for ports that are connected to edges according to the calculated edge connection points. Alternatively, this class can be used to automatically translate NodePort connected to edges into port constraints.

See Also:
isAutomaticEdgeGroupsEnabled(), isAutomaticPortConstraintsEnabled(), PortConstraint

Field Summary
static Object EDGE2D_DPKEY
          Data provider key that identifies a data provider which allows access to the edge instances of the Graph2D for a new graph layout is calculated.
 
Constructor Summary
NodePortLayoutConfigurator()
          Initializes an new NodePortLayoutConfigurator instance.
 
Method Summary
 LayoutStage createPortConsistencyStage()
          Creates a layout stage that calculates edge connection points that are consistent with the supported node port locations of the node ports associated to the edges.
protected  byte getEdgeDirection(NodePort port)
          Determines the preferred direction from which an edge should connect to the specified node port.
 boolean isAutomaticEdgeGroupsEnabled()
          Returns true if this configurator will group edges by node port and false otherwise.
 boolean isAutomaticPortConstraintsEnabled()
          Returns true if this configurator will translate node ports into port constraints and false otherwise.
 boolean isStrongGroupConstraintsEnabled()
          Returns true if this configurator will create strong constraints automatically translating node ports at group nodes into port constraints and false otherwise.
 void prepareAll(Graph2D graph)
          Performs all necessary layout preparations for the specified graph.
protected  void prepareEdgeGroups(Graph2D graph)
          Groups edges by connected node port.
protected  void preparePortConstraints(Graph2D graph)
          Translates NodePort positions into strong port constraints.
 void restoreAll(Graph2D graph)
          Performs all necessary resource cleanup and data translation after a layout calculation.
protected  void restoreEdgeGroups(Graph2D graph)
          Restores saved edge group data.
protected  void restorePortConstraints(Graph2D graph)
          Restores saved port constraints data.
protected  void restorePortPositions(Graph2D graph)
          Restores node port positions according to the corresponding edge connection points.
 void setAutomaticEdgeGroupsEnabled(boolean enabled)
          Specifies whether or not this configurator will group edges by node port.
 void setAutomaticPortConstraintsEnabled(boolean enabled)
          Specifies whether or not this configurator will translate node ports into port constraints.
 void setStrongGroupConstraintsEnabled(boolean enabled)
          Specifies whether this configurator will create strong or weak constraints when automatically translating node ports at group nodes into port constraints.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EDGE2D_DPKEY

public static final Object EDGE2D_DPKEY
Data provider key that identifies a data provider which allows access to the edge instances of the Graph2D for a new graph layout is calculated.

See Also:
createPortConsistencyStage()
Constructor Detail

NodePortLayoutConfigurator

public NodePortLayoutConfigurator()
Initializes an new NodePortLayoutConfigurator instance.

Method Detail

isAutomaticPortConstraintsEnabled

public boolean isAutomaticPortConstraintsEnabled()
Returns true if this configurator will translate node ports into port constraints and false otherwise.

For normal nodes and folder nodes, a strong port constraint is created for each node port that is bound to an edge. For group nodes, method isStrongGroupConstraintsEnabled() determines whether a strong or a weak port constraint is created for each node port that is bound to an edge.

Defaults to false.

Returns:
true if this configurator will translate node ports into port constraints and false otherwise.
See Also:
setAutomaticPortConstraintsEnabled(boolean)

setAutomaticPortConstraintsEnabled

public void setAutomaticPortConstraintsEnabled(boolean enabled)
Specifies whether or not this configurator will translate node ports into port constraints.

For normal nodes and folder nodes, a strong port constraint is created for each node port that is bound to an edge. For group nodes, method isStrongGroupConstraintsEnabled() determines whether a strong or a weak port constraint is created for each node port that is bound to an edge.

Defaults to false.

Parameters:
enabled - if true this configurator will translate node ports into port constraints.
See Also:
isAutomaticPortConstraintsEnabled()

isAutomaticEdgeGroupsEnabled

public boolean isAutomaticEdgeGroupsEnabled()
Returns true if this configurator will group edges by node port and false otherwise.

Defaults to true.

Returns:
true if this configurator will group edges by node port and false otherwise.
See Also:
setAutomaticEdgeGroupsEnabled(boolean)

setAutomaticEdgeGroupsEnabled

public void setAutomaticEdgeGroupsEnabled(boolean enabled)
Specifies whether or not this configurator will group edges by node port.

Defaults to true.

Parameters:
enabled - if true this configurator will group edges by node port.
See Also:
isAutomaticEdgeGroupsEnabled()

isStrongGroupConstraintsEnabled

public boolean isStrongGroupConstraintsEnabled()
Returns true if this configurator will create strong constraints automatically translating node ports at group nodes into port constraints and false otherwise.

Strong port constraints should be used for edge routing algorithms, because routing algorithms do not rearrange nodes and therefore do not resize group nodes. Weak port constraints should be used for layout algorithms that rearrange nodes and therefore usually have to resize group nodes.

Defaults to true.

Returns:
true if this configurator will translate node ports at group nodes into strong port constraints and false otherwise.
See Also:
setStrongGroupConstraintsEnabled(boolean), isAutomaticPortConstraintsEnabled()

setStrongGroupConstraintsEnabled

public void setStrongGroupConstraintsEnabled(boolean enabled)
Specifies whether this configurator will create strong or weak constraints when automatically translating node ports at group nodes into port constraints.

Strong port constraints should be used for edge routing algorithms, because routing algorithms do not rearrange nodes and therefore do not resize group nodes. Weak port constraints should be used for layout algorithms that rearrange nodes and therefore usually have to resize group nodes.

Defaults to true.

Parameters:
enabled - if true this configurator will translate node ports at group nodes into strong port constraints.
See Also:
isStrongGroupConstraintsEnabled(), isAutomaticPortConstraintsEnabled()

prepareAll

public void prepareAll(Graph2D graph)
Performs all necessary layout preparations for the specified graph.

Parameters:
graph - the Graph2D instance that is prepared for automated layout calculation.
See Also:
restoreAll(Graph2D)

prepareEdgeGroups

protected void prepareEdgeGroups(Graph2D graph)
Groups edges by connected node port. Existing edge group data is saved for later restoration (see restoreEdgeGroups(Graph2D)).

Parameters:
graph - the Graph2D whose edges have to be grouped by node port.
See Also:
restoreEdgeGroups(Graph2D)

preparePortConstraints

protected void preparePortConstraints(Graph2D graph)
Translates NodePort positions into strong port constraints. Existing port constraint data is saved for later restoration (see restorePortPositions(Graph2D)).

Parameters:
graph - the Graph2D whose node ports have to be translated into strong port constraints.
See Also:
restorePortConstraints(Graph2D)

getEdgeDirection

protected byte getEdgeDirection(NodePort port)
Determines the preferred direction from which an edge should connect to the specified node port.

Parameters:
port - the NodePort for which the direction of connecting edges is determined.
Returns:
one of

restoreAll

public void restoreAll(Graph2D graph)
Performs all necessary resource cleanup and data translation after a layout calculation.

Parameters:
graph - the Graph2D instance that was previously prepared for automated layout calculation.
See Also:
prepareAll(Graph2D)

restoreEdgeGroups

protected void restoreEdgeGroups(Graph2D graph)
Restores saved edge group data.

Parameters:
graph - the Graph2D whose edges were grouped by node port.
See Also:
prepareEdgeGroups(Graph2D)

restorePortConstraints

protected void restorePortConstraints(Graph2D graph)
Restores saved port constraints data.

Parameters:
graph - the Graph2D whose node ports were translated into strong port constraints.
See Also:
preparePortConstraints(Graph2D)

restorePortPositions

protected void restorePortPositions(Graph2D graph)
Restores node port positions according to the corresponding edge connection points. If more than one edge is connected to a given node port and the connection points of these edges differ, one of the connections points is chosen as port position and common connection point for all edges.

The layout stage created by createPortConsistencyStage() can be used to ensure that the connection points of edges connecting to a common node port do not differ from each other.

Parameters:
graph - the Graph2D whose node port positions are adjusted.

createPortConsistencyStage

public LayoutStage createPortConsistencyStage()
Creates a layout stage that calculates edge connection points that are consistent with the supported node port locations of the node ports associated to the edges.

Note: The stage created by this method relies on information registered with the EDGE2D_DPKEY data provider key. Methods prepareAll(Graph2D) and restoreAll(Graph2D) will automatically registered said information.

Returns:
a new layout stage.

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