Package uk.ac.rdg.resc.edal.grid
Class AbstractReferenceableAxis<T extends Comparable<? super T>>
- java.lang.Object
-
- uk.ac.rdg.resc.edal.grid.AbstractReferenceableAxis<T>
-
- All Implemented Interfaces:
Serializable,DiscreteDomain<T,Extent<T>>,Domain<T>,ReferenceableAxis<T>
- Direct Known Subclasses:
AbstractIrregularAxis,RegularAxisImpl
public abstract class AbstractReferenceableAxis<T extends Comparable<? super T>> extends Object implements ReferenceableAxis<T>, Serializable
Abstract superclass forReferenceableAxisimplementations. Handles the tricky case of searching for longitude values in the axis (longitude values wrap around the globe).- Author:
- Jon, Guy
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractReferenceableAxis(String name)Creates an axis with the given name.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancontains(T position)booleanequals(Object obj)protected abstract TextendFirstValue(T firstVal, T nextVal)This should return the lower bound of the first value of the axis, based on the first and second values.protected abstract TextendLastValue(T lastVal, T secondLastVal)This should return the upper bound of the last value of the axis, based on the last two values.Extent<T>getCoordinateExtent()Gets the extent encompassing all the positions on this axis.List<T>getCoordinateValues()Gets all of the coordinate values of the axisArray<Extent<T>>getDomainObjects()Returns anArrayof domain objects that comprise this domain.protected TgetFirstValue()Gets the value of the axis at index 0protected TgetLastValue()Gets the value of the axis at index (size - 1)protected TgetMaximumValue()Returns the maximum coordinate value of this axis.protected TgetMinimumValue()Returns the minimum coordinate value of this axis.StringgetName()inthashCode()-
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
findIndexOf, getCoordinateBounds, getCoordinateValue, isAscending, size, wraps
-
-
-
-
Constructor Detail
-
AbstractReferenceableAxis
protected AbstractReferenceableAxis(String name)
Creates an axis with the given name.
-
-
Method Detail
-
getFirstValue
protected final T getFirstValue()
Gets the value of the axis at index 0
-
getLastValue
protected final T getLastValue()
Gets the value of the axis at index (size - 1)
-
getMinimumValue
protected final T getMinimumValue()
Returns the minimum coordinate value of this axis. This will be the first coordinate value if the coordinate values are in ascending order, or the last coordinate value if the coordinate values are in descending order.- Returns:
- the minimum coordinate value of this axis
-
getMaximumValue
protected final T getMaximumValue()
Returns the maximum coordinate value of this axis. This will be the last coordinate value if the coordinate values are in ascending order, or the first coordinate value if the coordinate values are in descending order.- Returns:
- the maximum coordinate value of this axis
-
getName
public String getName()
- Specified by:
getNamein interfaceReferenceableAxis<T extends Comparable<? super T>>- Returns:
- The name of the axis.
-
getCoordinateExtent
public Extent<T> getCoordinateExtent()
Description copied from interface:ReferenceableAxisGets the extent encompassing all the positions on this axis. This will usually be given by the low value of the first set ofcoordinate boundsand the high value of the last set of coordinate bounds (but beware that values along the axis might decrease, not increase).- Specified by:
getCoordinateExtentin interfaceReferenceableAxis<T extends Comparable<? super T>>
-
getCoordinateValues
public List<T> getCoordinateValues()
Description copied from interface:ReferenceableAxisGets all of the coordinate values of the axis- Specified by:
getCoordinateValuesin interfaceReferenceableAxis<T extends Comparable<? super T>>- Returns:
- A list of coordinate values
-
getDomainObjects
public Array<Extent<T>> getDomainObjects()
Description copied from interface:DiscreteDomainReturns anArrayof domain objects that comprise this domain.- Specified by:
getDomainObjectsin interfaceDiscreteDomain<T extends Comparable<? super T>,Extent<T extends Comparable<? super T>>>
-
contains
public boolean contains(T position)
- Specified by:
containsin interfaceDomain<T extends Comparable<? super T>>- Returns:
- true if the given position is contained within this domain.
-
extendFirstValue
protected abstract T extendFirstValue(T firstVal, T nextVal)
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
- Parameters:
firstVal- The first value of the axisnextVal- The second value of the axis- Returns:
- The lower bound of the first axis value
-
extendLastValue
protected abstract T extendLastValue(T lastVal, T secondLastVal)
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
- Parameters:
lastVal- The last value of the axissecondLastVal- The next-to-last value of the axis- Returns:
- The upper bound of the the final axis value
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceReferenceableAxis<T extends Comparable<? super T>>- Overrides:
hashCodein classObject
-
equals
public boolean equals(Object obj)
- Specified by:
equalsin interfaceReferenceableAxis<T extends Comparable<? super T>>- Overrides:
equalsin classObject
-
-