Package uk.ac.rdg.resc.edal.grid
Class AbstractIrregularAxis<T extends Comparable<? super T>>
- java.lang.Object
-
- uk.ac.rdg.resc.edal.grid.AbstractReferenceableAxis<T>
-
- uk.ac.rdg.resc.edal.grid.AbstractIrregularAxis<T>
-
- Type Parameters:
T- The type of value the axis contains
- All Implemented Interfaces:
Serializable,DiscreteDomain<T,Extent<T>>,Domain<T>,ReferenceableAxis<T>
- Direct Known Subclasses:
ReferenceableAxisImpl,TimeAxisImpl
public abstract class AbstractIrregularAxis<T extends Comparable<? super T>> extends AbstractReferenceableAxis<T>
Partial implementation of an irregular axis.- Author:
- Guy, Jon
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected T[]axisValuesThe axis values, always in ascending numerical order to simplify searchingprotected booleanreversedTrue if axis values in the above array have been reversed
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractIrregularAxis(String name, List<T> axisValues)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcheckAscending()Checks that the axis values ascend or descend monotonically, throwing an IllegalArgumentException if not.protected abstract doubledifference(T pos1, T pos2)Returns the difference between the supplied values.booleanequals(Object obj)intfindIndexOf(T value)Finds the index along this axis that corresponds with the given position.Extent<T>getCoordinateBounds(int index)Gets the coordinate bounds associated with the point at the given index.TgetCoordinateValue(int index)Gets the coordinate value at the given indexprotected abstract TgetMidpoint(T pos1, T pos2)Returns the midpoint of the supplied values.inthashCode()booleanisAscending()Returns true if the values on the axis are in ascending order according to their natural ordering.intsize()-
Methods inherited from class uk.ac.rdg.resc.edal.grid.AbstractReferenceableAxis
contains, extendFirstValue, extendLastValue, getCoordinateExtent, getCoordinateValues, getDomainObjects, getFirstValue, getLastValue, getMaximumValue, getMinimumValue, getName
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface uk.ac.rdg.resc.edal.grid.ReferenceableAxis
wraps
-
-
-
-
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
-
-
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:ReferenceableAxisGets 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:ReferenceableAxisFinds 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:ReferenceableAxisReturns 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:ReferenceableAxisGets 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 valuepos2- 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 valuepos2- the second value- Returns:
- the value corresponding to pos1 - pos2
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceReferenceableAxis<T extends Comparable<? super T>>- Overrides:
hashCodein classAbstractReferenceableAxis<T extends Comparable<? super T>>
-
equals
public boolean equals(Object obj)
- Specified by:
equalsin interfaceReferenceableAxis<T extends Comparable<? super T>>- Overrides:
equalsin classAbstractReferenceableAxis<T extends Comparable<? super T>>
-
-