Search this API

y.layout.hierarchic.incremental
Class SwimLaneDescriptor

java.lang.Object
  extended by y.layout.hierarchic.incremental.SwimLaneDescriptor
All Implemented Interfaces:
java.lang.Comparable, Comparators.PartialOrder

public class SwimLaneDescriptor
extends java.lang.Object
implements java.lang.Comparable, Comparators.PartialOrder

This class is used by HierarchicLayouter during the various phases and models a swimlane structure.

For layout orientation LayoutOrientation.TOP_TO_BOTTOM, swimlanes partition the drawing area into vertical stripes. Each node is placed within a user-specified lane. Swimlanes are, for example, often used in flow diagrams to separate logical units.

Each node should be associated with a SwimLaneDescriptor instance; nodes in the same lane may share one instance. The results of the calculation of the swimlanes' geometry will be stored by the instances after the layout.

A SwimLaneDescriptor instance can be bound to the layout algorithm using a DataProvider registered with the graph using key HierarchicLayouter.SWIMLANE_DESCRIPTOR_DPKEY that returns a SwimLaneDescriptor instance for each node of the graph.

 
Class PartitionGrid offers a newer implementation which supports both horizontal and vertical swimlanes.
See Also:
HierarchicLayouter.SWIMLANE_DESCRIPTOR_DPKEY
 

Constructor Summary
SwimLaneDescriptor(java.lang.Comparable clientObject)
          Creates a new SwimLaneDescriptor instance with a given Comparable object.
SwimLaneDescriptor(java.lang.Object clientObject, java.util.Comparator comparator)
          Creates a new SwimLaneDescriptor instance with a given client Object and a given Comparator.
 
Method Summary
 int compareTo(java.lang.Object o)
          Implements the Comparable interface using the getComparator() and getClientObject() fields.
 java.lang.Object getClientObject()
          Returns the client object.
 java.util.Comparator getComparator()
          Returns the Comparator instance used for sorting the lanes.
 int getComputedLaneIndex()
          Returns the computed zero-based index of the swimlane after the layout has been calculated.
 double getComputedLanePosition()
          Returns the computed position (smaller coordinate) of the swimlane after the layout has been calculated.
 double getComputedLaneWidth()
          Returns the computed width of the swimlane after the layout has been calculated.
 double getLaneTightness()
          Returns the tightness factor of the lane.
 double getLeftLaneInset()
          Returns the left insets of the swimlane in which no element will lie in the resulting layout.
 double getMinimumLaneWidth()
          Returns the minimum width of the swimlane.
 double getRightLaneInset()
          Returns the right insets of the swimlane in which no element will lie in the resulting layout.
 boolean isIndexFixed()
          Returns whether or not an index of a swimlane is fixed (based on the result of the comparison with the other swimlanes) or whether the index should be chosen automatically in order to minimize edge lengths.
 void setClientObject(java.lang.Object o)
          Specifies the client object.
 void setComparator(java.util.Comparator comparator)
          Specifies the Comparator instance used for sorting the lanes.
 void setIndexFixed(boolean fixIndex)
          Specifies whether or not an index of a swimlane is fixed (based on the result of the comparison with the other swimlanes) or whether the index should be chosen automatically in order to minimize edge lengths.
 void setLaneTightness(double tightness)
          Specifies the tightness factor of the lane.
 void setLeftLaneInset(double inset)
          Specifies the left insets of the swimlane in which no element will lie in the resulting layout.
 void setMinimumLaneWidth(double laneWidth)
          Specifies the minimum width of the swimlane.
 void setRightLaneInset(double inset)
          Specifies the right insets of the swimlane in which no element will lie in the resulting layout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwimLaneDescriptor

public SwimLaneDescriptor(java.lang.Comparable clientObject)
Creates a new SwimLaneDescriptor instance with a given Comparable object.

Parameters:
clientObject - a Comparable used for determining the order of the lanes
Throws:
java.lang.IllegalArgumentException - if the specified client object is null.

SwimLaneDescriptor

public SwimLaneDescriptor(java.lang.Object clientObject,
                          java.util.Comparator comparator)
Creates a new SwimLaneDescriptor instance with a given client Object and a given Comparator.

The given client Object should be an instance of Comparable if the given Comparator is null.

Parameters:
clientObject - a client Object used for sorting the lanes
comparator - a Comparator used for comparing the client objects
Throws:
java.lang.IllegalArgumentException - if the specified client Object is null or the specified Comparator is null but the specified client Object is not an instance of Comparable.
Method Detail

isIndexFixed

public boolean isIndexFixed()
Returns whether or not an index of a swimlane is fixed (based on the result of the comparison with the other swimlanes) or whether the index should be chosen automatically in order to minimize edge lengths.

For all swimlanes where this property is set to true, the relative ordering given by the client objects is preserved. The remaining swimlanes may be sorted again so that the overall edge lengths are minimized.

Returns:
true if the swimlane index are determined automatically, false otherwise
See Also:
setIndexFixed(boolean)

setIndexFixed

public void setIndexFixed(boolean fixIndex)
Specifies whether or not an index of a swimlane is fixed (based on the result of the comparison with the other swimlanes) or whether the index should be chosen automatically in order to minimize edge lengths.

For all swimlanes where this property is set to true, the relative ordering given by the client objects is preserved. The remaining swimlanes may be sorted again so that the overall edge lengths are minimized.

Default Value:
The default value is true. The index of the swimlane will not be determined automatically.
Parameters:
fixIndex - true if the swimlane index should not be determined automatically, false otherwise

setClientObject

public void setClientObject(java.lang.Object o)
Specifies the client object.

The given client Object should be an instance of Comparable.

Parameters:
o - the given client Object
Throws:
java.lang.IllegalArgumentException - if there is currently no comparator and the specified object is not a Comparable instance or if the given client object is null
See Also:
getComparator(), setComparator(java.util.Comparator)

getClientObject

public java.lang.Object getClientObject()
Returns the client object.

The given client Object is an instance of Comparable.

Returns:
the given client Object
See Also:
setClientObject(Object), getComparator(), setComparator(java.util.Comparator)

setLaneTightness

public void setLaneTightness(double tightness)
Specifies the tightness factor of the lane.

This value should lie within [0,1] interval.

The greater the value, the more will the lane be forced to obtain its minimum possible width.

Default Value:
The default value is 0.0d. Swimlane will not be compressed.
Parameters:
tightness - a tightness value from [0,1] interval
Throws:
java.lang.IllegalArgumentException - if the tightness value is outside [0,1] interval

getLaneTightness

public double getLaneTightness()
Returns the tightness factor of the lane.

This value should lie within [0,1] interval.

The greater the value, the more will the lane be forced to obtain its minimum possible width.

Returns:
a tightness value from [0,1] interval
See Also:
setLaneTightness(double)

setComparator

public void setComparator(java.util.Comparator comparator)
Specifies the Comparator instance used for sorting the lanes.

Parameters:
comparator - the given Comparator instance
Throws:
java.lang.IllegalArgumentException - if the specified Comparator is null.

getComparator

public java.util.Comparator getComparator()
Returns the Comparator instance used for sorting the lanes.

Returns:
the current Comparator instance
See Also:
setComparator(Comparator)

getMinimumLaneWidth

public double getMinimumLaneWidth()
Returns the minimum width of the swimlane.

The minimum width should be non-negative.

Returns:
the minimum width
See Also:
setMinimumLaneWidth(double)

setMinimumLaneWidth

public void setMinimumLaneWidth(double laneWidth)
Specifies the minimum width of the swimlane.

The minimum width should be non-negative.

Default Value:
The default value is 0.0d.
Parameters:
laneWidth - the given minimum width
Throws:
java.lang.IllegalArgumentException - if the specified value negative
Sample Graphs:

Minimum swimlane width 0.0d

Minimum swimlane width 100.0d

getLeftLaneInset

public double getLeftLaneInset()
Returns the left insets of the swimlane in which no element will lie in the resulting layout.

The inset should be non-negative.

Returns:
the current left insets
See Also:
setLeftLaneInset(double)

getRightLaneInset

public double getRightLaneInset()
Returns the right insets of the swimlane in which no element will lie in the resulting layout.

The inset should be non-negative.

Returns:
the current right insets
See Also:
setRightLaneInset(double)

setLeftLaneInset

public void setLeftLaneInset(double inset)
Specifies the left insets of the swimlane in which no element will lie in the resulting layout.

The inset should be non-negative.

Default Value:
The default value is 0.0d.
Parameters:
inset - the given left insets
Throws:
java.lang.IllegalArgumentException - if the specified value is less than 0.
Sample Graphs:

Minimum left inset 5.0d

Minimum left inset 100.0d

setRightLaneInset

public void setRightLaneInset(double inset)
Specifies the right insets of the swimlane in which no element will lie in the resulting layout.

The inset should be non-negative.

Default Value:
The default value is 0.0d.
Parameters:
inset - the given right insets
Throws:
java.lang.IllegalArgumentException - if the specified value is less than 0.
Sample Graphs:

Minimum right inset 5.0d

Minimum right inset 100.0d

getComputedLanePosition

public double getComputedLanePosition()
Returns the computed position (smaller coordinate) of the swimlane after the layout has been calculated.

Returns:
the smaller coordinate of the swimlane

getComputedLaneWidth

public double getComputedLaneWidth()
Returns the computed width of the swimlane after the layout has been calculated.

Returns:
the computed width of the swimlane

getComputedLaneIndex

public int getComputedLaneIndex()
Returns the computed zero-based index of the swimlane after the layout has been calculated.

Returns:
the computed lane index or -1 if no index has been computed for this lane.

compareTo

public int compareTo(java.lang.Object o)
Implements the Comparable interface using the getComparator() and getClientObject() fields.

Specified by:
compareTo in interface java.lang.Comparable

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