y.layout.tree
Class DefaultPortAssignment

java.lang.Object
  extended by y.layout.tree.DefaultPortAssignment
All Implemented Interfaces:
PortAssignment

public class DefaultPortAssignment
extends Object
implements PortAssignment

This class provides simple default port assignment strategies.

 
Your browser does not support SVG content.

Field Summary
static byte MODE_NONE
          Mode constant describing the strategy where all ports are reset to the center of their nodes.
static byte MODE_PORT_CONSTRAINTS
          Mode constant describing the strategy where edges having a weak port constraint, i.e., effectively a side constraint, will be anchored at the center of that side no port constraint set will be anchored at the center of the node Edges having a strong port constraint are anchored at that coordinates.
 
Constructor Summary
DefaultPortAssignment()
          Creates a new DefaultPortAssignment instance using mode MODE_NONE.
DefaultPortAssignment(byte mode)
          Creates a new DefaultPortAssignment instance using the given mode.
 
Method Summary
protected  void assignChildEdgeSourcePort(LayoutGraph graph, Node node, Edge edge, int index)
          This method assigns the source port of an edge that goes to a child node.
protected  void assignParentEdgeTargetPort(LayoutGraph graph, Node node, Edge edge)
          This method assigns the target port of the edge that goes to the parent node.
 void assignPorts(LayoutGraph graph, Node node)
          Called by GenericTreeLayouter before the actual layout of the graph takes place.
 byte getMode()
          Gets the current mode constant.
protected  PortConstraint getSourcePortConstraint(LayoutGraph graph, Edge edge, int index)
          Returns the PortConstraint for the given edge or null if no PortConstraint is set.
protected  PortConstraint getTargetPortConstraint(LayoutGraph graph, Edge edge)
          Returns the PortConstraint for the given edge or null if no PortConstraint is set.
 void setMode(byte mode)
          Sets the new mode constant.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_PORT_CONSTRAINTS

public static final byte MODE_PORT_CONSTRAINTS
Mode constant describing the strategy where edges having Edges having a strong port constraint are anchored at that coordinates.

See Also:
Constant Field Values

MODE_NONE

public static final byte MODE_NONE
Mode constant describing the strategy where all ports are reset to the center of their nodes.

See Also:
Constant Field Values
Constructor Detail

DefaultPortAssignment

public DefaultPortAssignment()
Creates a new DefaultPortAssignment instance using mode MODE_NONE.


DefaultPortAssignment

public DefaultPortAssignment(byte mode)
Creates a new DefaultPortAssignment instance using the given mode. Possible values for mode are MODE_NONE and MODE_PORT_CONSTRAINTS.

Method Detail

assignPorts

public void assignPorts(LayoutGraph graph,
                        Node node)
Description copied from interface: PortAssignment
Called by GenericTreeLayouter before the actual layout of the graph takes place. This method assigns both the single incoming edge's target port as well as all source ports for all outgoing child edges. Note that at the time this method gets invoked, GenericTreeLayouter may have reversed some edges in order to normalize the tree structure.

Specified by:
assignPorts in interface PortAssignment
Parameters:
graph - the graph instance the node is part of
node - the node whose adjacent edges' ports should be set

assignParentEdgeTargetPort

protected void assignParentEdgeTargetPort(LayoutGraph graph,
                                          Node node,
                                          Edge edge)
This method assigns the target port of the edge that goes to the parent node.

Parameters:
graph - the graph which contains the node
node - the node
edge - the edge to the parent node

assignChildEdgeSourcePort

protected void assignChildEdgeSourcePort(LayoutGraph graph,
                                         Node node,
                                         Edge edge,
                                         int index)
This method assigns the source port of an edge that goes to a child node.

Parameters:
graph - the graph which contains the node
node - the parent node
edge - the edge to the child node
index - the zero-based index of the child edge

getSourcePortConstraint

protected PortConstraint getSourcePortConstraint(LayoutGraph graph,
                                                 Edge edge,
                                                 int index)
Returns the PortConstraint for the given edge or null if no PortConstraint is set. This implementation uses the PortConstraint data provider that is bound to the graph, if available.

Parameters:
graph - the graph the edge is part of
edge - the edge whose PortConstraint is to be determined
index - the child's index
Returns:
a PortConstraint or null

getTargetPortConstraint

protected PortConstraint getTargetPortConstraint(LayoutGraph graph,
                                                 Edge edge)
Returns the PortConstraint for the given edge or null if no PortConstraint is set. This implementation uses the PortConstraint data provider that is bound to the graph, if available.

Parameters:
graph - the graph the edge is part of
edge - the edge whose PortConstraint is to be determined
Returns:
a PortConstraint or null

getMode

public byte getMode()
Gets the current mode constant. Possible values are MODE_NONE and MODE_PORT_CONSTRAINTS.

Returns:
the mode constant

setMode

public void setMode(byte mode)
Sets the new mode constant. Possible values are MODE_NONE and MODE_PORT_CONSTRAINTS.

Parameters:
mode - the new mode

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