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.Swath

java.lang.Object
  |
  +--ncsa.horizon.util.Swath
Subclasses:
AdjustableSwath

public class Swath
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
an immutable representation of an arbitrary straight path between two voxels in an N-dimensional space.

This class describes a line through data space via 2 voxels: the start voxel and the end voxel. As a result, all the restrictions on voxel position range applies to these ends of this line. Also like the Voxel, positions can be fractional.

In this implementation, Swaths are immutable--that is, their endpoints cannot change. (This is a new with Horizon 2.0.) Thus, isMutable() always returns false. When Swath.isMutable() returns false, objects can feel free to share a reference to the Voxel without worry about it changing. In contrast, an AdjustableSwath is change-able (isMutable() returns true). Swath subclasses (like AdjustableSwath) should override their isMutable() methods to return true if they allow the position to change with time.

See Also:
Voxel, Serialized Form

Field Summary
MoveableVoxel end
          the ending voxel of the swath
MoveableVoxel start
          the starting voxel for the swath
 
Constructor Summary
Swath(Voxel start, Voxel end)
          Create a new Swath given its beginning and ending Voxel.
Swath(int naxes)
          Create a default Swath of zero length
Swath()
          Create a default Swath of zero length in a 2-dimensional space
Swath(Swath in)
          Create a Swath that is a copy of another Swath.
 
Method Summary
java.lang.Object clone()
          return a copy
boolean equals(Swath that)
          return true if another Swath is the same as this one.
int[] getEndPos()
          return the ending position as an array of integers
int getEndPos(int axis)
          return the component of the ending position along a given axis
Voxel getEnd()
          return (a copy of) the ending Voxel
double[] getExactEndPos()
          return the ending position as an array of doubles
double getExactEndPos(int axis)
          return the ending position as an array of doubles
double[] getExactStartPos()
          return the starting position as an array of doubles
double getExactStartPos(int axis)
          return the starting position as an array of doubles
double getLength(int axis)
          return the projected length of the swath along a given axis.
double getLength()
          return the absolute length of the swath
java.util.Observable getMonitor()
          return an Observable monitor for listening for changes to this Volume, or null if this Volume is immutable.
Segment getProjection(int axis)
          return projection of the swath onto a given axis in the form of a Segment object.
int[] getStartPos()
          return the starting position as an array of integers
int getStartPos(int axis)
          return the component of the starting position along a given axis
Voxel getStart()
          return (a copy of) the starting Voxel
boolean isMutable()
          return true if the parameters of this Volume can change
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

start

protected MoveableVoxel start
the starting voxel for the swath

end

protected MoveableVoxel end
the ending voxel of the swath
Constructor Detail

Swath

public Swath(Voxel start,
             Voxel end)
Create a new Swath given its beginning and ending Voxel. The dimensionality will be set to the maximum of that for the two Voxels given; positions from any missing axes will be set to zero.

Swath

public Swath(int naxes)
Create a default Swath of zero length
Parameters:
naxes - the dimensionality of the space.

Swath

public Swath()
Create a default Swath of zero length in a 2-dimensional space

Swath

public Swath(Swath in)
Create a Swath that is a copy of another Swath. This constructor is useful when converting a mutable swath to an immutable one.
Method Detail

isMutable

public boolean isMutable()
return true if the parameters of this Volume can change

getMonitor

public java.util.Observable getMonitor()
return an Observable monitor for listening for changes to this Volume, or null if this Volume is immutable. Observers will be notified when any Volume parameters change, passing this Volume as an argument to the Observers' update() method.

getStart

public Voxel getStart()
return (a copy of) the starting Voxel

getStartPos

public int[] getStartPos()
return the starting position as an array of integers

getStartPos

public int getStartPos(int axis)
return the component of the starting position along a given axis

getExactStartPos

public double[] getExactStartPos()
return the starting position as an array of doubles

getExactStartPos

public double getExactStartPos(int axis)
return the starting position as an array of doubles

getEnd

public Voxel getEnd()
return (a copy of) the ending Voxel

getEndPos

public int[] getEndPos()
return the ending position as an array of integers

getEndPos

public int getEndPos(int axis)
return the component of the ending position along a given axis

getExactEndPos

public double[] getExactEndPos()
return the ending position as an array of doubles

getExactEndPos

public double getExactEndPos(int axis)
return the ending position as an array of doubles

getProjection

public Segment getProjection(int axis)
return projection of the swath onto a given axis in the form of a Segment object.
Parameters:
axis - the zero-relative axis index.

getLength

public double getLength(int axis)
return the projected length of the swath along a given axis. The return value may be negative
Parameters:
axis - the zero-relative axis index.

getLength

public double getLength()
return the absolute length of the swath
Parameters:
axis - the zero-relative axis index.

equals

public boolean equals(Swath that)
return true if another Swath is the same as this one.

clone

public java.lang.Object clone()
return a copy
Overrides:
clone in class java.lang.Object

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