/** * Sets the value as a <code>float</code>. <p>The method assumes that this value is a scalar and therefore simply * calls <code>setElemFloatAt(0, value)</code>. * * @param value the value to be set * * @see #setElemFloatAt(int index, float value) */ public void setElemFloat(float value) { setElemFloatAt(0, value); }
private void setNoData(int x) { if (numObsLine != null) { numObsLine.setElemIntAt(x, -1); } if (numPassesLine != null) { numPassesLine.setElemIntAt(x, -1); } for (int i = 0; i < outputBands.length; i++) { outputLines[i].setElemFloatAt(x, fillValues[i]); } }
@Override public void setSample(int x, int y, float sample) { if (scaled) { sample = toRaw(sample); } dataBuffer.setElemFloatAt(index(x, y), sample); }
private void setData(int x, TemporalBin temporalBin, Vector outputVector) { if (numObsLine != null) { numObsLine.setElemIntAt(x, temporalBin.getNumObs()); } if (numPassesLine != null) { numPassesLine.setElemIntAt(x, temporalBin.getNumPasses()); } for (int i = 0; i < outputBands.length; i++) { outputLines[i].setElemFloatAt(x, outputVector.get(i)); } }
private void fillWithData(Band band, float multiplicator, float offset) { band.ensureRasterData(); final ProductData data = band.getRasterData(); for (int i = 0; i < data.getNumElems(); i++) { data.setElemFloatAt(i, i * multiplicator + offset); } } }
destBuffer.setElemFloatAt(destRasterIndex, value);
private static ProductData createProductDataForBand(final Band band, final float start) { final ProductData data = band.createCompatibleRasterData(); for (int i = 0; i < band.getSceneRasterWidth() * band.getSceneRasterHeight(); i++) { data.setElemFloatAt(i, start + i); } band.setData(data); return data; }
@Override protected void readBandRasterDataImpl(int sourceOffsetX, int sourceOffsetY, int sourceWidth, int sourceHeight, int sourceStepX, int sourceStepY, Band destBand, int destOffsetX, int destOffsetY, int destWidth, int destHeight, ProductData destBuffer, ProgressMonitor pm) throws IOException { _numReads++; pm.beginTask("Reading band raster data...", sourceHeight - sourceOffsetY); try { for (int sy = sourceOffsetY, j = 0; sy < sourceHeight; sy += sourceStepY, j++) { int dy = destOffsetX + j; for (int sx = sourceOffsetX, i = 0; sx < sourceWidth; sx += sourceStepX, i++) { int dx = destOffsetX + i; destBuffer.setElemFloatAt(dy * destWidth + dx, getRawPixelValue(sx, sy)); } pm.worked(1); } } finally { pm.done(); } }
for (int i = 0; i < destWidth; i++) { sourceX = sourceW - (destOffsetX + i + 1); destBuffer.setElemFloatAt(j * destWidth + i, line[sourceX]); for (int i = 0; i < destWidth; i++) { sourceX = destOffsetX + i; destBuffer.setElemFloatAt(j * destWidth + i, line[sourceX]); for (int i = 0; i < destWidth; i++) { sourceX = sourceW - (destOffsetX + i + 1); destBuffer.setElemFloatAt(j * destWidth + i, line[sourceX]);
if (prodtype == DataType.FLOAT) { buffer.setElemFloatAt(rasterIndex, elem.getFloat(i)); } else { buffer.setElemIntAt(rasterIndex, elem.getInt(i));
subRasterData.setElemFloatAt(i, pixels[i]);
/** * Sets the pixel at the given pixel coordinate to the given pixel value. * * @param x The X co-ordinate of the pixel location * @param y The Y co-ordinate of the pixel location * @param pixelValue the new pixel value * @throws NullPointerException if this band has no raster data */ @Override public void setPixelFloat(int x, int y, float pixelValue) { if (isScalingApplied()) { getRasterData().setElemDoubleAt(getRasterWidth() * y + x, scaleInverse(pixelValue)); } else { getRasterData().setElemFloatAt(getRasterWidth() * y + x, pixelValue); } fireProductNodeDataChanged(); setModified(true); }
elem = Float.NaN; destBuffer.setElemFloatAt(i, (Float) elem);
private void fillBandDataFloat(Band band, int startValue) { final ProductData data = band.createCompatibleProductData(product.getSceneRasterWidth() * product.getSceneRasterHeight()); int value = startValue; int dataIndex = 0; for(int i = 0; i < product.getSceneRasterWidth(); i++) { for(int j = 0; j < product.getSceneRasterHeight(); j++) { data.setElemFloatAt(dataIndex++, value++); } } band.setData(data); } }
final int xOffs = y * getRasterWidth(); for (x = x1; x <= x2; x++) { rasterData.setElemFloatAt(xOffs + x, pixels[pos++]);
for (int y = rect.y; y < rect.y + rect.height; y++) { for (int x = rect.x; x < rect.x + rect.width; x++) { dataBuffer.setElemFloatAt(dataBufferIndex, tile.getSampleFloat(x, y)); dataBufferIndex++;
/** * {@inheritDoc} * <p/> * <p>The default implementation throws a runtime exception with the message "not implemented"</p>. */ @Override public void computeTile(Band band, Tile targetTile, ProgressMonitor pm) throws OperatorException { Tile sourceTile = getSourceTile(sourceProduct.getBand(band.getName()), targetTile.getRectangle()); ProductData rawTarget = targetTile.getRawSamples(); ProductData rawSource = sourceTile.getRawSamples(); int n = rawTarget.getNumElems(); for (int i = 0; i < n; i++) { float v = rawSource.getElemFloatAt(i); if (v < 0) { v = 0; } if (v > 1) { v = 1; } rawTarget.setElemFloatAt(i, v); } targetTile.setRawSamples(rawTarget); } }
float[] pixels = g.readPixels(rectangle.x, rectangle.y, rectangle.width, rectangle.height, (float[])null, ProgressMonitor.NULL); for (int i = 0; i < pixels.length; i++) { rasterData.setElemFloatAt(i, pixels[i]);
protected void testFloat32RawSampleIO(TileImpl tile, int x, int y) { ProductData samplesGeneric = tile.getDataBuffer(); assertNotNull(samplesGeneric); float[] samplesFloat = tile.getDataBufferFloat(); assertNotNull(samplesFloat); assertSame(samplesFloat, samplesGeneric.getElems()); int lineOffset = tile.getScanlineOffset(); int lineStride = tile.getScanlineStride(); int index = lineOffset + (y - tile.getMinY()) * lineStride + (x - tile.getMinX()); assertTrue(index >= 0); assertTrue(index < samplesFloat.length); assertTrue(index < samplesGeneric.getNumElems()); assertEquals(index, tile.getDataBufferIndex(x, y)); samplesFloat[index] = 1234.56f; assertEquals(1234.56f, samplesFloat[index], 1e-5f); assertEquals(1234.56f, samplesGeneric.getElemFloatAt(index), 1e-5f); assertEquals(1234.56f, tile.getSampleFloat(x, y), 1e-5f); samplesGeneric.setElemFloatAt(index, 213.536f); assertEquals(213.536f, samplesFloat[index], 1e-5f); assertEquals(213.536f, samplesGeneric.getElemFloatAt(index), 1e-5f); assertEquals(213.536f, tile.getSampleFloat(x, y), 1e-5f); samplesGeneric.setElemIntAt(index, 707); assertEquals(707.0f, samplesFloat[index], 1e-5f); assertEquals(707.0f, samplesGeneric.getElemFloatAt(index), 1e-5f); assertEquals(707.0f, tile.getSampleFloat(x, y), 1e-5f); }