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 Object
implements Drawer

This class can be used to wrap Drawer implementations. It modifies the Drawer.NODE_BORDER_LEFT and Drawer.NODE_BORDER_RIGHT DataProvider instances and delegates the actual drawing to the inner drawer. Actual space requirements are calculated in 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. MedianLinearSegmentsDrawer 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 can therefor not be used with layout orientations other than top to bottom.


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 inner)
          Creates a new instance of NodeLabelSpaceDrawer
 
Method Summary
 void assignCoordinates(LayoutGraph g, NodeList[] layerLists, DataProvider layerID)
          This method assigns the coordinates to the nodes.
protected  double getHaloSpace(Node node, boolean left)
          Calculates the horizontal space requirements for the given node.
 void setDummyMap(NodeMap dummy)
          Gives the drawer the opportunity to distinguish between dummy nodes and real ones. dummy stores the original edge for each dummy node or null for real nodes.
 void setMinimalEdgeDistance(double d)
          Sets the minimal distance between two edges in the same layer.
 void setMinimalLayerDistance(double d)
          Sets the minimal distance between two layers.
 void setMinimalMultiEdgeDistance(double d)
          Sets the minimal distance between two edges sharing source/target (aka multi-edges) in the same layer.
 void setMinimalNodeDistance(double d)
          Sets the minimal 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 inner)
Creates a new instance of NodeLabelSpaceDrawer

Method Detail

assignCoordinates

public void assignCoordinates(LayoutGraph g,
                              NodeList[] layerLists,
                              DataProvider layerID)
Description copied from interface: Drawer
This method assigns the coordinates to the nodes.

Specified by:
assignCoordinates in interface Drawer

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 the halo values.

Parameters:
node - The node to calculate the halo for.
left - Whether to calculate the left (true) or right (false) halo.
Returns:
The additional space needed by the given node at the given side.

setDummyMap

public void setDummyMap(NodeMap dummy)
Description copied from interface: Drawer
Gives the drawer the opportunity to distinguish between dummy nodes and real ones. dummy stores the original edge for each dummy node or null for real nodes.

Specified by:
setDummyMap in interface Drawer

setMinimalEdgeDistance

public void setMinimalEdgeDistance(double d)
Description copied from interface: Drawer
Sets the minimal distance between two edges in the same layer.

Specified by:
setMinimalEdgeDistance in interface Drawer

setMinimalLayerDistance

public void setMinimalLayerDistance(double d)
Description copied from interface: Drawer
Sets the minimal distance between two layers.

Specified by:
setMinimalLayerDistance in interface Drawer

setMinimalMultiEdgeDistance

public void setMinimalMultiEdgeDistance(double d)
Description copied from interface: Drawer
Sets the minimal distance between two edges sharing source/target (aka multi-edges) in the same layer.

Specified by:
setMinimalMultiEdgeDistance in interface Drawer

setMinimalNodeDistance

public void setMinimalNodeDistance(double d)
Description copied from interface: Drawer
Sets the minimal distance between two nodes in the same layer.

Specified by:
setMinimalNodeDistance in interface Drawer

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