Search this API

y.layout.hierarchic
Interface ConstraintLayerer.ConstraintFactory

Enclosing class:
ConstraintLayerer

public static interface ConstraintLayerer.ConstraintFactory

Interface specification for classes that can create suitable constraints for a ConstraintLayerer instance. If you manually register a DataProvider with the graph using Layouter.NODE_ID_DPKEY key, 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.

 

Field Summary
static java.lang.Object LAYER_CONSTRAINTS_MEMENTO_DPKEY
          A DataProvider key for storing the constraint graph.
 
Method Summary
 void addPlaceNodeAboveConstraint(java.lang.Object referenceId, java.lang.Object aboveId)
          Adds a constraint that forces the node aboveId to lie above the node referenceId.
 void addPlaceNodeAboveConstraint(java.lang.Object referenceId, java.lang.Object aboveId, int minDistance)
          Adds a constraint that forces the node with ID aboveId to lie at least minDistance layers above the node with ID referenceId.
 void addPlaceNodeAboveConstraint(java.lang.Object referenceId, java.lang.Object aboveId, int minDistance, int weight)
          Adds a constraint that forces the node with ID aboveId to lie at least minDistance layers above the node with ID referenceId with a given weight penalty for larger layer differences.
 void addPlaceNodeAtBottomConstraint(java.lang.Object nodeId)
          Adds a constraint that places a node in the bottom layer
 void addPlaceNodeAtTopConstraint(java.lang.Object nodeId)
          Adds a constraint that places a node in the topmost layer
 void addPlaceNodeBelowConstraint(java.lang.Object referenceId, java.lang.Object belowId)
          Adds a constraint that forces a Node with ID belowId to lie below the Node with ID referenceId.
 void addPlaceNodeBelowConstraint(java.lang.Object referenceId, java.lang.Object belowId, int minDistance)
          Adds a constraint that forces the Node with ID belowId to lie at least minDistance layers below the Node with ID referenceId.
 void addPlaceNodeBelowConstraint(java.lang.Object referenceId, java.lang.Object belowId, int minDistance, int weight)
          Adds a constraint that forces the node with ID belowId to lie at least minDistance layers below the node with ID referenceId with a given weight penalty for larger layer differences.
 void addPlaceNodeInSameLayerConstraint(java.lang.Object referenceId, java.lang.Object sameLayerId)
          Adds a constraint that forces the node with ID sameLayerId to lie in the same-layer as the node with ID referenceId.
 void dispose()
          Disposes the ConstraintLayerer.ConstraintFactory.
 java.lang.Object getMemento()
          Returns a token that allows to bind a constraint factory to a graph instance after creation.
 void removeConstraints(java.lang.Object nodeId)
          Clears all constraints for a given node.
 

Field Detail

LAYER_CONSTRAINTS_MEMENTO_DPKEY

static final java.lang.Object LAYER_CONSTRAINTS_MEMENTO_DPKEY
A DataProvider key for storing the constraint graph.

Method Detail

getMemento

java.lang.Object getMemento()
Returns a token that allows to bind a constraint factory to a graph instance after creation.

This method should only be used if the constraint factory is not bound to a graph instance initially. It allows to bind the ConstraintLayerer.ConstraintFactory to a graph instance after creation. See the factory methods that create instances of this interface for a description.

Returns:
a token that allows to bind the constraint factory to a graph instance
See Also:
ConstraintLayerer.createConstraintFactory(Graph)

dispose

void dispose()
Disposes the ConstraintLayerer.ConstraintFactory.

This method should be called when the factory is not needed anymore, i.e., after the layout has been calculated. Calling this method also clears all constraints.

The factory cannot be used after the disposal.


addPlaceNodeBelowConstraint

void addPlaceNodeBelowConstraint(java.lang.Object referenceId,
                                 java.lang.Object belowId)
Adds a constraint that forces a Node with ID belowId to lie below the Node with ID referenceId.

Parameters:
referenceId - the ID of the reference node
belowId - the ID of the node that should lie below
Sample Graphs:

Layout without layer constraint

Layout considering below layer constraint

addPlaceNodeBelowConstraint

void addPlaceNodeBelowConstraint(java.lang.Object referenceId,
                                 java.lang.Object belowId,
                                 int minDistance)
Adds a constraint that forces the Node with ID belowId to lie at least minDistance layers below the Node with ID referenceId.

 
The minimum distance includes potentially empty layers that are removed by this instance. In that case, the actual layer difference may be smaller than the minimum distance.
Parameters:
referenceId - the ID of the reference node
belowId - the ID of the node that should lie below
minDistance - the minimum layer distance between the node and its reference node
Sample Graphs:

Layout without layer constraint

Layout considering below layer constraint with minimum distance 2

addPlaceNodeBelowConstraint

void addPlaceNodeBelowConstraint(java.lang.Object referenceId,
                                 java.lang.Object belowId,
                                 int minDistance,
                                 int weight)
Adds a constraint that forces the node with ID belowId to lie at least minDistance layers below the node with ID referenceId with a given weight penalty for larger layer differences.

 
The minimum distance includes potentially empty layers that are removed by the layerer. In that case, the actual layer difference may be smaller than minDistance.
Parameters:
referenceId - the ID of the reference node
belowId - the ID of the node that should lie below
minDistance - the minimum layer distance between the node and its reference node
weight - the weight penalty for larger layer differences
Sample Graphs:

Layout without layer constraint

Layout considering below layer constraint with minimum distance 2 and weight 1000

addPlaceNodeAboveConstraint

void addPlaceNodeAboveConstraint(java.lang.Object referenceId,
                                 java.lang.Object aboveId)
Adds a constraint that forces the node aboveId to lie above the node referenceId.

Parameters:
referenceId - the ID of the reference node
aboveId - the ID of the node that should lie above
Sample Graphs:

Layout without layer constraint

Layout considering above layer constraint

addPlaceNodeAboveConstraint

void addPlaceNodeAboveConstraint(java.lang.Object referenceId,
                                 java.lang.Object aboveId,
                                 int minDistance)
Adds a constraint that forces the node with ID aboveId to lie at least minDistance layers above the node with ID referenceId.

 
The minimum distance includes potentially empty layers that are removed by the layerer. In that case, the actual layer difference may be smaller than minDistance
Parameters:
referenceId - the ID of the reference node
aboveId - the ID of the node that should lie above
minDistance - the minimum layer distance between the node and its reference node
Sample Graphs:

Layout without layer constraint

Layout considering above layer constraint with minimum distance 2

addPlaceNodeAboveConstraint

void addPlaceNodeAboveConstraint(java.lang.Object referenceId,
                                 java.lang.Object aboveId,
                                 int minDistance,
                                 int weight)
Adds a constraint that forces the node with ID aboveId to lie at least minDistance layers above the node with ID referenceId with a given weight penalty for larger layer differences.

 
The minimum distance includes potentially empty layers that are removed by the layerer. In that case, the actual layer difference may be smaller than minDistance
Parameters:
referenceId - the ID of the reference node
aboveId - the ID of the node that should lie above
minDistance - the minimum layer distance between the node and its reference node
weight - the weight penalty for larger layer differences
Sample Graphs:

Layout without layer constraint

Layout considering above layer constraint with minimum distance 2 and weight 1000

addPlaceNodeInSameLayerConstraint

void addPlaceNodeInSameLayerConstraint(java.lang.Object referenceId,
                                       java.lang.Object sameLayerId)
Adds a constraint that forces the node with ID sameLayerId to lie in the same-layer as the node with ID referenceId.

Parameters:
referenceId - the ID of the reference node
sameLayerId - the ID of the node that should lie in the same-layer
Sample Graphs:

Layout without layer constraint

Layout considering same layer constraint

addPlaceNodeAtTopConstraint

void addPlaceNodeAtTopConstraint(java.lang.Object nodeId)
Adds a constraint that places a node in the topmost layer

Parameters:
nodeId - the ID of the node that should lie at the top
Sample Graphs:

Layout without layer constraint

Layout considering top layer constraint

addPlaceNodeAtBottomConstraint

void addPlaceNodeAtBottomConstraint(java.lang.Object nodeId)
Adds a constraint that places a node in the bottom layer

Parameters:
nodeId - the ID of the node that should lie at the bottom
Sample Graphs:

Layout without layer constraint

Layout considering bottom layer constraint

removeConstraints

void removeConstraints(java.lang.Object nodeId)
Clears all constraints for a given node.

Parameters:
nodeId - the ID of the node for which all constraints should be cleared

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