Packagecom.yworks.yfiles.layout
Classpublic class PortCalculator
InheritancePortCalculator Inheritance AbstractLayoutStage Inheritance YObject Inheritance Object
Implements LayoutStage

This class implements a LayoutStage that can be used to adjust the final port assignments after a layout has been calculated. This can be useful if the port assignment calculated by the layout algorithm is insufficient. This stage uses com.yworks.yfiles.base.DataProvider instances bound to the graph using the keys defined in the com.yworks.yfiles.layout.IntersectionCalculator interface to calculate the new port offsets. For each edge in the LayoutGraph instance the DataProviders are queried for an implementation of the com.yworks.yfiles.layout.IntersectionCalculator interface. If the result is non-null, that implementation will be queried and if the result of the query is non-null, the returned point will be applied to the edge layout.

For this layout stage to work use com.yworks.yfiles.layout.CompositeLayoutStage.prependStage() or com.yworks.yfiles.layout.CanonicMultiStageLayouter.prependStage() to add this layout stage and register appropriate com.yworks.yfiles.base.DataProvider implementations to the graph using the keys defined in com.yworks.yfiles.layout.IntersectionCalculator.

Note, that this class will not change the coordinates of a port if it is associated with a strong port constraint.

See also

com.yworks.yfiles.layout.IntersectionCalculator
com.yworks.yfiles.layout.IntersectionCalculatorKeys.SOURCE_INTERSECTION_CALCULATOR_DPKEY
com.yworks.yfiles.layout.IntersectionCalculatorKeys.TARGET_INTERSECTION_CALCULATOR_DPKEY
com.yworks.yfiles.layout.PortConstraint
com.yworks.yfiles.base.DataProvider
com.yworks.yfiles.layout.CompositeLayoutStage.prependStage()
com.yworks.yfiles.layout.CanonicMultiStageLayouter.prependStage()


Public Properties
 PropertyDefined By
 InheritedcoreLayouter : Layouter
Specifies the core layouter.
AbstractLayoutStage
Protected Properties
 PropertyDefined By
  EPS : Number
EPSILON used by equalsEps().
PortCalculator
Public Methods
 MethodDefined By
  
PortCalculator(init:Boolean = true)
Creates a new PortCalculator without a core layouter.
PortCalculator
  
canLayout(graph:LayoutGraph):Boolean
[override]
PortCalculator
  
doLayout(graph:LayoutGraph):void
[override]
PortCalculator
 Inherited
equals(o:Object):Boolean
YObject
  
getClass():Class
[override]
PortCalculator
 Inherited
hashCode():int
YObject
  
[static] Creates a new PortCalculator without a core layouter.
PortCalculator
  
[static] Creates a new PortCalculator using the given layouter as the core of this layout stage.
PortCalculator
Protected Methods
 MethodDefined By
  
Performs the actual port calculation on the specified graph instance.
PortCalculator
 Inherited
canLayoutCore(graph:LayoutGraph):Boolean
Queries the core layouter whether or not the given graph can be laid out.
AbstractLayoutStage
 Inherited
Invokes the layout routine of the core layouter.
AbstractLayoutStage
  
equalsEps(x1:Number, y1:Number, x2:Number, y2:Number):Boolean
Callback method that determines whether two points are equal.
PortCalculator
 Inherited
AbstractLayoutStage
 Inherited
AbstractLayoutStage
  
Initializes this object.
PortCalculator
  
Initializes this object.
PortCalculator
Property Detail
EPSproperty
protected var EPS:Number

EPSILON used by equalsEps(). By default this is 0.2d.

See also

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

Creates a new PortCalculator without a core layouter.

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.
Method Detail
calculatePorts()method
protected function calculatePorts(graph:LayoutGraph):void

Performs the actual port calculation on the specified graph instance.

Parameters

graph:LayoutGraph

canLayout()method 
override public function canLayout(graph:LayoutGraph):Boolean

Parameters

graph:LayoutGraph

Returns
Boolean
doLayout()method 
override public function doLayout(graph:LayoutGraph):void

Parameters

graph:LayoutGraph

equalsEps()method 
protected function equalsEps(x1:Number, y1:Number, x2:Number, y2:Number):Boolean

Callback method that determines whether two points are equal.

Parameters

x1:Number
 
y1:Number
 
x2:Number
 
y2:Number

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

Returns
Class
initPortCalculator1()method 
protected final function initPortCalculator1():void

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

See also

initPortCalculator2()method 
protected final function initPortCalculator2(core:Layouter):void

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

Parameters

core:Layouter

See also

newPortCalculator1()method 
public static function newPortCalculator1():PortCalculator

Creates a new PortCalculator without a core layouter.

Returns
PortCalculator
newPortCalculator2()method 
public static function newPortCalculator2(core:Layouter):PortCalculator

Creates a new PortCalculator using the given layouter as the core of this layout stage.

Parameters

core:Layouter

Returns
PortCalculator