diva.graph.layout
Class LevelLayout

java.lang.Object
  extended by diva.graph.layout.AbstractGlobalLayout
      extended by diva.graph.layout.LevelLayout
All Implemented Interfaces:
GlobalLayout

public class LevelLayout
extends AbstractGlobalLayout

A level-based layout algorithm originally implemented by Ulfar Erlingsson at Cornell/RPI and modified to fit into this system.

The algorithm is structured in the following way:

TODO:

Version:
$Revision: 1.23 $
Author:
Michael Shilman (michaels@eecs.berkeley.edu)

Nested Class Summary
 class LevelLayout.LevelData
           
static class LevelLayout.LevelInfo
          The semantic object of each node in the graph copy that is being layed out.
 
Field Summary
protected  int _orientation
          Keep track of the orientation; vertical by default.
static int HORIZONTAL
          Layout the graph in levels from left to right.
static int VERTICAL
          Layout the graph in levels from top to bottom.
 
Constructor Summary
LevelLayout(LayoutTarget target)
          Construct a new levelizing layout with a vertical orientation.
 
Method Summary
 void applyLayout(LevelLayout.LevelData levelData, Object g)
          Place the nodes in the target environment according to their levels and sorting order which are specified in levelData.
 void applyLayout(LevelLayout.LevelData levelData, Object g, boolean useDummies)
          Place the nodes in the target environment according to their levels and sorting order which are specified in levelData.
 LevelLayout.LevelData calculateLayout(Object composite)
          This method performs levelizing layout on the given composite.
protected  Object copyComposite(Object origComposite)
          Copy the given graph and make the nodes/edges in the copied graph point to the nodes/edges in the original.
protected  void copyLayout(Object origComposite, Object copyComposite)
          Take the layout generated by the core layout algorithm and copy it back into the view of the original composite passed in by the user.
 BasicGraphModel getLocalGraphModel()
          Return the local graph model.
 int getOrientation()
          Return the orientation in which the graph is to be layed out, either VERTICAL or HORIZONTAL.
 boolean getRandomizedPlacement()
          Return whether or not placement will be randomized.
 boolean isVisited(Object node)
           
 void layout(Object composite)
          Perform the levelizing layout on the given composite in the given target environment.
 void setAllVisited(Object composite, boolean val)
           
 void setOrientation(int o)
          Set the orientation in which the graph is to be layed out, either VERTICAL or HORIZONTAL.
 void setRandomizedPlacement(boolean flag)
          Set whether or not placement will be randomized.
 void setVisited(Object node, boolean val)
           
 
Methods inherited from class diva.graph.layout.AbstractGlobalLayout
getLayoutTarget, setLayoutTarget
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERTICAL

public static final int VERTICAL
Layout the graph in levels from top to bottom.

See Also:
setOrientation(int), Constant Field Values

HORIZONTAL

public static final int HORIZONTAL
Layout the graph in levels from left to right.

See Also:
setOrientation(int), Constant Field Values

_orientation

protected int _orientation
Keep track of the orientation; vertical by default.

Constructor Detail

LevelLayout

public LevelLayout(LayoutTarget target)
Construct a new levelizing layout with a vertical orientation.

Method Detail

copyComposite

protected Object copyComposite(Object origComposite)
Copy the given graph and make the nodes/edges in the copied graph point to the nodes/edges in the original.


copyLayout

protected void copyLayout(Object origComposite,
                          Object copyComposite)
Take the layout generated by the core layout algorithm and copy it back into the view of the original composite passed in by the user.


getLocalGraphModel

public BasicGraphModel getLocalGraphModel()
Return the local graph model.


getOrientation

public int getOrientation()
Return the orientation in which the graph is to be layed out, either VERTICAL or HORIZONTAL.


getRandomizedPlacement

public boolean getRandomizedPlacement()
Return whether or not placement will be randomized.


layout

public void layout(Object composite)
Perform the levelizing layout on the given composite in the given target environment. It operates on a copy of the composite and then copies the layout results back into the original view (the given layout target).

Specified by:
layout in interface GlobalLayout
Specified by:
layout in class AbstractGlobalLayout

calculateLayout

public LevelLayout.LevelData calculateLayout(Object composite)
This method performs levelizing layout on the given composite. It figures out the node levels, but doesn't actually layout the composite in the target environment yet. The level information can be accessed through the returned LevelData. This information can be used to size the viewport. The following are the operations performed in this method:

applyLayout

public void applyLayout(LevelLayout.LevelData levelData,
                        Object g)
Place the nodes in the target environment according to their levels and sorting order which are specified in levelData. By default, the dummy nodes are used while doing the layout. This method should be called after calculateLayout(t, g) which returns the levelData used by this method.


applyLayout

public void applyLayout(LevelLayout.LevelData levelData,
                        Object g,
                        boolean useDummies)
Place the nodes in the target environment according to their levels and sorting order which are specified in levelData. If "useDummies" is false, the dummy nodes are not used in the layout which produces a more compact layout: nodes in the same level may overlap and edges may cross over nodes. If "useDummies" is true, the dummy nodes are used in the layout. This method should be called after calculateLayout(t, g) which returns the levelData used by this method.


setOrientation

public void setOrientation(int o)
Set the orientation in which the graph is to be layed out, either VERTICAL or HORIZONTAL.


setRandomizedPlacement

public void setRandomizedPlacement(boolean flag)
Set whether or not placement will be randomized.


setVisited

public void setVisited(Object node,
                       boolean val)

setAllVisited

public void setAllVisited(Object composite,
                          boolean val)

isVisited

public boolean isVisited(Object node)


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.