Class ncsa.horizon.coordinates.CoordPos
All Packages Class Hierarchy This Package Previous Next Index
Class ncsa.horizon.coordinates.CoordPos
java.lang.Object
|
+----ncsa.horizon.coordinates.CoordPos
- public class CoordPos
- extends Object
- implements Cloneable
support for accessing a representation (string or double) of a position
in a coordinate system.
A CoordPos object represents a position in a coordinate space. Such an
object is often returned by CoordinateSystem object methods and can be
handed back to a Coordinate object for conversion to a data voxel location.
One of the most useful features of the CoordPos object is that is knows
how to format itself as a string. Code to print out parts of the
CoordPos's value might look something like this:
CoordPos wcspos;
...
wcspos = wcs.getCoordPos(datapos);
System.out.println( wcspos.getAxisLabel(0) + // print position
": " + // along 1st axis
wcspos.valueString(0) );
System.out.println( wcspos.getAxisLabel(1) + // print position
": " + // along 2nd axis
wcspos.valueString(1) );
which might produce something the following:
RA: 12:45:39.11
Dec: -30:17:20.2
Note that axes are numbered beginning with 0.
Position values as doubles can be both retrieved and set.
Coordinate Metadata
A CoordPos can also carry along with it information about the coordinate
system within which it exists, stored as a Metadata object. In general,
the values within the Metadata list are not actually used by the CoordPos
itself (with the exception of two constructors, CoordPos(Metadata) and
CoordPos(Metadata, double[])). For this reason, CoordPos allows you
to directly manipulate its own copy of its Metadata list. That is,
one can make updates to the list directly and have the changes stick
with the CoordPos object without a call to setMetadata(); e.g:
CoordPos wcspos;
...
wcspos.getMetadata().put("name", "Celestial-Velocity");
See Metadata for more
information about accesssing and setting metadata. See also
CoordMetadata
for information about recognized coordinate metadata names.
-
cmdata
-
-
defPosPrinter
-
-
labels
-
-
naxes
-
-
pos
-
-
posPrinter
-
-
CoordPos(int)
- Construct a default coordinate position in a system with a specified
number of axes.
-
CoordPos(int, double[], double, String[], String, AxisPosFormatter[], AxisPosFormatter, Metadata)
- Construct a CoordPos object, specifying all of its internal data.
-
CoordPos(int, double[], Metadata)
- Construct a default coordinate position in a system with a specified
number of axes and an initial position.
-
CoordPos(int, double[], String[], AxisPosFormatter[], Metadata)
- Construct a CoordPos object, specifying all of its internal data.
-
CoordPos(int, Metadata)
- Construct a default coordinate position in a system with a specified
number of axes.
-
CoordPos(Metadata)
- Construct a default coordinate position in a system with a specified
number of axes.
-
CoordPos(Metadata, double[])
- Construct a default coordinate position in a system with a specified
number of axes.
-
clone()
- clone this object.
-
getAxisLabel()
- return the axis labels as an array of strings.
-
getAxisLabel(int)
- return the currently set label for an axis
-
getMetadata()
- return a Metadata object that identifies the coordinate
system within which this coordinate position exists.
-
getNaxes()
- return the number of axes in this coordinate system
-
getValue()
- return an array of doubles representing the position along each
axis
-
getValue(int)
- return a double containing the position's projection along
an axis
-
setAxisLabel(int, String)
- set an axis label.
-
setAxisLabel(String[])
- set the axis labels.
-
setMetadata(Metadata)
- set the Metadata object that identifies the coordinate
system within which this coordinate position exists.
-
setValue(double[])
- set the position along all axes with the values given in the input
array, returning the old values;
-
setValue(int, double)
- set the position's projection along an axis to a value
-
valueString(int)
- return a formatted string containing the position's projection along
an axis
-
valueString(int, int)
- return a formatted string containing the position's projection along
an axis
-
valueStrings()
- return an array of formatted strings containing the position's
projection along each axis
-
valueStrings(int)
- return an array of formatted strings containing the position's
projection along each axis
naxes
protected int naxes
labels
protected String labels[]
pos
protected double pos[]
posPrinter
protected AxisPosFormatter posPrinter[]
defPosPrinter
protected static GenericAxisPosFormatter defPosPrinter
cmdata
protected Metadata cmdata
CoordPos
public CoordPos(int naxes)
- Construct a default coordinate position in a system with a specified
number of axes.
- Parameters:
- naxes - the number of axes in the coordinate system
CoordPos
public CoordPos(int naxes,
Metadata md)
- Construct a default coordinate position in a system with a specified
number of axes. Note that the value of naxes overrides any value
that might appear in the Metadata list.
- Parameters:
- naxes - the number of axes in the coordinate system
- md - the Metadata describing the coordinate system within
which this position exists. Can be null. A copy
of this object (using md.deepClone()) is stored
internally.
CoordPos
public CoordPos(int naxes,
double position[],
Metadata md)
- Construct a default coordinate position in a system with a specified
number of axes and an initial position. Note that the value of
naxes overrides any value
that might appear in the Metadata list.
- Parameters:
- naxes - the number of axes in the coordinate system
- position - a representation of the coordinate position
as a double array. Can be null.
- md - the Metadata describing the coordinate system within
which this position exists. Can be null. A copy
of this object (using md.deepClone()) is stored
internally.
CoordPos
public CoordPos(Metadata md) throws CorruptedMetadataException
- Construct a default coordinate position in a system with a specified
number of axes. The number of axes, the labels, and the formatters
are all obtained from the specified Metadata list.
- Parameters:
- md - the Metadata describing the coordinate system within
which this position exists. Can be null. A copy
of this object (using md.deepClone()) is stored
internally.
- Throws: CorruptedMetadataException
- if the "naxes" metadatum is
not found in md or is of an illegal value
CoordPos
public CoordPos(Metadata md,
double position[]) throws CorruptedMetadataException
- Construct a default coordinate position in a system with a specified
number of axes. The number of axes, the labels, and the formatters
are all obtained from the specified Metadata list.
- Parameters:
- md - the Metadata describing the coordinate system within
which this position exists. Can be null. A copy
of this object (using md.deepClone()) is stored
internally.
- position - a representation of the coordinate position
as a double array. Can be null.
- Throws: CorruptedMetadataException
- if the "naxes" metadatum is
not found in md or is of an illegal value
CoordPos
public CoordPos(int naxes,
double position[],
String labels[],
AxisPosFormatter formatters[],
Metadata md) throws IllegalArgumentException
- Construct a CoordPos object, specifying all of its internal data.
Any metadata of unexpected types are ignored.
- Parameters:
- naxes - the number of axes in the coordinate system
- position - a representation of the coordinate position
as a double array. Can be null.
- labels - the labels to use for identifying each of the
axes. If a label is missing (or is null), then
the value of the "Axis[n].label" metadatum is
used; failing that, "Axis[n].name" is used followed
by the string "Pixels".
- formatters - the formatting objects to use when printing a
position along each coordinate axis. If a formatter
is missing (or is null), then the value of the
"Axis[n].formatter" is used; failing that, a
GenericAxisPosFormatter object is used.
- md - the Metadata describing the coordinate system within
which this position exists. Can be null. A copy
of this object (using md.deepClone()) is stored
internally.
- Throws: IllegalArgumentException
- if naxes <= 0
CoordPos
public CoordPos(int naxes,
double position[],
double defpos,
String labels[],
String deflab,
AxisPosFormatter formatters[],
AxisPosFormatter deffmtr,
Metadata md) throws IllegalArgumentException
- Construct a CoordPos object, specifying all of its internal data.
Note that appropriate values for the formatters and labels found
in the Metadata object overrides the default given in this
constructor. Any metadata of unexpected types are ignored.
- Parameters:
- naxes - the number of axes in the coordinate system
- position - a representation of the coordinate position
as a double array. Can be null.
- defpos - a default value to use for elements that are
missing from position (i.e. elements with indices
< naxes but >= position.length).
- labels - the labels to use for identifying each of the
axes. If a label is missing (or is null), then
the value of the "Axis[n].label" metadatum is
used; failing that, "Axis[n].name" is used followed
by the value of deflab.
- deflab - the default label to use if nothing better can be
found. If null, "Pixels" is used
- formatters - the formatting objects to use when printing a
position along each coordinate axis. If a formatter
is missing (or is null), then the value of the
"Axis[n].formatter" is used; failing that, deffmtr
is used.
- deffmtr - the default label to use if nothing better can be
found. If null, a GenericAxisPosFormatter object
is used.
- md - the Metadata describing the coordinate system within
which this position exists. Can be null. A copy
of this object (using md.deepClone()) is stored
internally.
- Throws: IllegalArgumentException
- if naxes <= 0
getNaxes
public int getNaxes()
- return the number of axes in this coordinate system
getAxisLabel
public String getAxisLabel(int axis) throws ArrayIndexOutOfBoundsException
- return the currently set label for an axis
- Parameters:
- axis - the axis of interest; axes are numbered beginning with 0.
getAxisLabel
public String[] getAxisLabel()
- return the axis labels as an array of strings. The index of the
label for the first axis is zero.
setAxisLabel
public void setAxisLabel(String labs[])
- set the axis labels. Extra labels in the input array are ignored.
setAxisLabel
public void setAxisLabel(int i,
String lab) throws ArrayIndexOutOfBoundsException
- set an axis label. This method will not affect the contents of
the Metadata object returned by the getMetadata() method.
getMetadata
public Metadata getMetadata()
- return a Metadata object that identifies the coordinate
system within which this coordinate position exists.
- Returns:
- Metadata an editable Metadata object (not a copy), or null
if one is not available.
Updates made to the returned Metadata's
contents will be carried along with this CoordPos
object even without calls to setMetadata().
setMetadata
public void setMetadata(Metadata md)
- set the Metadata object that identifies the coordinate
system within which this coordinate position exists.
getValue
public double getValue(int axis) throws ArrayIndexOutOfBoundsException
- return a double containing the position's projection along
an axis
- Parameters:
- axis - the axis of interest; axes are numbered beginning with 0.
setValue
public void setValue(int axis,
double newval) throws ArrayIndexOutOfBoundsException
- set the position's projection along an axis to a value
- Parameters:
- axis - the axis of interest; axes are numbered beginning with 0.
- newval - the new value
- Returns:
- the old value
getValue
public double[] getValue()
- return an array of doubles representing the position along each
axis
setValue
public void setValue(double newpos[])
- set the position along all axes with the values given in the input
array, returning the old values;
valueString
public String valueString(int axis) throws ArrayIndexOutOfBoundsException
- return a formatted string containing the position's projection along
an axis
- Parameters:
- axis - the axis of interest; axes are numbered beginning with 0.
valueString
public String valueString(int axis,
int prec) throws ArrayIndexOutOfBoundsException
- return a formatted string containing the position's projection along
an axis
- Parameters:
- axis - the axis of interest; axes are numbered beginning with 0.
- prec - the precision of the string; the interpretation of the
as depends on the AxisPosFormatter object in use for the
requested axis.
valueStrings
public String[] valueStrings() throws ArrayIndexOutOfBoundsException
- return an array of formatted strings containing the position's
projection along each axis
valueStrings
public String[] valueStrings(int prec) throws ArrayIndexOutOfBoundsException
- return an array of formatted strings containing the position's
projection along each axis
- Parameters:
- prec - the precision of the string; the interpretation of the
as depends on the AxisPosFormatter object in use for the
requested axis.
clone
public Object clone()
- clone this object.
- Overrides:
- clone in class Object
All Packages Class Hierarchy This Package Previous Next Index