Class ReferenceableAxisImpl

    • Constructor Detail

      • ReferenceableAxisImpl

        public ReferenceableAxisImpl​(String name,
                                     List<Double> axisValues,
                                     boolean isLongitude)
        Creates a ReferenceableAxis from the given array of axis values. The axis values are copied to internal data structures, therefore subsequent modifications to the array of axis values have no effect on this object.
        Parameters:
        name - The name of the axis
        axisValues - List of axis values; must ascend or descend monotonically
        isLongitude - True if this is a longitude axis in degrees (hence values of 0 and 360 are equivalent).
        Throws:
        NullPointerException - if axisValues is null
        IllegalArgumentException - if the axis values are not in strictly ascending numerical order, or if the array of axis values is empty
    • Method Detail

      • wraps

        public boolean wraps()
        Description copied from interface: ReferenceableAxis
        Returns true if the values on the axis wrap around (e.g. longitude)
      • findIndexOf

        public int findIndexOf​(Double position)
        Description copied from interface: ReferenceableAxis

        Finds the index along this axis that corresponds with the given position. Formally, this returns an index such that getCoordinateBounds(index).contains(position) returns true. Returns -1 if the given position is not associated with any axis index.

        If this is a longitude axis, this method will handle the case of longitude values wrapping, therefore values of -180 and +180 are treated as equivalent by this method, irrespective of the values in ReferenceableAxis.getCoordinateValue(int).

        Specified by:
        findIndexOf in interface ReferenceableAxis<Double>
        Overrides:
        findIndexOf in class AbstractIrregularAxis<Double>
        Returns:
        the index of the given coordinate value, or -1 if not found.
      • extendFirstValue

        protected Double extendFirstValue​(Double firstVal,
                                          Double nextVal)
        Description copied from class: AbstractReferenceableAxis
        This should return the lower bound of the first value of the axis, based on the first and second values. This will generally be equivalent to:

        firstVal - (nextVal-firstVal)/2

        Specified by:
        extendFirstValue in class AbstractReferenceableAxis<Double>
        Parameters:
        firstVal - The first value of the axis
        nextVal - The second value of the axis
        Returns:
        The lower bound of the first axis value
      • extendLastValue

        protected Double extendLastValue​(Double lastVal,
                                         Double secondLastVal)
        Description copied from class: AbstractReferenceableAxis
        This should return the upper bound of the last value of the axis, based on the last two values. This will generally be equivalent to:

        lastVal + (lastVal-secondLastVal)/2

        Specified by:
        extendLastValue in class AbstractReferenceableAxis<Double>
        Parameters:
        lastVal - The last value of the axis
        secondLastVal - The next-to-last value of the axis
        Returns:
        The upper bound of the the final axis value
      • difference

        protected double difference​(Double pos1,
                                    Double pos2)
        Description copied from class: AbstractIrregularAxis
        Returns the difference between the supplied values. This is so that certain methods can be abstracted without worrying about non-trivial difference calculation (e.g. DateTimes)
        Specified by:
        difference in class AbstractIrregularAxis<Double>
        Parameters:
        pos1 - the first value
        pos2 - the second value
        Returns:
        the value corresponding to pos1 - pos2
      • getMidpoint

        protected Double getMidpoint​(Double pos1,
                                     Double pos2)
        Description copied from class: AbstractIrregularAxis
        Returns the midpoint of the supplied values. This is so that certain methods can be abstracted without worrying about non-trivial midpoint calculation (e.g. DateTimes)
        Specified by:
        getMidpoint in class AbstractIrregularAxis<Double>
        Parameters:
        pos1 - the first value
        pos2 - the second value
        Returns:
        the midpoint of the values