y.layout.hierarchic
Class ConstraintLayerer

java.lang.Object
  extended by y.layout.hierarchic.ConstraintLayerer
All Implemented Interfaces:
Layerer

public class ConstraintLayerer
extends Object
implements 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 ConstraintLayerer.ConstraintFactory instance, which should be created with createConstraintFactory(y.base.Graph) for a given graph instance.

 
Your browser does not support SVG content.

Nested Class Summary
static interface ConstraintLayerer.ConstraintFactory
          Interface specification for classes that can create suitable constraints for a ConstraintLayerer instance.
 
Field Summary
static String EDGE_WEIGHTS_DPKEY
          DataProvider key for additional edge weights of type int.
 
Constructor Summary
ConstraintLayerer()
           
ConstraintLayerer(Layerer coreLayerer)
           
 
Method Summary
 int assignNodeLayer(LayoutGraph g, NodeMap layer, EdgeList reversedEdges)
          This method assigns the nodes in the graph to layers.
protected  void checkConstraints()
          Checks if the current set of strong constraints is consistent (i.e. has no cycles)
static ConstraintLayerer.ConstraintFactory createConstraintFactory(Graph g)
          Create an instance of ConstraintLayerer.ConstraintFactory that is suitable for this layerer implementation.
 Layerer getCoreLayerer()
          Gets the core layerer for this layerer instance.
 boolean isAllowSameLayerEdges()
          Returns if same layer edges can be created by this layerer instance.
 void setAllowSameLayerEdges(boolean allowSameLayerEdges)
          Set whether same layer edges can be created by this layerer instance.
 void setCoreLayerer(Layerer coreLayerer)
          Sets the core layerer for this layerer instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EDGE_WEIGHTS_DPKEY

public static final String EDGE_WEIGHTS_DPKEY
DataProvider key for additional edge weights of type int. The Layerer tries to keep edges with higher weights short.

See Also:
Constant Field Values
Constructor Detail

ConstraintLayerer

public ConstraintLayerer(Layerer coreLayerer)

ConstraintLayerer

public ConstraintLayerer()
Method Detail

getCoreLayerer

public Layerer getCoreLayerer()
Gets 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 TopologicalLayerer is used.

Returns:
the layerer that is used for unconstrained nodes

setCoreLayerer

public void setCoreLayerer(Layerer coreLayerer)
Sets 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 TopologicalLayerer is used.

Parameters:
coreLayerer - the layerer that is used for unconstrained nodes

isAllowSameLayerEdges

public boolean isAllowSameLayerEdges()
Returns if 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.

Returns:
true iff unconstrained same layer edges are allowed.

setAllowSameLayerEdges

public void setAllowSameLayerEdges(boolean allowSameLayerEdges)
Set 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.

Parameters:
allowSameLayerEdges - true iff unconstrained same layer edges are allowed.

assignNodeLayer

public int assignNodeLayer(LayoutGraph g,
                           NodeMap layer,
                           EdgeList reversedEdges)
This method assigns the nodes in the graph to layers.

Specified by:
assignNodeLayer in interface Layerer
Throws:
IllegalArgumentException - if any strong constraints are inconsistent
Parameters:
g - the graph for which the layers are determined.
layer - here the layers are stored
reversedEdges - here the edges are stored which had been reversed.
Returns:
the number of layers

checkConstraints

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

Throws:
IllegalArgumentException - if the constraint network is inconsistent

createConstraintFactory

public static ConstraintLayerer.ConstraintFactory createConstraintFactory(Graph g)
Create an instance of ConstraintLayerer.ConstraintFactory that is suitable for this layerer implementation. The ConstraintFactory instance is 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 If you manually registered a DataProvider under Layouter.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 - the current graph for the layerer
Returns:
a ContraintFactory bound to this graph.

© Copyright 2000-2008,
yWorks GmbH.
All rights reserved.