Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

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);
        }
}

 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Community Programs   Unidata is a member of the UCAR Community Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690