Packagecom.yworks.yfiles.layout.tree
Classpublic class DefaultPortAssignment
InheritanceDefaultPortAssignment Inheritance YObject Inheritance Object
Implements PortAssignment

This class provides simple default port assignment strategies.



Public Properties
 PropertyDefined By
  borderGapToPortGapRatio : Number
Getter: Returns the ratio of the gap between the border of the node and the next port and the gap between the ports.
DefaultPortAssignment
  mode : int
Specifies the port assignment mode.
DefaultPortAssignment
  reversedPortOrder : Boolean
Getter: Indicates if the port assignment is set to reversed order.
DefaultPortAssignment
Public Methods
 MethodDefined By
  
DefaultPortAssignment(init:Boolean = true)
Creates a new DefaultPortAssignment instance using mode MODE_NONE.
DefaultPortAssignment
  
assignPorts(graph:LayoutGraph, node:Node):void
DefaultPortAssignment
 Inherited
equals(o:Object):Boolean
YObject
  
getClass():Class
[override]
DefaultPortAssignment
 Inherited
hashCode():int
YObject
  
[static] Creates a new DefaultPortAssignment instance using mode MODE_NONE.
DefaultPortAssignment
  
[static] Creates a new DefaultPortAssignment instance using the given mode and the default value for the ratio of the gap between the border and the ports and the gap between the ports themselves.
DefaultPortAssignment
  
[static] Creates a new DefaultPortAssignment instance using the given mode and a given value for the ratio of the gap between the border and the ports and the gap between the ports themselves.
DefaultPortAssignment
Protected Methods
 MethodDefined By
  
assignChildEdgeSourcePort(graph:LayoutGraph, node:Node, edge:Edge, index:int):void
This method assigns the source port of an edge that goes to a child node.
DefaultPortAssignment
  
This method assigns the target port of the edge that goes to the parent node.
DefaultPortAssignment
  
getPortBorderGap(sideLength:Number, edgeCount:int):Number
Callback method used to determine the port border gap for each node and side.
DefaultPortAssignment
  
getPortDistanceDelta(sideLength:Number, edgeCount:int, portBorderGap:Number):Number
Callback method used to determine the distance between two adjacent ports
DefaultPortAssignment
  
Returns the PortConstraint for the given edge or null if no PortConstraint is set.
DefaultPortAssignment
  
Returns the PortConstraint for the given edge or null if no PortConstraint is set.
DefaultPortAssignment
  
Initializes this object.
DefaultPortAssignment
  
Initializes this object.
DefaultPortAssignment
  
initDefaultPortAssignment3(mode:int, ratio:Number):void
Initializes this object.
DefaultPortAssignment
Public Constants
 ConstantDefined By
  MODE_NONE : int = 0
[static] Mode constant describing the strategy where all ports are reset to the center of their nodes.
DefaultPortAssignment
  MODE_PORT_CONSTRAINTS : int = 1
[static] 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.
DefaultPortAssignment
  MODE_PORT_DISTRIBUTED_EAST : int = 4
[static] Mode constant describing the strategy where edges are distributed evenly at the eastern side of their nodes.
DefaultPortAssignment
  MODE_PORT_DISTRIBUTED_NORTH : int = 2
[static] Mode constant describing the strategy where edges are distributed evenly at the northern side of their nodes.
DefaultPortAssignment
  MODE_PORT_DISTRIBUTED_SOUTH : int = 3
[static] Mode constant describing the strategy where edges are distributed evenly at the southern side of their nodes.
DefaultPortAssignment
  MODE_PORT_DISTRIBUTED_WEST : int = 5
[static] Mode constant describing the strategy where edges are distributed evenly at the western side of their nodes.
DefaultPortAssignment
Property Detail
borderGapToPortGapRatioproperty
borderGapToPortGapRatio:Number

Getter: Returns the ratio of the gap between the border of the node and the next port and the gap between the ports. For example, the default value, 0.5, indicates that the border gap is as wide as half the gap between the ports.

Setter: Sets the ratio of the gap between the border of the node and the next port and the gap between the ports. For example, 0.5 sets the border gap as wide as half the gap between the ports. Thus, the lower the value is, the wider "spread" the ports at the side of the node. Note: This setting is only useful for distributed port assignment.


Implementation
    public function get borderGapToPortGapRatio():Number
    public function set borderGapToPortGapRatio(value:Number):void
modeproperty 
mode:int

Specifies the port assignment mode. Possible values are


Implementation
    public function get mode():int
    public function set mode(value:int):void

See also

reversedPortOrderproperty 
reversedPortOrder:Boolean

Getter: Indicates if the port assignment is set to reversed order. The default order is from left to right and from top to bottom. Thus, the default value is false.

Setter: Sets if the port assignment should use a reversed order. If set to true, the order is from right to left and from bottom to top. Note: This setting is only useful for distributed port assignment.


Implementation
    public function get reversedPortOrder():Boolean
    public function set reversedPortOrder(value:Boolean):void
Constructor Detail
DefaultPortAssignment()Constructor
public function DefaultPortAssignment(init:Boolean = true)

Creates a new DefaultPortAssignment instance using mode MODE_NONE.

Parameters
init:Boolean (default = true) — An internally used switch to help handle proper instance initialization in inheritance chains where classes can have multiple constructor-like factory methods. This parameter can safely be ignored/omitted when calling the constructor.

See also

Method Detail
assignChildEdgeSourcePort()method
protected function assignChildEdgeSourcePort(graph:LayoutGraph, node:Node, edge:Edge, index:int):void

This method assigns the source port of an edge that goes to a child node.

Parameters

graph:LayoutGraph — the graph which contains the node
 
node:Node — the parent node
 
edge:Edge — the edge to the child node
 
index:int — the zero-based index of the child edge

assignParentEdgeTargetPort()method 
protected function assignParentEdgeTargetPort(graph:LayoutGraph, node:Node, edge:Edge):void

This method assigns the target port of the edge that goes to the parent node.

Parameters

graph:LayoutGraph — the graph which contains the node
 
node:Node — the node
 
edge:Edge — the edge to the parent node

assignPorts()method 
public function assignPorts(graph:LayoutGraph, node:Node):void

Parameters

graph:LayoutGraph
 
node:Node

getClass()method 
override public function getClass():Class

Returns
Class
getPortBorderGap()method 
protected function getPortBorderGap(sideLength:Number, edgeCount:int):Number

Callback method used to determine the port border gap for each node and side.

Parameters

sideLength:Number — the width/height of the side
 
edgeCount:int — the number of edges/port that connect to this side

Returns
Number — the absolute gap to be used on both sides of the ports
getPortDistanceDelta()method 
protected function getPortDistanceDelta(sideLength:Number, edgeCount:int, portBorderGap:Number):Number

Callback method used to determine the distance between two adjacent ports

Parameters

sideLength:Number — the width/height of the side
 
edgeCount:int — the number of edges/port that connect to this side
 
portBorderGap:Number — the previously calculated port border gap

Returns
Number — the absolute distance to be used between two adjacent ports
getSourcePortConstraint()method 
protected function getSourcePortConstraint(graph:LayoutGraph, edge:Edge, index:int):PortConstraint

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:LayoutGraph — the graph the edge is part of
 
edge:Edge — the edge whose PortConstraint is to be determined
 
index:int — the child's index

Returns
PortConstraint — a PortConstraint or null
getTargetPortConstraint()method 
protected function getTargetPortConstraint(graph:LayoutGraph, edge:Edge):PortConstraint

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:LayoutGraph — the graph the edge is part of
 
edge:Edge — the edge whose PortConstraint is to be determined

Returns
PortConstraint — a PortConstraint or null
initDefaultPortAssignment1()method 
protected final function initDefaultPortAssignment1():void

Initializes this object. See the documentation of the corresponding factory method newDefaultPortAssignment1() for details.

See also

initDefaultPortAssignment2()method 
protected final function initDefaultPortAssignment2(mode:int):void

Initializes this object. See the documentation of the corresponding factory method newDefaultPortAssignment2() for details.

Parameters

mode:int

See also

initDefaultPortAssignment3()method 
protected final function initDefaultPortAssignment3(mode:int, ratio:Number):void

Initializes this object. See the documentation of the corresponding factory method newDefaultPortAssignment3() for details.

Parameters

mode:int
 
ratio:Number

See also

newDefaultPortAssignment1()method 
public static function newDefaultPortAssignment1():DefaultPortAssignment

Creates a new DefaultPortAssignment instance using mode MODE_NONE.

Returns
DefaultPortAssignment

See also

newDefaultPortAssignment2()method 
public static function newDefaultPortAssignment2(mode:int):DefaultPortAssignment

Creates a new DefaultPortAssignment instance using the given mode and the default value for the ratio of the gap between the border and the ports and the gap between the ports themselves. The default value is 0.5. Possible values for mode are:

Parameters

mode:int

Returns
DefaultPortAssignment

See also

newDefaultPortAssignment3()method 
public static function newDefaultPortAssignment3(mode:int, ratio:Number):DefaultPortAssignment

Creates a new DefaultPortAssignment instance using the given mode and a given value for the ratio of the gap between the border and the ports and the gap between the ports themselves. Possible values for mode are:

Parameters

mode:int
 
ratio:Number

Returns
DefaultPortAssignment

See also

Constant Detail
MODE_NONEConstant
public static const MODE_NONE:int = 0

Mode constant describing the strategy where all ports are reset to the center of their nodes.

MODE_PORT_CONSTRAINTSConstant 
public static const MODE_PORT_CONSTRAINTS:int = 1

Mode constant describing the strategy where edges having

Edges having a strong port constraint are anchored at that coordinates.

If edges with port constraints are grouped, all edges in the same group will use the port coordinates of the first edge in the group.

See also

MODE_PORT_DISTRIBUTED_EASTConstant 
public static const MODE_PORT_DISTRIBUTED_EAST:int = 4

Mode constant describing the strategy where edges are distributed evenly at the eastern side of their nodes.

Grouped edges will use the same port coordinate and will be considered as a single edge when calculating the distribution.

See also

MODE_PORT_DISTRIBUTED_NORTHConstant 
public static const MODE_PORT_DISTRIBUTED_NORTH:int = 2

Mode constant describing the strategy where edges are distributed evenly at the northern side of their nodes.

Grouped edges will use the same port coordinate and will be considered as a single edge when calculating the distribution.

See also

MODE_PORT_DISTRIBUTED_SOUTHConstant 
public static const MODE_PORT_DISTRIBUTED_SOUTH:int = 3

Mode constant describing the strategy where edges are distributed evenly at the southern side of their nodes.

Grouped edges will use the same port coordinate and will be considered as a single edge when calculating the distribution.

See also

MODE_PORT_DISTRIBUTED_WESTConstant 
public static const MODE_PORT_DISTRIBUTED_WEST:int = 5

Mode constant describing the strategy where edges are distributed evenly at the western side of their nodes.

Grouped edges will use the same port coordinate and will be considered as a single edge when calculating the distribution.

See also