Class AbstractIrregularAxis<T extends Comparable<? super T>>

    • Field Detail

      • axisValues

        protected T extends Comparable<? super T>[] axisValues
        The axis values, always in ascending numerical order to simplify searching
      • reversed

        protected boolean reversed
        True if axis values in the above array have been reversed
    • Constructor Detail

      • AbstractIrregularAxis

        protected AbstractIrregularAxis​(String name,
                                        List<T> axisValues)
    • Method Detail

      • checkAscending

        protected void checkAscending()
        Checks that the axis values ascend or descend monotonically, throwing an IllegalArgumentException if not.
      • getCoordinateValue

        public T getCoordinateValue​(int index)
        Description copied from interface: ReferenceableAxis
        Gets the coordinate value at the given index
        Parameters:
        index - The index of the required position on the axis. Must be within the axis' extent.
        Returns:
        the coordinate value at the given index
      • findIndexOf

        public int findIndexOf​(T value)
        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).

        Returns:
        the index of the given coordinate value, or -1 if not found.
      • size

        public int size()
        Returns:
        The extent of this axis. Indices within this axis will run from 0 to ReferenceableAxis.size() - 1
      • isAscending

        public boolean isAscending()
        Description copied from interface: ReferenceableAxis
        Returns true if the values on the axis are in ascending order according to their natural ordering.
      • getCoordinateBounds

        public Extent<T> getCoordinateBounds​(int index)
        Description copied from interface: ReferenceableAxis
        Gets the coordinate bounds associated with the point at the given index. In some types of ReferenceableAxis, each point along the axis is associated with a range of positions, rather than a single infinitesimal position. This method returns this range.
        Returns:
        the coordinate bounds associated with the point at the given index. Returns an Extent with low=high if the bounds are infinitesimal. Never returns null.
      • getMidpoint

        protected abstract T getMidpoint​(T pos1,
                                         T pos2)
        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)
        Parameters:
        pos1 - the first value
        pos2 - the second value
        Returns:
        the midpoint of the values
      • difference

        protected abstract double difference​(T pos1,
                                             T pos2)
        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)
        Parameters:
        pos1 - the first value
        pos2 - the second value
        Returns:
        the value corresponding to pos1 - pos2