//Imports small.v5d and sets up specified mappings.

packag
e visad.ss;

import java.awt.*;
import java.io.*;

import java.net.*;
import java.rmi.*;
import java.util.*
;
import javax.swing.*;
import javax.swing.border.*;

import visad.*;
import visad.data.*;
import visad.util.*
;

import java.awt.event.*;
import java.awt.print.*;


import java.lang.reflect.*;
import java.rmi.registry
.*;
import javax.swing.event.*;

import visad.formula.
*;
import visad.java3d.*;

public class VisadAPI {

	
	
	public static SpreadSheet mySS;
	pu
blic static BasicSSCell myBasicSS;
	
	public VisadAPI(S
preadSheet ss, BasicSSCell basic) {
		
		mySS = s
s;
		myBasicSS = basic;
	}

	//loads sm
all.v5d into top left spreadsheet cell, called from SpreadSheet.java

	public static void loadMyDataSet() throws VisADException, Re
moteException {

 	try {
 	  System.out.println("I
n loadMyDataSet() and in try clause"); 
 	  mySS.myAutoDetect(
false);  
 	  System.out.println("After false");
 	  if
 (mySS == null) {
 	  	System.out.println("mySS is null"
);
 	  }
else {
	  mySS.DisplayCells[0][0].addData
Source("D:\\visad\\data\\small.v5d", BasicSSCell.URL_SOURCE);

	 }
	  System.out.println("after addDataSource()");

	  setMappings();
	  //System.out.println("after SetMappings
 and myMappings is " + mySS.myMappings[0] + " " + mySS.myMappings[1]
+ " "+ mySS.myMappings[2]+" "+mySS.myMappings[3]);
	  //myBasi
cSS.setMaps(mySS.myMappings);
	  System.out.println("after set
Maps");
}
	catch (VisADException exc) {
		System
.out.println("in loadMyDataSet() and there is a VisadException");

     	System.out.println("VisADException in loadMyDataSet().
Could not load file small.v5d. ");
}
	catch (RemoteExcept
ion exc) {
		System.out.println("in loadMyDataSet() and ther
e is a RemoteException");
    	System.out.println("RemoteExcep
tion in loadMyDataSet(). Could not load file small.v5d.");
	}

}

	//sets up default mappings when image is first
loaded in.
	public static void setMappings() throws VisADExcep
tion, RemoteException {

	try {		
	System.out.
println("In VisadAPI.java and setMappings()");	  
	  ScalarM
ap Alt_rad = new ScalarMap(RealType.Altitude, Display.Radius);	
	
	  ScalarMap Alt_green = new ScalarMap(RealType.Altitude
, Display.Green);
	  ScalarMap Lat_blue = new ScalarMap(Real
Type.Latitude, Display.Blue);
	  ScalarMap Long_red = new Sc
alarMap(RealType.Longitude, Display.Red);
	  	  
	  m
yBasicSS.setMaps(new ScalarMap[] {Alt_rad, Alt_green, Lat_blue, Long_
red});

	}

	catch (VisADException exc) {

		System.out.println("VisADException in method setMappings
in VisadAPI.java");
	}
	catch (RemoteException exc) {

		System.out.println("in loadMyDataSet() and there is a Rem
oteException");
    	System.out.println("RemoteException in lo
adMyDataSet(). Could not load file small.v5d.");
	}
}


}

