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, wait
localize, positionAsLongArray, positionAsPoint
localize, positionAsDoubleArray, positionAsRealPoint
public 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 EuclideanSpace
public 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 Iterator
IllegalStateException
- 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 Positionable
public 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 Positionable
public 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 Positionable
public void move(long[] deltas)
Position
by given deltas. Throws an
exception if any delta would move Position
outside its parent
Extents
.move
in interface Positionable
public 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 Positionable
public void move(int[] distance)
Position
by given deltas. Throws an
exception if any delta would move Position
outside its parent
Extents
.move
in interface Positionable
public 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 Positionable
public 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 Positionable
public 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 Positionable
public 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 Positionable
public 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 Positionable
public 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 Positionable
public 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 Localizable
public void localize(long[] pos)
Position
's coordinateslocalize
in interface Localizable
public void localize(float[] pos)
Position
's coordinateslocalize
in interface RealLocalizable
public void localize(double[] pos)
Position
's coordinateslocalize
in interface RealLocalizable
public int getIntPosition(int d)
Position
's i'th coordinate as an intgetIntPosition
in interface Localizable
public long getLongPosition(int d)
Position
's i'th coordinate as a longgetLongPosition
in interface Localizable
public float getFloatPosition(int d)
Position
's i'th coordinate as a floatgetFloatPosition
in interface Localizable
getFloatPosition
in interface RealLocalizable
public double getDoublePosition(int d)
Position
's i'th coordinate as a doublegetDoublePosition
in interface Localizable
getDoublePosition
in interface RealLocalizable
Copyright © 2014–2022 ImageJ. All rights reserved.