Пример #1
0
  /**
   * Overridden to call the {@link #computeSample(int, int, Sample[], WritableSample) computeSample}
   * method for every pixel in the given tile's rectangle.
   *
   * @param targetBand The target band.
   * @param targetTile The current tile associated with the target band to be computed.
   * @param pm A progress monitor which should be used to determine computation cancelation
   *     requests.
   * @throws OperatorException
   */
  @Override
  public final void computeTile(Band targetBand, Tile targetTile, ProgressMonitor pm)
      throws OperatorException {

    final Rectangle targetRectangle = targetTile.getRectangle();
    final Point location = new Point();
    final Sample[] sourceSamples = createSourceSamples(targetRectangle, location);
    final Sample sourceMaskSamples = createSourceMaskSamples(targetRectangle, location);
    final WritableSample targetSample = createTargetSample(targetTile, location);

    final int x1 = targetTile.getMinX();
    final int y1 = targetTile.getMinY();
    final int x2 = targetTile.getMaxX();
    final int y2 = targetTile.getMaxY();

    try {
      pm.beginTask(getId(), targetTile.getHeight());
      if (sourceMaskSamples != null) {
        for (location.y = y1; location.y <= y2; location.y++) {
          for (location.x = x1; location.x <= x2; location.x++) {
            if (sourceMaskSamples.getBoolean()) {
              computeSample(location.x, location.y, sourceSamples, targetSample);
            } else {
              setInvalid(targetSample);
            }
          }
          pm.worked(1);
        }
      } else {
        for (location.y = y1; location.y <= y2; location.y++) {
          for (location.x = x1; location.x <= x2; location.x++) {
            computeSample(location.x, location.y, sourceSamples, targetSample);
          }
          pm.worked(1);
        }
      }
    } finally {
      pm.done();
    }
  }
Пример #2
0
 public TileIndex(final Tile tile) {
   tileOffset = tile.getScanlineOffset();
   tileStride = tile.getScanlineStride();
   tileMinX = tile.getMinX();
   tileMinY = tile.getMinY();
 }