/* VisAD Tutorial Copyright (C) 2000 Ugo Taddei */ package tutorial.s5; // Import needed classes import visad.*; import visad.util.*; import visad.data.gif.*; import visad.java2d.DisplayImplJ2D; import visad.java3d.DisplayImplJ3D; import java.rmi.RemoteException; import java.awt.*; import javax.swing.*; import java.util.Calendar; import java.util.GregorianCalendar; import visad.jmet.*; /** VisAD Tutorial example 5_10 Animating a GIF/JPEG image ( time -> (( longitude, latitude ) -> ( redType, greenType, blueType ) ) ) Run program with java P5_10 * */ public class P5_10{ // Declare variables // The RealTypes private RealType time, longitude, latitude; private RealType redType, greenType, blueType; // The function // ( time -> ( ( longitude, latitude ) -> ( redType, greenType,blueType ) ) ) private FunctionType func_t_latlon; // Our Data values for longitude, latitude are represented by the set private Set latlonSet; // Time values are given by the set by the set private Set timeSet; // A FieldImpl private FieldImpl timeField; // The DataReference from the data to display private DataReferenceImpl data_ref; // The 2D display, and its the maps private DisplayImpl display; private ScalarMap timeAnimMap, timeZMap; private ScalarMap lonXMap, latYMap, altiZMap; private ScalarMap redMap, greenMap, blueMap; public P5_10 (String[] args) throws RemoteException, VisADException { if(args.length <= 1){ System.out.println("run with \"java P5_10 image_1.gif image_2.gif ...\""); return; } // The following will hold the number of images int nImages = args.length; // Create GIFForm object GIFForm image = new GIFForm(); // Get the image data DataImpl imageData = image.open(args[0]); // Print out the MathType System.out.println(imageData.getType().prettyString()); // Get the image type. Oh, well, we know it's a FunctionType FunctionType functionType = (FunctionType) imageData.getType(); // Get the domain... RealTupleType domain = (RealTupleType) functionType.getDomain(); // ...and the range RealTupleType range = (RealTupleType)functionType.getRange(); // Create the quantities longitude = (RealType) domain.getComponent(0); latitude = (RealType) domain.getComponent(1); redType = (RealType) range.getComponent(0); greenType = (RealType) range.getComponent(1); blueType = (RealType) range.getComponent(2); // Define Time and its set time = RealType.getRealTypeByName("Time"); // make set as big enaough to hold all nImages timeSet = new Integer1DSet(time, nImages); // Make Function ( time -> ( Image-MathType) ) func_t_latlon = new FunctionType(time, functionType); // Make Field timeField = new FieldImpl( func_t_latlon, timeSet); // Set Field with data from the images // set the first on, because it's already open timeField.setSample(0, imageData); // ...then set the rest for(int i=1;i