Text is turning white

Hi Everyone,

  I was doing something like (lat, lon)->height, with height mapped
to Display.Text.  This worked ok, and I could even colour it with
my favorite colour.  Then I did a setFont() on the textControl,
and apart from setting the font properly, it turned my text white!

  This is not seen when I rewrite my program to have
n->(lat, lon, height).

  Attached is a sample program to show this.  Uncomment the setFont()
line to turn the text white.

  Have I got something wrong here, or is this a bug?

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.java3d.DisplayImplJ3D;
import java.rmi.RemoteException;
import java.awt.*;
import javax.swing.*;


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

                // Domain
                RealType[] domainTypes = {
                        RealType.Latitude,
                        RealType.Longitude
                };
                RealTupleType domainTuple = new RealTupleType(domainTypes);

                int numSamples = 1;
                double[][] domainSamples = new double[2][numSamples];
                int i=0;
                domainSamples[0][i] = -42.0;
                domainSamples[1][i] = 142.0;

                // Assemble domain set
                Gridded2DDoubleSet domainSet = new Gridded2DDoubleSet(
                        domainTuple, domainSamples, numSamples);

                // Function
                FunctionType function = new FunctionType(
                        domainTuple, heightType);

                // Make the field
                FieldImpl field = new FlatField(function, domainSet);
        
                // Range
                float[][] rangeSamples = new float[1][numSamples];
                rangeSamples[0][i] = 123.4f;
                field.setSamples(rangeSamples);

                DataReferenceImpl data_ref = new DataReferenceImpl("data_ref");
                data_ref.setData(field);

                TextControl tcontrol = (TextControl)
                        heightScalarMap.getControl();

// Add add this line to make text white!
//              tcontrol.setFont(new Font("Arial", Font.PLAIN, 6));

                ConstantMap[] newConstantMap = {
                        new ConstantMap(0.0f, Display.Red),
                        new ConstantMap(1.0f,Display.Green),
                        new ConstantMap(1.0f, Display.Blue)
                };
                display.addReferences(new visad.java3d.DefaultRendererJ3D(),
                        data_ref, newConstantMap);
    
                // Create application window, put display into it 
                JFrame jframe = new JFrame("WhiteText");
                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 WhiteText(args);
        }
}

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