| Overview | Package | Class | Tree | Deprecated | Index | Help | |||
| PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||
java.lang.Object
|
+--java.util.Observable
|
+--ncsa.horizon.coordinates.CoordinateSystem
General Description
A CoordinateSystem object can be given a data voxel location and return a position in its world coordinate space in the form of a CoordPos object. The code might look something like this:
CoordinateSystem wcs;
CoordPos wcspos;
...
double datapos[] = { 0, 0, 0 }; // a position in the dataset
wcspos = wcs.getCoordPos(datapos); // the position in coordinate space
System.out.println( wcspos.getAxisLabel(0) + // print position
": " + // along 1st axis
wcspos.getValueString(0) );
System.out.println( wcspos.getAxisLabel(1) + // print position
": " + // along 2nd axis
wcspos.getValueString(1) );
which might produce something the following:
RA: 12:45:39.11
Dec: -30:17:20.2
The getDataLocation() and getVoxel() do the opposite transform of
getCoordPos(), translating a coordinate positions into voxel locations
in the dataset. A CoordinateSystem object can automatically convert positions to other coordinate systems by attaching one or more CoordTransform objects to it with attachTransform(); all subsequent calls to getCoordPos will produce positions in the new coordinate system.
Constructing a CoordinateSystem Usually, an application programmer would not need to explicitly construct CoordinateSystem objects; instead, such an object can be obtained by the Viewable method, getCoordinateSystem() which is all set up appropriately for the Viewable dataset.
| Field Summary | |
| Metadata | cmdata
|
| static GenericAxisPosFormatter | defPosPrinter
|
| int | gluedTrans
|
| java.lang.String[] | labels
|
| java.lang.String[] | modlabs
|
| Metadata | modmdata
|
| static MessageCenter | msgs
A bus for routing user messages. |
| java.lang.String[] | natlabs
|
| int | naxes
|
| int | nnataxes
|
| java.util.Stack | transdirs
|
| java.util.Stack | transforms
|
| java.util.Stack | transmaps
|
| boolean | usingTransforms
|
| Constructor Summary | |
| CoordinateSystem(int naxes,
Metadata md)
Construct a CoordinateSystem object |
|
| CoordinateSystem(int naxes)
Construct a CoordinateSystem object |
|
| CoordinateSystem(Metadata md)
Construct a CoordinateSystem object |
|
| CoordinateSystem()
Construct a CoordinateSystem object with 2 default axes |
|
| CoordinateSystem(int naxes,
Metadata md,
CoordTransform trans,
CoordTransformConstraints constraints)
Construct a CoordinateSystem using the specified transforms |
|
| CoordinateSystem(int naxes,
Metadata md,
java.util.Vector trans,
java.util.Vector constraints)
Construct a CoordinateSystem using the specified transforms |
|
| Method Summary | |
| void | attachTransform(CoordTransform t,
CoordTransformConstraints c)
attach a coordinate transform to this system with |
| void | attachTransform(CoordTransform t,
boolean attachForwards)
attach a coordinate transform to this system |
| void | attachTransform(CoordTransform t)
attach a coordinate transform to this system |
| java.lang.Object | clone()
clone this object |
| static CoordinateSystem | createSystem(Metadata cmd)
return a best-guess coordinate system given a set of metadata |
| CoordTransformConstraints | determineConstraints(CoordTransform in)
make an educated guess as to the proper way to apply a transform to this coordinate system. |
| CoordTransformConstraints | determineConstraints(CoordTransform in,
boolean forwards)
make an educated guess as to the proper way to apply a transform to this coordinate system. |
| java.lang.String | getAxisLabel(int axis)
return the currently set label for an axis |
| java.lang.String[] | getAxisLabel()
return the axis labels as an array of strings. |
| CoordPos | getCoordPos(Voxel vox)
return the coordinate position corresponding the specified data voxel |
| CoordPos | getCoordPos(double[] vox)
return the coordinate position corresponding the specified data voxel |
| double[] | getCoordValue(double[] vox)
return the coordinate position corresponding to the specified data voxel. |
| double[] | getDataLocation(double[] pos)
return the location within the dataset corresponding to the specified coordinate position |
| static int | getErrSlot()
return the slot number where error messages from this package are sent. |
| Metadata | getMetadata()
return a copy of the Metadata object that will describes this this system, accounting for any CoordTransform objects that may be attached and in use. |
| Metadata | getMetadata(boolean withTransforms)
return a copy of the Metadata object that will describes this this system |
| int | getNaxes()
return the number of axes in the space containing this position |
| int | getNTransforms()
return the number of removeable transforms attached to this CoordinateSystem. |
| Voxel | getVoxel(CoordPos pos)
return the location within the dataset corresponding to the specified coordinate position |
| Voxel | getVoxel(double[] pos)
return the location within the dataset corresponding to the specified coordinate position |
| void | glueTransforms(boolean updateMetadata)
permanently attach any removable transforms currently attached, making them non-removable. |
| boolean | isUsingTransforms()
return true attached CoordTransform objects are being used |
| CoordinateSystem | newCoordinateSystem()
return a CoordinateSystem that is a clone of this one except with the CoordTransform objects permanently attached |
| java.util.Stack | popAllTransforms()
remove and return all removable CoordTransform objects currently attached to this CoordinateSystem. |
| CoordTransform | popTransform()
remove and return the last CoordTransform object attached to this CoordinateSystem, or null if no transforms are currently attached |
| void | removeAllTransforms()
remove all removable CoordTransform object currently attached to this CoordinateSystem. |
| void | setAxisLabel(java.lang.String[] labs)
set the axis labels. |
| void | setAxisLabel(int i,
java.lang.String lab)
set an axis label. |
| static void | setErrSlot(int slot)
set the slot number were error messages from this package should be sent. |
| void | setUsingTransforms(boolean yes)
turn on or off the use of attached CoordTransform objects. |
| static void | suppressErrorMessages()
prevent error messages from this package from reaching the console |
| void | update(java.util.Observable o,
java.lang.Object arg)
|
| void | updateModifiedMetadata()
updates the modified metadata list. |
| static void | warn(java.lang.String msg)
print a warning message. |
| Methods inherited from class java.util.Observable | |
| addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged | |
| Methods inherited from class java.lang.Object | |
| clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait | |
| Field Detail |
protected int naxes
protected int nnataxes
protected boolean usingTransforms
protected Metadata cmdata
protected Metadata modmdata
protected java.lang.String[] labels
protected java.lang.String[] natlabs
protected java.lang.String[] modlabs
protected static GenericAxisPosFormatter defPosPrinter
protected java.util.Stack transforms
protected java.util.Stack transmaps
protected java.util.Stack transdirs
protected int gluedTrans
public static MessageCenter msgs
This bus is used by classes in this package (and its subpackages) to send error and warning messages to the user. The slot used by this package is returned by the getErrSlot() method.
| Constructor Detail |
public CoordinateSystem(int naxes,
Metadata md)
naxes
- the number of axes in this system
md
- the metadata that describes this system; note that no
transforms are defined based on values stored in this listpublic CoordinateSystem(int naxes)
naxes
- the number of axes in this systempublic CoordinateSystem(Metadata md)
md
- the metadata that describes this system; note that no
transforms are defined based on values stored in this listpublic CoordinateSystem()
public CoordinateSystem(int naxes,
Metadata md,
CoordTransform trans,
CoordTransformConstraints constraints)
throws java.lang.IllegalArgumentException
naxes
- the number of axes
md
- the metadata describing this system (after
any default transforms are applied)
trans
- the CoordTransform objects to apply by default,
or null if none should be applied. The transforms
should appear in this Vector in the order that
they should be applied. The Vector should not
contain any empty elements.
constraints
- the CoordTransformConstraints with which the
trans list should be applied, or null if
trans=null. The size of this Vector should be
equal to the size of trans and also should not
contain any empty elements.
public CoordinateSystem(int naxes,
Metadata md,
java.util.Vector trans,
java.util.Vector constraints)
throws java.lang.IllegalArgumentException
naxes
- the number of axes
md
- the metadata describing this system (after
any default transforms are applied)
trans
- a CoordTransform object to apply by default,
or null if none should be applied.
constraints
- the CoordTransformConstraints with which the
transform should be applied, or null if
trans=null.| Method Detail |
public int getNaxes()
public void attachTransform(CoordTransform t,
CoordTransformConstraints c)
throws java.lang.IllegalArgumentException,
java.lang.NullPointerException
t
- the transform to be atached
c
- the constraints by which to attach the transform
public void attachTransform(CoordTransform t,
boolean attachForwards)
throws IllegalTransformException
t
- the transform to be atached
attachForwards
- if true, the reverse transform should be
attached
public void attachTransform(CoordTransform t)
throws IllegalTransformException
t
- the transform to be atachedprotected void glueTransforms(boolean updateMetadata)
updateMetadata
- true if the default metadata should be updated
accordingly, or false if the currently set
default metadata should remain unchanged.public CoordTransformConstraints determineConstraints(CoordTransform in)
in
- the Metadata describing the system to be transformed
public CoordTransformConstraints determineConstraints(CoordTransform in,
boolean forwards)
in
- the Metadata describing the system to be transformed
forwards
- if false, the constraints determined should be
for attaching the reverse of the transformpublic int getNTransforms()
public CoordTransform popTransform()
public java.util.Stack popAllTransforms()
public void removeAllTransforms()
public boolean isUsingTransforms()
protected void updateModifiedMetadata()
public void setUsingTransforms(boolean yes)
yes
- true if the transforms should be usedpublic CoordinateSystem newCoordinateSystem()
public Metadata getMetadata()
public Metadata getMetadata(boolean withTransforms)
withTransforms
- true the Metadata returned should account
for any CoordTransform objects that may
be attached and in use; false, if they
should be ignored
public java.lang.String getAxisLabel(int axis)
throws java.lang.ArrayIndexOutOfBoundsException
axis
- the axis of interest; axes are numbered beginning with 0.public java.lang.String[] getAxisLabel()
public void setAxisLabel(java.lang.String[] labs)
public void setAxisLabel(int i,
java.lang.String lab)
throws java.lang.ArrayIndexOutOfBoundsException
public CoordPos getCoordPos(Voxel vox)
throws PositionBeyondDomainException,
TransformUndefinedException
vox
- the location in the dataset expressed as a Voxel.
The position along missing axes are taken to be
zero; extra axes are ignored.
public CoordPos getCoordPos(double[] vox)
throws PositionBeyondDomainException,
TransformUndefinedException
vox
- the location in the dataset expressed as an array
of doubles, with each element being the location
along each axis. Missing elements are taken to be
zero; extra elements are ignored.
public double[] getCoordValue(double[] vox)
throws PositionBeyondDomainException,
TransformUndefinedException
vox
- the location in the dataset expressed as a Voxel.
The position along missing axes are taken to be
zero; extra axes are ignored.
double[]
- the position in world coordinates, where each
element in the array is a representation of the
location along an axis as a double
public Voxel getVoxel(CoordPos pos)
throws PositionBeyondDomainException,
TransformUndefinedException
pos
- the position in world coordinates. No checking
is done to ensure that this position can exist
within this coordinate system (say, via a check
of its metadata). Values for missing axes are
taken to be zero; extra axes are ignored.
public Voxel getVoxel(double[] pos)
throws PositionBeyondDomainException,
TransformUndefinedException
pos
- the position in world coordinates, expressed as
an array of doubles where each element is a
representation of the location along an axis
Missing axes are taken to be zero; extra axes
are ignored.
public double[] getDataLocation(double[] pos)
throws PositionBeyondDomainException,
TransformUndefinedException
pos
- the position in world coordinates, expressed as
an array of doubles where each element is a
representation of the location along an axis
Missing axes are taken to be zero; extra axes
are ignored.public java.lang.Object clone()
public void update(java.util.Observable o,
java.lang.Object arg)
public static CoordinateSystem createSystem(Metadata cmd)
throws IllegalTransformException
cmd
- the metadata describing the systempublic static int getErrSlot()
public static void setErrSlot(int slot)
public static void suppressErrorMessages()
public static void warn(java.lang.String msg)
| Overview | Package | Class | Tree | Deprecated | Index | Help | |||
| PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||