Class Range
- java.lang.Object
-
- org.openstreetmap.josm.gui.mappaint.Range
-
-
Field Summary
Fields Modifier and Type Field Description private double
lower
private double
upper
static Range
ZERO_TO_INFINITY
The full scale range from zero to infinity
-
Constructor Summary
Constructors Constructor Description Range(double lower, double upper)
Constructs a newRange
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(double x)
Check if a number is contained in this rangestatic Range
cut(Range a, Range b)
provides the intersection of 2 overlapping rangesboolean
equals(Object o)
double
getLower()
Gets the lower bounddouble
getUpper()
Gets the upper boundint
hashCode()
Range
reduceAround(double x, Range other)
under the premise, that x is within this range, and not within the other range, it shrinks this range in a way to exclude the other range, but still contain x.String
toString()
-
-
-
Field Detail
-
lower
private final double lower
-
upper
private final double upper
-
ZERO_TO_INFINITY
public static final Range ZERO_TO_INFINITY
The full scale range from zero to infinity
-
-
Constructor Detail
-
Range
public Range(double lower, double upper)
Constructs a newRange
.- Parameters:
lower
- Lower bound. Must be positive or zeroupper
- Upper bound- Throws:
IllegalArgumentException
- if the range is invalid (lower < 0 || lower >= upper
)
-
-
Method Detail
-
contains
public boolean contains(double x)
Check if a number is contained in this range- Parameters:
x
- The number to test- Returns:
true
if it is in this range
-
cut
public static Range cut(Range a, Range b)
provides the intersection of 2 overlapping ranges- Parameters:
a
- first rangeb
- second range- Returns:
- intersection of
a
andb
-
reduceAround
public Range reduceAround(double x, Range other)
under the premise, that x is within this range, and not within the other range, it shrinks this range in a way to exclude the other range, but still contain x. x | this (------------------------------] other (-------] or (-----------------] result (----------------]- Parameters:
x
- valueother
- other range- Returns:
- reduced range
-
getLower
public double getLower()
Gets the lower bound- Returns:
- The lower, exclusive, bound
-
getUpper
public double getUpper()
Gets the upper bound- Returns:
- The upper, inclusive, bound
-
-