Search this API

y.layout.router.polyline
Class OrthogonalInterval

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

public class OrthogonalInterval
extends java.lang.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 for specifying the location where an edge enters or exits a partition cell.

See Also:
PathSearch
 

Constructor Summary
OrthogonalInterval(double from, double to, double location, boolean isVertical)
          Creates a new OrthogonalInterval instance using the from and to value as interval bounds.
OrthogonalInterval(Interval range, double location, boolean isVertical)
          Creates a new OrthogonalInterval instance with the given 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 whether or not this orthogonal interval is fully covered by the given orthogonal interval.
 boolean crosses(OrthogonalInterval other)
          Determines whether or not this orthogonal interval crosses the given one.
 double distanceTo(OrthogonalInterval other)
          Returns the distance of the ranges 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 whether or not this orthogonal interval and the given orthogonal interval cover the same range.
 boolean intersects(OrthogonalInterval other)
          Checks whether or not this orthogonal interval intersects the given orthogonal interval.
 boolean intersects(OrthogonalInterval other, double minIntersection)
          Checks whether or not this orthogonal interval intersects the given orthogonal interval and the intersection has a given minimum intersection size.
 boolean isVertical()
          Determines whether or not the orthogonal interval is oriented vertically.
 double manhattanDistanceTo(OrthogonalInterval other)
          Returns the Manhattan distance of this orthogonal interval and the given orthogonal interval.
 java.lang.String toString()
          Returns a string representation of this OrthogonalInterval object.
 
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 OrthogonalInterval 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 two-dimensional coordinate system
isVertical - true if the orthogonal interval is vertical, false if it is horizontal
Throws:
java.lang.IllegalArgumentException - if the given range is null

OrthogonalInterval

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

Parameters:
range - the given range
location - the location in the two-dimensional coordinate system
isVertical - true if the orthogonal interval is vertical, false if it is horizontal
Throws:
java.lang.IllegalArgumentException - if the given range is null
Method Detail

isVertical

public boolean isVertical()
Determines whether or not 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 or not this orthogonal interval crosses the given one.

The orthogonal intervals must have different orientations.

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

distanceTo

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

The orthogonal intervals must have the same orientation.

Parameters:
other - the other orthogonal interval
Returns:
0 if the orthogonal intervals intersect each other, otherwise the minimal distance between the orthogonal intervals is returned
Throws:
java.lang.IllegalArgumentException - if the orthogonal intervals have different orientations

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 and the other interval's location.

Parameters:
other - the other orthogonal interval
Returns:
the Manhattan distance between this interval and the given one

intersects

public boolean intersects(OrthogonalInterval other)
Checks whether or not 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 the same orientation.

Parameters:
other - the other orthogonal interval
Returns:
true if this interval intersects the given other orthogonal interval, false otherwise
Throws:
java.lang.IllegalArgumentException - if the orthogonal intervals have different orientations
See Also:
PartitionCell

intersects

public boolean intersects(OrthogonalInterval other,
                          double minIntersection)
Checks whether or not this orthogonal interval intersects the given orthogonal interval and the intersection has a given minimum intersection size.

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

Parameters:
other - the other orthogonal interval
minIntersection - the minimum size of the intersection
Returns:
true if this interval intersects the given other orthogonal interval, false otherwise
Throws:
java.lang.IllegalArgumentException - if the orthogonal intervals have different orientations
See Also:
PartitionCell

coveredBy

public boolean coveredBy(OrthogonalInterval other)
Checks whether or not this orthogonal interval is fully covered by the given orthogonal interval.

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 the same orientation.

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

hasSameRange

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

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

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

calculateIntersection

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

If the returned 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.

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

calculateUnion

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

If the returned 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.

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

toString

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

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

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