RE: java syntax question


Below is my own class called I created an instance of 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 non-static variable WIDTH_PERCENT cannot be referenced
from a static context
    final SpreadSheet ss = new SpreadSheet(WIDTH_PERCENT, HEIGHT_PERCENT,
                                           ^ 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
What constructor are they talking about that needs to be called? Or is it a
problem with how I declared mySS to be static?


  public SpreadSheet() {
    this(WIDTH_PERCENT, HEIGHT_PERCENT, 2, 2, null, null,
      "VisAD SpreadSheet", null, true);

My own

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 and setMappings()");       
          ScalarMap Alt_rad = new ScalarMap(RealType.Altitude,
          ScalarMap Alt_green = new ScalarMap(RealType.Altitude,
          ScalarMap Lat_blue = new ScalarMap(RealType.Latitude,
          ScalarMap Long_red = new ScalarMap(RealType.Longitude,

          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
        public static void loadMyDataSet() throws VisADException,
RemoteException {

        try {
          System.out.println("In loadMyDataSet() and in try clause"); 
        catch (VisADException exc) {
        System.out.println("Could not load file small.v5d into the
        catch (RemoteException exc) {
        System.out.println("Could not load file small.v5d into


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
in your own extension of the SpreadSheet, or some other solution,
that same method can contain the call to BasicSSCell.setMaps()
immediately afterward. 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.


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 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?

  • 2003 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: