Class Range

java.lang.Object
org.yamcs.studio.data.formula.Range

public final class Range extends Object
A range of numeric values.

For the purpose of range calculation, NaNs should be skipped. The only case where NaNs are allowed is for the UNDEFINED range.

The minimum and maximum are simply double values.

  • Method Summary

    Modifier and Type
    Method
    Description
    combine(Range other)
    Determines the range that can contain both ranges.
    boolean
    contains(double value)
    Determines whether the value is contained by the range or not.
    boolean
    contains(Range range)
    Determines whether the given range is contained by the range or not.
    static Range
    create(double minValue, double maxValue)
    Range from given min and max.
    boolean
     
    double
    The maximum value.
    double
    The minimum value.
    int
     
    boolean
    Whether the range is finite and non-zero.
    boolean
    Whether the range goes from min to max or from max to min.
    double
    normalize(double value)
    Returns the value normalized within the range.
     
    static Range
    An undefined range.

    Methods inherited from class java.lang.Object

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

    • getMinimum

      public double getMinimum()
      The minimum value.
      Returns:
      a value
    • getMaximum

      public double getMaximum()
      The maximum value.
      Returns:
      a value
    • isReversed

      public boolean isReversed()
      Whether the range goes from min to max or from max to min.
      Returns:
      true if range should be traversed from max to min
    • isFinite

      public boolean isFinite()
      Whether the range is finite and non-zero.
      Returns:
      true if range is finite and non-zero
    • normalize

      public double normalize(double value)
      Returns the value normalized within the range. It performs a linear transformation where the minimum value of the range becomes 0 while the maximum becomes 1.
      Parameters:
      value - a value
      Returns:
      the value transformed based on the range
    • contains

      public boolean contains(double value)
      Determines whether the value is contained by the range or not.
      Parameters:
      value - a value
      Returns:
      true if the value is within the range
    • contains

      public boolean contains(Range range)
      Determines whether the given range is contained by the range or not.
      Parameters:
      range - a range
      Returns:
      true if the range is a subrange of this
    • combine

      public Range combine(Range other)
      Determines the range that can contain both ranges. If one of the ranges in contained in the other, the bigger range is returned.
      Parameters:
      other - another range
      Returns:
      the bigger range
    • undefined

      public static Range undefined()
      An undefined range.
      Returns:
      the undefined range
    • toString

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

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

      public int hashCode()
      Overrides:
      hashCode in class Object
    • create

      public static Range create(double minValue, double maxValue)
      Range from given min and max. If max is greater than min, a reversed range is returned.
      Parameters:
      minValue - minimum value
      maxValue - maximum value
      Returns:
      the range