Making a simple VisAD application collaborative
This is a walkthrough of the process
of making a simple VisAD application collaborative.
We'll start with an application which reads a GIF file from
the Web and displays it using a DisplayImplJ2D:
Next
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.IOException;
import java.rmi.RemoteException;
import visad.*;
import visad.data.DefaultFamily;
import visad.java2d.DisplayImplJ2D;
import visad.util.ClientServer;
public class DisplayGIF
{
private static final String fileURL = "http://www.ssec.wisc.edu/~billh/billh.gif";
public static void main(String[] args)
throws IOException, RemoteException, VisADException
{
DisplayImpl dpy = new DisplayImplJ2D("display");
FlatField image = (FlatField )new DefaultFamily("dflt").open(fileURL);
FunctionType ftype = (FunctionType )image.getType();
RealTupleType dtype = ftype.getDomain();
RealTupleType rtype9 = (RealTupleType )ftype.getRange();
dpy.addMap(new ScalarMap((RealType )dtype.getComponent(0),
Display.XAxis));
dpy.addMap(new ScalarMap((RealType )dtype.getComponent(1),
Display.YAxis));
dpy.addMap(new ScalarMap((RealType )rtype9.getComponent(0),
Display.Red));
dpy.addMap(new ScalarMap((RealType )rtype9.getComponent(1),
Display.Green));
dpy.addMap(new ScalarMap((RealType )rtype9.getComponent(2),
Display.Blue));
DataReferenceImpl ref_image = new DataReferenceImpl("ref_image");
ref_image.setData(image);
dpy.addReference(ref_image, null);
JFrame jframe = new JFrame("GIF");
jframe.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) { System.exit(0); }
});
jframe.setContentPane((Container )dpy.getComponent());
jframe.pack();
jframe.setVisible(true);
}
}
Next
Last modified: Wed Jul 12 10:59:58 CDT 2000