Due to the current gap in continued funding from the U.S. National Science Foundation (NSF), the NSF Unidata Program Center has temporarily paused most operations. See NSF Unidata Pause in Most Operations for details.
Hi Everyone, Thanks for your help, Bill - your suggestions helped enormously and the program now works. I'm attaching the code snipped below for the archives. It does what statisticians call brushing - I've seen a couple of other references to this in the archives, so this code might be useful to someone else who wants to use Visad to brush 3D scatterplots. Thanks again - Adele DisplayRenderer dr = display.getDisplayRenderer(); MouseBehavior mb = dr.getMouseBehavior(); Vector v = display.getMapVector(); ScalarMap[] maps = new ScalarMap[v.size()]; for (int k=0; k<maps.length; k++) { maps[k] = (ScalarMap) v.elementAt(k); } ScalarMap Xmap, Ymap, Zmap; Xmap = null; Ymap = null; Zmap = null; for (int k=0; k<maps.length; k++) { if( maps[k].getDisplayScalar().equals(Display.XAxis)) { Xmap=maps[k]; } if( maps[k].getDisplayScalar().equals(Display.YAxis)) { Ymap=maps[k]; } if( maps[k].getDisplayScalar().equals(Display.ZAxis)) { Zmap=maps[k]; } } // get the RealType values for the data points: float[][] pos = new float[3][nrows]; pos[0] = Xmap.scaleValues(dataset[ixvar]); pos[1] = Ymap.scaleValues(dataset[iyvar]); pos[2] = Zmap.scaleValues(dataset[izvar]); float[] x = new float[nrows]; float[] y = new float[nrows]; for(int i=0;i<nrows;i++){ double[] position = new double[3]; position[0] = (double)pos[0][i]; position[1] = (double)pos[1][i]; position[2] = (double)pos[2][i]; // save the screen coordinates of this data point int[] screen = mb.getScreenCoords(position); x[i] = (float)screen[0]; y[i] = (float)screen[1]; } boolean[] selected = new boolean[nrows]; for(int i=0;i<nrows;i++) selected[i]=false; SampledSet[] sets = set.getSets(); for(int j=1; j<sets.length; j++){ //starts from 1 (invisible starter set) float[][] samples = sets[j].getSamples(true);// from the CurveManipulationRenderer boolean yes = DelaunayCustom.checkAndFixSelfIntersection(samples); // get the RealType values for the curve: int nsamp = samples[0].length; float[][] xyz = new float[2][nsamp]; xyz[0] = Xmap.scaleValues(samples[0]); xyz[1] = Ymap.scaleValues(samples[1]); // save their screen coordinates float[][]samp = new float[2][nsamp]; for(int jj=0;jj<nsamp;jj++){ double[] position = new double[3]; int[] screen = mb.getScreenCoords(position); position[0] = (double)xyz[0][jj]; position[1] = (double)xyz[1][jj]; position[2] = (double)0; screen = mb.getScreenCoords(position); samp[0][jj] = (float)screen[0]; samp[1][jj] = (float)screen[1]; } for (int i=0; i<nrows; i++) { // check to see if the screen coordinates of this point // are inside the screen coordinates of the curve, and // if they are, set selected=true if(DelaunayCustom.inside(samp,x[i],y[i])) { selected[i] = true; } } }
visad
archives: