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.

Re: UnionSet and Animation

Hi,
The small program is attached. The labels are displayed but their position
does not change based on the x,y,z values that are provided to them. I could
not see the labels earlier as they were being displayed outside the visible
range of my program. But now the problem is that their position does not
change. I have attached the small program. Thanks once again for all your
help.
> I can't think of anything. If you send me a *small* program
> that illustrates the problem, I'll run it and see if I can
> figure anything out.

With best regards,
Jay




import java.io.*;

import java.util.*;

import java.lang.Math;



// packages for main method

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.rmi.RemoteException;

import visad.*;

import visad.Set;

import visad.VisADException;

import visad.util.*;

import visad.java3d.*;

import visad.ss.*;

import visad.ss.FancySSCell;

import visad.data.Form;

import visad.data.netcdf.Plain;

import visad.data.tiff.TiffForm;

import visad.data.visad.VisADForm;

import visad.formula.*;

import VisPackage.*;



/**

   Delaunay represents an abstract class for calculating an

   N-dimensional Delaunay triangulation, that can be extended

   to allow for various triangulation methods.<P>

*/

public class ShortTest {

    





    /** A graphical demonstration of implemented Delaunay triangulation

        algorithms, in 2-D or 3-D */

    public static void main(String[] argv) throws VisADException,

                                                  RemoteException 

    {

        







        // set up frame

        JFrame frame = new JFrame();

        frame.addWindowListener(new WindowAdapter() {

                public void windowClosing(WindowEvent e) {

                    System.exit(0);

                }

            });

        



        

        // set up frame's panel

        JPanel panel = new JPanel();

        panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

        panel.add(makeStickFigure().getComponent());

        frame.getContentPane().add(panel);



        frame.setSize(new Dimension(510, 530));

        frame.setTitle("Triangulation results");

        frame.setVisible(true);

    }

    

 

    private static DisplayImpl makeStickFigure()throws
VisADException,RemoteException

    {

        int max_points = 3;

                

        //data types created for the right and left leg

        RealType x = RealType.getRealType("x");

        RealType y = RealType.getRealType("y");

        RealType z = RealType.getRealType("z");

        RealTupleType xyz_right = new RealTupleType(x,y,z);

        

        

        //the time for the animation

        RealType[] time = {RealType.Time};

        RealTupleType time_type = new RealTupleType(time);



        

        Gridded3DSet[] gsp_right = new Gridded3DSet[max_points];

        

        FunctionType time_samples_right = new FunctionType(time_type,new
SetType(xyz_right));

        



        DateTime base = new DateTime(1999, 122, 57060);

        double start = base.getValue();

        Set time_set = new Linear1DSet(time_type, start, start +
5.0,max_points);



        FieldImpl image_sequence_right = new FieldImpl(time_samples_right,
time_set);

        

        TextType text = new TextType("text");

        TupleType text_tuple = new TupleType(new MathType[] {x, y, z, text});

        FunctionType text_function = new
FunctionType(time_type,text_tuple);

        FieldImpl text_field = new FieldImpl(text_function, time_set);

        

        

        //TupleIface tt=null;

        float[][] samples1 = new float[3][6];

        for(int i=0;i<max_points;i++)

            {

                samples1[0][0] = 291 + i*1000;

                samples1[1][0] = 24 +i;

                samples1[2][0] = 255 + i*10;

                Data[] td1 = {new Real(x,291 +i*1000),

                              new Real(y,24 + i),

                              new Real(z,255+i*10),

                              new Text(text, "Sensor " + i)};

                /*

                Data[] td1 = {new Real(x,samples1[0][0]),

                              new Real(y,samples1[1][0]),

                              new Real(z,samples1[2][0]),

                              new Text(text, "Sensor " + i)};

                */

                TupleIface tt = new Tuple(text_tuple, td1);

                text_field.setSample(i, tt);



                samples1[0][1] = 190+i*1000;

                samples1[1][1] = 92+i;

                samples1[2][1] = 217+i*10;

        

                samples1[0][2] = 261+i;

                samples1[1][2] = 521+i*100;

                samples1[2][2] = 232+i*10;

        

                samples1[0][3] = 275+i;

                samples1[1][3] = 943+i*100;

                samples1[2][3] = 282+i*10;



                samples1[0][4] = 276+i;

                samples1[1][4] = 1051+i*100;

                samples1[2][4] = 252+i*10;

                

                samples1[0][5] = 273+i;

                samples1[1][5] = 1460+i*100;

                samples1[2][5] = 283+i*10;

        

                gsp_right[i] = new Gridded3DSet(xyz_right, samples1,6);

                image_sequence_right.setSample(i,gsp_right[i]);

            }



        FieldImpl[] figure = {image_sequence_right,text_field};

        Tuple big_tuple = new Tuple(figure);



        // set up Java3D Display

        DisplayImpl display = new DisplayImplJ3D("image display");

        

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

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

        ScalarMap zmap=new ScalarMap(z, Display.ZAxis);

        ScalarMap textmap = new ScalarMap(text,Display.Text);

        ScalarMap map1animation =  new ScalarMap(RealType.Time,
Display.Animation);

        xmap.setRange(-2500,2500);

        ymap.setRange(-2500,2500);

        zmap.setRange(-2500,2500);

        display.addMap(xmap);

        display.addMap(ymap);

        display.addMap(zmap);

        //text reference 

        display.addMap(textmap);

        display.addMap(new ConstantMap(1, Display.Red));

        display.addMap(new ConstantMap(1, Display.Green));

        display.addMap(new ConstantMap(0, Display.Blue));

        display.addMap(map1animation);



        //DataReferenceImpl rtf = new DataReferenceImpl("rtf");

        //rtf.setData(text_field);

        //display.addReference(rtf, null);





        final DataReference tetref = new DataReferenceImpl("tet");

        tetref.setData(big_tuple);

        display.addReference(tetref,null);



        // finish setting up Java3D Display

        

        GraphicsModeControlJ3D dispGMC;

        dispGMC = (GraphicsModeControlJ3D)  display.getGraphicsModeControl();

        dispGMC.setScaleEnable(true);    

        

        AnimationControl animation1control =  (AnimationControl)
map1animation.getControl();

        animation1control.setOn(true);



        AnimationWidget animWidget = new AnimationWidget(map1animation);

        JFrame generalframe = new JFrame("Animation Control");

        generalframe.getContentPane().setLayout( new BorderLayout());

        generalframe.getContentPane().add(animWidget, BorderLayout.CENTER);

        generalframe.setSize(400, 200);

        generalframe.setVisible(true);



        return display;



    }

            

}



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