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 forReferenceableAxis
implementations. 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 protected
AbstractReferenceableAxis(String name)
Creates an axis with the given name.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
contains(T position)
boolean
equals(Object obj)
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.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.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 anArray
of domain objects that comprise this domain.protected T
getFirstValue()
Gets the value of the axis at index 0protected T
getLastValue()
Gets the value of the axis at index (size - 1)protected T
getMaximumValue()
Returns the maximum coordinate value of this axis.protected T
getMinimumValue()
Returns the minimum coordinate value of this axis.String
getName()
int
hashCode()
-
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:
getName
in interfaceReferenceableAxis<T extends Comparable<? super T>>
- Returns:
- The name of the axis.
-
getCoordinateExtent
public Extent<T> getCoordinateExtent()
Description copied from interface:ReferenceableAxis
Gets the extent encompassing all the positions on this axis. This will usually be given by the low value of the first set ofcoordinate bounds
and the high value of the last set of coordinate bounds (but beware that values along the axis might decrease, not increase).- Specified by:
getCoordinateExtent
in interfaceReferenceableAxis<T extends Comparable<? super T>>
-
getCoordinateValues
public List<T> getCoordinateValues()
Description copied from interface:ReferenceableAxis
Gets all of the coordinate values of the axis- Specified by:
getCoordinateValues
in interfaceReferenceableAxis<T extends Comparable<? super T>>
- Returns:
- A list of coordinate values
-
getDomainObjects
public Array<Extent<T>> getDomainObjects()
Description copied from interface:DiscreteDomain
Returns anArray
of domain objects that comprise this domain.- Specified by:
getDomainObjects
in interfaceDiscreteDomain<T extends Comparable<? super T>,Extent<T extends Comparable<? super T>>>
-
contains
public boolean contains(T position)
- Specified by:
contains
in 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:
hashCode
in interfaceReferenceableAxis<T extends Comparable<? super T>>
- Overrides:
hashCode
in classObject
-
equals
public boolean equals(Object obj)
- Specified by:
equals
in interfaceReferenceableAxis<T extends Comparable<? super T>>
- Overrides:
equals
in classObject
-
-