y.layout.organic
Class OrganicLayouter

java.lang.Object
  |
  +--y.layout.CanonicMultiStageLayouter
        |
        +--y.layout.organic.OrganicLayouter
All Implemented Interfaces:
Layouter

public class OrganicLayouter
extends CanonicMultiStageLayouter

A graph layout algorithm that is based on a force directed model.

Here is a sample output of the layouter:


Field Summary
static byte ALL
          Sphere of action specifier.
static byte AS_IS
          Initial placement strategy.
static Object FIXED_GROUP_NODES_DPKEY
          DataProvider key used in conjunction with hierarchically grouped graphs.
static byte FIXED_GROUPS_POLICY
          Node group policy specifier.
static byte IGNORE_GROUPS_POLICY
          Node group policy specifier.
static byte LAYOUT_GROUPS_POLICY
          Node group policy specifier.
static byte MAINLY_SELECTION
          Sphere of action specifier.
static byte ONLY_SELECTION
          Sphere of action specifier.
static Object PREFERRED_EDGE_LENGTH_DATA
          Key used to associate a DataProvider with a LayoutGraph.
static byte RANDOM
          Initial placement strategy.
static Object SPHERE_OF_ACTION_NODES
          DataProvider key used in conjunction with the sphere-of-action feature.
static byte ZERO
          Initial placement strategy.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
OrganicLayouter()
          Returns a new organic Layouter.
 
Method Summary
 boolean canLayoutCore(LayoutGraph graph)
          Returns always true because this algorithms has no preconditions.
 void dispose()
          Frees resources
 void doLayoutCore(LayoutGraph graph)
          Invokes the core layout algorithm.
 boolean getActivateDeterministicMode()
          Returns whether or not this layouter is in deterministic mode.
 boolean getActivateTreeBeautifier()
          Returns whether or not to activate the subtree beautifier.
 int getAttraction()
          Getter for property attraction.
 double getFinalTemperature()
          Getter for property finalTemperature.
 double getGravityFactor()
          Returns the gravity factor.
 GroupBoundsCalculator getGroupBoundsCalculator()
          Getter for property groupBoundsCalculator.
 double getGroupNodeCompactness()
          Returns the group node compactness factor.
 byte getGroupNodePolicy()
          Returns the policy for group nodes.
 byte getInitialPlacement()
          Returns the initial placement strategy.
 double getInitialTemperature()
          Getter for property initialTemperature.
 double getIterationFactor()
          Returns the iteration factor of this layouter.
 long getMaximumDuration()
          Returns the maximal duration granted to this layouter
 boolean getObeyNodeSize()
          Returns whether or not node sizes should be considered by this layouter.
 int getPreferredEdgeLength()
          Returns the general edge length that should be attained by this layouter
 int getRepulsion()
          Getter for property repulsion.
 byte getSphereOfAction()
          Returns the sphere of action for this layouter.
 void setActivateDeterministicMode(boolean activate)
          Whether or not this layouter should work in a deterministic mode.
 void setActivateTreeBeautifier(boolean activate)
          Whether or not to activate the subtree beautifier.
 void setAttraction(int attraction)
          Setter for property attraction.
 void setFinalTemperature(double finalTemperature)
          Setter for property finalTemperature.
 void setGravityFactor(double factor)
          Sets the gravity factor.
 void setGroupBoundsCalculator(GroupBoundsCalculator groupBoundsCalculator)
          Setter for property groupBoundsCalculator.
 void setGroupNodeCompactness(double groupNodeCompactness)
          Sets the compactness of group nodes.
 void setGroupNodePolicy(byte groupNodePolicy)
          Sets the policy for group nodes.
 void setInitialPlacement(byte p)
          Sets the initial placement strategy.
 void setInitialTemperature(double initialTemperature)
          Setter for property initialTemperature.
 void setIterationFactor(double factor)
          Sets the iteration factor.
 void setMaximumDuration(long msec)
          Sets the maximal duration granted to this layouter.
 void setObeyNodeSize(boolean obey)
          Whether or not the node sizes should be considered by this layouter.
 void setPreferredEdgeLength(int edgeLength)
          Sets the general edge length that should be attained by this layouter By default an edge length of 80 is set.
 void setRepulsion(int repulsion)
          Setter for property repulsion.
 void setSphereOfAction(byte p)
          Sets the sphere of action for this layouter.
 
Methods inherited from class y.layout.CanonicMultiStageLayouter
appendStage, calcLayout, calcLayout, canLayout, doLayout, doLayout, enableOnlyCore, getComponentLayouter, getGroupNodeHider, getLabelLayouter, getLayoutOrientation, getOrientationLayouter, getParallelEdgeLayouter, getSelfLoopLayouter, getSubgraphLayouter, isComponentLayouterEnabled, isGroupNodeHidingEnabled, isLabelLayouterEnabled, isOrientationLayouterEnabled, isParallelEdgeLayouterEnabled, isSelfLoopLayouterEnabled, isSubgraphLayouterEnabled, prependStage, removeStage, setComponentLayouter, setComponentLayouterEnabled, setGroupNodeHider, setGroupNodeHidingEnabled, setLabelLayouter, setLabelLayouterEnabled, setLayoutOrientation, setOrientationLayouter, setOrientationLayouterEnabled, setParallelEdgeLayouter, setParallelEdgeLayouterEnabled, setSelfLoopLayouter, setSelfLoopLayouterEnabled, setSubgraphLayouter, setSubgraphLayouterEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPHERE_OF_ACTION_NODES

public static final Object SPHERE_OF_ACTION_NODES
DataProvider key used in conjunction with the sphere-of-action feature. If this dataprovider key is being used, then it must return for each node in the input graph a boolean value indicating whether or not it should be handled by this layouter.

See Also:
Graph.addDataProvider(Object, DataProvider), OrganicLayouter.setSphereOfAction(byte)

FIXED_GROUP_NODES_DPKEY

public static final Object FIXED_GROUP_NODES_DPKEY
DataProvider key used in conjunction with hierarchically grouped graphs. If this dataprovider key is registered with the LayoutGraph, then its associated dataprovider must return for each group node node in the input graph a boolean value indicating whether its contents/children should be treated as fixed or not.

See Also:
Graph.addDataProvider(Object, DataProvider), OrganicLayouter.setGroupNodePolicy(byte), OrganicLayouter.FIXED_GROUPS_POLICY

RANDOM

public static final byte RANDOM
Initial placement strategy. Start with randomly chosen positions.

See Also:
OrganicLayouter.setInitialPlacement(byte), Constant Field Values

ZERO

public static final byte ZERO
Initial placement strategy. Start with all positions set to (0,0,0).

See Also:
OrganicLayouter.setInitialPlacement(byte), Constant Field Values

AS_IS

public static final byte AS_IS
Initial placement strategy. Start with given positions.

See Also:
OrganicLayouter.setInitialPlacement(byte), Constant Field Values

LAYOUT_GROUPS_POLICY

public static final byte LAYOUT_GROUPS_POLICY
Node group policy specifier. This layouter will consider grouping information of an input graph. It will layout the contents of groups in a way that highlights their togetherness.

See Also:
Constant Field Values

FIXED_GROUPS_POLICY

public static final byte FIXED_GROUPS_POLICY
Node group policy specifier. This layouter will keep the relative positions of nodes that belong to the same group. The layouter will take the fixed groups into account when placing the other nodes of the graph.

See Also:
Constant Field Values

IGNORE_GROUPS_POLICY

public static final byte IGNORE_GROUPS_POLICY
Node group policy specifier. This layouter will ignore all grouping related information when laying out the graph.

See Also:
Constant Field Values

ALL

public static final byte ALL
Sphere of action specifier. Displace all nodes.

See Also:
OrganicLayouter.setSphereOfAction(byte), Constant Field Values

MAINLY_SELECTION

public static final byte MAINLY_SELECTION
Sphere of action specifier. Displace mainly selected nodes, but allow minor movement of unselected nodes as well. A node is considered to be selected if the LayoutGraph DataProvider registered with the key OrganicLayouter.SPHERE_OF_ACTION_NODES returns true for that node.

See Also:
OrganicLayouter.setSphereOfAction(byte), Constant Field Values

ONLY_SELECTION

public static final byte ONLY_SELECTION
Sphere of action specifier. Displace only selected nodes A node is considered to be selected if the LayoutGraph DataProvider registered with the key OrganicLayouter.SPHERE_OF_ACTION_NODES returns true for that node.

See Also:
OrganicLayouter.setSphereOfAction(byte), Constant Field Values

PREFERRED_EDGE_LENGTH_DATA

public static final Object PREFERRED_EDGE_LENGTH_DATA
Key used to associate a DataProvider with a LayoutGraph. The associated DataProvider must return an int values for each edge of the LayoutGraph. The value returned for a specific edge will be interpreted as its preferred edge length.

If a DataProvider is bound to this key, then the global preferredEdgeLength for all edges (see OrganicLayouter.setPreferredEdgeLength(int)) will be ignored.

Example: Assuming that a method int getWeight(Edge) is provided that returns for each edge a double value between 0.0 and 1.0, then these edge weights can be translated to edge length preferences between 0 and 200 that the OrganicLayouter tries to obey.

   import y.util.DataProviderAdapter;
 
   //define an adequate dataprovider 
   DataProviderAdapter edgeLengthData = new DataProviderAdapter() {
     public int getInt(Object o) {
       return (int)(200*getWeight((Edge)o));
     }
   }
 
   LayoutGraph graph = ...;
   OrganicLayouter layouter = ...;

   //register the data provider 
   graph.addDataProvider(PREFERRED_EDGE_LENGTH_DATA, edgeLengthData);

   //launch the layouter
   layouter.doLayout(graph);
 

Constructor Detail

OrganicLayouter

public OrganicLayouter()
Returns a new organic Layouter.

Method Detail

getRepulsion

public int getRepulsion()
Getter for property repulsion.

Returns:
Value of property repulsion.

setRepulsion

public void setRepulsion(int repulsion)
Setter for property repulsion.

Parameters:
repulsion - New value of property repulsion.

getAttraction

public int getAttraction()
Getter for property attraction.

Returns:
Value of property attraction.

setAttraction

public void setAttraction(int attraction)
Setter for property attraction.

Parameters:
attraction - New value of property attraction.

getGroupBoundsCalculator

public GroupBoundsCalculator getGroupBoundsCalculator()
Getter for property groupBoundsCalculator.

Returns:
Value of property groupBoundsCalculator.

setGroupBoundsCalculator

public void setGroupBoundsCalculator(GroupBoundsCalculator groupBoundsCalculator)
Setter for property groupBoundsCalculator.

Parameters:
groupBoundsCalculator - New value of property groupBoundsCalculator.

getGroupNodeCompactness

public double getGroupNodeCompactness()
Returns the group node compactness factor.


setGroupNodeCompactness

public void setGroupNodeCompactness(double groupNodeCompactness)
Sets the compactness of group nodes. Values should be in the range [0..1], where 0 results in group nodes not affecting the overall layout too much, whereas a value of 1 forces nodes in the same group to be clustered tightly.

Parameters:
groupNodeCompactness - the new value.

getGroupNodePolicy

public byte getGroupNodePolicy()
Returns the policy for group nodes. This policy controls the behaviour of this layouter when acting on hierarchically grouped graphs. The default is OrganicLayouter.LAYOUT_GROUPS_POLICY.

Returns:
one of OrganicLayouter.FIXED_GROUPS_POLICY, OrganicLayouter.LAYOUT_GROUPS_POLICY, or OrganicLayouter.IGNORE_GROUPS_POLICY

setGroupNodePolicy

public void setGroupNodePolicy(byte groupNodePolicy)
Sets the policy for group nodes. This policy controls the behaviour of this layouter when acting on hierarchically grouped graphs. This should be one of OrganicLayouter.FIXED_GROUPS_POLICY, OrganicLayouter.LAYOUT_GROUPS_POLICY, or OrganicLayouter.IGNORE_GROUPS_POLICY.


getInitialTemperature

public double getInitialTemperature()
Getter for property initialTemperature. The temperature is multiplied with the preferredEdgeLength and then assigned as the initial node heat. The default is 0.1d.

Returns:
Value of property initialTemperature.

setInitialTemperature

public void setInitialTemperature(double initialTemperature)
Setter for property initialTemperature. The temperature will be multiplied with the preferredEdgeLength and then assigned as the initial node heat. The default is 0.1d.

Parameters:
initialTemperature - New value of property initialTemperature.

getFinalTemperature

public double getFinalTemperature()
Getter for property finalTemperature. This is an absolute temperature. If the average temperature falls under this value, the layout process comes to a halt. The default is 1.0d.

Returns:
Value of property finalTemperature.

setFinalTemperature

public void setFinalTemperature(double finalTemperature)
Setter for property finalTemperature. This is an absolute temperature. If the average temperature falls under this value, the layout process comes to a halt. The default is 1.0d.

Parameters:
finalTemperature - New value of property finalTemperature.

setActivateDeterministicMode

public void setActivateDeterministicMode(boolean activate)
Whether or not this layouter should work in a deterministic mode. In a deterministic mode this layouter produces the same layouts for the same input graph and layout parameters.

By default deterministic mode is inactive


getActivateDeterministicMode

public boolean getActivateDeterministicMode()
Returns whether or not this layouter is in deterministic mode.

See Also:
OrganicLayouter.setActivateDeterministicMode(boolean)

setActivateTreeBeautifier

public void setActivateTreeBeautifier(boolean activate)
Whether or not to activate the subtree beautifier. Activating this feature lays out subtrees within the given graph structure in an optimized way.

By default this feature is inactive


getActivateTreeBeautifier

public boolean getActivateTreeBeautifier()
Returns whether or not to activate the subtree beautifier.

See Also:
OrganicLayouter.setActivateTreeBeautifier(boolean)

setGravityFactor

public void setGravityFactor(double factor)
Sets the gravity factor. The magnitude of the gravity factor determines the strength of the force towards the barycenter of the graph. A high factor layout tends to cluster nodes around the barycenter of the graph. A low factor stretches the outskirts of the graph far away from the center. By default a value of 0.0 is assumed.


getGravityFactor

public double getGravityFactor()
Returns the gravity factor.

See Also:
OrganicLayouter.setGravityFactor(double)

setSphereOfAction

public void setSphereOfAction(byte p)
Sets the sphere of action for this layouter.

See Also:
OrganicLayouter.SPHERE_OF_ACTION_NODES

getSphereOfAction

public byte getSphereOfAction()
Returns the sphere of action for this layouter. The default value is OrganicLayouter.ALL


setInitialPlacement

public void setInitialPlacement(byte p)
Sets the initial placement strategy.


getInitialPlacement

public byte getInitialPlacement()
Returns the initial placement strategy. The default value is OrganicLayouter.AS_IS


setMaximumDuration

public void setMaximumDuration(long msec)
Sets the maximal duration granted to this layouter.


getMaximumDuration

public long getMaximumDuration()
Returns the maximal duration granted to this layouter


setIterationFactor

public void setIterationFactor(double factor)
Sets the iteration factor. A higher iteration factor usually means better layout results and longer running times. By default an iteration factor of 3 is set.


getIterationFactor

public double getIterationFactor()
Returns the iteration factor of this layouter.

See Also:
OrganicLayouter.setIterationFactor(double)

setPreferredEdgeLength

public void setPreferredEdgeLength(int edgeLength)
Sets the general edge length that should be attained by this layouter By default an edge length of 80 is set.


getPreferredEdgeLength

public int getPreferredEdgeLength()
Returns the general edge length that should be attained by this layouter


setObeyNodeSize

public void setObeyNodeSize(boolean obey)
Whether or not the node sizes should be considered by this layouter. If you want to layout a diagramm with big nodes in it you can reduce node overlaps by setting this feature to true.


getObeyNodeSize

public boolean getObeyNodeSize()
Returns whether or not node sizes should be considered by this layouter.


canLayoutCore

public boolean canLayoutCore(LayoutGraph graph)
Returns always true because this algorithms has no preconditions.

Specified by:
canLayoutCore in class CanonicMultiStageLayouter
Returns:
true

doLayoutCore

public void doLayoutCore(LayoutGraph graph)
Invokes the core layout algorithm.

Specified by:
doLayoutCore in class CanonicMultiStageLayouter

dispose

public void dispose()
Frees resources


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

2003