Re: Problem with Simple Animation

  • To: Edward Stanford <stanford@xxxxxxx>
  • Subject: Re: Problem with Simple Animation
  • From: Doug Lindholm <lind@xxxxxxxx>
  • Date: Mon, 23 Oct 2000 14:47:24 -0600
I haven't seen any responses to your question yet. I'm sure it's just
some sort of delay in my receiving list traffic and you probably have
several solutions, but I'll give you my short answer anyway.

Instead of constructing a new AnimationControl, get it from the
ScalarMap to Display.Animation. This must be done after the ScalarMap is
created (and after it is added to the Display?).

AnimationControl animC = (AnimationControl) animMap.getControl();

Hope that helps.

Doug


Edward Stanford wrote:
> 
> I am trying to follow the pattern shown in SimpleAnimation.java to create
> an animated display of my own data set, but I appear to be making a subtle
> mistake in setting up my data structures.
> 
> Basically, I create two 2D FieldImpl's mapping ( (lat, lon) -> temp) ), then
> create a new FieldImpl mapping (time -> ( (lat, lon) -> temp) ).  I use the
> setSample method to make my first 2D field correspond to time 0, and the
> second to time 1.  Then I animate the result, and turn on stepping ( I think).
> 
> The first frame displays properly, and the legend in the lower right hand
> corner says 1 of 2, but the second frame doesn't ever appear.
> 
> Code is below: if anyone sees whatever obvious thing it is I've missed I'd
> appreciate it.
> 
>         Edward
> 
> DisplayImplJ2D makeAnimationDisplay(FieldImpl displayField1, FieldImpl
> displayField2) throws VisADException, java.rmi.RemoteException
>      {
>         // get the FunctionType of the flatfield
>          FunctionType myFuncType = (FunctionType)displayField1.getType();
>          RealType rangeType = (RealType) myFuncType.getRange();
>          RealTupleType domainType = (RealTupleType) myFuncType.getDomain();
>          RealType domainComponents[] = domainType.getRealComponents();
> 
>          // create a new FieldImpl containing the two slices as alternate 
> times
>          RealType time = RealType.Time;
>          RealTupleType timeTupleType = new RealTupleType(time);
>          FunctionType animatedFuncType = new FunctionType(time, myFuncType);
> 
>          // fake up a time domain
>          float timeSamples[][] = { {0, 1} };
>          Gridded1DSet timeSet = new Gridded1DSet(RealType.Time,
> timeSamples, 2);
> 
>          // fake up a Field
>          FieldImpl displayField = new FieldImpl(animatedFuncType, timeSet);
> 
>          // add the first layer to the time stream
> 
>          double timeSample1[] = { (double) timeSamples[0][0] };
>          double timeSample2[] = { (double) timeSamples[0][1] };
>          RealTuple time1 = new RealTuple(timeTupleType, timeSample1);
>          RealTuple time2 = new RealTuple(timeTupleType, timeSample2);
> 
>          displayField.setSample(time1, displayField1);
>          displayField.setSample(time2, displayField2);
> 
>          // check the function type
> 
>          FunctionType seqType = (FunctionType) displayField.getType();
>          RealTupleType testDomainType = seqType.getDomain();
>          RealType indexType = (RealType) testDomainType.getComponent(0);
> 
>          Set domainSet = (Gridded1DSet) displayField.getDomainSet();
> 
>          // create the display and the scales
>          DisplayImplJ2D display = new DisplayImplJ2D("myDisplay");
> 
>          GraphicsModeControl dispGMC = (GraphicsModeControl)
> display.getGraphicsModeControl();
>          dispGMC.setScaleEnable(true);
> 
>          AnimationControl animC = new AnimationControlJ2D(display,
> time);
>          animC.setOn(true);
>          //animC.setStep(1);
>          animC.setDirection(true);
> 
>          ScalarMap colMap = new ScalarMap( domainComponents[1],
> Display.XAxis );
>          ScalarMap rowMap = new ScalarMap( domainComponents[0],
> Display.YAxis );
>          ScalarMap pixMap = new ScalarMap( rangeType,  Display.RGB );
>          ScalarMap animMap = new ScalarMap( indexType , Display.Animation);
> 
>          // Add maps to display
> 
>          display.addMap( colMap );
>          display.addMap( rowMap );
>          display.addMap( pixMap );
>          display.addMap( animMap );
> 
>          // create data reference
> 
>          DataReferenceImpl dataReference = new 
> DataReferenceImpl("displayRef");
>          dataReference.setData(displayField);
> 
>          // add reference to display
>          display.addReference( dataReference);
> 
>          return display;
>      }

-- 
*----------------------------------------------------------------------*
| Doug Lindholm, Software Engineer          |  E-mail: lind@xxxxxxxx   |
| Research Applications Program             |   Phone: 303-497-8374    |
| National Center for Atmospheric Research  |                          |
| P.O. Box 3000                             |     There's no place     |
| Boulder, Colorado 80307-3000              |        like $HOME        |
*----------------------------------------------------------------------*


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