Example #1
0
 @Override
 public void setPosition(final Localizable localizable) {
   localizable.localize(position);
   int index = 0;
   for (int d = 0; d < n; ++d) index += position[d] * img.steps[d];
   type.updateIndex(index);
 }
Example #2
0
 @Override
 public void fwd() {
   if (++index > lastIndexInCell) {
     moveToNextCell();
     index = 0;
   }
   type.updateIndex(index);
 }
Example #3
0
 @Override
 public void setPosition(final int[] pos) {
   int index = 0;
   for (int d = 0; d < n; ++d) {
     position[d] = pos[d];
     index += pos[d] * img.steps[d];
   }
   type.updateIndex(index);
 }
Example #4
0
  protected ArrayCursor(final ArrayCursor<T> cursor) {
    super(cursor.numDimensions());

    this.container = cursor.container;
    this.type = container.createLinkedType();
    this.lastIndex = (int) container.size() - 1;

    type.updateIndex(cursor.type.getIndex());
    type.updateContainer(this);
  }
Example #5
0
 @Override
 public void setPosition(final long[] pos) {
   int index = 0;
   for (int d = 0; d < n; ++d) {
     final int p = (int) pos[d];
     position[d] = p;
     index += p * img.steps[d];
   }
   type.updateIndex(index);
 }
Example #6
0
  public ArrayRandomAccess(final ArrayImg<T, ?> container) {
    super(container.numDimensions());

    this.img = container;
    this.type = container.createLinkedType();

    for (int d = 0; d < n; d++) position[d] = 0;

    type.updateContainer(this);
    type.updateIndex(0);
  }
Example #7
0
  protected CellCursor(final CellCursor<T, A, C> cursor) {
    super(cursor.numDimensions());

    this.type = cursor.type.duplicateTypeOnSameNativeImg();
    this.cursorOnCells = cursor.cursorOnCells.copyCursor();
    isNotLastCell = cursor.isNotLastCell;
    lastIndexInCell = cursor.lastIndexInCell;
    index = cursor.index;

    type.updateContainer(this);
    type.updateIndex(index);
  }
Example #8
0
 @Override
 public void jumpFwd(final long steps) {
   long newIndex = index + steps;
   while (newIndex > lastIndexInCell) {
     newIndex -= lastIndexInCell + 1;
     cursorOnCells.fwd();
     isNotLastCell = cursorOnCells.hasNext();
     lastIndexInCell = (int) (getCell().size() - 1);
   }
   index = (int) newIndex;
   type.updateIndex(index);
   type.updateContainer(this);
 }
Example #9
0
  protected ArrayRandomAccess(final ArrayRandomAccess<T> randomAccess) {
    super(randomAccess.numDimensions());

    this.img = randomAccess.img;
    this.type = img.createLinkedType();

    int index = 0;
    for (int d = 0; d < n; d++) {
      position[d] = randomAccess.position[d];
      index += position[d] * img.steps[d];
    }

    type.updateContainer(this);
    type.updateIndex(index);
  }
Example #10
0
 @Override
 public void reset() {
   type.updateIndex(-1);
   type.updateContainer(this);
 }
Example #11
0
 @Override
 public void reset() {
   cursorOnCells.reset();
   moveToNextCell();
   type.updateIndex(index);
 }
Example #12
0
 /**
  * Sets the {@link ArrayRandomAccess} to a certain position in dimension 0
  *
  * <p>Careful: it assumes that it is only a one-dimensional image, all other dimensions would be
  * set to zero (this saves one subtraction)
  *
  * @param pos - the new position
  */
 public void setPositionDim0(final long pos) {
   type.updateIndex((int) pos);
   position[0] = (int) pos;
 }
Example #13
0
 /**
  * Sets the {@link ArrayRandomAccess} to a certain position in dimension 0
  *
  * <p>Careful: it assumes that it is only a one-dimensional image, all other dimensions would be
  * set to zero (this saves one subtraction)
  *
  * @param pos - the new position
  */
 public void setPositionDim0(final int pos) {
   type.updateIndex(pos);
   position[0] = pos;
 }