Class RegularAxisImpl

    • Constructor Detail

      • RegularAxisImpl

        public RegularAxisImpl​(String name,
                               double firstValue,
                               double spacing,
                               int size,
                               boolean isLongitude)
    • Method Detail

      • getCoordinateSpacing

        public double getCoordinateSpacing()
        Description copied from interface: RegularAxis
        Gets the spacing between coordinate values, might be negative.
        Specified by:
        getCoordinateSpacing in interface RegularAxis
      • getCoordinateValue

        public Double getCoordinateValue​(int index)
        Description copied from interface: ReferenceableAxis
        Gets the coordinate value at the given index
        Specified by:
        getCoordinateValue in interface ReferenceableAxis<Double>
        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
      • 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.
        Specified by:
        isAscending in interface ReferenceableAxis<Double>
      • getCoordinateBounds

        public Extent<Double> 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.
        Specified by:
        getCoordinateBounds in interface ReferenceableAxis<Double>
        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.
      • 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>
        Returns:
        the index of the given coordinate value, or -1 if not found.
      • findIndexOfUnconstrained

        public int findIndexOfUnconstrained​(Double position)
        Description copied from interface: RegularAxis
        Finds the apparent index of a given position, even if this is beyond the bounds of the axis.
        Specified by:
        findIndexOfUnconstrained in interface RegularAxis
        Parameters:
        position - The position to test.
        Returns:
        The index where the position would appear, even if outside the bounds of this axis
      • 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