|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.router.polyline.Interval
public class Interval
This class represents a one-dimensional closed interval.
Constructor Summary | |
---|---|
Interval(double bound1,
double bound2)
Creates a new Interval between the given bounds. |
Method Summary | |
---|---|
static Interval |
calculateBridge(Interval i1,
Interval i2)
Returns the bridging interval between the given intervals . |
static Interval |
calculateIntersection(Interval i1,
Interval i2)
Returns the intersection of the given intervals . |
static YRectangle |
calculateSpanningRectangle(Interval horizontal,
Interval vertical)
Returns the spanning rectangle between the given intervals . |
static Interval |
calculateUnion(Interval interval,
double value)
Returns the union of the given intervals and the given value. |
static Interval |
calculateUnion(Interval i1,
Interval i2)
Returns the union of the given intervals . |
boolean |
contains(double value)
Checks whether or not the given value lies within the interval. |
boolean |
coveredBy(Interval other)
Checks whether or not the given interval fully covers this interval . |
boolean |
coveredBy(Interval other,
double eps)
Checks whether or not the given interval fully covers this interval given a small
epsilon value. |
double |
distanceTo(double value)
Returns the distance between the value and this interval . |
double |
distanceTo(Interval other)
Returns the distance between this interval and the given interval . |
boolean |
equals(java.lang.Object other)
Checks whether or not this interval equals to the given interval . |
double |
getCenter()
Returns the midpoint of the interval. |
double |
getClosest(double value)
Returns the interval bound that is closest to the given value. |
double |
getMax()
Returns the upper bound of the interval. |
double |
getMin()
Returns the lower bound of the interval. |
double |
getSize()
Returns the size of the interval, i.e., the difference between the upper bound and
the lower bound . |
int |
hashCode()
Returns the hash code for this interval . |
boolean |
hasSameRange(Interval other)
Checks whether or not this interval and the given interval cover about the same range. |
boolean |
hasSameRange(Interval other,
double eps)
Checks whether or not this interval and the given interval cover the same range. |
boolean |
intersects(Interval other)
Checks whether or not this interval intersects with the given interval . |
boolean |
intersects(Interval other,
double minIntersection)
Checks whether or not this interval intersects with the given interval ,
considering the given minimum intersection length. |
boolean |
isGreaterThan(Interval other)
Checks whether or not the lower bound of this interval is greater than the upper bound of the given interval. |
boolean |
isLessThan(Interval other)
Checks whether or not the upper bound of this interval is smaller than the lower bound of the given interval. |
java.lang.String |
toString()
Returns a string representation of this Interval object. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Interval(double bound1, double bound2)
Interval
between the given bounds.
The upper and lower bound of the two given values are determined automatically, i.e., the smaller one will be treated as the lower bound and the larger one as the upper bound.
bound1
- the first interval boundbound2
- the second interval boundMethod Detail |
---|
public double getMin()
public double getMax()
public double getCenter()
public boolean contains(double value)
value
- the value to check
true
if the value lies within the interval, false
otherwisepublic double getSize()
upper bound
and
the lower bound
.
public boolean intersects(Interval other)
interval
intersects with the given interval
.
This means that both intervals have at least one common value.
other
- the other interval to check
true
if the intervals have at least one common value, false
otherwisepublic boolean intersects(Interval other, double minIntersection)
interval
intersects with the given interval
,
considering the given minimum intersection length.
other
- the other interval to checkminIntersection
- the minimum length of the intersection of the intervals
true
if the intervals intersect at least by the given minimum length, false
otherwisepublic double distanceTo(double value)
interval
.
If this interval contains the specified value, the distance is 0
. Otherwise, it is the minimum of
dist(value, lower bound)
and dist(value, upper bound)
.
value
- the value to which the distance is calculated
public double distanceTo(Interval other)
interval
and the given interval
.
If the intervals intersect
, the distance is 0
. Otherwise, it is equal
to dist(minimum of upper bounds, maximum of lower bounds)
.
other
- the other interval to which the distance is calculated
public boolean coveredBy(Interval other)
interval
fully covers this interval
.
The given interval covers this interval, if other lower bound - epsilon <= this lower bound
and
this upper bound <= other upper bound + epsilon
where epsilon
is a small value.
other
- the other interval
true
if this interval is fully covered by the other interval, false
otherwisepublic boolean coveredBy(Interval other, double eps)
interval
fully covers this interval
given a small
epsilon value.
The given interval covers this interval, if other lower bound - epsilon <= this lower bound
and
this upper bound <= other upper bound + epsilon
.
other
- the other intervaleps
- the epsilon value that determines the extended range of the other interval
true
if this interval is fully covered by the other interval, false
otherwisepublic double getClosest(double value)
interval
bound that is closest to the given value.
value
- the value for which the closest interval bound will be returned
value
, if the given value lies within the interval, orpublic boolean isLessThan(Interval other)
interval
is smaller than the lower bound of the given interval.
other
- the interval to compare
true
if the current interval is on the left of the given one, false
otherwisepublic boolean isGreaterThan(Interval other)
interval
is greater than the upper bound of the given interval.
other
- the interval to compare
true
if the current interval is on the right of the given one, false
otherwisepublic java.lang.String toString()
Interval
object.
toString
in class java.lang.Object
Interval
objectpublic boolean hasSameRange(Interval other)
interval
and the given interval
cover about the same range.
The intervals are considered to cover the same range, if their minimum values as well as their maximum values differ only in a small epsilon value.
other
- the other interval
true
if the intervals cover the same range, false
otherwisepublic boolean hasSameRange(Interval other, double eps)
interval
and the given interval
cover the same range.
The intervals are considered to cover the same range, if their minimum values as well as their maximum values differ only in the given epsilon value.
other
- the other intervaleps
- the maximum distance between the two minimum and the two maximum values
true
if the intervals cover the same range, false
otherwisepublic static Interval calculateIntersection(Interval i1, Interval i2)
intervals
.
The intersection is null
if the given intervals do not intersect each other. Otherwise, the intersection is
[maximum of lower bounds, minimum of upper bounds]
.
i1
- the first intervali2
- the second interval
null
if the intervals do not intersectpublic static Interval calculateUnion(Interval i1, Interval i2)
intervals
.
The union is [minimum of lower bounds, maximum of upper bounds]
.
i1
- the first intervali2
- the second interval
public static Interval calculateUnion(Interval interval, double value)
intervals
and the given value.
The union is between the minimum of the lower bound of the given interval and the given value and the maximum of the upper bound of the given interval and the given value.
interval
- the interval to be extendedvalue
- the value to be in the union
public static Interval calculateBridge(Interval i1, Interval i2)
interval
between the given intervals
.
The bridging interval is null
if the given intervals intersect each other. Otherwise, the bridging interval is
[minimum of upper bounds, maximum of lower bounds]
.
i1
- the first intervali2
- the second interval
null
if the intervals intersectpublic static YRectangle calculateSpanningRectangle(Interval horizontal, Interval vertical)
intervals
.
The first interval spans the rectangle in horizontal dimension, the second interval in vertical dimension.
horizontal
- the interval that defines the location and length of the rectangle in horizontal dimensionvertical
- the interval that defines the location and length of the rectangle in vertical dimension
public boolean equals(java.lang.Object other)
interval
equals to the given interval
.
Two intervals are equal if they have the same lower and upper bounds.
equals
in class java.lang.Object
other
- the other interval
true
if the two given intervals are equal, false
otherwisepublic int hashCode()
interval
.
hashCode
in class java.lang.Object
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |