public static void main(String[] args) throws Exception { DisplayImpl display = new DisplayImplJ2D("display"); display.getDisplayRenderer().setBoxOn(false); double[] matrix = display.getProjectionControl().getMatrix(); matrix[0] = 1.25; matrix[3] = -1.25; display.getProjectionControl().setMatrix(matrix); display.addMap(new ScalarMap(RealType.YAxis, Display.YAxis)); display.addMap(new ScalarMap(RealType.XAxis, Display.XAxis)); float[][] values = new float[3][220]; int l = 0; for (int x = 0; x < 11; x++) { for (int y = 0; y < 20; y++) { values[0][l] = -1.f + y / 10.f; values[1][l] = 1.f - x / 4.f; values[2][l] = l++; } } Gridded3DSet set = new Gridded3DSet(RealTupleType.SpatialCartesian3DTuple, values, l); ScalarMap shapeMap = new ScalarMap(RealType.ZAxis, Display.Shape); display.addMap(shapeMap); ShapeControl sc = (ShapeControl) shapeMap.getControl(); sc.setShapeSet(new Integer1DSet(l)); sc.setShapes(WeatherSymbols.getAllMetSymbols()); sc.setScale(0.1f); DataReference ref = new DataReferenceImpl("ref"); ref.setData(set); display.addReference(ref); JFrame frame = new JFrame("Weather Symbol Plot Test"); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); frame.getContentPane().add(display.getComponent()); frame.pack(); frame.setSize(500, 500); frame.setVisible(true); }
/** * Set the DisplayImpl this ScalarMap is linked to * * @param d display to link to * @throws VisADException map is already linked to a DisplayImpl or other VisAD error */ synchronized void setDisplay(DisplayImpl d) throws VisADException { if (d.equals(display)) return; if (display != null) { throw new DisplayException( "ScalarMap.setDisplay: ScalarMap cannot belong" + " to two Displays"); } display = d; if (scale_flag) makeScale(); // System.out.println("setDisplay " + Scalar + " -> " + DisplayScalar); // WLH 27 Nov 2000 if (!(this instanceof ConstantMap)) { ProjectionControl pcontrol = display.getProjectionControl(); try { setAspectCartesian(pcontrol.getAspectCartesian()); } catch (RemoteException e) { } } }