Search this API

y.layout.hierarchic
Class MedianDrawerWrapper

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

public class MedianDrawerWrapper
extends java.lang.Object
implements Drawer

This class can be used for improving the results of different drawers.

It is designed as a wrapper to another drawer (especially SimplexDrawer). It will insert additional dummy nodes for each node that has an even number of incoming edges or outgoing edges. Dummy nodes will be inserted in the neighboring layer at the center of the other edges' opposite nodes.

The produced drawings are considered to be more symmetric.

 

Field Summary
protected  Drawer drawerDelegate
          The delegate Drawer instance that will perform the actual drawing.
protected  NodeMap dummy
          A NodeMap used for identifying dummy nodes.
 
Fields inherited from interface y.layout.hierarchic.Drawer
NODE_BORDER_BOTTOM, NODE_BORDER_LEFT, NODE_BORDER_RIGHT, NODE_BORDER_TOP, NODE_DISTANCE
 
Constructor Summary
MedianDrawerWrapper(Drawer drawerDelegate)
          Creates an instance of MedianDrawerWrapper 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.
 Drawer getDelegate()
          Returns the Drawer to which the actual drawing is delegated.
protected  void postprocess(LayoutGraph graph, NodeList[] layerLists, NodeMap layerID)
          Called as a hook after the actual drawing is performed by the delegate Drawer instance.
protected  void preprocess(LayoutGraph graph, NodeList[] layerLists, NodeMap layerID)
          Called as a hook before the actual drawing is performed by the delegate Drawer instance.
 void setDelegate(Drawer drawerDelegate)
          Specifies the Drawer to which the actual drawing is delegated.
 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
 

Field Detail

drawerDelegate

protected Drawer drawerDelegate
The delegate Drawer instance that will perform the actual drawing.

See Also:
setDummyMap(NodeMap)

dummy

protected NodeMap dummy
A NodeMap used for identifying dummy nodes.

It returns the original edge for each dummy node or null for real nodes.

See Also:
setDummyMap(y.base.NodeMap)
Constructor Detail

MedianDrawerWrapper

public MedianDrawerWrapper(Drawer drawerDelegate)
Creates an instance of MedianDrawerWrapper 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

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 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 10

Node distance 100

preprocess

protected void preprocess(LayoutGraph graph,
                          NodeList[] layerLists,
                          NodeMap layerID)
Called as a hook before the actual drawing is performed by the delegate Drawer instance.

This method is called by assignCoordinates(LayoutGraph, NodeList[], DataProvider) and calculates the dummy nodes that have to be inserted to the graph for each node that has an even number of incoming edges or outgoing edges. These nodes are being removed in postprocess(LayoutGraph, NodeList[], NodeMap) method.

Parameters:
graph - the graph
layerLists - an array of NodeLists each of which contains nodes that belong to the same layer
layerID - the NodeMap that will be filled during the calculation and holds the zero-based index of the layer to which each node belongs
See Also:
postprocess(LayoutGraph, NodeList[], NodeMap)

postprocess

protected void postprocess(LayoutGraph graph,
                           NodeList[] layerLists,
                           NodeMap layerID)
Called as a hook after the actual drawing is performed by the delegate Drawer instance.

This method is called by assignCoordinates(LayoutGraph, NodeList[], DataProvider) as a last step in order to remove the dummy nodes inserted by preprocess(LayoutGraph, NodeList[], NodeMap) method and restore the graph.

Parameters:
graph - the graph
layerLists - an array of NodeLists each of which contains nodes that belong to the same layer
layerID - the NodeMap that returns the zero-based index of the layer to which each node belongs
See Also:
postprocess(LayoutGraph, NodeList[], NodeMap)

getDelegate

public Drawer getDelegate()
Returns the Drawer to which the actual drawing is delegated.

Returns:
the Drawer instance that performs the actual drawing
See Also:
setDelegate(Drawer)

setDelegate

public void setDelegate(Drawer drawerDelegate)
Specifies the Drawer to which the actual drawing is delegated.

Parameters:
drawerDelegate - the given Drawer instance that performs the actual drawing

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