edu.uci.ics.jung.algorithms.layout
Class KKLayout<V,E>

java.lang.Object
  extended by edu.uci.ics.jung.algorithms.layout.AbstractLayout<V,E>
      extended by edu.uci.ics.jung.algorithms.layout.KKLayout<V,E>
All Implemented Interfaces:
Layout<V,E>, IterativeContext, org.apache.commons.collections15.Transformer<V,Point2D>

public class KKLayout<V,E>
extends AbstractLayout<V,E>
implements IterativeContext

Implements the Kamada-Kawai algorithm for node layout. Does not respect filter calls, and sometimes crashes when the view changes to it.

Author:
Masanori Harada
See Also:
"Tomihisa Kamada and Satoru Kawai: An algorithm for drawing general indirect graphs. Information Processing Letters 31(1):7-15, 1989", "Tomihisa Kamada: On visualization of abstract objects and relations. Ph.D. dissertation, Dept. of Information Science, Univ. of Tokyo, Dec. 1988."

Field Summary
protected  double diameter
          The diameter of the visible graph.
protected  Distance<V> distance
          Retrieves graph distances between vertices of the visible graph
 
Fields inherited from class edu.uci.ics.jung.algorithms.layout.AbstractLayout
graph, initialized, locations, size
 
Constructor Summary
KKLayout(Graph<V,E> g)
          Creates an instance for the specified graph.
KKLayout(Graph<V,E> g, Distance<V> distance)
          Creates an instance for the specified graph and distance metric.
 
Method Summary
 void adjustForGravity()
          Shift all vertices so that the center of gravity is located at the center of the screen.
 boolean done()
          Returns true once the current iteration has passed the maximum count.
 boolean getAdjustForGravity()
          Returns true if gravity point adjusting is enabled.
 boolean getExchangeVertices()
          Returns true if the local minimum escape technique by exchanging vertices is enabled.
 String getStatus()
          Returns a string with information about the current status of the algorithm.
 void initialize()
          Initializes fields in the node that may not have been set during the constructor.
 boolean isIncremental()
          This one is an incremental visualization.
 void reset()
           
 void setAdjustForGravity(boolean on)
          Enable or disable gravity point adjusting.
 void setDisconnectedDistanceMultiplier(double disconnected_multiplier)
          Sets a multiplicative factor that specifies the fraction of the graph's diameter to be used as the inter-vertex distance between disconnected vertices.
 void setExchangeVertices(boolean on)
          Enable or disable the local minimum escape technique by exchanging vertices.
 void setLengthFactor(double length_factor)
          Sets a multiplicative factor which partly specifies the "preferred" length of an edge (L).
 void setMaxIterations(int maxIterations)
          Sets the maximum number of iterations.
 void setSize(Dimension size)
          When a visualization is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data.
 void step()
          Advances one step.
 
Methods inherited from class edu.uci.ics.jung.algorithms.layout.AbstractLayout
getGraph, getSize, getX, getY, isLocked, lock, lock, offsetVertex, setGraph, setInitializer, setLocation, setLocation, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

distance

protected Distance<V> distance
Retrieves graph distances between vertices of the visible graph


diameter

protected double diameter
The diameter of the visible graph. In other words, the maximum over all pairs of vertices of the length of the shortest path between a and bf the visible graph.

Constructor Detail

KKLayout

public KKLayout(Graph<V,E> g)
Creates an instance for the specified graph.


KKLayout

public KKLayout(Graph<V,E> g,
                Distance<V> distance)
Creates an instance for the specified graph and distance metric.

Method Detail

setLengthFactor

public void setLengthFactor(double length_factor)
Sets a multiplicative factor which partly specifies the "preferred" length of an edge (L).


setDisconnectedDistanceMultiplier

public void setDisconnectedDistanceMultiplier(double disconnected_multiplier)
Sets a multiplicative factor that specifies the fraction of the graph's diameter to be used as the inter-vertex distance between disconnected vertices.


getStatus

public String getStatus()
Returns a string with information about the current status of the algorithm.


setMaxIterations

public void setMaxIterations(int maxIterations)
Sets the maximum number of iterations.


isIncremental

public boolean isIncremental()
This one is an incremental visualization.


done

public boolean done()
Returns true once the current iteration has passed the maximum count.

Specified by:
done in interface IterativeContext

initialize

public void initialize()
Description copied from interface: Layout
Initializes fields in the node that may not have been set during the constructor. Must be called before the iterations begin.

Specified by:
initialize in interface Layout<V,E>

step

public void step()
Description copied from interface: IterativeContext
Advances one step.

Specified by:
step in interface IterativeContext

adjustForGravity

public void adjustForGravity()
Shift all vertices so that the center of gravity is located at the center of the screen.


setSize

public void setSize(Dimension size)
Description copied from class: AbstractLayout
When a visualization is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data. The current method calls initializeLocations followed by initialize_local.

Specified by:
setSize in interface Layout<V,E>
Overrides:
setSize in class AbstractLayout<V,E>

setAdjustForGravity

public void setAdjustForGravity(boolean on)
Enable or disable gravity point adjusting.


getAdjustForGravity

public boolean getAdjustForGravity()
Returns true if gravity point adjusting is enabled.


setExchangeVertices

public void setExchangeVertices(boolean on)
Enable or disable the local minimum escape technique by exchanging vertices.


getExchangeVertices

public boolean getExchangeVertices()
Returns true if the local minimum escape technique by exchanging vertices is enabled.


reset

public void reset()
Specified by:
reset in interface Layout<V,E>


Copyright © 2009. All Rights Reserved.