|
Search this API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.layout.hierarchic.ConstraintLayerer
public class ConstraintLayerer
ConstraintLayerer considers relative and absolute layering constraints when assigning the nodes to layers.
There are two supported sets of constraints:
ConstraintLayerer.ConstraintFactory instance,
which should be created with createConstraintFactory(Graph) for a given graph instance.
The ConstraintLayerer will try to create a layering for the nodes and edges that have no constraints that
resembles the one produced by the core layerer. The result is better if
less constraints exist. Ideally, the constrained nodes are just embedded into the layering created by the core
layerer.
IncrementalHierarchicLayouter as well as HierarchicLayouter and
HierarchicGroupLayouter.![]() |
![]() |
![]() |
![]() |
| Nested Class Summary | |
|---|---|
static interface |
ConstraintLayerer.ConstraintFactory
Interface specification for classes that can create suitable constraints for a ConstraintLayerer instance. |
| Field Summary | |
|---|---|
static java.lang.String |
EDGE_WEIGHTS_DPKEY
A DataProvider key for adding weights to the edges of the graph.
|
| Constructor Summary | |
|---|---|
ConstraintLayerer()
Creates a new instance of ConstraintLayerer with the default settings. |
|
ConstraintLayerer(Layerer coreLayerer)
Creates an instance of ConstraintLayerer with the given core Layerer instance. |
|
| Method Summary | |
|---|---|
void |
assignLayers(LayoutGraph graph,
Layers layers,
LayoutDataProvider ldp)
Assigns all nodes of the graph to layers and adds them to the Layers instance. |
int |
assignNodeLayer(LayoutGraph graph,
NodeMap layerID,
EdgeList reversedEdges)
Assigns all nodes of the graph to layers |
protected void |
checkConstraints()
Checks whether the current set of strong constraints is consistent (i.e., has no cycles). |
static ConstraintLayerer.ConstraintFactory |
createConstraintFactory(Graph graph)
Creates an instance of ConstraintLayerer.ConstraintFactory that is suitable for this
layerer implementation. |
Layerer |
getCoreLayerer()
Returns the core layerer for this ConstraintLayerer instance. |
boolean |
isAllowSameLayerEdges()
Returns whether or not same-layer edges can be created by this instance. |
void |
setAllowSameLayerEdges(boolean allowSameLayerEdges)
Specifies whether or not same-layer edges can be created by this instance. |
void |
setCoreLayerer(Layerer coreLayerer)
Specifies the core layerer for this ConstraintLayerer instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String EDGE_WEIGHTS_DPKEY
DataProvider key for adding weights to the edges of the graph.
The layerer tries to maintain edges with higher weights short.
| Constructor Detail |
|---|
public ConstraintLayerer(Layerer coreLayerer)
ConstraintLayerer with the given core Layerer instance.
coreLayerer - the given Layerer instancepublic ConstraintLayerer()
ConstraintLayerer with the default settings.
| Method Detail |
|---|
public Layerer getCoreLayerer()
ConstraintLayerer 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 core layerer. This works better if less constraints exist.
Ideally, the constrained nodes are just embedded into the layering created by the core layerer.
setCoreLayerer(Layerer)public void setCoreLayerer(Layerer coreLayerer)
ConstraintLayerer 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 core layerer. This works better if
less constraints exist. Ideally, the constrained nodes are just embedded into the layering created by the core
layerer.
TopologicalLayerer. A layerer based on topological sorting is used.coreLayerer - the layerer used for unconstrained nodespublic boolean isAllowSameLayerEdges()
This only concerns edges between nodes that have no hard constraints that will force a same-layer edge (i.e., a same-layer constraint).
true if unconstrained same-layer edges are allowed, false
otherwisesetAllowSameLayerEdges(boolean)public void setAllowSameLayerEdges(boolean allowSameLayerEdges)
This only concerns edges between nodes that have no hard constraints that will force a same-layer edge (i.e., a same-layer constraint).
allowSameLayerEdges - true if unconstrained same-layer edges are allowed, false
otherwise
public int assignNodeLayer(LayoutGraph graph,
NodeMap layerID,
EdgeList reversedEdges)
graph - the graphlayerID - the NodeMap that will be filled by the layout algorithm and returns the zero-based index
of the layer to which each node belongsreversedEdges - an EdgeList containing the edges which had been reversed
java.lang.IllegalArgumentException - if any strong constraints are inconsistentprotected void checkConstraints()
This method is called in assignNodeLayer(LayoutGraph, NodeMap, EdgeList) after all explicit constraints
have been created and checks whether this constraint network is acyclic. It can be overridden for custom
constraint checking.
java.lang.IllegalArgumentException - if the constraint network is inconsistent
public void assignLayers(LayoutGraph graph,
Layers layers,
LayoutDataProvider ldp)
Layers instance.
assignLayers in interface Layerergraph - the input graphlayers - the Layers instance that will be filled with the results of the calculationldp - the LayoutDataProvider used for querying information about the nodes and edgesLayers.insert(byte, int),
Layer.add(y.base.Node)public static ConstraintLayerer.ConstraintFactory createConstraintFactory(Graph graph)
ConstraintLayerer.ConstraintFactory that is suitable for this
layerer implementation.
The ConstraintLayerer.ConstraintFactory instance is usually bound to Graph instance graph, i.e., if the input
graph for the layerer changes, a new ConstraintLayerer.ConstraintFactory instance must be retrieved. This instance can be
used for creating constraints for this graph instance.
You can create a ConstraintLayerer.ConstraintFactory instance 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 graph = ...;
graph.addDataProvider(ConstraintFactory.LAYER_CONSTRAINTS_MEMENTO_DPKEY,
DataProviders.createConstantDataProvider(cf.getMemento())););
//Calculate layout
DataProvider with the graph using Layouter.NODE_ID_DPKEY,
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.graph - the graph
ConstraintLayerer.ConstraintFactory instance bound to the input graphConstraintLayerer.ConstraintFactory.getMemento(),
ConstraintLayerer.ConstraintFactory.LAYER_CONSTRAINTS_MEMENTO_DPKEY
|
© Copyright 2000-2025, yWorks GmbH. All rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||