All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object
|
+----java.util.Observable
|
+----ncsa.horizon.coordinates.CoordTransform
This is an abstract class which can be sub-classed and fully
implemented to create a CoordTransform object that can be
attached to a CoordinateSystem object or used by itself.
Attaching a CoordTransform to a
CoordinateSystemC
A CoordTransform object is most commonly used by
attaching it to a CoordinateSystem via the latter's
attachTransform. This causes the
CoordinateSystem to automatically apply the transform
everytime positions are requested from the system. When the transform
is attached, it can (if necessary) adjust the parameters of the
transform based on the CoordinateSystem's metadata; it
can also advise the CoordinateSystem on how the latter
should update its metadata to reflect the new transformation.
Two of the things an attached
Using a
The methods
Each element in the position array given to
In the documentation below, the terms "old" and "new" refer the to
two systems relative to the direction of this transform; that is,
the forward() method transforms a position in the "old" system to
a position in the new system.
Implementing a CoordTransform Object
A instantiatable CoordTransform must at a minimum implement six method:
Implementations may also wish to override one or a few of the other
methods in this class that are called when the transform is attached
to a
Finally, implementations may wish to set some default axis names and
formatters within the transform constructors. For these to be passed on
to a
Note that method that update the internal state of a
CoordTransform can suggest
to a CoordinateSystem are what to name the transformed
axes and how to print out the transformed positions. This is done
by providing some suggested Strings to use as names and
AxisPosFormatter objects to use as formatters. The default
suggestions (if there are any) can be overriden via the
setName() and setFormatter() method. CoordTransform Directlyforward() and reverse() apply
the transform to an array of doubles that represents a position in one
of the systems (each element being the position along an axis of the
system). What defines the forward transform is in general completely
arbitrary and up to the specific implementations. Furthermore, the
number axes in the two systems do not need to be equal. For
efficiency, these methods have the option of manipulating the elements
of the input position array directly and returning it, or return a new
array if number of axes in the input system is different from that of
the output system. forward(double[]) or reverse(double[])
represents a position along some coordinate system axis. When one of
these methods is called, the CoordTransform applies its operation on
the input array assuming that axes are in some specific order; for
instance, it may assume that the first element is a longitude and the
second is a latitude. (See the transform's documentation for
forward(double[]) and reverse(double[]) for
the assumed order.) However, one can take more control over how the
transform is applied by calling forward(double[], int[])
or reverse(double[], int[]). The second argument in this
case is an axis index array which gives the location in the position
array of each required axis. So, using our example, if the longitude
axis is actually the third element and the latitude is first element,
the axis index array should be equal to {2, 0}. The position elements
not listed in the axis index array are left unchanged by the
transform.
The last two return the minimum number of axes needed to apply the
transform (see description below). The other four actually perform the
transformation. The forward(double[]) and reverse(double[]) methods
assume that the axes of the position are ordered in the default way.
Most of the Horizon CoordTransform classes put the actual transforming
code in the version of forward() and reverse() that take an axis index
array (see previous section); the single argument versions of forward()
and reverse() merely call the two-argument versions with a default
axis index array. CoordinateSystem. When the transform is attached,
the CoordinateSystem calls the transform's
init(); this allows the transform to adjust its internal
parameters according to the system's metadata. (By default
init() is a do-nothing method.) Next, the
CoordinateSystem calls the transform's
getMetadata() to update the system's metadata to reflect
the new transformation. The default version of getMetadata()
calls applyNamesAndFormatters() to update the axis names
and formatters; thus overriding versions should call either
super.getMetadata() or applyNamesAndFormatters().
CoordinateSystem during attachment, it is not necessary
to override getMetadata(); the default version does this
automatically. CoordTransform should consider that the transform might be
attached to a CoordinateSystem at the time; therefore, the
methods should call hasChanged() and notifyObservers().
fwdfmtrs
fwdnames
revfmtrs
revnames
applyNamesAndFormatters(Metadata, boolean, int[])
canTransform(Metadata)
canTransform(Metadata, boolean)
canTransform(Metadata, CoordTransformConstraints)
clone()
determineConstraints(Metadata)
determineConstraints(Metadata, boolean)
forward(double[])
forward(double[], int[])
getFormatters(boolean)
getInNaxes()
getMetadata(Metadata, boolean, int[])
getNames(boolean)
getOutNaxes()
init(CoordinateSystem, boolean, int[])
reverse(double[])
reverse(double[], int[])
setFormatter(int, AxisPosFormatter, boolean)
setName(int, String, boolean)
fwdfmtrs
protected Vector fwdfmtrs
revfmtrs
protected Vector revfmtrs
fwdnames
protected Vector fwdnames
revnames
protected Vector revnames
CoordTransform
public CoordTransform()
forward
public abstract double[] forward(double position[],
int axisIndices[]) throws PositionBeyondDomainException, TransformUndefinedException
forward
public abstract double[] forward(double position[]) throws PositionBeyondDomainException, TransformUndefinedException
reverse
public abstract double[] reverse(double position[],
int axisIndices[]) throws PositionBeyondDomainException, TransformUndefinedException
reverse
public abstract double[] reverse(double position[]) throws PositionBeyondDomainException, TransformUndefinedException
getInNaxes
public int getInNaxes()
getOutNaxes
public int getOutNaxes()
init
public void init(CoordinateSystem csys,
boolean forward,
int axisIndices[]) throws IllegalTransformException
getMetadata
public Metadata getMetadata(Metadata in,
boolean forward,
int axisIndices[])
determineConstraints
public CoordTransformConstraints determineConstraints(Metadata in)
new CoordTransformConstraints(n) where
n is the value of the "naxes" metadatum; however, sub-classers are
encouraged to override this. Note that there may exist a number
of ways that this transform might be logically applied to a
coordinate system.
determineConstraints
public CoordTransformConstraints determineConstraints(Metadata in,
boolean forwards)
new CoordTransformConstraints(n) where
n is the value of the "naxes" metadatum; however, sub-classers are
encouraged to override this. Note that there may exist a number
of ways that this transform might be logically applied to a
coordinate system.
canTransform
public boolean canTransform(Metadata in)
canTransform
public boolean canTransform(Metadata in,
boolean forwards)
canTransform
public boolean canTransform(Metadata in,
CoordTransformConstraints c)
setFormatter
public synchronized void setFormatter(int axis,
AxisPosFormatter formatter,
boolean forForward)
getFormatters
public AxisPosFormatter[] getFormatters(boolean forForward)
setName
public synchronized void setName(int axis,
String name,
boolean forForward)
getNames
public String[] getNames(boolean forForward)
applyNamesAndFormatters
public synchronized void applyNamesAndFormatters(Metadata md,
boolean forward,
int axisIndices[])
clone
public synchronized Object clone()
All Packages Class Hierarchy This Package Previous Next Index