java.lang.Object
org.openstreetmap.josm.gui.mappaint.Range

public class Range extends Object
A scale interval of the form "lower < x <= upper" where 0 <= lower < upper. (upper can be Double.POSITIVE_INFINITY) immutable class
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final double
     
    private final double
     
    static final Range
    The full scale range from zero to infinity
  • Constructor Summary

    Constructors
    Constructor
    Description
    Range(double lower, double upper)
    Constructs a new Range.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(double x)
    Check if a number is contained in this range
    static Range
    cut(Range a, Range b)
    provides the intersection of 2 overlapping ranges
    boolean
     
    double
    Gets the lower bound
    double
    Gets the upper bound
    int
     
    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.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • 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 Details

    • Range

      public Range(double lower, double upper)
      Constructs a new Range.
      Parameters:
      lower - Lower bound. Must be positive or zero
      upper - Upper bound
      Throws:
      IllegalArgumentException - if the range is invalid (lower < 0 || lower >= upper)
  • Method Details

    • 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 range
      b - second range
      Returns:
      intersection of a and b
    • 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 - value
      other - 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
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object