Search this API

y.layout
Class NormalizingGraphElementOrderStage

java.lang.Object
  extended by y.layout.AbstractLayoutStage
      extended by y.layout.NormalizingGraphElementOrderStage
All Implemented Interfaces:
Layouter, LayoutStage

public class NormalizingGraphElementOrderStage
extends AbstractLayoutStage

NormalizingGraphElementOrderStage normalizes the order of the elements within a graph to ensure the same order for multiple layout invocations.

Among other factors, the results produced by layout algorithms usually depend on the order of the nodes and edges within a graph. Unfortunately, useful operations such as hiding or unhiding elements from a graph or simply invoking layout algorithms on a graph will have the potential side effect of changing that order.

With this LayoutStage it is possible to establish a predefined order of nodes and edges within a graph to avoid non-deterministic layout behavior. Defining the order of nodes and edges is done by associating each node or edge in the graph with a Comparable value using a DataProvider registered with the key COMPARABLE_NODE_DPKEY or COMPARABLE_EDGE_DPKEY, respectively.

 
Your browser does not support SVG content.

Field Summary
static java.lang.Object COMPARABLE_EDGE_DPKEY
          A DataProvider key for defining a (global) order for edges
static java.lang.Object COMPARABLE_NODE_DPKEY
          A DataProvider key for defining a (global) order for nodes
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
NormalizingGraphElementOrderStage()
          Creates a new NormalizingGraphElementOrderStage instance with default settings.
NormalizingGraphElementOrderStage(Layouter coreLayouter)
          Creates a new NormalizingGraphElementOrderStage instance using the given core layout algorithm.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Accepts all general graphs.
 void doLayout(LayoutGraph graph)
          Enforces the specified order of nodes and order of edges before invoking the core layout algorithm.
static void fillComparableMapFromGraph(Graph graph, DataMap comparableNodeMap, DataMap comparableEdgeMap)
          Assigns comparable values for each node and edge.
 
Methods inherited from class y.layout.AbstractLayoutStage
canLayoutCore, doLayoutCore, getCoreLayouter, setCoreLayouter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPARABLE_NODE_DPKEY

public static final java.lang.Object COMPARABLE_NODE_DPKEY
A DataProvider key for defining a (global) order for nodes


COMPARABLE_EDGE_DPKEY

public static final java.lang.Object COMPARABLE_EDGE_DPKEY
A DataProvider key for defining a (global) order for edges

Constructor Detail

NormalizingGraphElementOrderStage

public NormalizingGraphElementOrderStage()
Creates a new NormalizingGraphElementOrderStage instance with default settings.


NormalizingGraphElementOrderStage

public NormalizingGraphElementOrderStage(Layouter coreLayouter)
Creates a new NormalizingGraphElementOrderStage instance using the given core layout algorithm.

Parameters:
coreLayouter - the core layout routine
Method Detail

canLayout

public boolean canLayout(LayoutGraph graph)
Accepts all general graphs.

Parameters:
graph - the input graph
Returns:
true for every graph
See Also:
Layouter.doLayout(LayoutGraph)

doLayout

public void doLayout(LayoutGraph graph)
Enforces the specified order of nodes and order of edges before invoking the core layout algorithm.

Parameters:
graph - the input graph
Throws:
java.lang.IllegalStateException - if there is no DataProvider registered for one of the keys COMPARABLE_NODE_DPKEY and COMPARABLE_EDGE_DPKEY
See Also:
COMPARABLE_NODE_DPKEY, COMPARABLE_EDGE_DPKEY

fillComparableMapFromGraph

public static void fillComparableMapFromGraph(Graph graph,
                                              DataMap comparableNodeMap,
                                              DataMap comparableEdgeMap)
Assigns comparable values for each node and edge.

The compared values are induced from the current ordering of the nodes and edges within the given graph.

This is a convenient method to fill the given DataMaps which can then be registered with the graph with keys COMPARABLE_NODE_DPKEY and COMPARABLE_EDGE_DPKEY and used for several layout calculations.

Parameters:
graph - the input graph
comparableNodeMap - the map that will be filled with comparable values for the nodes
comparableEdgeMap - the map that will be filled with comparable values for the edges

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