void setupServerData(LocalDisplay[] dpys) throws RemoteException, VisADException { RealType[] types = {RealType.Latitude, RealType.Longitude}; RealTupleType earth_location = new RealTupleType(types); RealType vis_radiance = RealType.getRealType("vis_radiance"); RealType ir_radiance = RealType.getRealType("ir_radiance"); RealType[] types2 = {vis_radiance, ir_radiance}; RealTupleType radiance = new RealTupleType(types2); FunctionType image_tuple = new FunctionType(earth_location, radiance); int size = 64; FlatField imaget1 = FlatField.makeField(image_tuple, size, false); dpys[0].addMap(new ScalarMap(RealType.Latitude, Display.YAxis)); dpys[0].addMap(new ScalarMap(RealType.Longitude, Display.XAxis)); dpys[0].addMap(new ScalarMap(ir_radiance, Display.Green)); dpys[0].addMap(new ScalarMap(vis_radiance, Display.RGB)); dpys[0].addMap(new ScalarMap(ir_radiance, Display.ZAxis)); dpys[0].addMap(new ConstantMap(0.5, Display.Blue)); dpys[0].addMap(new ConstantMap(0.5, Display.Red)); ScalarMap map1contour; map1contour = new ScalarMap(vis_radiance, Display.IsoContour); dpys[0].addMap(map1contour); if (uneven) { ContourControl control = (ContourControl) map1contour.getControl(); float[] levs = {10.0f, 12.0f, 14.0f, 16.0f, 24.0f, 32.0f, 40.0f}; control.setLevels(levs, 15.0f, true); control.enableLabels(true); } DataReferenceImpl ref_imaget1 = new DataReferenceImpl("ref_imaget1"); ref_imaget1.setData(imaget1); dpys[0].addReference(ref_imaget1, null); }
void setupServerData(LocalDisplay[] dpys) throws RemoteException, VisADException { RealType x = RealType.getRealType("x"); RealType y = RealType.getRealType("y"); Unit super_degree = CommonUnit.degree.scale(2.5); RealType lon = RealType.getRealType("lon", super_degree); RealType radius = RealType.getRealType("radius"); RealTupleType cartesian = new RealTupleType(x, y); PolarCoordinateSystem polar_coord_sys = new PolarCoordinateSystem(cartesian); RealTupleType polar = new RealTupleType(lon, radius, polar_coord_sys, null); RealType vis_radiance = RealType.getRealType("vis_radiance"); RealType ir_radiance = RealType.getRealType("ir_radiance"); RealType[] types2 = {vis_radiance, ir_radiance}; RealTupleType radiance = new RealTupleType(types2); FunctionType image_polar = new FunctionType(polar, radiance); Unit[] units = {super_degree, null}; Linear2DSet domain_set = new Linear2DSet(polar, 0.0, 60.0, 61, 0.0, 60.0, 61, polar_coord_sys, units, null); FlatField imaget1 = new FlatField(image_polar, domain_set); FlatField.fillField(imaget1, 1.0, 30.0); dpys[0].addMap(new ScalarMap(x, Display.XAxis)); dpys[0].addMap(new ScalarMap(y, Display.YAxis)); dpys[0].addMap(new ScalarMap(vis_radiance, Display.Green)); dpys[0].addMap(new ConstantMap(0.5, Display.Red)); dpys[0].addMap(new ConstantMap(0.0, Display.Blue)); DataReferenceImpl ref_imaget1 = new DataReferenceImpl("ref_imaget1"); ref_imaget1.setData(imaget1); dpys[0].addReference(ref_imaget1, null); }
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()); } } }
private DataReferenceImpl loadFile(DefaultFamily df, String fileName, String refName) throws RemoteException, VisADException { if (fileName == null) { return null; } Data data = (FlatField) df.open(fileName); DataReferenceImpl ref = new DataReferenceImpl(refName); ref.setData(data); return ref; }
private DataReferenceImpl loadFile() throws RemoteException, VisADException { FieldImpl data; try { data = (FieldImpl) new Plain().open(fileName); } catch (IOException e) { System.err.println("Couldn't open \"" + fileName + "\": " + e.getMessage()); System.exit(1); return null; } // System.out.println("data type = " + data.getType()); DataReferenceImpl ref = new DataReferenceImpl("netcdf"); ref.setData(data); return ref; }
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); } */ }
void setupServerData(LocalDisplay[] dpys) throws RemoteException, VisADException { RealType ir_radiance = RealType.getRealType("ir_radiance"); RealType count = RealType.getRealType("count"); FunctionType ir_histogram = new FunctionType(ir_radiance, count); RealType vis_radiance = RealType.getRealType("vis_radiance"); int size = 64; FlatField histogram1 = FlatField.makeField(ir_histogram, size, false); Real direct = new Real(ir_radiance, 2.0); Real[] reals3; reals3 = new Real[] {new Real(count, 1.0), new Real(ir_radiance, 2.0), new Real(vis_radiance, 1.0)}; RealTuple direct_tuple = new RealTuple(reals3); dpys[0].addMap(new ScalarMap(vis_radiance, Display.ZAxis)); dpys[0].addMap(new ScalarMap(ir_radiance, Display.XAxis)); dpys[0].addMap(new ScalarMap(count, Display.YAxis)); dpys[0].addMap(new ScalarMap(count, Display.Green)); GraphicsModeControl mode = dpys[0].getGraphicsModeControl(); mode.setPointSize(5.0f); mode.setPointMode(false); mode.setScaleEnable(true); DisplayRendererJ3D dr = (DisplayRendererJ3D) dpys[0].getDisplayRenderer(); dr.setClip(0, true, 1.0f, 0.0f, 0.0f, -1.0f); dr.setClip(1, true, -1.0f, 0.0f, 0.0f, -1.0f); dr.setClip(2, true, 0.0f, 1.0f, 0.0f, -1.0f); dr.setClip(3, true, 0.0f, -1.0f, 0.0f, -1.0f); dr.setClip(4, true, 0.0f, 0.0f, 1.0f, -1.0f); dr.setClip(5, true, 0.0f, 0.0f, -1.0f, -1.0f); DataReferenceImpl ref_direct = new DataReferenceImpl("ref_direct"); ref_direct.setData(direct); DataReference[] refs1 = new DataReferenceImpl[] {ref_direct}; dpys[0].addReferences(new DirectManipulationRendererJ3D(), refs1, null); DataReferenceImpl ref_direct_tuple; ref_direct_tuple = new DataReferenceImpl("ref_direct_tuple"); ref_direct_tuple.setData(direct_tuple); DataReference[] refs2 = new DataReference[] {ref_direct_tuple}; dpys[0].addReferences(new DirectManipulationRendererJ3D(), refs2, null); DataReferenceImpl ref_histogram1; ref_histogram1 = new DataReferenceImpl("ref_histogram1"); ref_histogram1.setData(histogram1); DataReference[] refs3 = new DataReference[] {ref_histogram1}; dpys[0].addReferences(new DirectManipulationRendererJ3D(), refs3, null); new Delay(500); dpys[1].addMap(new ScalarMap(ir_radiance, Display.XAxis)); dpys[1].addMap(new ScalarMap(count, Display.YAxis)); dpys[1].addMap(new ScalarMap(count, Display.Green)); GraphicsModeControl mode2 = dpys[1].getGraphicsModeControl(); mode2.setPointSize(5.0f); mode2.setPointMode(false); dpys[1].addReferences(new DirectManipulationRendererJ2D(), refs1, null); dpys[1].addReferences(new DirectManipulationRendererJ2D(), refs2, null); dpys[1].addReferences(new DirectManipulationRendererJ2D(), refs3, null); dpys[0].addDisplayListener(this); dpys[1].addDisplayListener(this); }
/** * run 'java FlowTest middle_latitude' to test with (lat, lon) run 'java FlowTest middle_latitude * x' to test with (lon, lat) adjust middle_latitude for south or north */ public static void main(String args[]) throws VisADException, RemoteException { double mid_lat = -10.0; if (args.length > 0) { try { mid_lat = Double.valueOf(args[0]).doubleValue(); } catch (NumberFormatException e) { } } boolean swap = (args.length > 1); RealType lat = RealType.Latitude; RealType lon = RealType.Longitude; RealType[] types; if (swap) { types = new RealType[] {lon, lat}; } else { types = new RealType[] {lat, lon}; } RealTupleType earth_location = new RealTupleType(types); System.out.println("earth_location = " + earth_location + " mid_lat = " + mid_lat); RealType flowx = RealType.getRealType("flowx", CommonUnit.meterPerSecond); RealType flowy = RealType.getRealType("flowy", CommonUnit.meterPerSecond); RealType red = RealType.getRealType("red"); RealType green = RealType.getRealType("green"); EarthVectorType flowxy = new EarthVectorType(flowx, flowy); TupleType range = null; range = new TupleType(new MathType[] {flowxy, red, green}); FunctionType flow_field = new FunctionType(earth_location, range); DisplayImpl display = new DisplayImplJ3D("display1", new TwoDDisplayRendererJ3D()); ScalarMap xmap = new ScalarMap(lon, Display.XAxis); display.addMap(xmap); ScalarMap ymap = new ScalarMap(lat, Display.YAxis); display.addMap(ymap); ScalarMap flowx_map = new ScalarMap(flowx, Display.Flow1X); display.addMap(flowx_map); flowx_map.setRange(-10.0, 10.0); ScalarMap flowy_map = new ScalarMap(flowy, Display.Flow1Y); display.addMap(flowy_map); flowy_map.setRange(-10.0, 10.0); FlowControl flow_control = (FlowControl) flowy_map.getControl(); flow_control.setFlowScale(0.05f); display.addMap(new ScalarMap(red, Display.Red)); display.addMap(new ScalarMap(green, Display.Green)); display.addMap(new ConstantMap(1.0, Display.Blue)); double lonlow = -10.0; double lonhi = 10.0; double latlow = mid_lat - 10.0; double lathi = mid_lat + 10.0; Linear2DSet set; if (swap) { set = new Linear2DSet(earth_location, lonlow, lonhi, N, latlow, lathi, N); } else { set = new Linear2DSet(earth_location, latlow, lathi, N, lonlow, lonhi, N); } double[][] values = new double[4][N * N]; int m = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { int k = i; int l = j; if (swap) { k = j; l = i; } double u = (N - 1.0) / 2.0 - l; double v = k - (N - 1.0) / 2.0; // double u = 2.0 * k / (N - 1.0) - 1.0; // double v = 2.0 * l / (N - 1.0); double fx = 6.0 * u; double fy = 6.0 * v; values[0][m] = fx; values[1][m] = fy; values[2][m] = u; values[3][m] = v; m++; } } FlatField field = new FlatField(flow_field, set); field.setSamples(values); DataReferenceImpl ref = new DataReferenceImpl("ref"); ref.setData(field); display.addReference(ref); // create JFrame (i.e., a window) for display and slider JFrame frame = new JFrame("test FlowTest"); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); // create JPanel in JFrame JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setAlignmentY(JPanel.TOP_ALIGNMENT); panel.setAlignmentX(JPanel.LEFT_ALIGNMENT); frame.getContentPane().add(panel); // add display to JPanel panel.add(display.getComponent()); // set size of JFrame and make it visible frame.setSize(500, 500); frame.setVisible(true); }
void setupServerData(LocalDisplay[] dpys) throws RemoteException, VisADException { RealType xr = RealType.getRealType("xr"); RealType yr = RealType.getRealType("yr"); RealType zr = RealType.getRealType("zr"); RealType wr = RealType.getRealType("wr"); RealType[] types3d = {xr, yr, zr}; RealTupleType earth_location3d = new RealTupleType(types3d); FunctionType grid_tuple = new FunctionType(earth_location3d, wr); // int NX = 32; // int NY = 32; // int NZ = 32; int NX = 35; int NY = 35; int NZ = 35; Integer3DSet set = new Integer3DSet(NX, NY, NZ); FlatField grid3d = new FlatField(grid_tuple, set); float[][] values = new float[1][NX * NY * NZ]; int k = 0; for (int iz = 0; iz < NZ; iz++) { // double z = Math.PI * (-1.0 + 2.0 * iz / (NZ - 1.0)); double z = Math.PI * (-1.0 + 2.0 * iz * iz / ((NZ - 1.0) * (NZ - 1.0))); for (int iy = 0; iy < NY; iy++) { double y = -1.0 + 2.0 * iy / (NY - 1.0); for (int ix = 0; ix < NX; ix++) { double x = -1.0 + 2.0 * ix / (NX - 1.0); double r = x - 0.5 * Math.cos(z); double s = y - 0.5 * Math.sin(z); double dist = Math.sqrt(r * r + s * s); values[0][k] = (float) ((dist < 0.1) ? 10.0 : 1.0 / dist); k++; } } } grid3d.setSamples(values); dpys[0].addMap(new ScalarMap(xr, Display.XAxis)); dpys[0].addMap(new ScalarMap(yr, Display.YAxis)); dpys[0].addMap(new ScalarMap(zr, Display.ZAxis)); ScalarMap xrange = new ScalarMap(xr, Display.SelectRange); ScalarMap yrange = new ScalarMap(yr, Display.SelectRange); ScalarMap zrange = new ScalarMap(zr, Display.SelectRange); dpys[0].addMap(xrange); dpys[0].addMap(yrange); dpys[0].addMap(zrange); GraphicsModeControl mode = dpys[0].getGraphicsModeControl(); mode.setScaleEnable(true); if (nice) mode.setTransparencyMode(DisplayImplJ3D.NICEST); mode.setTexture3DMode(texture3DMode); // new RealType duh = RealType.getRealType("duh"); int NT = 32; Linear2DSet set2 = new Linear2DSet(0.0, (double) NX, NT, 0.0, (double) NY, NT); RealType[] types2d = {xr, yr}; RealTupleType domain2 = new RealTupleType(types2d); FunctionType ftype2 = new FunctionType(domain2, duh); float[][] v2 = new float[1][NT * NT]; for (int i = 0; i < NT * NT; i++) { v2[0][i] = (i * i) % (NT / 2 + 3); } // float[][] v2 = {{1.0f,2.0f,3.0f,4.0f}}; FlatField field2 = new FlatField(ftype2, set2); field2.setSamples(v2); dpys[0].addMap(new ScalarMap(duh, Display.RGB)); ScalarMap map1color = new ScalarMap(wr, Display.RGBA); dpys[0].addMap(map1color); ColorAlphaControl control = (ColorAlphaControl) map1color.getControl(); control.setTable(buildTable(control.getTable())); DataReferenceImpl ref_grid3d = new DataReferenceImpl("ref_grid3d"); ref_grid3d.setData(grid3d); DataReferenceImpl ref2 = new DataReferenceImpl("ref2"); ref2.setData(field2); ConstantMap[] cmaps = {new ConstantMap(0.0, Display.TextureEnable)}; dpys[0].addReference(ref2, cmaps); dpys[0].addReference(ref_grid3d, null); }