Search this API

y.layout.organic
Class OrganicLayouter

java.lang.Object
  extended by y.layout.CanonicMultiStageLayouter
      extended by 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()
          Returns the current attraction.
 double getFinalTemperature()
          Returns the final temperature.
 double getGravityFactor()
          Returns the gravity factor.
 GroupBoundsCalculator getGroupBoundsCalculator()
          Returns the GroupBoundsCalculator instance that is used for the calculation of the group nodes' bounds if a hierarchically grouped graph is being laid out.
 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()
          Returns the initial temperature.
 double getIterationFactor()
          Returns the iteration factor of this layouter.
 long getMaximumDuration()
          Returns the maximum 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()
          Returns the current repulsion.
 byte getSphereOfAction()
          Returns the sphere of action for this layouter.
 void setActivateDeterministicMode(boolean activate)
          Specifies whether or not this layouter should work in a deterministic mode.
 void setActivateTreeBeautifier(boolean activate)
          Specifies whether or not to activate the subtree beautifier.
 void setAttraction(int attraction)
          Sets the current attraction.
 void setFinalTemperature(double finalTemperature)
          Sets the final temperature.
 void setGravityFactor(double factor)
          Sets the gravity factor.
 void setGroupBoundsCalculator(GroupBoundsCalculator groupBoundsCalculator)
          Sets the instance used for the calculation of the group nodes' bounds if a hierarchically grouped graph is being laid out.
 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)
          Specifies the initial temperature.
 void setIterationFactor(double factor)
          Sets the iteration factor of this layouter.
 void setMaximumDuration(long msec)
          Sets the maximum duration granted to this layouter.
 void setObeyNodeSize(boolean obey)
          Specifies whether or not node sizes should be considered by this layouter.
 void setPreferredEdgeLength(int edgeLength)
          Sets the general edge length that should be attained by this layouter.
 void setRepulsion(int repulsion)
          Sets the current repulsion.
 void setSphereOfAction(byte p)
          Sets the sphere of action for this layouter.
 
Methods inherited from class y.layout.CanonicMultiStageLayouter
appendStage, calcLayout, calcLayout, canLayout, checkGroupNodeSize, checkNodeSize, 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 data provider 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), 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 data provider key is registered with the LayoutGraph, then its associated data provider 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), setGroupNodePolicy(byte), FIXED_GROUPS_POLICY

RANDOM

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

See Also:
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:
setInitialPlacement(byte), Constant Field Values

AS_IS

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

See Also:
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:
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 SPHERE_OF_ACTION_NODES returns true for that node.

See Also:
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 SPHERE_OF_ACTION_NODES returns true for that node.

See Also:
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 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 data provider 
   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()
Returns the current repulsion.


setRepulsion

public void setRepulsion(int repulsion)
Sets the current repulsion.


getAttraction

public int getAttraction()
Returns the current attraction.


setAttraction

public void setAttraction(int attraction)
Sets the current attraction.

Parameters:
attraction - a value in [0,2].

getGroupBoundsCalculator

public GroupBoundsCalculator getGroupBoundsCalculator()
Returns the GroupBoundsCalculator instance that is used for the calculation of the group nodes' bounds if a hierarchically grouped graph is being laid out. By default a MinimumSizeGroupBoundsCalculator instance is registered with this instance.

Returns:
Value of property groupBoundsCalculator.

setGroupBoundsCalculator

public void setGroupBoundsCalculator(GroupBoundsCalculator groupBoundsCalculator)
Sets the instance used for the calculation of the group nodes' bounds if a hierarchically grouped graph is being laid out.

Parameters:
groupBoundsCalculator - the new instance

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.

Throws:
IllegalArgumentException - if compactness value does not lie in [0..1]
Parameters:
groupNodeCompactness - the new value.

getGroupNodePolicy

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

Returns:
one of FIXED_GROUPS_POLICY, LAYOUT_GROUPS_POLICY, or IGNORE_GROUPS_POLICY

setGroupNodePolicy

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


getInitialTemperature

public double getInitialTemperature()
Returns the initial temperature. The temperature will be multiplied with the preferredEdgeLength and then assigned as the initial node heat.

The default is 0.1d.


setInitialTemperature

public void setInitialTemperature(double initialTemperature)
Specifies the initial temperature. The temperature will be multiplied with the preferredEdgeLength and then assigned as the initial node heat.

The default is 0.1d.


getFinalTemperature

public double getFinalTemperature()
Returns the final temperature. 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)
Sets the final temperature. 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)
Specifies 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:
setActivateDeterministicMode(boolean)

setActivateTreeBeautifier

public void setActivateTreeBeautifier(boolean activate)
Specifies 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:
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:
setGravityFactor(double)

setSphereOfAction

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

The default value is ALL.

See Also:
SPHERE_OF_ACTION_NODES

getSphereOfAction

public byte getSphereOfAction()
Returns the sphere of action for this layouter.

The default value is ALL.


setInitialPlacement

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

The default value is AS_IS.


getInitialPlacement

public byte getInitialPlacement()
Returns the initial placement strategy.

The default value is AS_IS.


setMaximumDuration

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


getMaximumDuration

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


setIterationFactor

public void setIterationFactor(double factor)
Sets the iteration factor of this layouter. 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:
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)
Specifies whether or not node sizes should be considered by this layouter. If you want to layout a diagram with big nodes in it you can reduce node overlaps by setting this feature to true.

Defaults 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-2013,
yWorks GmbH.
All rights reserved.