Search this API

y.layout.hierarchic.incremental
Class SwimLaneDescriptor

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

public class SwimLaneDescriptor
extends Object
implements Comparable, Comparators.PartialOrder

This class is used by HierarchicLayouter during the various phases to associate swim lanes with each node. 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 geometry of the swim lanes will be placed into the instances of this class after the layout.
It can be bound to the layout algorithm using the HierarchicLayouter.SWIMLANE_DESCRIPTOR_DPKEY DataProvider key.
This class is designed as a class to allow for future additions of new getter methods.

See Also:
HierarchicLayouter.SWIMLANE_DESCRIPTOR_DPKEY

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

Constructor Detail

SwimLaneDescriptor

public SwimLaneDescriptor(Comparable clientObject)
Creates a new swim lane descriptor with an associated client object.

Throws:
NullPointerException - if the specified client object is null.
Parameters:
clientObject - an object provided by the client that will be used for determining the order of the lanes.

SwimLaneDescriptor

public SwimLaneDescriptor(Object clientObject,
                          Comparator cmp)
Creates a new swim lane descriptor using the given client object and comparator.

Throws:
NullPointerException - if the specified client object is null or the specified comparator is null but the specified client object is not a Comparable instance.
Parameters:
clientObject - a client object used for sorting the lanes
cmp - a Comparator used for comparing the client objects.
Method Detail

isIndexFixed

public boolean isIndexFixed()
Returns whether the index of this swim lane is fixed or whether the algorithm should try to find the best possible position. The default is true

Returns:
true iff the swim lane's index should not be determined automatically.
See Also:
setIndexFixed(boolean)

setIndexFixed

public void setIndexFixed(boolean fixIndex)
Specifies whether a swim lane's index is fixed (based on the result of the comparison with the other swim lanes) or whether the index should be chosen automatically in order to minimize edge lengths.

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

By default, this feature is enabled.

Parameters:
fixIndex - true iff the swim lane index should not be determined automatically.
See Also:
isIndexFixed()

setClientObject

public void setClientObject(Object o)
Sets the client object.

Throws:
IllegalArgumentException - if there is currently no comparator set and the specified object is not a Comparable instance.
Parameters:
o - the new object
See Also:
getComparator(), setComparator(java.util.Comparator)

getClientObject

public Object getClientObject()
Returns the client object.

Returns:
the client object

setLaneTightness

public void setLaneTightness(double tightness)
Sets the tightness factor of the lane. The greater the value the more will the lane to be forced to be of its minimal possible width. A value of 0.0d will disable compression of the lane. A value of 1.0d will try to force the lane to be of its minimum width.

Throws:
IllegalArgumentException - if tightness is out of the valid range
Parameters:
tightness - the tightness of the lane [0.0d .. 1.0d]

getLaneTightness

public double getLaneTightness()
Returns the tightness factor of the lane. The default is 0.0d.

Returns:
the tightness of the lane [0.0d .. 1.0d]
See Also:
setLaneTightness(double)

setComparator

public void setComparator(Comparator c)
Sets the comparator that is used for sorting the lanes.

Throws:
NullPointerException - if the specified comparator is null.
Parameters:
c - the comparator.

getComparator

public Comparator getComparator()
Returns the comparator that is used for sorting the lanes.


getMinimumLaneWidth

public double getMinimumLaneWidth()
Returns the minimum lane width. The default is 0.0d.

Returns:
the minimum width of a swim lane

setMinimumLaneWidth

public void setMinimumLaneWidth(double laneWidth)
Sets the minimum width of the lane.

Throws:
IllegalArgumentException - if the specified value is less than 0.
Parameters:
laneWidth - the new width.

getLeftLaneInset

public double getLeftLaneInset()
Returns the left lane insets where no element will lie in the resulting drawing. The default is 0.0d.

Returns:
the left insets

getRightLaneInset

public double getRightLaneInset()
Returns the right lane insets where no element will lie in the resulting drawing. The default is 0.0d.

Returns:
the right insets

setLeftLaneInset

public void setLeftLaneInset(double inset)
Sets the left lane insets where no element will lie in the resulting drawing.

Throws:
IllegalArgumentException - if the specified value is less than 0.
Parameters:
inset - the new insets

setRightLaneInset

public void setRightLaneInset(double inset)
Sets the right lane insets where no element will lie in the resulting drawing.

Throws:
IllegalArgumentException - if the specified value is less than 0.
Parameters:
inset - the new insets.

getComputedLanePosition

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

Returns:
the smaller coordinate of the lane

getComputedLaneWidth

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

Returns:
the computed width of the lane

getComputedLaneIndex

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

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

compareTo

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

Specified by:
compareTo in interface Comparable

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