The random colour changing bug

Hi,

  For some time many of us here at the Bureau of Meteorology have
been aware of our VisAD apps changing colour for an unknown reason.
I vaguely recall showing this to Bill when he last visited, but I
am uncertain of this.

  It has recently become a problem, with some of our operational people
wanting to choose specific colours, only to have them changed by
our applications.

 On every computer we have tried it on (including Linux nvidia, windows
opengl and windows directx) the fault occurs.

 Attached is a simple program which displays a yellow box.  If you click
with your middle mouse button, the yellow box becomes darker.  This
thought to be the same problem that our applications have.  The sample
program does not have any code to respond to a mouse button or change
colours.

 Any help would be very greatly appreciated.

 I think we first need to work out if the problem is with java3d or
VisAD.  I don't have a good understanding of all the things that happen
when the middle mouse button is pressed, hopefully someone else can
add to this!

thanks,

Andrew.



import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.URL;
import java.rmi.RemoteException;
import visad.*;
import visad.bom.*;
import visad.java3d.*;

public class ColourBug
{
        private DataReferenceImpl dataReference;

        public ColourBug()
                throws Exception
        {
                DisplayImplJ3D display;
                ScalarMap latMap, lonMap;

                visad.java3d.DisplayRendererJ3D displayRenderer
                        new TwoDDisplayRendererJ3D();
                display = new DisplayImplJ3D("display", displayRenderer);

                lonMap = new ScalarMap(RealType.Longitude, Display.XAxis);
                latMap = new ScalarMap(RealType.Latitude, Display.YAxis);
                display.addMap(latMap);
                display.addMap(lonMap);

                RealType pixel = RealType.getRealType("PIXEL");

                FunctionType functionType = new FunctionType(
                        RealTupleType.LatitudeLongitudeTuple, pixel);
                Set domainSet = new Integer2DSet(
                        RealTupleType.LatitudeLongitudeTuple, 2, 2);

                float[][] flat_samples = new float[1][2*2];
                flat_samples[0][0] = 1;
                flat_samples[0][1] = 1;
                flat_samples[0][2] = 1;
                flat_samples[0][3] = 1;

                FlatField vals_ff = new FlatField(functionType, domainSet);
                vals_ff.setSamples(flat_samples);

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

                Color colour = new Color(254,240,179);
                ConstantMap[] colourConstantMap = new ConstantMap[3];
                colourConstantMap[0] = new ConstantMap(colour.getRed()/255.0f,
                                Display.Red);
                colourConstantMap[1] = new ConstantMap(colour.getGreen()/255.0f,
                                Display.Green);
                colourConstantMap[2] = new ConstantMap(colour.getBlue()/255.0f,
                                Display.Blue);

                display.addReference(data_ref, colourConstantMap);

                // Swing stuff
                JFrame frame = new JFrame("ColourBug example program");
                frame.getContentPane().add(display.getComponent());

                frame.setSize(500, 500);
                frame.setVisible(true);
        }

        public static void main(String[] args)
                throws Exception
        {
                new ColourBug();
        }
}