Search this API

y.layout.tree
Class NodeOrderComparator

java.lang.Object
  extended by y.layout.tree.NodeOrderComparator
All Implemented Interfaces:
java.util.Comparator, Comparators.PartialOrder

public class NodeOrderComparator
extends java.lang.Object
implements java.util.Comparator, Comparators.PartialOrder

The NodeOrderComparator compares edges according to a specified order.

It obtains the order from a DataProvider registered with the graph with key NODE_ORDER_DPKEY.

Various tree layout algorithms can use this Comparator to influence the resulting layout. To achieve this, use this comparator and assign it to the comparator property of the layout algorithm classes.

See Also:
TreeLayouter.setComparator(Comparator), GenericTreeLayouter.setDefaultChildComparator(Comparator), GenericTreeLayouter.CHILD_COMPARATOR_DPKEY, BalloonLayouter.setComparator(Comparator), ARTreeLayouter.setComparator(Comparator), HVTreeLayouter.setComparator(Comparator), NODE_ORDER_DPKEY
 

Field Summary
static java.lang.Object NODE_ORDER_DPKEY
          A DataProvider key for registering an order for each node in the graph
 
Constructor Summary
NodeOrderComparator()
          Creates a new NodeOrderComparator instance.
 
Method Summary
 int compare(java.lang.Object edge1, java.lang.Object edge2)
          Compares two edges according to their index in the order specified using a DataProvider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

NODE_ORDER_DPKEY

public static final java.lang.Object NODE_ORDER_DPKEY
A DataProvider key for registering an order for each node in the graph

Constructor Detail

NodeOrderComparator

public NodeOrderComparator()
Creates a new NodeOrderComparator instance.

Method Detail

compare

public int compare(java.lang.Object edge1,
                   java.lang.Object edge2)
Compares two edges according to their index in the order specified using a DataProvider.

Target nodes for which the DataProvider registered with NODE_ORDER_DPKEY returns null or an Object that does not implement Comparable are treated as being smaller than other target nodes.

Specified by:
compare in interface java.util.Comparator
Parameters:
edge1 - the first edge
edge2 - the second edge
See Also:
NODE_ORDER_DPKEY

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