| 26 | } |
| 27 | |
| 28 | public void setTopRow(double[][] line) { |
| 29 | if (image == null) { |
| 30 | return; |
| 31 | } |
| 32 | if (pixelData.length != image.getWidth() * image.getHeight()) { |
| 33 | return; |
| 34 | } |
| 35 | if (griddata instanceof ArrayData) { // replace top row of array |
| 36 | for (int c = 0; c < line.length; c++) { |
| 37 | double[][] data = griddata.getData()[c]; |
| 38 | int len = data[0].length - 1; |
| 39 | for (int ix = 0, nx = data.length; ix < nx; ix++) { |
| 40 | System.arraycopy(data[ix], 0, data[ix], 1, len); |
| 41 | data[ix][0] = line[c][ix]; |
| 42 | } |
| 43 | } |
| 44 | } else { |
| 45 | double[][][] data = griddata.getData(); |
| 46 | for (int ix = 0, nx = data.length; ix < nx; ix++) { |
| 47 | int len = line.length; |
| 48 | for (int ny = data[0].length - 1, iy = ny; iy > 0; iy--) { |
| 49 | System.arraycopy(data[ix][iy - 1], 2, data[ix][iy], 2, len); |
| 50 | } |
| 51 | for (int c = 0; c < len; c++) { |
| 52 | data[ix][0][2 + c] = line[c][ix]; |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | int imageWidth = image.getWidth(); |
| 57 | int imageHeight = image.getHeight(); |
| 58 | double x0 = griddata.getLeft(); |
| 59 | double y = griddata.getTop(); |
| 60 | double dx = (griddata.getRight() - x0) / (imageWidth - 1); |
| 61 | double dy = (griddata.getBottom() - y) / (imageHeight - 1); |
| 62 | int nr = 1 + (int) Math.abs(griddata.getDy() / dy); |
| 63 | int offset = nr * imageWidth; |
| 64 | int length = imageWidth * imageHeight * 4 - offset; |
| 65 | System.arraycopy(pixelData, 0, pixelData, offset, length); |
| 66 | writeToRaster(x0, y, dx, dy); |
| 67 | } |
| 68 | |
| 69 | } |
| 70 | |