Class DataRange

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class DataRange
    extends java.lang.Object
    implements java.lang.Cloneable

    Defines range (limits) of data.

    Version:
    $Id: DataRange.java,v 1.7 2006-06-22 12:09:30 gkruk Exp $
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected double max  
      protected double min  
    • Constructor Summary

      Constructors 
      Constructor Description
      DataRange()
      Creates a new DataRange that is not defined.
      DataRange​(double min, double max)
      Creates a new DataRange with the specified min and max values.
      DataRange​(DataRange range)
      Creates a copy of the specified data range.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(double value)
      Adds value to this range.
      void add​(DataRange range)
      Add the specified data range to this range.
      java.lang.Object clone()  
      boolean contains​(double value)
      Examines if this range contains the specified value.
      void empty()
      Empties this DataRange.
      boolean equals​(java.lang.Object obj)  
      void expand​(double value)
      Expands this data set by the given value.
      double getLength()
      Returns length of this range (max - min).
      double getMax()  
      double getMin()  
      int hashCode()  
      boolean isDefined()
      Determines if this DataRange is defined - min and max values are defined.
      boolean isMaxDefined()
      Determines if max value has been defined.
      boolean isMinDefined()
      Determines if min value has been defined.
      void set​(double min, double max)
      Sets min and max values for this range.
      void set​(DataRange range)
      Sets updates range to the specified one.
      void setMax​(double max)
      Sets max value for this range.
      void setMin​(double min)
      Sets min value for this range.
      DataRange substract​(DataRange range)
      Substracts the specified data range from this range.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • min

        protected double min
      • max

        protected double max
    • Constructor Detail

      • DataRange

        public DataRange()
        Creates a new DataRange that is not defined.
        See Also:
        isDefined()
      • DataRange

        public DataRange​(double min,
                         double max)
        Creates a new DataRange with the specified min and max values.
        Parameters:
        min - the new min value
        max - the new max value
      • DataRange

        public DataRange​(DataRange range)
        Creates a copy of the specified data range.
        Parameters:
        range - other DataRange object
    • Method Detail

      • isDefined

        public boolean isDefined()
        Determines if this DataRange is defined - min and max values are defined.
        Returns:
        true: range is defined
      • isMinDefined

        public boolean isMinDefined()
        Determines if min value has been defined.
        Returns:
        true: min is defined
      • isMaxDefined

        public boolean isMaxDefined()
        Determines if max value has been defined.
        Returns:
        true max is defined
      • getMax

        public double getMax()
        Returns:
        Returns the max.
      • setMax

        public void setMax​(double max)
        Sets max value for this range.
        Parameters:
        max - the new max value
      • getMin

        public double getMin()
        Returns:
        the minimum of the range
      • setMin

        public void setMin​(double min)
        Sets min value for this range.
        Parameters:
        min - the new data range minimum
      • set

        public void set​(DataRange range)
        Sets updates range to the specified one.
        Parameters:
        range - other DataRange object
      • set

        public void set​(double min,
                        double max)
        Sets min and max values for this range.
        Parameters:
        min - new minimum of the range
        max - new maximum of the range
      • getLength

        public double getLength()
        Returns length of this range (max - min).
        Returns:
        max - min or 0.0 if the range is not defined.
      • add

        public boolean add​(double value)
        Adds value to this range.
        Parameters:
        value - value to be added
        Returns:
        true if the value becomes min or max.
      • add

        public void add​(DataRange range)
        Add the specified data range to this range.
        Parameters:
        range - other DataRange
      • substract

        public DataRange substract​(DataRange range)
        Substracts the specified data range from this range.
        Parameters:
        range - other DataRange
        Returns:
        new data Range
      • expand

        public void expand​(double value)
        Expands this data set by the given value.
        Parameters:
        value - range to expand to
      • empty

        public void empty()
        Empties this DataRange. After calling this method this data range becomes undefined.
        See Also:
        isDefined()
      • contains

        public boolean contains​(double value)
        Examines if this range contains the specified value.
        Parameters:
        value - to be tested
        Returns:
        true: data value is within range
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException