Search this API

y.layout
Class NodeHalo

java.lang.Object
  extended by y.layout.NodeHalo

public final class NodeHalo
extends java.lang.Object

A NodeHalo specifies a rectangular area around a specific node. A layout algorithm that supports NodeHalos, keeps this area clear of graph elements, except the node labels of this specific node and the adjacent segments of its edges. All minimum distances to this node, which are used in the layout calculation, e.g., minimum first segment length, will be extended by the halo size.

This class defines a key used for registering a DataProvider that provides NodeHalos for all nodes of the input graph. NodeHalo-aware layout algorithms like IncrementalHierarchicLayouter look for DataProviders registered with this key to retrieve NodeHalo information.

The following layouters support NodeHalos with different restrictions:

 

Field Summary
 double bottom
          The NodeHalo size at the bottom side of the node.
 double left
          The NodeHalo size at the left side of the node.
static java.lang.Object NODE_HALO_DPKEY
          A DataProvider key for assigning halos for the nodes
 double right
          The NodeHalo size at the right side of the node.
 double top
          The NodeHalo size at the top side of the node.
static NodeHalo ZERO_HALO
          A constant holding a NodeHalo with zero size on each side.
 
Method Summary
static NodeHalo create(double value)
          Creates a NodeHalo object with the specified value on each side of the node.
static NodeHalo create(double top, double left, double bottom, double right)
          Creates a NodeHalo with the specified values.
 boolean equals(java.lang.Object o)
           
static NodeHalo getHalo(LayoutGraph graph, Node node)
          Returns the NodeHalo associated with the given node.
static YRectangle getHaloBox(LayoutGraph graph, Node node)
          Returns a YRectangle instance with the bounds of the given node including its NodeHalo.
static boolean hasHalos(LayoutGraph graph)
          Checks whether or not the given graph contains NodeHalo information.
 int hashCode()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NODE_HALO_DPKEY

public static final java.lang.Object NODE_HALO_DPKEY
A DataProvider key for assigning halos for the nodes


ZERO_HALO

public static final NodeHalo ZERO_HALO
A constant holding a NodeHalo with zero size on each side.


top

public final double top
The NodeHalo size at the top side of the node.


left

public final double left
The NodeHalo size at the left side of the node.


bottom

public final double bottom
The NodeHalo size at the bottom side of the node.


right

public final double right
The NodeHalo size at the right side of the node.

Method Detail

create

public static NodeHalo create(double top,
                              double left,
                              double bottom,
                              double right)
Creates a NodeHalo with the specified values.

The values must not be negative, Double.NaN or Double.POSITIVE_INFINITY.

Parameters:
top - the NodeHalo size at the top side of the node
left - the NodeHalo size at the left side of the node
bottom - the NodeHalo size at the bottom side of the node
right - the NodeHalo size at the right side of the node
Returns:
the newly created NodeHalo
Throws:
java.lang.IllegalArgumentException - if one of the values is negative, Double.NaN or Double.POSITIVE_INFINITY

create

public static NodeHalo create(double value)
Creates a NodeHalo object with the specified value on each side of the node.

The value must not be negative, Double.NaN or Double.POSITIVE_INFINITY.

Parameters:
value - the halo size at each side of the node
Returns:
the newly created NodeHalo
Throws:
java.lang.IllegalArgumentException - if the value is negative, Double.NaN or Double.POSITIVE_INFINITY

hasHalos

public static boolean hasHalos(LayoutGraph graph)
Checks whether or not the given graph contains NodeHalo information.

This method looks for a DataProvider that has been registered with the given graph using NODE_HALO_DPKEY.

Parameters:
graph - the input graph
Returns:
true if a DataProvider has been registered with the according key, false otherwise

getHalo

public static NodeHalo getHalo(LayoutGraph graph,
                               Node node)
Returns the NodeHalo associated with the given node.

If no such NodeHalo is available, this method returns a ZERO_HALO.

Parameters:
graph - the graph containing the given node
node - the node whose NodeHalo will be determined
Returns:
the NodeHalo of the given node if available, otherwise a ZERO_HALO

getHaloBox

public static YRectangle getHaloBox(LayoutGraph graph,
                                    Node node)
Returns a YRectangle instance with the bounds of the given node including its NodeHalo.

This YRectangle is located at the position of the node.

If the node does not have a NodeHalo assigned, this box has the same size as the node.

Parameters:
graph - the graph containing the given node
node - the node whose NodeHalo will be determined
Returns:
a YRectangle instance with the bounds of the given node including its NodeHalo

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

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