public class Position extends Object implements Localizable, Positionable, Iterator
| Constructor and Description |
|---|
Position(Extents parentSpace)
Constructor - takes an
Extents object that represents the parent
space to iterate within. |
Position(Position pos)
Constructs a position that is a copy of the given position.
|
| Modifier and Type | Method and Description |
|---|---|
void |
bck()
Moves the
Position backward by one step. |
void |
bck(int d)
Moves the
Position backward one step in specified dimension. |
long |
dimension(int i)
|
void |
first()
Sets the
Position to its first state (all dimension positions to
min values). |
void |
fwd()
Moves the
Position forward by one step. |
void |
fwd(int d)
Moves the
Position forward one step in specified dimension. |
double |
getDoublePosition(int d)
Gets the current
Position's i'th coordinate as a double |
Extents |
getExtents()
|
float |
getFloatPosition(int d)
Gets the current
Position's i'th coordinate as a float |
long |
getIndex()
Gets the long index from the current
Position. |
int |
getIntPosition(int d)
Gets the current
Position's i'th coordinate as an int |
long |
getLongPosition(int d)
Gets the current
Position's i'th coordinate as a long |
boolean |
hasNext()
Returns true if position can be moved forward (i.e.
|
boolean |
hasPrev()
Returns true if position can be moved backward (i.e.
|
void |
jumpBck(long steps)
Moves the
Position backward the given number of steps. |
void |
jumpFwd(long steps)
Moves the
Position forward the given number of steps. |
void |
last()
Sets the
Position to its last state (all dimension positions to
max-1) |
void |
localize(double[] pos)
Populates a given double[] with the current
Position's coordinates |
void |
localize(float[] pos)
Populates a given float[] with the current
Position's coordinates |
void |
localize(int[] pos)
Populates a given int[] with the current
Position's coordinates |
void |
localize(long[] pos)
Populates a given long[] with the current
Position's coordinates |
void |
move(int[] distance)
Moves all dimensions of the
Position by given deltas. |
void |
move(int distance,
int d)
Moves a given dimension of the
Position by a given delta. |
void |
move(Localizable localizable)
Moves all dimensions of the
Position by given deltas. |
void |
move(long[] deltas)
Moves all dimensions of the
Position by given deltas. |
void |
move(long delta,
int dim)
Moves a given dimension of the
Position by a given delta. |
int |
numDimensions()
Returns the number of dimensions within the
Position. |
void |
reset()
Resets the
Position for forward or backward traversal. |
void |
setIndex(long index)
Sets the
Position from a given long index. |
void |
setPosition(int[] position)
Sets the values of the
Position for all dimensions. |
void |
setPosition(int position,
int d)
Sets the value of the
Position for a given dimension. |
void |
setPosition(Localizable localizable)
Sets the values of the
Position for all dimensions. |
void |
setPosition(long[] value)
Sets the values of the
Position for all dimensions. |
void |
setPosition(long value,
int dim)
Sets the value of the
Position for a given dimension. |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitlocalize, positionAsLongArray, positionAsPointlocalize, positionAsDoubleArray, positionAsRealPointpublic Position(Extents parentSpace)
Extents object that represents the parent
space to iterate within.public Position(Position pos)
public Extents getExtents()
public int numDimensions()
Position.numDimensions in interface EuclideanSpacepublic long dimension(int i)
public boolean hasNext()
public boolean hasPrev()
public void reset()
Position for forward or backward traversal.public void first()
Position to its first state (all dimension positions to
min values).public void last()
Position to its last state (all dimension positions to
max-1)public void fwd()
Position forward by one step. Increments the dimension
positions from left to right.fwd in interface IteratorIllegalStateException - if called from last position.public void bck()
Position backward by one step. Decrements the dimension
positions from left to right.IllegalStateException - if called from first position.public void fwd(int d)
Position forward one step in specified dimension. Throws
an exception if specified move would take position outside parent
Extents.fwd in interface Positionablepublic void bck(int d)
Position backward one step in specified dimension. Throws
an exception if specified move would take position outside parent
Extents.bck in interface Positionablepublic void jumpFwd(long steps)
Position forward the given number of steps.public void jumpBck(long steps)
Position backward the given number of steps.public void move(long delta,
int dim)
Position by a given delta. Throws an
exception if delta would move Position outside its parent
Extents.move in interface Positionablepublic void move(long[] deltas)
Position by given deltas. Throws an
exception if any delta would move Position outside its parent
Extents.move in interface Positionablepublic void move(int distance,
int d)
Position by a given delta. Throws an
exception if delta would move Position outside its parent
Extents.move in interface Positionablepublic void move(int[] distance)
Position by given deltas. Throws an
exception if any delta would move Position outside its parent
Extents.move in interface Positionablepublic void move(Localizable localizable)
Position by given deltas. Throws an
exception if any delta would move Position outside its parent
Extents. The delta is encoded as a relative Localizable vector.move in interface Positionablepublic void setPosition(long value,
int dim)
Position for a given dimension. Throws an
exception if the given value is outside the bounds of the parent
Extents.setPosition in interface Positionablepublic void setPosition(long[] value)
Position for all dimensions. Throws an
exception if any given value is outside the bounds of the parent
Extents.setPosition in interface Positionablepublic void setPosition(int[] position)
Position for all dimensions. Throws an
exception if any given value is outside the bounds of the parent
Extents.setPosition in interface Positionablepublic void setPosition(int position,
int d)
Position for a given dimension. Throws an
exception if the given value is outside the bounds of the parent
Extents.setPosition in interface Positionablepublic void setPosition(Localizable localizable)
Position for all dimensions. Throws an
exception if any given value is outside the bounds of the parent
Extents. The position is encoded as an absolute Localizable vector.setPosition in interface Positionablepublic void setIndex(long index)
Position from a given long index. The index ranges from 0
to extents.numElements()-1. Throws an exception if index out of range.public long getIndex()
Position. The index ranges
from 0 to extents.numElements()-1.public void localize(int[] pos)
Position's coordinateslocalize in interface Localizablepublic void localize(long[] pos)
Position's coordinateslocalize in interface Localizablepublic void localize(float[] pos)
Position's coordinateslocalize in interface RealLocalizablepublic void localize(double[] pos)
Position's coordinateslocalize in interface RealLocalizablepublic int getIntPosition(int d)
Position's i'th coordinate as an intgetIntPosition in interface Localizablepublic long getLongPosition(int d)
Position's i'th coordinate as a longgetLongPosition in interface Localizablepublic float getFloatPosition(int d)
Position's i'th coordinate as a floatgetFloatPosition in interface LocalizablegetFloatPosition in interface RealLocalizablepublic double getDoublePosition(int d)
Position's i'th coordinate as a doublegetDoublePosition in interface LocalizablegetDoublePosition in interface RealLocalizableCopyright © 2014–2022 ImageJ. All rights reserved.