Search this API

y.layout.router.polyline
Class AbstractSegmentInfo

java.lang.Object
  extended by y.layout.router.polyline.AbstractSegmentInfo
Direct Known Subclasses:
CellSegmentInfo, SegmentInfo

public abstract class AbstractSegmentInfo
extends java.lang.Object

This class stores location information for orthogonal item segments.

Most notably, AbstractSegmentInfo stores the direction to which the segment points and the interval describing possible locations and extensions of a segment.

 

Field Summary
static byte ALIGNMENT_ANY
          A constant specifying that the segment can be placed anywhere within its location range.
static byte ALIGNMENT_MAX
          A constant specifying that the segment prefers to be placed close to the upper bound of its location range.
static byte ALIGNMENT_MIN
          A constant specifying that the segment prefers to be placed close to the lower bound of its location range.
 
Constructor Summary
protected AbstractSegmentInfo(java.lang.Object item, int segmentIndex, Direction direction, Interval locationRange, Interval minExtension, Interval maxExtension)
          Creates a new instance of AbstractSegmentInfo.
protected AbstractSegmentInfo(java.lang.Object item, int segmentIndex, LineSegment segment)
          Creates a new instance of AbstractSegmentInfo using a line segment to describe the edge segment.
 
Method Summary
 Direction getDirection()
          Returns the Direction to which the segment of this info points.
 double getLocation()
          Returns the fixed location within the location range for this segment info.
 Interval getLocationRange()
          Returns the range, i.e., the interval within which the segment should be placed.
 Interval getMaxExtension()
          Returns the maximum extension that this segment can span.
 Interval getMinExtension()
          Returns the minimum known extension of the segment, i.e., the minimum interval that this segment will cover in any case.
 byte getPreferredAlignment()
          Returns the preferred placement of this segment within its location range.
 SegmentGroup getSegmentGroup()
          Returns the segment group to which this segment info belongs.
 int getSegmentIndex()
          Returns the index of the segment of this info.
 boolean isFixed()
          Determines whether or not this segment info is fixed, i.e., a fixed location has been determined within its location range.
 boolean isVertical()
          Determines whether or not the associated segment is vertical.
 void setLocation(double location)
          Specifies the fixed location within the location range for this segment info.
 void setPreferredAlignment(byte alignment)
          Specifies the preferred placement of this segment within its location range.
 void setSegmentGroup(SegmentGroup segmentGroup)
          Specifies the segment group to which this segment info belongs.
 java.lang.String toString()
          Returns a string representation of this AbstractSegmentInfo object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALIGNMENT_MIN

public static final byte ALIGNMENT_MIN
A constant specifying that the segment prefers to be placed close to the lower bound of its location range.

See Also:
getPreferredAlignment(), setPreferredAlignment(byte), Constant Field Values
Sample Graph:

ALIGNMENT_MAX

public static final byte ALIGNMENT_MAX
A constant specifying that the segment prefers to be placed close to the upper bound of its location range.

See Also:
getPreferredAlignment(), setPreferredAlignment(byte), Constant Field Values
Sample Graph:

ALIGNMENT_ANY

public static final byte ALIGNMENT_ANY
A constant specifying that the segment can be placed anywhere within its location range.

See Also:
getPreferredAlignment(), setPreferredAlignment(byte), Constant Field Values
Sample Graph:
Constructor Detail

AbstractSegmentInfo

protected AbstractSegmentInfo(java.lang.Object item,
                              int segmentIndex,
                              Direction direction,
                              Interval locationRange,
                              Interval minExtension,
                              Interval maxExtension)
Creates a new instance of AbstractSegmentInfo.

Parameters:
item - the item to which the segment of this info belongs
segmentIndex - the index of the segment to which this info belongs
direction - the direction to which the segment of this info points
locationRange - the range within which the common location of this segment has to lie
minExtension - the minimum interval in extension direction this segment is known to intersect
maxExtension - the maximum interval in extension direction this segment will span

AbstractSegmentInfo

protected AbstractSegmentInfo(java.lang.Object item,
                              int segmentIndex,
                              LineSegment segment)
Creates a new instance of AbstractSegmentInfo using a line segment to describe the edge segment.

This constructor is meant to be used for fixed orthogonal edge segments.

Parameters:
item - the item to which this segment info belongs
segmentIndex - the index of the segment to which this info belongs
segment - a line segment describing the item segment
Method Detail

toString

public java.lang.String toString()
Returns a string representation of this AbstractSegmentInfo object.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this AbstractSegmentInfo object

getMinExtension

public Interval getMinExtension()
Returns the minimum known extension of the segment, i.e., the minimum interval that this segment will cover in any case.

For horizontal intervals, this is the minimum horizontal extension; for vertical intervals, this is the minimum vertical extension.

Returns:
the minimum extension of the segment or null if no minimum extension can be determined

getMaxExtension

public Interval getMaxExtension()
Returns the maximum extension that this segment can span.

For horizontal intervals, this is the maximum horizontal extension; for vertical intervals, this is the maximum vertical extension.

Returns:
the maximum extension that this segment can span

getLocationRange

public Interval getLocationRange()
Returns the range, i.e., the interval within which the segment should be placed.

For horizontal segments, this is the range containing the vertical location; for vertical segments, this is the range containing the horizontal location.

Returns:
the interval within which the segment should be placed

getPreferredAlignment

public byte getPreferredAlignment()
Returns the preferred placement of this segment within its location range.

Returns:
one of the predefined alignments
See Also:
setPreferredAlignment(byte)

setPreferredAlignment

public void setPreferredAlignment(byte alignment)
Specifies the preferred placement of this segment within its location range.

Default Value:
The default value is ALIGNMENT_ANY. The segment can be placed anywhere within its location range.
Parameters:
alignment - one of the predefined alignments
Throws:
java.lang.IllegalArgumentException - if an unknown alignment is given

setLocation

public void setLocation(double location)
Specifies the fixed location within the location range for this segment info.

For horizontal segments, this is the vertical location; for vertical segments, this is the horizontal location.

Default Value:
The default value is 0. No fixed location for the segment info has been set.
Parameters:
location - the fixed location that this segment info shall use
Throws:
java.lang.IllegalStateException - if the segment info already has a fixed location
java.lang.IllegalArgumentException - if the given location does not lie within the location range
See Also:
isFixed(), getLocationRange()
Sample Graphs:

Location 0 when location range is [3,47]

Location 5 when location range is [3,47]

Location 40 when location range is [3,47]

getLocation

public double getLocation()
Returns the fixed location within the location range for this segment info.

For horizontal segments, this is the vertical location; for vertical segments, this is the horizontal location.

Returns:
the fixed location that has been set before or 0 if no fixed location has been set
See Also:
setLocation(double), isFixed(), getLocationRange()

isFixed

public boolean isFixed()
Determines whether or not this segment info is fixed, i.e., a fixed location has been determined within its location range.

Returns:
true if this segment info has a fixed location assigned to it, false otherwise

isVertical

public boolean isVertical()
Determines whether or not the associated segment is vertical.

Returns:
true if the segment of this segment info is vertical, false if it is horizontal

getDirection

public Direction getDirection()
Returns the Direction to which the segment of this info points.

Returns:
the direction to which the segment of this info points

getSegmentIndex

public int getSegmentIndex()
Returns the index of the segment of this info.

Returns:
the index of the segment of this info

setSegmentGroup

public void setSegmentGroup(SegmentGroup segmentGroup)
Specifies the segment group to which this segment info belongs.

When defining the segment group, the location range will be adjusted to use the common interval of the segment group.

Parameters:
segmentGroup - the segment group to which this segment info should belong
See Also:
SegmentGroup.getCommonLocationRange()

getSegmentGroup

public SegmentGroup getSegmentGroup()
Returns the segment group to which this segment info belongs.

When defining the segment group, the location range will be adjusted to use the common interval of the segment group.

Returns:
the segment group to which this segment info belongs or null if no segment group is assigned
See Also:
setSegmentGroup(SegmentGroup), SegmentGroup.getCommonLocationRange()

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