NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi, Below is my own class called Go.java. I created an instance of SpreadSheet.java called mySS but in the constructor of SpreadSheet, it uses WIDTH_PERCENT and HEIGHT_PERCENT which are non-static variables. So when I compiled it, I got the following error: javac SpreadSheet.java SpreadSheet.java:535: non-static variable WIDTH_PERCENT cannot be referenced from a static context final SpreadSheet ss = new SpreadSheet(WIDTH_PERCENT, HEIGHT_PERCENT, ^ SpreadSheet.java:582: cannot reference WIDTH_PERCENT before supertype constructor has been called this(WIDTH_PERCENT, HEIGHT_PERCENT, 2, 2, null, null, ^ 2 errors I'm not sure what the supertype constructor is that it's referring to because the only class that WIDTH_PERCENT is used in is SpreadSheet.java. What constructor are they talking about that needs to be called? Or is it a problem with how I declared mySS to be static? from SpreadSheet.java: public SpreadSheet() { this(WIDTH_PERCENT, HEIGHT_PERCENT, 2, 2, null, null, "VisAD SpreadSheet", null, true); } My own Go.java: public class Go { public static SpreadSheet mySS = new SpreadSheet(); public static BasicSSCell myBasicSS = new BasicSSCell("myCell"); //sets up default mappings when image is first loaded in. public static void setMappings() { System.out.println("In Go.java and setMappings()"); ScalarMap Alt_rad = new ScalarMap(RealType.Altitude, Display.Radius); ScalarMap Alt_green = new ScalarMap(RealType.Altitude, Display.Green); ScalarMap Lat_blue = new ScalarMap(RealType.Latitude, Display.Blue); ScalarMap Long_red = new ScalarMap(RealType.Longitude, Display.Red); mySS.myMappings[0] = Alt_rad; mySS.myMappings[1] = Alt_green; mySS.myMappings[2] = Lat_blue; mySS.myMappings[3] = Long_red; } //loads small.v5d into top left spreadsheet cell, called from SpreadSheet.java public static void loadMyDataSet() throws VisADException, RemoteException { try { System.out.println("In loadMyDataSet() and in try clause"); mySS.myAutoDetect(false); mySS.DisplayCells[0][0].addDataSource("D:\\visad\\data\\small.v5d", BasicSSCell.URL_SOURCE); setMappings(); myBasicSS.setMaps(mySS.myMappings); } catch (VisADException exc) { System.out.println("Could not load file small.v5d into the SpreadSheet"); } catch (RemoteException exc) { System.out.println("Could not load file small.v5d into spreadsheet"); } } } Michelle Kam (408) 742-2881 Lockheed Martin Space Systems Co. SSM/ATC/MSIS B/153 O/L922 1111 Lockheed Martin Way, Sunnyvale, CA 94089 -----Original Message----- From: Curtis Rueden [mailto:curtis@xxxxxxxxxxxxx] Sent: Tuesday, June 10, 2003 5:44 PM To: Kam, Michelle C Subject: RE: your mail Hi Michelle, Somewhere, you are calling BasicSSCell.addDataSource(). Wherever you are doing that, whether by hacking SpreadSheet.java in your own extension of the SpreadSheet, or some other solution, that same method can contain the call to BasicSSCell.setMaps() immediately afterward. Swells.java does not use the SpreadSheet; it just uses the general VisAD functionality. If you want a SpreadSheet cell to use certain mappings, call BasicSSCell.setMaps(). If you just want a normal VisAD display (i.e., not a SpreadSheet cell), then feel free to use DisplayImpl.addMap() repeatedly to add the maps. -Curtis At 06:13 PM 6/10/2003, Kam, Michelle C wrote: >Hi Curtis, > >Ok so from my understanding, if I want to change the default mappings that >first appear or overwrite the default mappings when loading a file, I would >have to create a new class which creates the array of ScalarMap's and adds >them to the display such as with a call to display.addMap(someMap)? > > >Also, I was looking at Swells.java as an example, and they don't call >BasicSSCell.setMaps() from within that class so do you recommend trying to >call it from my own subclass? > >Thanks, >Michelle
visad
archives: