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 Object

Stores location information for orthogonal edge segments.

Most notably, AbstractSegmentInfo stores direction, segment points and intervals describing possible location and extension of a segment.


Field Summary
static byte ALIGNMENT_ANY
          Specifies that the segment can be placed somewhere in its location range.
static byte ALIGNMENT_MAX
          Specifies that the segment prefers to be placed close to the upper bound of its location range.
static byte ALIGNMENT_MIN
          Specifies that the segment prefers to be placed close to the lower bound of its location range.
 
Constructor Summary
protected AbstractSegmentInfo(Edge edge, int segmentIndex, Direction direction, Interval locationRange, Interval minExtension, Interval maxExtension)
          Creates a new instance for the segment
protected AbstractSegmentInfo(Edge edge, int segmentNo, LineSegment segment)
          Creates a new instance using a line segment to describe the edge segment.
 
Method Summary
 Direction getDirection()
          Returns the direction the segment of this info points to.
 Edge getEdge()
          Returns the edge this segment info belongs to.
 double getLocation()
          Returns the fixed location inside the location range that has been set before.
 Interval getLocationRange()
          Returns the range, the location of the segment shall be placed in.
 Interval getMaxExtension()
          Returns the maximum extension this segment will stretch.
 Interval getMinExtension()
          The minimal known extension of the segment, that is the minimal interval this segment will cover in any case.
 byte getPreferredAlignment()
          Returns whether this segment prefers to be placed close to the lower bound, upper bound or somewhere of its location range.
 SegmentGroup getSegmentGroup()
          Returns the segment group this segment info belongs to or null if this segment info doesn't belong to any group.
 int getSegmentIndex()
          Returns the index of this info's segment.
 boolean isFixed()
          Determines whether or not this segment info is fixed, that means a fixed location has been determined inside its location range.
 boolean isVertical()
          Determines whether or not the associated segment is vertical.
 void setLocation(double location)
          Sets a fixed location for this segment info.
 void setPreferredAlignment(byte alignment)
          Sets whether this segment prefers to be placed close to the lower bound, upper bound or somewhere of its location range.
 void setSegmentGroup(SegmentGroup segmentGroup)
          Sets the segment group this segment info belongs to and adjusts the location range to use the common interval of the group.
 String toString()
           
 
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
Specifies that the segment prefers to be placed close to the lower bound of its location range.

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

ALIGNMENT_MAX

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

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

ALIGNMENT_ANY

public static final byte ALIGNMENT_ANY
Specifies that the segment can be placed somewhere in its location range.

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

AbstractSegmentInfo

protected AbstractSegmentInfo(Edge edge,
                              int segmentIndex,
                              Direction direction,
                              Interval locationRange,
                              Interval minExtension,
                              Interval maxExtension)
Creates a new instance for the segment

Parameters:
edge - The edge the segment of this info belongs to.
segmentIndex - The index of the segment this info belongs to.
direction - The direction the segment points to.
locationRange - The range the common location of this segment has to be inside.
minExtension - The minimal interval in extension direction this segment is known to intersect.
maxExtension - The maximum interval in extension direction this segment will span.

AbstractSegmentInfo

protected AbstractSegmentInfo(Edge edge,
                              int segmentNo,
                              LineSegment segment)
Creates a new instance using a line segment to describe the edge segment.

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

Parameters:
edge - The edge this segment info belongs to.
segmentNo - The number of the segment this info belongs to.
segment - A line segment describing the edge segment.
Method Detail

toString

public String toString()
Overrides:
toString in class Object

getMinExtension

public Interval getMinExtension()
The minimal known extension of the segment, that is the minimal interval this segment will cover in any case.

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

Returns:
The minimal extension of the segment or null if no minimal extension can be determined.

getMaxExtension

public Interval getMaxExtension()
Returns the maximum extension this segment will stretch.

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

Returns:
The maximum extension this segment will stretch.

getLocationRange

public Interval getLocationRange()
Returns the range, the location of the segment shall be placed in.

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

Returns:
The range, the segment shall be placed in.

getPreferredAlignment

public byte getPreferredAlignment()
Returns whether this segment prefers to be placed close to the lower bound, upper bound or somewhere of its location range.

Returns:
The preferred alignment of the segment inside the location range.
See Also:
ALIGNMENT_MIN, ALIGNMENT_MAX, ALIGNMENT_ANY

setPreferredAlignment

public void setPreferredAlignment(byte alignment)
Sets whether this segment prefers to be placed close to the lower bound, upper bound or somewhere of its location range.

Parameters:
alignment - The preferred alignment of the segment inside the location range.
See Also:
ALIGNMENT_MIN, ALIGNMENT_MAX, ALIGNMENT_ANY

setLocation

public void setLocation(double location)
Sets a fixed location for this segment info. This location has to be inside the segment infos location range.

Throws:
RuntimeException - If the segment info already has a fixed location.
IllegalArgumentException - If the given location isn't inside the location range.
Parameters:
location - The fixed location this segment info shall use.
See Also:
isFixed(), getLocationRange()

getLocation

public double getLocation()
Returns the fixed location inside the location range that has been set before.

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

Returns:
The location in the location range that has been set before or 0 if no fixed location has been set, yet.

isFixed

public boolean isFixed()
Determines whether or not this segment info is fixed, that means a fixed location has been determined inside 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 the segment of this info points to.

Returns:
The direction the segment of this info points to.

getEdge

public Edge getEdge()
Returns the edge this segment info belongs to.

Returns:
The edge this segment info belongs to.

getSegmentIndex

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

Returns:
The index of this info's segment.

setSegmentGroup

public void setSegmentGroup(SegmentGroup segmentGroup)
Sets the segment group this segment info belongs to and adjusts the location range to use the common interval of the group.

Parameters:
segmentGroup - The segment group this segment info shall belong to.
See Also:
SegmentGroup.getCommonLocationRange()

getSegmentGroup

public SegmentGroup getSegmentGroup()
Returns the segment group this segment info belongs to or null if this segment info doesn't belong to any group.

Returns:
The segment group this segment info belongs to or null.

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