Search this API

y.layout.hierarchic
Class NodeLabelSpaceDrawer

java.lang.Object
  extended by y.layout.hierarchic.NodeLabelSpaceDrawer
All Implemented Interfaces:
Drawer

public class NodeLabelSpaceDrawer
extends java.lang.Object
implements Drawer

This class can be used for wrapping Drawer implementations.

It modifies the DataProvider instances registered with the graph using keys Drawer.NODE_BORDER_LEFT and Drawer.NODE_BORDER_RIGHT and delegates the actual drawing to the inner drawer.

Actual space requirements are calculated by getHaloSpace(Node, boolean). This implementation uses the maximum left and right label overlaps as the halo values. Note that this will only work with Drawer implementations that respect the values provided through the DataProviders, e.g. MedianLinearSegmentDrawer and SimplexDrawer.

Here is some example set up code:
   // create the Layouter
   HierarchicLayouter hl = new HierarchicLayouter();
   // set a suitable Drawer
   hl.setDrawer(new SimplexDrawer());
   // wrap the Drawer
   hl.setDrawer(new NodeLabelSpaceDrawer(hl.getDrawer()));
 

 
This implementation uses NodeLabelLayouts and, therefore, cannot be used with layout orientations other than top-to-bottom.
 
Your browser does not support SVG content.

Field Summary
 
Fields inherited from interface y.layout.hierarchic.Drawer
NODE_BORDER_BOTTOM, NODE_BORDER_LEFT, NODE_BORDER_RIGHT, NODE_BORDER_TOP, NODE_DISTANCE
 
Constructor Summary
NodeLabelSpaceDrawer(Drawer drawerDelegate)
          Creates an instance of NodeLabelSpaceDrawer using the delegate Drawer instance to perform the core work.
 
Method Summary
 void assignCoordinates(LayoutGraph graph, NodeList[] layerLists, DataProvider layerID)
          Assigns the coordinates to the nodes of the given graph.
protected  double getHaloSpace(Node node, boolean left)
          Calculates the horizontal space requirements for the given node.
 void setDummyMap(NodeMap dummyMap)
          Specifies a NodeMap instance for identifying the dummy nodes from the real ones.
 void setMinimalEdgeDistance(double d)
          Specifies the minimum distance between two edges that span the same layer.
 void setMinimalLayerDistance(double d)
          Specifies the minimum distance between two layers.
 void setMinimalMultiEdgeDistance(double d)
          Specifies the minimum distance between two edges sharing source/target in the same layer.
 void setMinimalNodeDistance(double d)
          Specifies the minimum distance between two nodes in the same layer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeLabelSpaceDrawer

public NodeLabelSpaceDrawer(Drawer drawerDelegate)
Creates an instance of NodeLabelSpaceDrawer using the delegate Drawer instance to perform the core work.

Parameters:
drawerDelegate - the delegate Drawer instance
Method Detail

assignCoordinates

public void assignCoordinates(LayoutGraph graph,
                              NodeList[] layerLists,
                              DataProvider layerID)
Description copied from interface: Drawer
Assigns the coordinates to the nodes of the given graph.

Specified by:
assignCoordinates in interface Drawer
Parameters:
graph - the graph
layerLists - the array of NodeLists each of which contains nodes that belong to the same layer
layerID - the DataProvider that returns the zero-based index of the layer to which each node belongs

getHaloSpace

protected double getHaloSpace(Node node,
                              boolean left)
Calculates the horizontal space requirements for the given node.

This implementation uses the maximum left and right label overlaps as halo values.

Parameters:
node - the given node
left - true if the left halo should be calculated, false if the right halo should be calculated
Returns:
the additional space needed by the given node at the given side

setDummyMap

public void setDummyMap(NodeMap dummyMap)
Specifies a NodeMap instance for identifying the dummy nodes from the real ones.

Specified by:
setDummyMap in interface Drawer
Parameters:
dummyMap - the NodeMap that returns an object (the original edge) for each dummy node or null for real nodes

setMinimalEdgeDistance

public void setMinimalEdgeDistance(double d)
Specifies the minimum distance between two edges that span the same layer.

Minimum distance must be non-negative.

Specified by:
setMinimalEdgeDistance in interface Drawer
Default Value:
The default value is 5.0.
Parameters:
d - the minimum distance between two edges
Throws:
java.lang.IllegalArgumentException - if the minimum distance is negative
Sample Graphs:

Edge distance 10

Edge distance 100

setMinimalLayerDistance

public void setMinimalLayerDistance(double d)
Specifies the minimum distance between two layers.

Minimum distance must be non-negative.

Specified by:
setMinimalLayerDistance in interface Drawer
Default Value:
The default value is 60.0.
Parameters:
d - the minimum distance between two edges sharing source/target
Throws:
java.lang.IllegalArgumentException - if the minimum distance is negative
Sample Graphs:

Layer distance 40

Layer distance 100

setMinimalMultiEdgeDistance

public void setMinimalMultiEdgeDistance(double d)
Specifies the minimum distance between two edges sharing source/target in the same layer.

Minimum distance must be non-negative.

Specified by:
setMinimalMultiEdgeDistance in interface Drawer
Default Value:
The default value is 0.0.
Parameters:
d - the minimum distance between two edges sharing source/target
Throws:
java.lang.IllegalArgumentException - if the minimum distance is negative
Sample Graphs:

Multi-edge distance 10

Multi-edge distance 200

setMinimalNodeDistance

public void setMinimalNodeDistance(double d)
Specifies the minimum distance between two nodes in the same layer.

Minimum distance must be non-negative.

Specified by:
setMinimalNodeDistance in interface Drawer
Default Value:
The default value is 20.0.
Parameters:
d - the minimum distance between two edges sharing source/target
Throws:
java.lang.IllegalArgumentException - if the minimum distance is negative
Sample Graphs:

Node distance 20

Node distance 100

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