Packagecom.yworks.yfiles.layout.labeling
Classpublic class AbstractLabelingAlgorithm
InheritanceAbstractLabelingAlgorithm Inheritance AbstractLayoutStage Inheritance YObject Inheritance Object
Subclasses MISLabelingAlgorithm

This class is an abstract base class for labeling algorithms. A labeling algorithm places a set of labels.



Public Properties
 PropertyDefined By
  applyPostprocessing : Boolean
Getter: Returns true if the postprocessing step is applied.
AbstractLabelingAlgorithm
  autoFlippingEnabled : Boolean
Determines whether or not edge labels associated with a "free" label model (see for example y.view.SmartEdgeLabelModel) should be automatically flipped if they would be upside-down.
AbstractLabelingAlgorithm
 InheritedcoreLayouter : Layouter
Specifies the core layouter.
AbstractLayoutStage
  edgeGroupOverlapAllowed : Boolean
Getter: Returns whether edge labels may overlap with edges belonging to the same edge group.
AbstractLabelingAlgorithm
  moveInternalNodeLabels : Boolean
Specifies true if the labeling algorithm is allowed to move internal node labels.
AbstractLabelingAlgorithm
  placeEdgeLabels : Boolean
Specifies whether labels assigned to edges in a graph should be placed or ignored.
AbstractLabelingAlgorithm
  placeNodeLabels : Boolean
Specifies whether labels assigned to nodes in a graph should be placed or ignored.
AbstractLabelingAlgorithm
  profitModel : ProfitModel
Sets the profit model that is used to rank the available positions for each label.
AbstractLabelingAlgorithm
  rects : YList
[read-only] Returns the set of all generated candidate rectangles.
AbstractLabelingAlgorithm
  removeEdgeOverlaps : Boolean
Specifies how label candidates which overlap with edges are handled.
AbstractLabelingAlgorithm
  removeNodeOverlaps : Boolean
Specifies how label candidates which overlap with nodes are handled.
AbstractLabelingAlgorithm
  selectedLabelsDpKey : Object
Getter: Returns the labeling selection DataProvider key.
AbstractLabelingAlgorithm
  storeRects : Boolean
Specifies whether the candidate rectangles should be stored to be retrieved.
AbstractLabelingAlgorithm
  useAlternativeSideHandling : Boolean
Getter: Returns true if the preference on which side of an edge a corresponding label should be placed is interpreted by human perception instead of always following the edge from source to target.
AbstractLabelingAlgorithm
Public Methods
 MethodDefined By
  
AbstractLabelingAlgorithm(init:Boolean = true)
Creates a new instance of this class.
AbstractLabelingAlgorithm
  
canLayout(graph:LayoutGraph):Boolean
[override] Returns true.
AbstractLabelingAlgorithm
  
doLayout(graph:LayoutGraph):void
[override] Place the labels in the graph.
AbstractLabelingAlgorithm
 Inherited
equals(o:Object):Boolean
YObject
  
getClass():Class
[override]
AbstractLabelingAlgorithm
  
Returns the profit model that is used to rank the available positions for each label.
AbstractLabelingAlgorithm
 Inherited
hashCode():int
YObject
  
Place the labels in the graph.
AbstractLabelingAlgorithm
  
labelSome(gl:LayoutGraph, key:Object):void
Place a subset of the labels.
AbstractLabelingAlgorithm
  
labelSome2(gl:LayoutGraph, nodeLabels:YList, edgeLabels:YList):void
Place some labels in the graph.
AbstractLabelingAlgorithm
Protected Methods
 MethodDefined By
 Inherited
canLayoutCore(graph:LayoutGraph):Boolean
Queries the core layouter whether or not the given graph can be laid out.
AbstractLayoutStage
  
checkGroupNodeSize(layout:GraphLayout, node:Object):void
This method throws an com.yworks.bridge.util.IllegalArgumentException if the width/height of the given group node object is zero.
AbstractLabelingAlgorithm
  
checkNodeSize(layout:GraphLayout, node:Object):void
This method throws an com.yworks.bridge.util.IllegalArgumentException if the width/height of the given node object is zero.
AbstractLabelingAlgorithm
 Inherited
Invokes the layout routine of the core layouter.
AbstractLayoutStage
  
AbstractLabelingAlgorithm
 Inherited
AbstractLayoutStage
 Inherited
AbstractLayoutStage
Public Constants
 ConstantDefined By
  LABEL_MODEL_DPKEY : Object = y.layout.labeling.AbstractLabelingAlgorithm.LABEL_MODEL_DPKEY
[static] com.yworks.yfiles.base.DataProvider key to specify for each com.yworks.yfiles.layout.EdgeLabelLayout s and each com.yworks.yfiles.layout.NodeLabelLayout a replacement com.yworks.yfiles.layout.EdgeLabelModel or com.yworks.yfiles.layout.NodeLabelModel, respectively, that is used by the labeling algorithm instead of the original label model.
AbstractLabelingAlgorithm
Property Detail
applyPostprocessingproperty
applyPostprocessing:Boolean

Getter: Returns true if the postprocessing step is applied. The postprocessing step tries to further reduce the number of overlaps.

Setter: Sets if the postprocessing step should be applied. The postprocessing step tries to further reduce the number of overlaps.

Note: the postprocessing step is only applied to edge labels whose edge label model is FreeEdgeLabelModel and node labels whose node label model is FreeNodeLabelModel.


Implementation
    public function get applyPostprocessing():Boolean
    public function set applyPostprocessing(value:Boolean):void
autoFlippingEnabledproperty 
autoFlippingEnabled:Boolean

Determines whether or not edge labels associated with a "free" label model (see for example y.view.SmartEdgeLabelModel) should be automatically flipped if they would be upside-down.

By default, this property is set to false.


Implementation
    public function get autoFlippingEnabled():Boolean
    public function set autoFlippingEnabled(value:Boolean):void
edgeGroupOverlapAllowedproperty 
edgeGroupOverlapAllowed:Boolean

Getter: Returns whether edge labels may overlap with edges belonging to the same edge group.

Setter: Sets the policy for edge groups. If edge labels overlap with other edges of the same group, this flag decides whether these positions are allowed.


Implementation
    public function get edgeGroupOverlapAllowed():Boolean
    public function set edgeGroupOverlapAllowed(value:Boolean):void
moveInternalNodeLabelsproperty 
moveInternalNodeLabels:Boolean

Specifies true if the labeling algorithm is allowed to move internal node labels. A node label is deemed internal if the label's bounds are completely within the node bounds.


Implementation
    public function get moveInternalNodeLabels():Boolean
    public function set moveInternalNodeLabels(value:Boolean):void
placeEdgeLabelsproperty 
placeEdgeLabels:Boolean

Specifies whether labels assigned to edges in a graph should be placed or ignored. This method has higher priority than a specified selection, that means that all selected edge labels are ignored by this algorithm if this property is set to false.


Implementation
    public function get placeEdgeLabels():Boolean
    public function set placeEdgeLabels(value:Boolean):void

See also

placeNodeLabelsproperty 
placeNodeLabels:Boolean

Specifies whether labels assigned to nodes in a graph should be placed or ignored. This method has higher priority than a specified selection, that means that all selected node labels are ignored by this algorithm if this property is set to false.


Implementation
    public function get placeNodeLabels():Boolean
    public function set placeNodeLabels(value:Boolean):void

See also

profitModelproperty 
profitModel:ProfitModel

Sets the profit model that is used to rank the available positions for each label. The higher the rank of a position, the more likely it will be chosen by the algorithm. By default an instance of type com.yworks.yfiles.layout.LabelRanking is set.


Implementation
    public function get profitModel():ProfitModel
    public function set profitModel(value:ProfitModel):void

See also

rectsproperty 
rects:YList  [read-only]

Returns the set of all generated candidate rectangles.

Debug only.


Implementation
    public function get rects():YList
removeEdgeOverlapsproperty 
removeEdgeOverlaps:Boolean

Specifies how label candidates which overlap with edges are handled. If true these candidates are not considered, if false these candidates are considered, but a penalty is assigned to them.


Implementation
    public function get removeEdgeOverlaps():Boolean
    public function set removeEdgeOverlaps(value:Boolean):void
removeNodeOverlapsproperty 
removeNodeOverlaps:Boolean

Specifies how label candidates which overlap with nodes are handled. If true these candidates are not considered, if false these candidates are considered, but a penalty is assigned to them.


Implementation
    public function get removeNodeOverlaps():Boolean
    public function set removeNodeOverlaps(value:Boolean):void
selectedLabelsDpKeyproperty 
selectedLabelsDpKey:Object

Getter: Returns the labeling selection DataProvider key.

Setter: Sets the DataProvider key, under which the labeling selection can be retrieved. The data provider registered with this key has to return true for labels that should be placed and false for all other labels.


Implementation
    public function get selectedLabelsDpKey():Object
    public function set selectedLabelsDpKey(value:Object):void
storeRectsproperty 
storeRects:Boolean

Specifies whether the candidate rectangles should be stored to be retrieved.

Debug only.


Implementation
    public function get storeRects():Boolean
    public function set storeRects(value:Boolean):void
useAlternativeSideHandlingproperty 
useAlternativeSideHandling:Boolean

Getter: Returns true if the preference on which side of an edge a corresponding label should be placed is interpreted by human perception instead of always following the edge from source to target.

Setter: Specifies whether the preference on which side of an edge a corresponding label should be placed is interpreted by human perception instead of always following the edge from source to target.

Note: the alternative side handling is only applied to edge labels whose edge label model is FreeEdgeLabelModel.


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

Creates a new instance of this class.

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
canLayout()method
override public function canLayout(graph:LayoutGraph):Boolean

Returns true.

Parameters

graph:LayoutGraph

Returns
Boolean
checkGroupNodeSize()method 
protected function checkGroupNodeSize(layout:GraphLayout, node:Object):void

This method throws an com.yworks.bridge.util.IllegalArgumentException if the width/height of the given group node object is zero. It is called by the label-methods for each group node object in the input graph.

Parameters

layout:GraphLayout — a graph layout object.
 
node:Object — the group node object to test.


Throws
IllegalArgumentException — thrown if the width/height of the group node object is zero.

See also

checkNodeSize()method 
protected function checkNodeSize(layout:GraphLayout, node:Object):void

This method throws an com.yworks.bridge.util.IllegalArgumentException if the width/height of the given node object is zero. It is called by the label-methods for each node object in the input graph.

Parameters

layout:GraphLayout — a graph layout object.
 
node:Object — the node object to test.


Throws
IllegalArgumentException — thrown if the width/height of the node object is zero.

See also

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

Place the labels in the graph. This method is equivalent to the label() method.

Parameters

graph:LayoutGraph — The graph to label.

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

Returns
Class
getProfit()method 
public function getProfit(l:LabelCandidate):Number

Returns the profit model that is used to rank the available positions for each label. The higher the rank of a position, the more likely it will be chosen by the algorithm. By default an instance of type com.yworks.yfiles.layout.LabelRanking is set.

Parameters

l:LabelCandidate

Returns
Number

See also

initAbstractLabelingAlgorithm()method 
protected final function initAbstractLabelingAlgorithm():void

label()method 
public function label(gl:LayoutGraph):void

Place the labels in the graph.

Parameters

gl:LayoutGraph — The graph to label.

labelSome()method 
public function labelSome(gl:LayoutGraph, key:Object):void

Place a subset of the labels.

Parameters

gl:LayoutGraph
 
key:Object — The key for a DataProvider in gl. Labels which should be placed return true.

labelSome2()method 
public function labelSome2(gl:LayoutGraph, nodeLabels:YList, edgeLabels:YList):void

Place some labels in the graph. The selection is ignored, if set.

Parameters

gl:LayoutGraph
 
nodeLabels:YList
 
edgeLabels:YList

Constant Detail
LABEL_MODEL_DPKEYConstant
public static const LABEL_MODEL_DPKEY:Object = y.layout.labeling.AbstractLabelingAlgorithm.LABEL_MODEL_DPKEY

com.yworks.yfiles.base.DataProvider key to specify for each com.yworks.yfiles.layout.EdgeLabelLayout s and each com.yworks.yfiles.layout.NodeLabelLayout a replacement com.yworks.yfiles.layout.EdgeLabelModel or com.yworks.yfiles.layout.NodeLabelModel, respectively, that is used by the labeling algorithm instead of the original label model. If this key is not defined or if a label has no mapping, the original model is used as normal. Otherwise, a model parameter that fits the calculated position of the replacement model best is set for the original model.

This feature is especially useful to restrict a free model. For example, to place a label upon its associated edge, a centered com.yworks.yfiles.layout.RotatedSliderEdgeLabelLayoutModel can be used a replacement model.

See also