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.

Problem with mapping RealType and TextType to Display.Text

I've been able to get text on the display with either
    a) mapping a RealType to Display.Text
or  b) mapping a TextType to Display.Text

but if I map both, the RealType is not displayed.

Is that behaviour expected?  What is the official solution?

See the attached program to demonstrate this.

thanks,

Andrew.

-- 
 Andrew Donaldson                                           
 Email:   A.Donaldson@xxxxxxxxxx                Bureau of Meteorology
 Phone:   +61 3 9669 4537            P.O. Box. 1289K/150 Lonsdale St,
 Fax:     +61 3 9669 4128                       Melbourne, Australia.
import visad.*;
import visad.java2d.DisplayImplJ2D;
import java.rmi.RemoteException;
import java.awt.*;
import javax.swing.*;


public class simple
{
        public simple (String []args)
                throws RemoteException, VisADException
        {
                RealType time = new RealType("time");
                RealType height = new RealType("height");
    
                DisplayImpl display = new DisplayImplJ2D("display1");
    
                // Maps
                display.addMap(new ScalarMap(RealType.Latitude, Display.XAxis));
                display.addMap(new ScalarMap(RealType.Longitude, 
Display.YAxis));
                display.addMap(new ScalarMap(height, Display.Text));

                // The line below does not break this program!
                display.addMap(new ScalarMap(new RealType("bar"), 
Display.Text));

                // The line below breaks this program!
                display.addMap(new ScalarMap(new TextType("foo"), 
Display.Text));
                /*
                 * Load up the data
                 */
                RealType cnameType = height;
        
                RealType[] rangeTypes = {
                        RealType.Latitude,
                        RealType.Longitude,
                        cnameType
                };
                RealTupleType rangeTupleType = new RealTupleType(rangeTypes);

                FunctionType function
                        new FunctionType(RealType.Generic, rangeTupleType);

                // Domain
                int ntimes = 2;
                Set timeSet = new Linear1DSet(RealType.Generic, 0.0,
                        (double) (ntimes - 1.0), ntimes);

                FieldImpl field = new FieldImpl(function, timeSet);
        
                // Store the range data
                Real[] data = {
                        new Real(RealType.Latitude, 33.5),
                        new Real(RealType.Longitude, 33.5),
                        new Real(cnameType, 33.5)
                };
                RealTuple rangeTuple = new RealTuple(data);
                field.setSample(0, rangeTuple);
    
                DataReferenceImpl data_ref = new DataReferenceImpl("data_ref");
                data_ref.setData( field );

                display.addReference( data_ref );
    
                // Create application window, put display into it 
                JFrame jframe = new JFrame("simple");
                jframe.getContentPane().add(display.getComponent());
    
                // Set window size and make it visible
                jframe.setSize(300, 300);
                jframe.setVisible(true);
        }
  
        public static void main(String[] args)
                throws RemoteException, VisADException
        {
                new simple(args);
        }
}

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