Re: The random colour changing bug


Andrew Donaldson wrote:


  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.

I've seen this too and reported on:

(see also other emails on the same thread)

but dismissed because I thought it had to do with other native j3D objects I was adding to the display (via dispRendenerer.getTrans().addChild())



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

 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!




import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.rmi.RemoteException;
import visad.*;
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);

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

                DataReferenceImpl data_ref = new DataReferenceImpl("data_ref");

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

                display.addReference(data_ref, colourConstantMap);

                // Swing stuff
                JFrame frame = new JFrame("ColourBug example program");

                frame.setSize(500, 500);

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

l a t / l o n  GmbH
Aennchenstrasse 19           53177 Bonn, Germany
phone ++49 +228 184960       fax ++49 +228 1849629