| 8 | package org.opensourcephysics.display2d; |
| 9 | |
| 10 | public class ComplexCarpet extends ComplexInterpolatedPlot implements ICarpet { |
| 11 | /** |
| 12 | * Constructor ComplexCarpet |
| 13 | * |
| 14 | * @param griddata |
| 15 | */ |
| 16 | public ComplexCarpet(GridData griddata) { |
| 17 | super(griddata); |
| 18 | setShowGridLines(false); |
| 19 | } |
| 20 | |
| 21 | @Override |
| 22 | public void clearData() { |
| 23 | if (griddata instanceof ArrayData) { |
| 24 | double[][][] data = griddata.getData(); |
| 25 | for (int ix = 0, nx = griddata.getNx(); ix < nx; ix++) { |
| 26 | for (int iy = 0, ny = griddata.getNy(); iy < ny; iy++) { |
| 27 | data[0][ix][iy] = 0; |
| 28 | data[1][ix][iy] = 0; |
| 29 | data[2][ix][iy] = 0; |
| 30 | } |
| 31 | } |
| 32 | } else { // point data |
| 33 | double[][][] data = griddata.getData(); |
| 34 | for (int ix = 0, nx = griddata.getNx(); ix < nx; ix++) { |
| 35 | for (int iy = 0, ny = griddata.getNy(); iy < ny; iy++) { |
| 36 | data[nx][ny][2] = 0; |
| 37 | data[nx][ny][3] = 0; |
| 38 | data[nx][ny][4] = 0; |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | update(); |
| 43 | } |
| 44 | |
| 45 | @Override |
| 46 | public void setTopRow(double[][] line) { |
| 47 | if (image == null) { |
| 48 | return; |
| 49 | } |
| 50 | if (pixelData.length != image.getWidth() * image.getHeight() * 4) { |
| 51 | return; |
| 52 | } |
| 53 | if (griddata instanceof ArrayData) { // replace top row of array |
| 54 | for (int c = 0; c < line.length; c++) { |
| 55 | double[][] data = griddata.getData()[c]; |
| 56 | int len = data[0].length - 1; |
| 57 | for (int ix = 0, nx = data.length; ix < nx; ix++) { |
| 58 | System.arraycopy(data[ix], 0, data[ix], 1, len); |
| 59 | data[ix][0] = line[c][ix]; |
| 60 | } |
| 61 | } |
| 62 | } else { |
| 63 | double[][][] data = griddata.getData(); |
| 64 | for (int ix = 0, nx = data.length; ix < nx; ix++) { |
| 65 | int len = line.length; |
| 66 | for (int ny = data[0].length - 1, iy = ny; iy > 0; iy--) { |
| 67 | System.arraycopy(data[ix][iy - 1], 2, data[ix][iy], 2, len); |
nothing calls this directly
no outgoing calls
no test coverage detected