Packagecom.yworks.yfiles.layout.hierarchic
Classpublic class ConstraintLayerer
InheritanceConstraintLayerer Inheritance YObject Inheritance Object
Implements OldLayerer, Layerer

Layerer implementation that uses relative and absolute layering constraints.

This layerer can use two sets of constraints:

Constraints for a given graph can be created with means of a com.yworks.yfiles.layout.hierarchic.ConstraintLayerer_ConstraintFactory instance, which should be created with createConstraintFactory() for a given graph instance.

See also

com.yworks.yfiles.layout.hierarchic.ConstraintLayerer_ConstraintFactory
createConstraintFactory()


Public Properties
 PropertyDefined By
  allowSameLayerEdges : Boolean
Specifies whether same layer edges can be created by this layerer instance.
ConstraintLayerer
  coreLayerer : OldLayerer
Specifies the core layerer for this layerer instance.
ConstraintLayerer
Public Methods
 MethodDefined By
  
ConstraintLayerer(init:Boolean = true)
ConstraintLayerer
  
ConstraintLayerer
  
assignNodeLayer(g:LayoutGraph, layer:NodeMap, reversedEdges:EdgeList):int
This method assigns the nodes in the graph to layers.
ConstraintLayerer
  
[static] Create an instance of com.yworks.yfiles.layout.hierarchic.ConstraintLayerer_ConstraintFactory that is suitable for this layerer implementation.
ConstraintLayerer
 Inherited
equals(o:Object):Boolean
YObject
  
getClass():Class
[override]
ConstraintLayerer
 Inherited
hashCode():int
YObject
  
[static]
ConstraintLayerer
  
[static]
ConstraintLayerer
Protected Methods
 MethodDefined By
  
Checks if the current set of strong constraints is consistent (i.e.
ConstraintLayerer
  
Initializes this object.
ConstraintLayerer
  
Initializes this object.
ConstraintLayerer
Public Constants
 ConstantDefined By
  EDGE_WEIGHTS_DPKEY : String = y.layout.hierarchic.ConstraintLayerer.EDGE_WEIGHTS_DPKEY
[static] DataProvider key for additional edge weights of type int.
ConstraintLayerer
Property Detail
allowSameLayerEdgesproperty
allowSameLayerEdges:Boolean

Specifies whether same layer edges can be created by this layerer instance.

This only concerns edges between nodes that have no hard constraints that will force a same layer edge (i.e. a same layer constraint).

Default value is false.


Implementation
    public function get allowSameLayerEdges():Boolean
    public function set allowSameLayerEdges(value:Boolean):void
coreLayererproperty 
coreLayerer:OldLayerer

Specifies the core layerer for this layerer instance.

The ConstraintLayerer tries to create a layering for the nodes and edges that have no constraints that resembles the layering that would be created by the coreLayerer. This works the better the less constraints exist. Ideally, the constrained nodes are just embedded into the layering created by the coreLayerer. By default, an instance of com.yworks.yfiles.layout.hierarchic.TopologicalLayerer is used.


Implementation
    public function get coreLayerer():OldLayerer
    public function set coreLayerer(value:OldLayerer):void

See also

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

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
assignLayers()method
public function assignLayers(graph:LayoutGraph, layers:Layers, ldp:LayoutDataProvider):void

Parameters

graph:LayoutGraph
 
layers:Layers
 
ldp:LayoutDataProvider

assignNodeLayer()method 
public function assignNodeLayer(g:LayoutGraph, layer:NodeMap, reversedEdges:EdgeList):int

This method assigns the nodes in the graph to layers.

Parameters

g:LayoutGraph — the graph for which the layers are determined.
 
layer:NodeMap — here the layers are stored
 
reversedEdges:EdgeList — here the edges are stored which had been reversed.

Returns
int — the number of layers

Throws
IllegalArgumentException — if any strong constraints are inconsistent
checkConstraints()method 
protected function checkConstraints():void

Checks if the current set of strong constraints is consistent (i.e. has no cycles)


Throws
IllegalArgumentException — if the constraint network is inconsistent
createConstraintFactory()method 
public static function createConstraintFactory(g:Graph):ConstraintLayerer_ConstraintFactory

Create an instance of com.yworks.yfiles.layout.hierarchic.ConstraintLayerer_ConstraintFactory that is suitable for this layerer implementation. The ConstraintFactory instance is usually bound to the graph instance g, i.e. if the input graph for the layerer changes, a new ConstraintFactory instance must be retrieved. This instance can be used to create constraints for this graph instance.

You can create a ConstraintFactory without binding it to a graph instance initially by passing a null parameter. In that case, you must bind the returned instance to the graph instance before calculating a layering:

 ConstraintFactory cf = ConstraintLayerer.createConstraintFactory(null);... Graph g = ...; g.addDataProvider(ConstraintFactory.LAYER_CONSTRAINTS_MEMENTO_DPKEY, DataProviders.createConstantDataProvider(cf.getMemento()));); //Calculate layout 

If you manually registered a DataProvider under com.yworks.yfiles.layout.LayouterKeys.NODE_ID_DPKEY on the graph, you must use the corresponding node ids stored in this DataProvider as arguments for all methods that create a constraint. Otherwise, you can just use the node instances themselves.

Parameters

g:Graph — the current graph for the layerer

Returns
ConstraintLayerer_ConstraintFactory — a ConstraintFactory bound to this graph.

See also

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

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

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

See also

initConstraintLayerer2()method 
protected final function initConstraintLayerer2(coreLayerer:OldLayerer):void

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

Parameters

coreLayerer:OldLayerer

See also

newConstraintLayerer1()method 
public static function newConstraintLayerer1():ConstraintLayerer

Returns
ConstraintLayerer
newConstraintLayerer2()method 
public static function newConstraintLayerer2(coreLayerer:OldLayerer):ConstraintLayerer

Parameters

coreLayerer:OldLayerer

Returns
ConstraintLayerer
Constant Detail
EDGE_WEIGHTS_DPKEYConstant
public static const EDGE_WEIGHTS_DPKEY:String = y.layout.hierarchic.ConstraintLayerer.EDGE_WEIGHTS_DPKEY

DataProvider key for additional edge weights of type int. The Layerer tries to keep edges with higher weights short.