Packagecom.yworks.yfiles.layout
Classpublic class EdgeLabelOrientationSupport
InheritanceEdgeLabelOrientationSupport Inheritance YObject Inheritance Object

Helper for layouter with integrated edge labeling to support orientation and mirroring.

To calculate the position and orientation of edge labels, whose placements are defined with the com.yworks.yfiles.layout.PreferredPlacementDescriptor, the com.yworks.yfiles.layout.OrientationLayouter would need the direction of the associated edge. Since this direction is not available for the OrientationLayouter, because it is a wrapper, the calculation must be done in the core layouter itself with the help of the EdgeLabelOrientationSupport.

Important: Since all layouters with integrated edge labeling could not deal with ambiguous preferred placement descriptors (combinations of the same setting e.g. source or target for the com.yworks.yfiles.layout.PreferredPlacementDescriptor.placeAlongEdge), preProcessLabel() removes combinations and replaces the original descriptor with a "non-ambiguous" one during the layout calculation.

See also

com.yworks.yfiles.layout.PreferredPlacementDescriptor
com.yworks.yfiles.layout.OrientationLayouter
com.yworks.yfiles.layout.PreferredPlacementDescriptor.placeAlongEdge
preProcessLabel()


Public Methods
 MethodDefined By
  
EdgeLabelOrientationSupport(init:Boolean = true)
Creates an instance.
EdgeLabelOrientationSupport
 Inherited
equals(o:Object):Boolean
YObject
  
getClass():Class
[override]
EdgeLabelOrientationSupport
  
[static] Calculates the up vector of an edge label considering the preferred placement of the label as well as the direction of the edge segment the label is attached to.
EdgeLabelOrientationSupport
  
getLabelUpVector(rightVectorAngle:Number):YVector
[static] Calculates the up vector for a label whose right vector is rotated clockwise by the given rightVectorAngle.
EdgeLabelOrientationSupport
  
getOrientedDirection(direction:Direction, orientation:int, mirrorMask:int):Direction
[static] Transforms a direction of the layout to the oriented layout.
EdgeLabelOrientationSupport
 Inherited
hashCode():int
YObject
  
isOrientationMirrored(orientation:int, mirrorMask:int):Boolean
[static] Returns whether or not the orientation is mirrored.
EdgeLabelOrientationSupport
  
[static] Creates an instance.
EdgeLabelOrientationSupport
  
Called by the core layouter with the integrated edge labeling for each edge label after the location of the label is determined.
EdgeLabelOrientationSupport
  
preProcessLabel(graph:Graph, label:LabelLayoutData, segmentDirection:Direction):void
Called by the core layouter with the integrated edge labeling for each edge label before the layouter uses the labels geometry.
EdgeLabelOrientationSupport
  
Replaces the com.yworks.yfiles.layout.PreferredPlacementDescriptor s of all edge labels in the given graph with non-ambiguous descriptors.
EdgeLabelOrientationSupport
  
Restores the com.yworks.yfiles.layout.PreferredPlacementDescriptor s of all edge labels in the given graph with their original descriptors.
EdgeLabelOrientationSupport
  
updateLabelOrientation(label:LabelLayoutData, segmentDirection:Direction):void
[static] Calculates and sets the up vector of an edge label considering the preferred placement of the label as well as the direction of the edge segment the label is attached to.
EdgeLabelOrientationSupport
Protected Methods
 MethodDefined By
  
Initializes this object.
EdgeLabelOrientationSupport
Constructor Detail
EdgeLabelOrientationSupport()Constructor
public function EdgeLabelOrientationSupport(init:Boolean = true)

Creates an instance. Since this class handles the orientation of the edge labels, the core layouter should switch the calculation in its com.yworks.yfiles.layout.OrientationLayouter off.

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
getClass()method
override public function getClass():Class

Returns
Class
getEdgeLabelUpVector()method 
public static function getEdgeLabelUpVector(descriptor:PreferredPlacementDescriptor, segmentDirection:Direction):YVector

Calculates the up vector of an edge label considering the preferred placement of the label as well as the direction of the edge segment the label is attached to.

Parameters

descriptor:PreferredPlacementDescriptor — The data describing the preferred label orientation.
 
segmentDirection:Direction — The direction the edge segment is pointing to.

Returns
YVector — An up vector for the edge label that considers the preferred placement of the label as well as the direction of the edge segment the label is attached to.
getLabelUpVector()method 
public static function getLabelUpVector(rightVectorAngle:Number):YVector

Calculates the up vector for a label whose right vector is rotated clockwise by the given rightVectorAngle.

Parameters

rightVectorAngle:Number — The angle in radians the right vector is rotated by.

Returns
YVector — The up vector for a label whose right vector is rotated clockwise by the given angle.
getOrientedDirection()method 
public static function getOrientedDirection(direction:Direction, orientation:int, mirrorMask:int):Direction

Transforms a direction of the layout to the oriented layout.

Parameters

direction:Direction — direction in the layout
 
orientation:int
 
mirrorMask:int — @return the direction in the oriented layout

Returns
Direction
initEdgeLabelOrientationSupport()method 
protected final function initEdgeLabelOrientationSupport():void

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

See also

isOrientationMirrored()method 
public static function isOrientationMirrored(orientation:int, mirrorMask:int):Boolean

Returns whether or not the orientation is mirrored.

Parameters

orientation:int
 
mirrorMask:int

Returns
Booleantrue if the orientation is mirrored; false otherwise
newEdgeLabelOrientationSupport()method 
public static function newEdgeLabelOrientationSupport():EdgeLabelOrientationSupport

Creates an instance. Since this class handles the orientation of the edge labels, the core layouter should switch the calculation in its com.yworks.yfiles.layout.OrientationLayouter off.

Returns
EdgeLabelOrientationSupport

See also

postProcessLabel()method 
public function postProcessLabel(graph:Graph, label:LabelLayoutData):void

Called by the core layouter with the integrated edge labeling for each edge label after the location of the label is determined.

It restores the original com.yworks.yfiles.layout.LabelLayoutData.preferredPlacementDescriptor that has been replaced in preProcessLabel() . Then it move and rotates the label (com.yworks.yfiles.layout.LabelLayoutData.bounds) in respect of the orientation.

Parameters

graph:Graph — graph to get the orientation information from
 
label:LabelLayoutData — edge label whose location is determined

See also

preProcessLabel()method 
public function preProcessLabel(graph:Graph, label:LabelLayoutData, segmentDirection:Direction):void

Called by the core layouter with the integrated edge labeling for each edge label before the layouter uses the labels geometry. The method should be called as soon as the direction of the segment the label belongs to is determined.

First it replaces the com.yworks.yfiles.layout.LabelLayoutData.preferredPlacementDescriptor of the edge label by a PreferredPlacementDescriptor that has only relative references. This descriptor is orientation independent and could be used in the core layouter. Second it rotates the label (com.yworks.yfiles.layout.LabelLayoutData.bounds) in respect of it PreferredPlacementDescriptor and the direction of the segment it belongs to. After that call the core layouter could use the geometry ( com.yworks.yfiles.layout.LabelLayoutData.width and com.yworks.yfiles.layout.LabelLayoutData.width) of the label to calculate its location.

Parameters

graph:Graph — graph to get the orientation information from
 
label:LabelLayoutData — edge label whose segment direction is determined
 
segmentDirection:Direction — direction of the segment the edge label belongs to

See also

replaceAmbiguousLabelDescriptors()method 
public function replaceAmbiguousLabelDescriptors(graph:Graph):void

Replaces the com.yworks.yfiles.layout.PreferredPlacementDescriptor s of all edge labels in the given graph with non-ambiguous descriptors.

It should be called by a layouter at the beginning of layout calculation to assure that the label's placement is handled consistently.

Parameters

graph:Graph

See also

resetAmbiguousLabelDescriptors()method 
public function resetAmbiguousLabelDescriptors(graph:Graph):void

Restores the com.yworks.yfiles.layout.PreferredPlacementDescriptor s of all edge labels in the given graph with their original descriptors.

It should be called by a layouter at the end of layout calculation to assure that the original state of the graph is not corrupted.

Parameters

graph:Graph

See also

updateLabelOrientation()method 
public static function updateLabelOrientation(label:LabelLayoutData, segmentDirection:Direction):void

Calculates and sets the up vector of an edge label considering the preferred placement of the label as well as the direction of the edge segment the label is attached to.

Parameters

label:LabelLayoutData — The data that describes the label orientation and is used to set the new up vector.
 
segmentDirection:Direction — The direction the edge segment is pointing to.

See also