Re: Scatter Plot Animation w/ Increasing # Particles

Hi Mike,

You can update a subset of a FlatField's range samples
using the setSamples() signature:

  public void setSamples(int start, double[][] range)

Here, start is the index of the first sample to update,
and range[0].length is the number of samples to update.
Sorry this was not documented.

However, the display logic will update the display of all
FlatField points. It may help a bit if the unused sample
val;ues are all set to NaN (i.e., missing).

If this is still to slow, you can partition your FlatField
and its domain Integer1DSet into disjoint sub-intervals,
with each FlatField independently linked to the Display
via its own DataReference. When you need to update sample
values, only update those FlatFields with samples that
change.

Good luck,
Bill


On Mon, 9 Feb 2004, Kapper Michael G Contr AFRL/PRSA wrote:

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