// TestStormSingeltonSet
//
package visad;
// import needed classes
import visad.*;
import visad.java3d.DisplayImplJ3D;
import visad.java2d.DisplayImplJ2D;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.rmi.*;
/**
TestStormSingletonSet is a trival class for testing out StormSingletonSet.<P>
*/
public class TestStormSingletonSet {
public static void main(String args[])
throws VisADException, RemoteException {
// define the real types
RealType rtLat = RealType.Latitude;
RealType rtLon = RealType.Longitude;
RealType rtTop = new RealType("Top", null, null);
RealType rtMajorRad = new RealType("MajorRadius", null, null);
RealType rtMinorRad = new RealType("MinorRadius", null, null);
RealType rtOrientation = new RealType("Orientation", null, null);
// define a real tuple type made up from the above types
RealTuple rtupleStorm = new RealTuple( new Real[] {
new Real( rtLat, -35.0),
new Real( rtLon, 155.0) ,
new Real( rtTop, 10.0 ) ,
new Real( rtMajorRad, 0.5 ) ,
new Real( rtMinorRad, 0.4 ) ,
new Real( rtOrientation, 45.0 ) } );
// define a Specialised SingletonSet (StormSingletonSet) based on the
above real tuple
StormSingletonSet ssStorm = new StormSingletonSet(rtupleStorm);
// now do the display stuff
final DataReference drTime2Storm = new DataReferenceImpl("Time2Storm");
drTime2Storm.setData(ssStorm);
// create a Display using Java3D
DisplayImpl display = new DisplayImplJ3D("image display");
// map rttLatLon coordinates to display coordinates
display.addMap(new ScalarMap(RealType.Longitude, Display.XAxis));
display.addMap(new ScalarMap(RealType.Latitude, Display.YAxis));
display.addMap(new ScalarMap(rtTop, Display.ZAxis));
display.addMap(new ScalarMap(rtTop, Display.RGB));
// link the Display to the data reference
display.addReference(drTime2Storm);
// create JFrame (i.e., a window) for display and slider
JFrame frame = new JFrame("Storm VisAD Application");
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);
}
}
// StormSingletonSet
//
package visad;
// import needed classes
import visad.*;
import java.rmi.*;
/**
StormSingletonSet is a special class for Set-s containing one member.
It is designed for displaying Thunderstorm Tracks as ellipses<P>
*/
public class StormSingletonSet extends SingletonSet {
/** construct a StormSingletonSet with the single sample given by a RealTuple */
public StormSingletonSet(RealTuple d)
throws VisADException, RemoteException {
super(d);
System.out.println("StormSingletonSet constructor");
}
/** create a PointArray from this Set and color_values;
can be applied to ManifoldDimension = 1, 2 or 3 */
public VisADGeometryArray makePointGeometry(byte[][] color_values)
throws VisADException {
System.out.println("StormSingletonSet: makePointGeometry");
VisADGeometryArray array = super.makePointGeometry(color_values);
// put some stuff in here, or in a setGeometryArray method to
// change a single point array to an array of points which make
// an ellipse
return array;
}
}