Search this API

y.layout.router.polyline
Class OrthogonalInterval

java.lang.Object
  extended by y.layout.router.polyline.OrthogonalInterval

public class OrthogonalInterval
extends Object

A horizontal or vertical Interval that additionally stores a y- (in the horizontal case) or x-coordinate (in the vertical case).

During a PathSearch, orthogonal intervals are used to describe where an edge enters or leaves a PartitionCell.

See Also:
PathSearch

Constructor Summary
OrthogonalInterval(double from, double to, double location, boolean isVertical)
          Creates a new instance using the from and to value as interval bounds.
OrthogonalInterval(Interval range, double location, boolean isVertical)
          Creates a new instance using the range as interval bounds.
 
Method Summary
static OrthogonalInterval calculateIntersection(OrthogonalInterval i1, OrthogonalInterval i2)
          Calculates the intersection of the given orthogonal intervals.
static OrthogonalInterval calculateUnion(OrthogonalInterval i1, OrthogonalInterval i2)
          Calculates the union of the given orthogonal intervals.
 boolean coveredBy(OrthogonalInterval other)
          Checks if the given orthogonal interval covers this one fully.
 boolean crosses(OrthogonalInterval other)
          Determines whether this orthogonal interval crosses the given one.
 double distanceTo(OrthogonalInterval other)
          Returns the distance of the getRange()s of this orthogonal interval and the given orthogonal interval.
 YPoint getCenter()
          Returns the center of this orthogonal interval in the 2d-coordinate system.
 double getLocation()
          Returns the vertical coordinate for horizontal intervals or the horizontal coordinate for vertical intervals, respectively.
 double getMax()
          Returns the upper bound of the orthogonal interval.
 double getMin()
          Returns the lower bound of the orthogonal interval.
 Interval getRange()
          Returns the range of this orthogonal interval.
 double getSize()
          Returns the length of the orthogonal interval.
 boolean hasSameRange(OrthogonalInterval other)
          Checks if this orthogonal interval and the given orthogonal interval cover the same range.
 boolean intersects(OrthogonalInterval other)
          Checks if this orthogonal interval intersects the given orthogonal interval.
 boolean intersects(OrthogonalInterval other, double minIntersection)
          Checks if this orthogonal interval intersects the given orthogonal interval and the intersection has a minimal size of minIntersection.
 boolean isVertical()
          Determines whether the orthogonal interval is oriented vertically.
 double manhattanDistanceTo(OrthogonalInterval other)
          Returns the manhattan distance of this orthogonal interval and the given orthogonal interval.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OrthogonalInterval

public OrthogonalInterval(double from,
                          double to,
                          double location,
                          boolean isVertical)
Creates a new instance using the from and to value as interval bounds.

Parameters:
from - the start of the interval bounds
to - the end of the interval bounds
location - the location in the 2D coordinate system
isVertical - true, if the orthogonal interval is vertical; false, if it is horizontal vertical.

OrthogonalInterval

public OrthogonalInterval(Interval range,
                          double location,
                          boolean isVertical)
Creates a new instance using the range as interval bounds.

Throws:
IllegalArgumentException - if range is null
Parameters:
range - the range
location - the location in the 2D coordinate system
isVertical - true, if the orthogonal interval is vertical; false, if it is horizontal.
Method Detail

isVertical

public boolean isVertical()
Determines whether the orthogonal interval is oriented vertically.

Returns:
true if the orthogonal interval is oriented vertically, false otherwise.

getMin

public double getMin()
Returns the lower bound of the orthogonal interval.

Returns:
The lower bound of the orthogonal interval.

getMax

public double getMax()
Returns the upper bound of the orthogonal interval.

Returns:
The upper bound of the orthogonal interval.

getSize

public double getSize()
Returns the length of the orthogonal interval.

Returns:
The length of the orthogonal interval.
See Also:
Interval.getSize()

getRange

public Interval getRange()
Returns the range of this orthogonal interval.

Returns:
the range of this orthogonal interval.

getLocation

public double getLocation()
Returns the vertical coordinate for horizontal intervals or the horizontal coordinate for vertical intervals, respectively.

Returns:
the vertical coordinate for horizontal intervals or the horizontal coordinate for vertical intervals, respectively.

getCenter

public YPoint getCenter()
Returns the center of this orthogonal interval in the 2d-coordinate system.

Returns:
The center of this orthogonal interval in the 2d-coordinate system.

crosses

public boolean crosses(OrthogonalInterval other)
Determines whether this orthogonal interval crosses the given one.

The orthogonal intervals must have different orientations.

Throws:
IllegalArgumentException - if orthogonal intervals have same orientation
Parameters:
other - The other orthogonal interval.
Returns:
true if this orthogonal interval crosses the given one, false otherwise.

distanceTo

public double distanceTo(OrthogonalInterval other)
Returns the distance of the getRange()s of this orthogonal interval and the given orthogonal interval.

The orthogonal intervals must have same orientation.

Throws:
IllegalArgumentException - if the orthogonal intervals have different orientations
Parameters:
other - The second orthogonal interval.
Returns:
0 if the orthogonal intervals intersects(OrthogonalInterval), otherwise the minimal distance between the orthogonal intervals.

manhattanDistanceTo

public double manhattanDistanceTo(OrthogonalInterval other)
Returns the manhattan distance of this orthogonal interval and the given orthogonal interval.

If both intervals have the same orientation, the manhattan distance is the sum of the distance between the intervals' ranges and the distance between the intervals' locations.

If the intervals have different orientations, the manhattan distance is the sum of the distances between one interval's range with the other interval's location.

Parameters:
other - The second orthogonal interval.
Returns:
The manhattan distance between this interval and the given one.

intersects

public boolean intersects(OrthogonalInterval other)
Checks if this orthogonal interval intersects the given orthogonal interval.

Orthogonal intervals intersect each other, if their ranges intersect each other. The location of both orthogonal intervals is ignored. The orthogonal intervals must have same orientation.

Throws:
IllegalArgumentException - if the orthogonal intervals have different orientations
Parameters:
other - the second orthogonal interval.
Returns:
true if both orthogonal intervals intersect, false otherwise.
See Also:
PartitionCell

intersects

public boolean intersects(OrthogonalInterval other,
                          double minIntersection)
Checks if this orthogonal interval intersects the given orthogonal interval and the intersection has a minimal size of minIntersection.

Orthogonal intervals intersect each other, if their ranges intersect each other by at least minIntersection. The location of both orthogonal intervals is ignored. The orthogonal intervals must have same orientation.

Throws:
IllegalArgumentException - if the orthogonal intervals have different orientations
Parameters:
other - the second orthogonal interval.
minIntersection - The minimal size of the intersection.
Returns:
true if both orthogonal intervals intersect, false otherwise.
See Also:
PartitionCell

coveredBy

public boolean coveredBy(OrthogonalInterval other)
Checks if the given orthogonal interval covers this one fully.

The given orthogonal interval covers this orthogonal interval, if this interval's range is covered by the given interval's range. The location of both orthogonal intervals is ignored. The orthogonal intervals must have same orientation.

Throws:
IllegalArgumentException - if the orthogonal intervals have different orientations
Parameters:
other - The other orthogonal interval
Returns:
true, if this orthogonal interval is fully covered by the other orthogonal interval, false otherwise.
See Also:
PartitionCell

hasSameRange

public boolean hasSameRange(OrthogonalInterval other)
Checks if this orthogonal interval and the given orthogonal interval cover the same range.

If both orthogonal intervals cover the same range, they are considered same. The location of both orthogonal intervals is ignored. The orthogonal intervals must have same orientation.

Throws:
IllegalArgumentException - if the orthogonal intervals have different orientations
Parameters:
other - The second orthogonal interval
Returns:
true, if the orthogonal intervals cover the same range, false otherwise.
See Also:
PartitionCell

calculateIntersection

public static OrthogonalInterval calculateIntersection(OrthogonalInterval i1,
                                                       OrthogonalInterval i2)
Calculates the intersection of the given orthogonal intervals.

If the created orthogonal interval is vertical, it will have the same horizontal location as i2 and the shared vertical range of both intervals. If it is horizontal, it will have the same vertical location as i2 and the shared horizontal range of both intervals. The orthogonal intervals must have same orientation.

Throws:
IllegalArgumentException - if the orthogonal intervals have different orientations
Parameters:
i1 - The first orthogonal interval.
i2 - The second orthogonal interval.
Returns:
The shared orthogonal interval of both given orthogonal intervals.
See Also:
intersects(OrthogonalInterval, double)

calculateUnion

public static OrthogonalInterval calculateUnion(OrthogonalInterval i1,
                                                OrthogonalInterval i2)
Calculates the union of the given orthogonal intervals.

If the created orthogonal interval is vertical, it will have the same horizontal location as i2 and the shared vertical range of both orthogonal intervals. If it is horizontal, it will have the same vertical location as i2 and the shared vertical range of both orthogonal intervals. The orthogonal intervals must have same orientation.

Throws:
IllegalArgumentException - if the orthogonal intervals have different orientations
Parameters:
i1 - The first orthogonal interval.
i2 - The second orthogonal interval.
Returns:
The union of both given orthogonal intervals.
See Also:
intersects(OrthogonalInterval, double)

toString

public String toString()
Overrides:
toString in class Object

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