Scatter Plot Animation w/ Increasing # Particles

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

Content-Type: text/plain

Greetings,

 

I have been able to get animations in VisAD to work very smoothly for a lot
of different cases until I had to animate a 2D scatter plot in which
particle generation was involved.  In the (stripped-down) code below, the
updatePlot() method is called with 2 vectors containing the x and y
coordinates of each particle.  Because the number of particles increases, I
created a new Integer1DSet, FlatField, and reset the flatfield data into the
DataRefernece at each "update" iteration.  This results in the screen
flashing at each iteration and poor performance.

In an opposing case, I initialized the plot with an Integer1DSet that was
very large -->Integer1DSet(maximum # of particles that could possibly be
generated).  I didn't have to create a new FlatField and reset it into the
DataReference everytime I updated the plot, but I did have to call
setSamples() with a very large data set even though there was only a few
particles present.  While the screen no longer flashes, performance is
sacrificed when a small # of particles is present.

What is the proper way to do this?  Does a new Integer1DSet have to be
created everytime as well as resetting the flatfield data?  Much thanks in
advance.

 

Mike

 

 

public void initPlot()

{   

    ...

    

    index = RealType.getRealType("index");

    x     = RealType.getRealType("x");

    y     = RealType.getRealType("y");

    

     xy = new RealTupleType(x,y);

    fxy = new FunctionType(index,xy);

 

    xMap = new ScalarMap(x,Display.XAxis);

    yMap = new ScalarMap(y,Display.YAxis);

 

    DisplayImpl display = new DisplayImplJ2D("display1");

    

    display.addMap(xMap);

    display.addMap(yMap);

    

    data_ref = new DataReferenceImpl("data_ref");

    display.addReference(data_ref);

    

    JFrame jframe = new JFrame("VisAD");

    jframe.getContentPane().add(display.getComponent());

    jframe.setSize(700, 200);

    jframe.setVisible(true);

 

}

    

public static void updatePlot(double[] vx, double[] vy)

{   int Nparts = vx.length;

    

    data = new double[2][Nparts];

    for(int n=0;n<Nparts;n++)

    {   data[0][n] = vx[n];

        data[1][n] = vy[n];

    }

    

    set = new Integer1DSet(Nparts);

    flatfield = new FlatField(fxy,set);

    data_ref.setData(flatfield);

    flatfield.setSamples( data, false );

 

}

 

 

 


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