Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class ncsa.horizon.util.AdjustableVolume

java.lang.Object
  |
  +--ncsa.horizon.util.Volume
        |
        +--ncsa.horizon.util.AdjustableVolume

public class AdjustableVolume
extends Volume
implements SafeAsMetadata
a reshapable Volume.

This class provides methods for changing the volumes position, size, sampling, and axis order. Only the number of axes in the space in which this Volume lives is immutable, being set at construction.

See Also:
Volume, Serialized Form

Inner classes inherited from class ncsa.horizon.util.Volume
Volume.IndexOrder
 
Fields inherited from class ncsa.horizon.util.Volume
CAN_EXTRAPOLATE, CAN_INTERPOLATE, flags, loc, naxes, NONE, order, sample, size
 
Constructor Summary
AdjustableVolume(int nax)
          create a Volume object in a space of nax dimensions and initialize it to have a unit size with a sampling of 1 along each axis.
AdjustableVolume(int nax, int[] ori, int[] sz, int[] sam)
          create a Volume object in a space of nax dimensions and initialize it to a given location, size, and sampling for each axis.
AdjustableVolume(int nax, double[] ori, double[] sz, double[] sam)
          create a Volume object in a space of nax dimensions and initialize it to a given location, size, and sampling for each axis.
AdjustableVolume(Volume in)
          create a Volume object that is a copy of another Volume.
AdjustableVolume(Voxel in)
          create a Volume object of unit size (and unit sampling) whose origin vertex is located at the given voxel.
 
Method Summary
void expandTo(Voxel vox)
          expand this Volume just enough to include a given Voxel.
void expandTo(Volume that)
          compute the union of this volume with another.
double[] getExactOrigin()
          return the exact origin of this Volume represented as an array of doubles.
double getExactOrigin(int axis)
          return the exact origin of this Volume along a given axis.
java.util.Observable getMonitor()
          return an Observable monitor for listening for changes to this Volume.
int[] getOrigin()
          return the origin of this Volume (rounded to the nearest integer) represented as an array of integers.
int getOrigin(int axis)
          return the origin of this Volume (rounded to the nearest integer) along a given axis.
int[] getRoundedStride()
          return an array of ints representing the sampling of the data space along each side, rounded to the nearest integer.
int[] getSize()
          return the size of the largest volume with lengths of integer length enclosed by this volume.
int getSize(int axis)
          return the largest integer length that is less than or equal to the length of one side of this volume.
double[] getStride()
          return an array of doubles representing the sampling of the data space along each side.
double getStride(int i)
          return the sampling of the data space along a given side.
void grow(Voxel vox)
          increase the size of each side by the projected distance of a Voxel from its origin along each corresponding axis.
void grow(int[] pos)
          increase the size of each side by the projected distance of a position from its origin along each corresponding axis.
void grow(double[] pos)
          increase the size of each side by the projected distance of a position from its origin along each corresponding axis.
boolean isMutable()
          return true if the paramters of this Volume can change.
void resetAxisOrder()
          reset the axis order to their natural order; i.e. {
void reverseAxes()
          reverse the axis order.
void setAxisOrder(int[] axorder)
          set the axis order.
void setOrigin(int[] pos)
          set the origin of this Volume to a position given by an array of integers.
void setOrigin(int idx, int pos)
          set one component of the origin of this Volume to a given position along a given axis
void setOrigin(double[] pos)
          set the origin of this Volume to a fractional position given by an array of integers.
void setOrigin(int idx, double pos)
          set one component of the origin of this Volume to a given position along a given axis
void setOrigin(Voxel vox)
          set the origin of this volume to the position of a given Voxel
void setSize(int[] sz)
          set the size of this volume to the lengths given in an integer array
void setSize(int idx, int sz)
          set the length of this volume along one axis to a given integer value
void setSize(double[] sz)
          set the size of this volume to the fractional lengths given in an array of doubles
void setSize(int idx, double sz)
          set the length of this volume along one axis to a given fractional value
void setStride(double[] sam)
          set the sampling rate along each axis of the volume
void setStride(int idx, double sam)
          return the sampling of the data space along a given side.
void setStride(int[] sam)
          set the sampling rate along each axis of the volume
void setStride(int idx, int sam)
          return the sampling of the data space along a given side.
void shiftAxes(int n)
          shift the axis order forward n steps.
void swapAxes(int axisA, int axisB)
          swap two axes
void translate(Voxel vox)
          move this Volume to a relative position
void translate(int[] pos)
          move this Volume to a relative position
void translate(double[] pos)
          move this Volume to a relative position
void unshiftAxes(int n)
          shift the axis order backward n steps.
void untranslate(Voxel vox)
          move this Volume to a relative position, in the opposite sense as is done by translate().
void untranslate(int[] pos)
          move this Volume to a relative position, in the opposite sense as is done by translate().
void untranslate(double[] pos)
          move this Volume to a relative position, in the opposite sense as is done by translate().
 
Methods inherited from class ncsa.horizon.util.Volume
axisPos, clone, doubleToInt, equals, getAxisOrder, getExactOrigin, getExactOrigin, getExactSize, getExactSize, getFlags, getLength, getLocation, getLocation, getMonitor, getNaxes, getOrigin, getOrigin, getRoundedStride, getRoundedStride, getSampledCount, getSampledSize, getSampledSize, getSampling, getSampling, getSize, getSize, getStep, getStride, getStride, getTrueLength, getTrueSize, getTrueSize, getVoxel, hashCode, includes, includes, includes, includes, intersection, intersects, intToDouble, isEmpty, isInNaturalAxisOrder, isMutable, isSamplingFully, isSamplingPositively, isSamplingWholly, makeLengthsPositive, projection, reorder, reorder, reorder, roundDoubleToInt, samples, sampleWholly, toString, union, union
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Constructor Detail

AdjustableVolume

public AdjustableVolume(int nax)
                 throws ValueOutOfBoundsException
create a Volume object in a space of nax dimensions and initialize it to have a unit size with a sampling of 1 along each axis. The index of the first axis will be zero.
Parameters:
nax - number of axes or dimensions in the space
Throws:
java.lang.ArrayIndexOutOfBoundsException - thrown if nax < 0

AdjustableVolume

public AdjustableVolume(int nax,
                        int[] ori,
                        int[] sz,
                        int[] sam)
                 throws java.lang.ArrayIndexOutOfBoundsException
create a Volume object in a space of nax dimensions and initialize it to a given location, size, and sampling for each axis. The index of the first axis will be zero. Input arrays can be null to get default.
Parameters:
nax - number of axes or dimensions in the space
ori - location of volume vertex (default: zero-origin)
sz - length of each side (default: one)
sam - sampling along each side (default: one)
Throws:
ValueOutOfBoundsException - thrown if nax < 0

AdjustableVolume

public AdjustableVolume(int nax,
                        double[] ori,
                        double[] sz,
                        double[] sam)
                 throws ValueOutOfBoundsException,
                        PositionOutOfBoundsException
create a Volume object in a space of nax dimensions and initialize it to a given location, size, and sampling for each axis. The index of the first axis will be zero. Input arrays can be null to get default.
Parameters:
nax - number of axes or dimensions in the space
ori - location of volume vertex (default: origin)
sz - length of each side (default: one)
sam - sampling along each side (default: one)
Throws:
ValueOutOfBoundsException - thrown if nax < 0
PositionOutOfBoundsException - thrown if any value of the input arrays are out of range

AdjustableVolume

public AdjustableVolume(Volume in)
create a Volume object that is a copy of another Volume. The index of the new Volume will be that of the input Volume

AdjustableVolume

public AdjustableVolume(Voxel in)
create a Volume object of unit size (and unit sampling) whose origin vertex is located at the given voxel. The index of the new Volume will be that of the input Volume.
Method Detail

isMutable

public boolean isMutable()
return true if the paramters of this Volume can change. This implementation always returns true.
Overrides:
isMutable in class Volume

getMonitor

public java.util.Observable getMonitor()
return an Observable monitor for listening for changes to this Volume. Clients interested in such changes can add themselves to the Observable returned by this method. They will be notified when any of the Volume parameters position change, passing this Volume as an argument to the Observers' update() method.
Overrides:
getMonitor in class Volume

setOrigin

public void setOrigin(int[] pos)
set the origin of this Volume to a position given by an array of integers.

setOrigin

public void setOrigin(int idx,
                      int pos)
set one component of the origin of this Volume to a given position along a given axis

setOrigin

public void setOrigin(double[] pos)
              throws PositionOutOfBoundsException
set the origin of this Volume to a fractional position given by an array of integers.
Throws:
PositionOutOfRangeException - if the position is out of range

setOrigin

public void setOrigin(int idx,
                      double pos)
              throws PositionOutOfBoundsException
set one component of the origin of this Volume to a given position along a given axis
Throws:
PositionOutOfRangeException - if the position is out of range

setOrigin

public void setOrigin(Voxel vox)
set the origin of this volume to the position of a given Voxel

setSize

public void setSize(int[] sz)
set the size of this volume to the lengths given in an integer array

setSize

public void setSize(int idx,
                    int sz)
set the length of this volume along one axis to a given integer value

setSize

public void setSize(double[] sz)
            throws PositionOutOfBoundsException
set the size of this volume to the fractional lengths given in an array of doubles
Throws:
PositionOutOfBoundsException - if any lengths are out of range

setSize

public void setSize(int idx,
                    double sz)
            throws PositionOutOfBoundsException
set the length of this volume along one axis to a given fractional value
Throws:
PositionOutOfRangeException - if any lengths are out of range

setStride

public void setStride(double[] sam)
set the sampling rate along each axis of the volume

setStride

public void setStride(int idx,
                      double sam)
              throws PositionOutOfBoundsException
return the sampling of the data space along a given side.
Throws:
PositionOutOfRangeException - if the stride is out of range

setStride

public void setStride(int[] sam)
set the sampling rate along each axis of the volume

setStride

public void setStride(int idx,
                      int sam)
              throws PositionOutOfBoundsException
return the sampling of the data space along a given side.

setAxisOrder

public void setAxisOrder(int[] axorder)
                 throws java.lang.IllegalArgumentException,
                        java.lang.ArrayIndexOutOfBoundsException
set the axis order. This method is prone to user error, so it is recommended that one use the other order editing methods if possible.
Parameters:
int[] - the axis order as an array of the axis indices. Each index should appear only once. Missing axes will be appended in numerical order; extra axes are ignored.
Throws:
java.lang.IllegalArgumentException - if an axis is repeated in the array.
java.lang.ArrayIndexOutOfBoundsException - if an axis index is out of range of [0, naxes-1].

resetAxisOrder

public void resetAxisOrder()
reset the axis order to their natural order; i.e. {0, 1, ..., naxes-1}

swapAxes

public void swapAxes(int axisA,
                     int axisB)
swap two axes
Throws:
ArrayIndexOutOfRangeException - if either axis index is out of range of [0, naxes-1].

shiftAxes

public void shiftAxes(int n)
shift the axis order forward n steps. Shifting forward 1 step will move the first axis to the second position and the last axis to the first position.

unshiftAxes

public void unshiftAxes(int n)
shift the axis order backward n steps. Shifting backward 1 step will move the first axis to the last position and the second axis to the first position.

reverseAxes

public void reverseAxes()
reverse the axis order.

translate

public void translate(Voxel vox)
move this Volume to a relative position
Parameters:
vox - the relative position to add to this volume's origin; only dimensions that overlap this space will be added.

translate

public void translate(int[] pos)
move this Volume to a relative position
Parameters:
vox - the relative position to add to this volume's origin; only dimensions that overlap this space will be added.

translate

public void translate(double[] pos)
move this Volume to a relative position
Parameters:
vox - the relative position to add to this volume's origin; only dimensions that overlap this space will be added.

untranslate

public void untranslate(Voxel vox)
move this Volume to a relative position, in the opposite sense as is done by translate().
Parameters:
vox - the relative position to subtract to this volume's position; only dimensions that overlap this space will be added.

untranslate

public void untranslate(int[] pos)
move this Volume to a relative position, in the opposite sense as is done by translate().
Parameters:
vox - the relative position to subtract to this volume's position; only dimensions that overlap this space will be added.

untranslate

public void untranslate(double[] pos)
move this Volume to a relative position, in the opposite sense as is done by translate().
Parameters:
vox - the relative position to subtract to this volume's position; only dimensions that overlap this space will be added.

expandTo

public void expandTo(Voxel vox)
expand this Volume just enough to include a given Voxel. The sampling stride for this volume will not be changed, and so the result is not guaranteed to actually sample the voxel.

expandTo

public void expandTo(Volume that)
compute the union of this volume with another. The dimensionality and sampling will be that of this volume.

grow

public void grow(Voxel vox)
increase the size of each side by the projected distance of a Voxel from its origin along each corresponding axis.

grow

public void grow(int[] pos)
increase the size of each side by the projected distance of a position from its origin along each corresponding axis.

grow

public void grow(double[] pos)
increase the size of each side by the projected distance of a position from its origin along each corresponding axis.

getOrigin

public final int[] getOrigin()
return the origin of this Volume (rounded to the nearest integer) represented as an array of integers.
Overrides:
getOrigin in class Volume

getOrigin

public final int getOrigin(int axis)
return the origin of this Volume (rounded to the nearest integer) along a given axis.
Overrides:
getOrigin in class Volume

getExactOrigin

public final double[] getExactOrigin()
return the exact origin of this Volume represented as an array of doubles.
Overrides:
getExactOrigin in class Volume

getExactOrigin

public final double getExactOrigin(int axis)
return the exact origin of this Volume along a given axis.
Overrides:
getExactOrigin in class Volume

getSize

public final int[] getSize()
return the size of the largest volume with lengths of integer length enclosed by this volume.
Overrides:
getSize in class Volume

getSize

public final int getSize(int axis)
return the largest integer length that is less than or equal to the length of one side of this volume.
Overrides:
getSize in class Volume

getStride

public final double[] getStride()
return an array of doubles representing the sampling of the data space along each side.
Overrides:
getStride in class Volume

getStride

public final double getStride(int i)
return the sampling of the data space along a given side.
Overrides:
getStride in class Volume

getRoundedStride

public final int[] getRoundedStride()
return an array of ints representing the sampling of the data space along each side, rounded to the nearest integer.
Overrides:
getRoundedStride in class Volume

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD