public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("del")) { try { UnionSet set = (UnionSet) ref.getData(); SampledSet[] sets = set.getSets(); SampledSet[] new_sets = new SampledSet[sets.length - 1]; System.arraycopy(sets, 0, new_sets, 0, sets.length - 1); ref.setData(new UnionSet(set.getType(), new_sets)); } catch (VisADException ex) { } catch (RemoteException ex) { } } else if (cmd.equals("fill")) { UnionSet set = null; try { set = (UnionSet) ref.getData(); System.out.println("area = " + DelaunayCustom.computeArea(set)); } catch (VisADException ex) { System.out.println(ex.getMessage()); } try { // Irregular2DSet new_set = DelaunayCustom.fill(set); Irregular2DSet new_set = DelaunayCustom.fillCheck(set, false); if (new_ref == null) { new_ref = new DataReferenceImpl("fill"); ConstantMap[] cmaps = new ConstantMap[] { new ConstantMap(1.0, Display.Blue), new ConstantMap(1.0, Display.Red), new ConstantMap(0.0, Display.Green) }; DataRenderer renderer = (display instanceof DisplayImplJ3D) ? (DataRenderer) new DefaultRendererJ3D() : (DataRenderer) new DefaultRendererJ2D(); renderer.suppressExceptions(true); display.addReferences(renderer, new_ref, cmaps); } new_ref.setData(new_set); } catch (VisADException ex) { System.out.println(ex.getMessage()); } catch (RemoteException ex) { System.out.println(ex.getMessage()); } } else if (cmd.equals("lines")) { try { lines = !lines; GraphicsModeControl mode = display.getGraphicsModeControl(); if (lines) { mode.setPolygonMode(DisplayImplJ3D.POLYGON_LINE); } else { mode.setPolygonMode(DisplayImplJ3D.POLYGON_FILL); } } catch (VisADException ex) { System.out.println(ex.getMessage()); } catch (RemoteException ex) { System.out.println(ex.getMessage()); } } }
public void doAction() throws VisADException, RemoteException { Tuple tuple = (Tuple) ref.getData(); float lon = (float) ((Real) tuple.getComponent(0)).getValue(); float lat = (float) ((Real) tuple.getComponent(1)).getValue(); RealTuple wind = (RealTuple) tuple.getComponent(2); float windx = (float) ((Real) wind.getComponent(0)).getValue(); float windy = (float) ((Real) wind.getComponent(1)).getValue(); System.out.println("wind = (" + windx + ", " + windy + ") at (" + +lat + ", " + lon + ")"); /* a testing hack count--; if (count < 0) { count = 20; scale = 0.15f * 0.3f / scale; flow_control.setFlowScale(scale); } */ }