Class SlicingCursor<T>

java.lang.Object
net.imglib2.AbstractEuclideanSpace
net.imglib2.view.iteration.SlicingCursor<T>
All Implemented Interfaces:
Iterator<T>, Cursor<T>, EuclideanSpace, Iterator, Localizable, RealCursor<T>, RealLocalizable, Sampler<T>, Typed<T>

public class SlicingCursor<T> extends AbstractEuclideanSpace implements Cursor<T>
Wrap a cursor that runs on a hyperslice and apply coordinate transform on localize calls.
  • Field Details

    • s

      private final Cursor<T> s
      source Cursor. note that this is the target of the transformToSource.
    • m

      private final int m
      number of dimensions of source Cursor, respectively numTargetDimensions of the Slicing transform.
    • sourceComponent

      private final int[] sourceComponent
      for each component of the source vector: to which target vector component should it be taken.
    • tmpPosition

      private final long[] tmpPosition
  • Constructor Details

    • SlicingCursor

      SlicingCursor(Cursor<T> source, Slicing transformToSource)
      Create a Cursor that forwards all Cursor methods to source, except Localizable methods. Localize calls are propagated through transformToSource.
    • SlicingCursor

      protected SlicingCursor(SlicingCursor<T> cursor)
  • Method Details

    • localize

      public void localize(int[] position)
      Write the current position into the passed array.
      Specified by:
      localize in interface Localizable
      Parameters:
      position - receives current position, length must be ≥ EuclideanSpace.numDimensions()
    • localize

      public void localize(long[] position)
      Write the current position into the passed array.
      Specified by:
      localize in interface Localizable
      Parameters:
      position - receives current position, length must be ≥ EuclideanSpace.numDimensions()
    • getIntPosition

      public int getIntPosition(int d)
      Return the current position in a given dimension.
      Specified by:
      getIntPosition in interface Localizable
      Parameters:
      d - dimension
      Returns:
      dimension of current position
    • getLongPosition

      public long getLongPosition(int d)
      Return the current position in a given dimension.
      Specified by:
      getLongPosition in interface Localizable
      Parameters:
      d - dimension
      Returns:
      dimension of current position
    • localize

      public void localize(float[] position)
      Write the current position into the passed array.
      Specified by:
      localize in interface RealLocalizable
      Parameters:
      position - receives current position, length must be ≥ EuclideanSpace.numDimensions()
    • localize

      public void localize(double[] position)
      Write the current position into the passed array.
      Specified by:
      localize in interface RealLocalizable
      Parameters:
      position - receives current position, length must be ≥ EuclideanSpace.numDimensions()
    • getFloatPosition

      public float getFloatPosition(int d)
      Return the current position in a given dimension.
      Specified by:
      getFloatPosition in interface Localizable
      Specified by:
      getFloatPosition in interface RealLocalizable
      Parameters:
      d - dimension
      Returns:
      dimension of current position
    • getDoublePosition

      public double getDoublePosition(int d)
      Return the current position in a given dimension.
      Specified by:
      getDoublePosition in interface Localizable
      Specified by:
      getDoublePosition in interface RealLocalizable
      Parameters:
      d - dimension
      Returns:
      dimension of current position
    • get

      public T get()
      Access the actual T instance providing access to a pixel, sub-pixel or integral region value the Sampler points at.
      Specified by:
      get in interface Sampler<T>
    • getType

      public T getType()
      Description copied from interface: Typed
      Get an instance of T.

      It should not be assumed that the returned T instance is an independent copy. In particular, repeated calls to getType() may return the same instance.

      Specified by:
      getType in interface Sampler<T>
      Specified by:
      getType in interface Typed<T>
      Returns:
      an instance of T
    • copy

      public SlicingCursor<T> copy()
      Specified by:
      copy in interface Cursor<T>
      Specified by:
      copy in interface RealCursor<T>
      Specified by:
      copy in interface Sampler<T>
      Returns:
      - A new Sampler in the same state accessing the same values. It does NOT copy T, just the state of the Sampler. Otherwise use T.copy() if available. Sampler.copy().get() == Sampler.get(), i.e. both hold the same value, not necessarily the same instance (this is the case for an ArrayCursor for example)
    • jumpFwd

      public void jumpFwd(long steps)
      Move steps × forward.

      Highly recommended to override this with a more efficient version.

      Specified by:
      jumpFwd in interface Iterator
      Parameters:
      steps - number of steps to move forward
    • fwd

      public void fwd()
      Move forward.
      Specified by:
      fwd in interface Iterator
    • reset

      public void reset()
      Reset the Iterator, that is put it to where it would be if newly created.
      Specified by:
      reset in interface Iterator
    • hasNext

      public boolean hasNext()
      Returns true if another step forward is possible.
      Specified by:
      hasNext in interface Iterator<T>
      Specified by:
      hasNext in interface Iterator
      Returns:
      true, if there is another step forward is possible, otherwise false
    • next

      public T next()
      Default implementation, calls Iterator.fwd() then Sampler.get().

      Note, that hasNext() is not checked before fwd(). If such a check is desired it should be implemented in fwd() (throwing NoSuchElementException).

      Specified by:
      next in interface Iterator<T>
      Specified by:
      next in interface RealCursor<T>