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

This class implements the default port assignment strategy. Ports are either placed at the center (PORT_ASSIGNMENT_MODE_CENTER) or get distributed (PORT_ASSIGNMENT_MODE_DISTRIBUTED) at the sides of the node.

If com.yworks.yfiles.layout.PortConstraint s are specified the strong PortConstraints are handled separately and keep their initial location relative to the node while weak PortConstraints just influence on which side the port is placed.

If there are edge groups specified the edges which belong to the same group get the same port locations.

See also

center
distributed
com.yworks.yfiles.layout.PortConstraint


Public Properties
 PropertyDefined By
  borderGapToPortGapRatio : Number
Specifies the ratio of the gap between the border of the node and the next port and the gap between the ports.
DefaultPortAssignment
  forkStyle : int
Specifies the fork style which influences the port assignment.
DefaultPortAssignment
  mode : int
Specifies the port assignment mode.
DefaultPortAssignment
Public Methods
 MethodDefined By
  
DefaultPortAssignment(init:Boolean = true)
Creates a new DefaultPortAssignment instance using mode PORT_ASSIGNMENT_MODE_CENTER.
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 PORT_ASSIGNMENT_MODE_CENTER.
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 (borderGapToPortGapRatio) and the gap between the ports themselves.
DefaultPortAssignment
Protected Methods
 MethodDefined By
  
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
  
Initializes this object.
DefaultPortAssignment
  
Initializes this object.
DefaultPortAssignment
  
initDefaultPortAssignment3(mode:int, ratio:Number):void
Initializes this object.
DefaultPortAssignment
Public Constants
 ConstantDefined By
  FORK_STYLE_AT_NODE : int = 1
[static] Constant that describes fork style on a node.
DefaultPortAssignment
  FORK_STYLE_OUTSIDE_NODE : int = 0
[static] Constant that describes a fork style outside a node.
DefaultPortAssignment
  PORT_ASSIGNMENT_MODE_CENTER : int = 0
[static] Mode constant describing the strategy where ports are reset to the center of their nodes unless their are strong com.yworks.yfiles.layout.PortConstraint s registered which will be kept.
DefaultPortAssignment
  PORT_ASSIGNMENT_MODE_DISTRIBUTED : int = 1
[static] Mode constant describing the strategy where the ports of incoming and outgoing edges are distributed evenly at the side of their nodes.
DefaultPortAssignment
Property Detail
borderGapToPortGapRatioproperty
borderGapToPortGapRatio:Number

Specifies 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
forkStyleproperty 
forkStyle:int

Specifies the fork style which influences the port assignment.

If the fork style is set to FORK_STYLE_OUTSIDE_NODE, edges without port constraints will be assigned in flow direction.

If the fork style is set to FORK_STYLE_AT_NODE the ports of edges in flow direction also get distributed to the sides unless they are without bends. Note that edges may overlap due to large minimum first/last segment lengths.


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

See also

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

Constructor Detail
DefaultPortAssignment()Constructor
public function DefaultPortAssignment(init:Boolean = true)

Creates a new DefaultPortAssignment instance using mode PORT_ASSIGNMENT_MODE_CENTER.

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
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
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 PORT_ASSIGNMENT_MODE_CENTER.

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 (borderGapToPortGapRatio) and the gap between the ports themselves.

Possible values for mode are:

Parameters

mode:int
 
ratio:Number

Returns
DefaultPortAssignment

See also

Constant Detail
FORK_STYLE_AT_NODEConstant
public static const FORK_STYLE_AT_NODE:int = 1

Constant that describes fork style on a node. Edges leave/enter the nodes south/north if they are straight (no bends) or east and west of the node.

FORK_STYLE_OUTSIDE_NODEConstant 
public static const FORK_STYLE_OUTSIDE_NODE:int = 0

Constant that describes a fork style outside a node. Edges leave/enter the nodes south/north and bend between their source and target.

PORT_ASSIGNMENT_MODE_CENTERConstant 
public static const PORT_ASSIGNMENT_MODE_CENTER:int = 0

Mode constant describing the strategy where ports are reset to the center of their nodes unless their are strong com.yworks.yfiles.layout.PortConstraint s registered which will be kept.

See also

PORT_ASSIGNMENT_MODE_DISTRIBUTEDConstant 
public static const PORT_ASSIGNMENT_MODE_DISTRIBUTED:int = 1

Mode constant describing the strategy where the ports of incoming and outgoing edges are distributed evenly at the side of their nodes.

The source ports of edges without com.yworks.yfiles.layout.PortConstraint s will be distributed at the sides of their source and target nodes. Edges with weak PortConstraints are distributed at the side of the nodes that is specified in the PortConstraint. Strong PortConstraints are excluded from the even distribution to keep their port locations.

Grouped edges will get the same port location.

See also