Re: how to add time stamp to a display?

Hi Helen-

Helen Yi wrote:

> I download the new Java3D 1.3 beta for Window 2000, it works.
> But on SGI (with Java 1.3.1 and Java3DTM BETA 1.2.1), the timestamps are
> still missing.
> How can I add one?

You could add a ControlListener to the ScalarMap and listen for
changes, get the value from the AnimationSet and add that to a
JLabel outside the display.  Something like:

    final JLabel myLabel = new JLabel();
    ScalarMap aniMap = new ScalarMap(RealType.Time, Display.Animation);
    final AnimationControl animationControl = 
            (AnimationControl) aniMap.getControl();
    animationControl.addControlListener(new ControlListener() {
         public void controlChanged(ControlEvent ce) {
             Set aniSet = animationControl.getSet();
             if (aniSet != null) {
                try {
                   DateTime aniValue = new DateTime(
                           new int[] {animationControl.getCurrent()}));
                } catch (Exception excp) {
                   System.err.println("Unable to compute value");

(the above is just an example, I haven't tried compiling it or 
verifying that it works, but it's sort of what we do in our code).

If what you have mapped to animation is something different than
RealType.Time or the units of your Time set are not seconds since
the epoch, you'd have to do a little more computing to create a
Real which "equals" your actually set value.  

You could also look at AnimationControlJ3D.init() for how
VisAD does this (which is essentially the above in the long
run, at least the calculation part).

Don Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307