Search this API

y.layout.hierarchic.incremental
Class DefaultLayerSequencer

java.lang.Object
  extended by y.layout.hierarchic.incremental.DefaultLayerSequencer
All Implemented Interfaces:
Sequencer

public class DefaultLayerSequencer
extends Object
implements Sequencer

This class implements the second phase of the Sugiyama algorithm. It minimizes the crossings in the diagram by using either the barycentric or median heuristic.


Field Summary
static byte BARYCENTER_HEURISTIC
          Weight assignment heuristic specifier.
static byte MEDIAN_HEURISTIC
          Weight assignment heuristic specifier.
 
Constructor Summary
DefaultLayerSequencer()
           
 
Method Summary
 long getMaximalDuration()
          Returns the proposed maximal duration for the calculation of the sequence.
 int getRandomizationRounds()
          Returns the number of randomized rounds this algorithm will try if there was no optimal solution.
 byte getWeightHeuristic()
          Returns the currently set weight heuristic.
 boolean isGroupTranspositionEnabled()
          Returns whether or not the group transposition heuristic should be used.
 boolean isTranspositionEnabled()
          Returns whether or not the transposition crossing minimization heuristic should be used.
 void sequenceNodeLayers(LayoutGraph graph, Layers glayers, LayoutDataProvider ldp, ItemFactory itemFactory)
          Called by HierarchicLayouter during the second phase.
 void setGroupTranspositionEnabled(boolean b)
          Specifies whether or not an additional crossing minimization heuristic should be used in the presence of grouped graphs.
 void setMaximalDuration(long msec)
          Sets the maximum amount of time granted for this sequencer per execution.
 void setRandomizationRounds(int randomizationRounds)
          Sets the number of additional rounds the algorithm will restart with randomized solutions as long as there might be a better solution to the current best.
 void setTranspositionEnabled(boolean b)
          Specifies whether or not an additional crossing minimization heuristic should be used.
 void setWeightHeuristic(byte h)
          Sets the weight heuristic to be used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BARYCENTER_HEURISTIC

public static final byte BARYCENTER_HEURISTIC
Weight assignment heuristic specifier. A node position within a layer will be determined by the barycenter of its successor (downward pass) and predecessor (upward pass) nodes.

See Also:
Constant Field Values

MEDIAN_HEURISTIC

public static final byte MEDIAN_HEURISTIC
Weight assignment heuristic specifier. A node position within a layer will be determined by the median position of its successor (downward pass) and predecessor (upward pass) nodes.

See Also:
Constant Field Values
Constructor Detail

DefaultLayerSequencer

public DefaultLayerSequencer()
Method Detail

setTranspositionEnabled

public void setTranspositionEnabled(boolean b)
Specifies whether or not an additional crossing minimization heuristic should be used. Activating this heuristic can reduce the overall number of edge crossings. On the other hand its activation increases running time.

By default the transposition rule is active.

Parameters:
b - whether to use the heuristic

isTranspositionEnabled

public boolean isTranspositionEnabled()
Returns whether or not the transposition crossing minimization heuristic should be used.

Returns:
whether the heuristic is active
See Also:
setTranspositionEnabled(boolean)

setGroupTranspositionEnabled

public void setGroupTranspositionEnabled(boolean b)
Specifies whether or not an additional crossing minimization heuristic should be used in the presence of grouped graphs. Activating this heuristic can reduce the overall number of edge crossings in grouped graphs. On the other hand its activation increases running time.

By default the transposition rule is not active.

Parameters:
b - whether to use the heuristic

isGroupTranspositionEnabled

public boolean isGroupTranspositionEnabled()
Returns whether or not the group transposition heuristic should be used.

Returns:
whether the heuristic is active
See Also:
setGroupTranspositionEnabled(boolean)

setWeightHeuristic

public void setWeightHeuristic(byte h)
Sets the weight heuristic to be used. By default BARYCENTER_HEURISTIC is set.

Throws:
IllegalArgumentException - if the constant is unknown
Parameters:
h - one of BARYCENTER_HEURISTIC and MEDIAN_HEURISTIC.

getWeightHeuristic

public byte getWeightHeuristic()
Returns the currently set weight heuristic.

Returns:
a byte constant as defined in this class
See Also:
setWeightHeuristic(byte)

getMaximalDuration

public long getMaximalDuration()
Returns the proposed maximal duration for the calculation of the sequence. The default is 10000

Returns:
the time allowed for retrying in milliseconds

getRandomizationRounds

public int getRandomizationRounds()
Returns the number of randomized rounds this algorithm will try if there was no optimal solution.

Returns:
the number of rounds. Default is 50.

setRandomizationRounds

public void setRandomizationRounds(int randomizationRounds)
Sets the number of additional rounds the algorithm will restart with randomized solutions as long as there might be a better solution to the current best.

Parameters:
randomizationRounds - the new number of additional rounds

setMaximalDuration

public void setMaximalDuration(long msec)
Sets the maximum amount of time granted for this sequencer per execution.

Parameters:
msec - granted time in milliseconds

sequenceNodeLayers

public void sequenceNodeLayers(LayoutGraph graph,
                               Layers glayers,
                               LayoutDataProvider ldp,
                               ItemFactory itemFactory)
Description copied from interface: Sequencer
Called by HierarchicLayouter during the second phase. Calculates a sequence of the nodes in layers and finally writes back the calculated sequence using the Layer.setNodeOrder(y.base.YList) method.

Specified by:
sequenceNodeLayers in interface Sequencer
Parameters:
graph - the graph that contains the elements from layers
glayers - the Layer implementation that holds the Layers for sequencing
ldp - the LayoutDataProvider that provides the necessary NodeData and EdgeData
itemFactory - an ItemFactory implementation that can be used to modify the graph consistently

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