FlatData stores numeric data for 2d visualizations using a single array. Components are stored in the array in row-major order. Data components can represent almost anything. For example, we store an n by m grid of complex numbers as follows: data=new double [2 n m]<\code> <\pre>
| 25 | * @version 1.0 |
| 26 | */ |
| 27 | public class FlatData implements GridData { |
| 28 | protected double[] data; |
| 29 | protected double left, right, bottom, top; |
| 30 | protected double dx = 0, dy = 0; |
| 31 | protected boolean cellData = false; |
| 32 | protected String[] names; |
| 33 | int nx, ny, stride; |
| 34 | |
| 35 | /** |
| 36 | * FlatData constructor. The data array will contain ncomponents*ix*iy values. |
| 37 | * |
| 38 | * @param ix the number of x values |
| 39 | * @param iy the number of y values |
| 40 | * @param ncomponents the number of components |
| 41 | */ |
| 42 | public FlatData(int ix, int iy, int ncomponents) { |
| 43 | if((iy<1)||(ix<1)) { |
| 44 | throw new IllegalArgumentException("Number of dataset rows and columns must be positive. Your row="+iy+" col="+ix); //$NON-NLS-1$ //$NON-NLS-2$ |
| 45 | } |
| 46 | if((ncomponents<1)) { |
| 47 | throw new IllegalArgumentException("Number of 2d data components must be positive. Your ncomponents="+ncomponents); //$NON-NLS-1$ |
| 48 | } |
| 49 | nx = ix; |
| 50 | ny = iy; |
| 51 | stride = ncomponents; |
| 52 | data = new double[ncomponents*ix*iy]; // x, y, and components |
| 53 | setScale(0, ix, 0, iy); |
| 54 | names = new String[ncomponents]; |
| 55 | for(int i = 0; i<ncomponents; i++) { |
| 56 | names[i] = "Component_"+i; //$NON-NLS-1$ |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Sets the name of the component. |
| 62 | * |
| 63 | * @param i int the component index |
| 64 | * @param name String |
| 65 | */ |
| 66 | @Override |
| 67 | public void setComponentName(int i, String name) { |
| 68 | names[i] = name; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Gets the name of the component, |
| 73 | * @param i int the component index |
| 74 | * @return String the name |
| 75 | */ |
| 76 | @Override |
| 77 | public String getComponentName(int i) { |
| 78 | return names[i]; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Gets the number of data components. |
| 83 | * |
| 84 | * @return int |
nothing calls this directly
no outgoing calls
no test coverage detected