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.

UnionSet bug?

Dear All,

Can UnionSet only accept unions of Linear2DSets with equal number of
elements in each direction, or have I done something wrong? The code below
works fine for

        noPoints = 10

but fails for example for

        noPoints = 11



import visad.*;
import visad.java2d.DisplayImplJ2D;
import java.rmi.RemoteException;
import javax.swing.*;
import java.awt.event.*;


public class Main {

  public static void main(String[] args) throws VisADException,
RemoteException {
    Main main = new Main();
    main.run();
  }

  void run() throws VisADException, RemoteException {
    RealType x = new RealType("x");
    RealType y = new RealType("y");
    RealTupleType xy = new RealTupleType(x,y);
    RealType z = new RealType("z");
    DataReferenceImpl ref = new DataReferenceImpl("ref");
    DisplayImplJ2D display = new DisplayImplJ2D("display");

    int noPoints = 11;
    Linear2DSet domain1 = new Linear2DSet(xy,1.0,10.0,10,20.0,30.0,10);
    Linear2DSet domain2 = new Linear2DSet(xy,20.0,40.0,noPoints,
50.0,60.0,10);
    UnionSet union = new UnionSet(xy,new SampledSet[] { domain1, domain2 });
    FlatField f = new FlatField(new FunctionType(xy,z), union);
    int noSamples = 10*10+noPoints*10;

    double[][] samples = new double[1][noSamples];

    for(int i=0;i<noSamples;++i) {
      samples[0][i] = (double) i*i;
    }

    f.setSamples(samples);

    ref.setData(f);
    display.addMap(new ScalarMap(x,Display.XAxis));
    display.addMap(new ScalarMap(y,Display.YAxis));
    display.addMap(new ScalarMap(z,Display.RGB));
    display.addReference(ref);

    JFrame frame =  new JFrame("VisAD Test");
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {System.exit(0);}
    });
    frame.setSize(300,300);
    frame.getContentPane().add(display.getComponent());
    frame.show();
  }
}



This produces:

java.lang.ArrayIndexOutOfBoundsException        at
visad.java2d.VisADCanvasJ2D.render(VisADCanvasJ2D.java:955)     at
visad.java2d.VisADCanvasJ2D.render(VisADCanvasJ2D.java:507)     at
visad.java2d.VisADCanvasJ2D.render(VisADCanvasJ2D.java:507)     at
visad.java2d.VisADCanvasJ2D.render(VisADCanvasJ2D.java:496)     at
visad.java2d.VisADCanvasJ2D.render(VisADCanvasJ2D.java:507)     at
visad.java2d.VisADCanvasJ2D.render(VisADCanvasJ2D.java:507)     at
visad.java2d.VisADCanvasJ2D.paintComponent(VisADCanvasJ2D.java:392)     at
visad.java2d.VisADCanvasJ2D.run(VisADCanvasJ2D.java:317)        at
java.lang.Thread.run(Thread.java:484)




Regards,
Jakob


----------------------------------------------------------
Dr Jakob Svensson, Max Planck Institute for Plasma Physics
Boltzmannstrasse 2, D-85748 Garching, Germany
Tel +49-(0)89-32991786


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