| 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.CoordTransform
|
+--ncsa.horizon.coordinates.transforms.AbsToRelCoordTransform
See the documentation for the super class, CoordTransform, for a general description of how a transform is used.
The transform applied by this class is governed by two basic pieces of data: a reference position and a stepsize. The stepsize, a scale factor to be applied to width of a voxel, is usually left to its default value of 1.0. The reference position is the absolute position that the relative positions are referred to; that is, the reference position in the old system will be shifted to 0.0 in the new, transformed system.
When one instantiates this class, one usually indicates whether the
transform can adapt its reference position and stepsize according to the
CoordinateSystem it gets attached to. If this transform
is adaptable (e.g. willAdapt() returns true), then when the transform is
attached to a CoordinateSystem, it will change its reference
position to that found in the system's metadata, and the stepsize will
be set to 1.0. If it is not adaptable, it will use the reference position
and stepsize set at construction.
For example, if one wants to make a CoordinateSystem give positions in relative coordinates, one can:
CoordinateSystem csys;
int numaxes;
... // csys and numaxes are set
CoordTransform t = new AbsToRelCoordTransform(numaxes);
csys.attachTransform(t);
The csys system will now print out its coordinate positions
relative to its native reference position. However, if we want positions
be be relative to some other reference, we can instead:
double[] ref = { 20.0, 31.53, -15.8 };
CoordTransform t = new AbsToRelCoordTransform(ref.length, ref, false);
csys.attachTransform(t);
Now suppose the system already prints out relative coordinate positions;
We can change the positions to absolute ones by attaching this transform
in reverse:
double[] ref = { 20.0, 31.53, -15.8 };
CoordTransform t = new AbsToRelCoordTransform(ref.length, ref, false);
csys.attachTransform(t, false);
In this case, we needed to provide the reference position, since the
native reference (if the positions really are relative coordinates) is
likely to be zero. However, it may not be, and you can allow the transform
use that reference when attached in reverse:
CoordTransform t = new AbsToRelCoordTransform(numaxes, null, true);
csys.attachTransform(t, false);
This will cause the zero position in the native system to be shifted to
the native reference position; in addition, -1.0 will be used as the
stepsize. This turns about to be exactly equivalent to our first example.
| Field Summary | |
| boolean | adapt
if true, this transform--when attached to a CoordinateSystem--will replace its reference position data with that of the CoordinateSystem being attached to. |
| LinearCoordTransform | delegate
|
| Fields inherited from class ncsa.horizon.coordinates.CoordTransform | |
| fwdfmtrs, fwdnames, revfmtrs, revnames | |
| Constructor Summary | |
| AbsToRelCoordTransform()
create a AbsToRelCoordTransform object with default values, assuming it will operate on up to 2 axes. |
|
| AbsToRelCoordTransform(int naxes)
create a AbsToRelCoordTransform object with default values. |
|
| AbsToRelCoordTransform(int naxes,
double[] refval,
boolean adapt)
create a AbsToRelCoordTransform object specifying all internal data. |
|
| AbsToRelCoordTransform(int naxes,
double[] refval,
double[] stepsize,
boolean adapt)
create a AbsToRelCoordTransform object specifying all internal data. |
|
| AbsToRelCoordTransform(Metadata md)
create a linear transform based on the specified metadata using the horizon schema. |
|
| Method Summary | |
| java.lang.Object | clone()
create a copy of this Transform |
| double[] | forward(double[] position,
int[] axisIndices)
apply a forward tranform on an input position. |
| double[] | forward(double[] position)
apply a forward tranform on an input position. |
| int | getInNaxes()
return the minimum number of axes that the forward transform operates on. |
| int | getMaxNaxes()
return the maximum number of axes this transform operates on |
| Metadata | getMetadata(Metadata in,
boolean forward,
int[] axisIndices)
update the input Metadata object to reflect the changes that this tranform makes to a coordinate position. |
| int | getOutNaxes()
return the minimum number of axes that results from the forward transform. |
| double | getRefvalue(int axis)
return the axis reference value for the specified axis. |
| double[] | getRefvalue()
return a copy of the axis reference values for all axes. |
| double | getStepsize(int axis)
return the axis step size for the specified axis. |
| double[] | getStepsize()
return the axis step size for each axis. |
| void | init(CoordinateSystem csys,
boolean forward,
int[] axisIndices)
initialize this transform according to the system it is to be applied to. |
| double[] | reverse(double[] position,
int[] axisIndices)
apply a reverse tranform on an input position |
| double[] | reverse(double[] position)
apply a reverse tranform on an input position. |
| void | setMaxNaxes(int naxes)
set the maximum number of axes this transform operates on |
| void | setRefvalue(int axis,
double in)
set the axis reference value for the specified axis. |
| void | setRefvalue(double[] in)
set the axis reference value for each axis. |
| void | setStepsize(int axis,
double in)
set the axis step size for the specified axis. |
| void | setStepsize(double[] in)
set the axis step size for each axis. |
| void | setToAdapt(boolean doadapt)
set whether this transform should adapt its internal data according to the reference position data of the CoordinateSystem it gets attached to. |
| boolean | willAdapt()
return whether the data internal to this object will get update upon attachment to a CoordinateSystem. |
| Methods inherited from class ncsa.horizon.coordinates.CoordTransform | |
| applyNamesAndFormatters, canTransform, canTransform, canTransform, clone, determineConstraints, determineConstraints, forward, forward, getFormatters, getInNaxes, getMetadata, getNames, getOutNaxes, init, reverse, reverse, setFormatter, setName | |
| 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 boolean adapt
protected LinearCoordTransform delegate
| Constructor Detail |
public AbsToRelCoordTransform()
public AbsToRelCoordTransform(int naxes)
naxes
- the maximum number of axes this transform can
operate on
public AbsToRelCoordTransform(int naxes,
double[] refval,
boolean adapt)
naxes
- the maximum number of axes this transform can
operate on
refval
- the position in the "output" system (the system
forward() transforms to) that is equal to the
the refpos position. Default equals 0.
adapt
- if false, these values should not be updated when
attached to a CoordinateSystem. (If one intends
intend to attach this AbsToRelCoordTransform to a
CoordinateSystem, this value will not be used.)
public AbsToRelCoordTransform(int naxes,
double[] refval,
double[] stepsize,
boolean adapt)
naxes
- the maximum number of axes this transform can
operate on
refval
- the position in the "output" system (the system
forward() transforms to) that is equal to the
the refpos position. Default equals 0.
stepsize
- the size of a voxel of the "output" system (the
system that forward() transforms to) in units of
the "input" system
adapt
- if false, these values should not be updated when
attached to a CoordinateSystem. (If one intends
intend to attach this AbsToRelCoordTransform to a
CoordinateSystem, this value will not be used.)
public AbsToRelCoordTransform(Metadata md)
throws IllegalTransformException
| Method Detail |
public double[] forward(double[] position,
int[] axisIndices)
position
- an array giving the input position to transform
axisIndices
- an array containing the indices of the position
array that should be used in the tranformation.
The order of the indices indicate how the position
should be interpreted by the transform.public double[] forward(double[] position)
position
- an array giving the input position to transform
public double[] reverse(double[] position,
int[] axisIndices)
position
- an array giving the input position to transform
axisIndices
- an array containing the indices of the position
array that should be used in the tranformation.
The order of the indices indicate how the position
should be interpreted by the transform.public double[] reverse(double[] position)
position
- an array giving the input position to transformpublic int getInNaxes()
public int getOutNaxes()
public int getMaxNaxes()
public void setMaxNaxes(int naxes)
throws java.lang.ArrayIndexOutOfBoundsException
public void setRefvalue(int axis,
double in)
throws java.lang.ArrayIndexOutOfBoundsException
axis
- the index of the axis to be set (first axis has index 0)
in
- value to be set
public double getRefvalue(int axis)
throws java.lang.ArrayIndexOutOfBoundsException
axis
- the index of the axis to be set (first axis has index 0)public void setRefvalue(double[] in)
in
- values to be set; missing or extra values are ignoredpublic double[] getRefvalue()
public void setStepsize(int axis,
double in)
throws java.lang.ArrayIndexOutOfBoundsException
axis
- the index of the axis to be set (first axis has index 0)
in
- value to be set
public double getStepsize(int axis)
throws java.lang.ArrayIndexOutOfBoundsException
axis
- the index of the axis to be set (first axis has index 0)public void setStepsize(double[] in)
axis
- the index of the axis to be set (first axis has index 0)
in
- value to be setpublic double[] getStepsize()
axis
- the index of the axis to be set (first axis has index 0)
in
- value to be setpublic java.lang.Object clone()
public Metadata getMetadata(Metadata in,
boolean forward,
int[] axisIndices)
public void setToAdapt(boolean doadapt)
public boolean willAdapt()
public void init(CoordinateSystem csys,
boolean forward,
int[] axisIndices)
throws IllegalTransformException
| Overview | Package | Class | Tree | Deprecated | Index | Help | |||
| PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||