Beispiel #1
0
  /**
   * From the "animationInfo" set of animation properties, set all these values into all the
   * Animation objects held as memeber data.
   *
   * @param transfer AnimationInfo to get properties from
   */
  public void setProperties(AnimationInfo transfer) {
    setBoxPanelVisible(transfer.getBoxesVisible());
    animationInfo.set(transfer);
    setSharing(animationInfo.shared);
    if (animationInfo.getAnimationGroup() != null) {
      setShareGroup(animationInfo.getAnimationGroup());
    }
    if (propertiesDialog != null) {
      propertiesDialog.setInfo(animationInfo);
    }

    try {
      if (anime != null) {
        anime.setAnimationInfo(animationInfo);
        DisplayMaster displayMaster = anime.getDisplayMaster();
        if (displayMaster != null) {
          displayMaster.dataChange();
        } else {
          if (getAnimationSetInfo().getActive()) {
            anime.setSet(getAnimationSetInfo().makeTimeSet(null));
          } else {
            anime.setSet(getAnimationSetInfo().getBaseTimes());
          }
        }
      }
    } catch (Exception exp) {
      LogUtil.logException("Error setting properties", exp);
    }
    updateRunButton();
    checkAutoUpdate();
  }
Beispiel #2
0
  /**
   * Method called when sharing is turned on.
   *
   * @param from source of shareable information
   * @param dataId ID for the data
   * @param data the shareable data
   */
  public void receiveShareData(Sharable from, Object dataId, Object[] data) {

    if (dataId.equals(SHARE_INDEX)) {
      if (anime != null) {
        anime.setCurrent(((Integer) data[0]).intValue());
      }
    } else if (dataId.equals(SHARE_VALUE)) {
      Real sharedValue = (Real) data[0];
      debug("receiveShareData " + sharedValue);
      handleSharedTime(sharedValue);
    } else if (dataId.equals(CMD_STARTSTOP)) {
      setRunning(((Boolean) data[0]).booleanValue());
    } else if (dataId.equals(CMD_FORWARD)) {
      stepForward();
    } else if (dataId.equals(CMD_BACKWARD)) {
      stepBackward();
    } else if (dataId.equals(CMD_BEGINNING)) {
      gotoBeginning();
    } else if (dataId.equals(CMD_END)) {
      gotoEnd();
    } else if (dataId.equals(CMD_PROPS)) {
      AnimationInfo newInfo = (AnimationInfo) data[0];
      if (propertiesDialog != null) {
        newInfo.shared = getSharing();
        propertiesDialog.setInfo(newInfo);
      }
      setProperties(newInfo);
    } else {
      super.receiveShareData(from, dataId, data);
    }
  }
Beispiel #3
0
 /**
  * Make and show an AnimationPropertiesDialog; if that returns animationInfo ok, set the new
  * animationInfo data into the the Animations.
  */
 protected void showPropertiesDialog() {
   if (propertiesDialog == null) {
     AnimationBoxPanel propertiesBoxPanel = new AnimationBoxPanel(null, boxPanel.getStepsOk());
     propertiesDialog =
         new AnimationPropertiesDialog(this, GuiUtils.getFrame(getContents()), propertiesBoxPanel);
     animationInfo.shared = getSharing();
     animationInfo.boxesVisible = getBoxPanelVisible();
     propertiesDialog.setInfo(animationInfo);
   }
   propertiesDialog.boxPanel.applyProperties(boxPanel);
   propertiesDialog.show();
 }
Beispiel #4
0
  /**
   * Contruct a new AnimationWidget.
   *
   * @param parentf the parent JFrame
   * @param anim a ucar.visad.display.Animation object to manage
   * @param info Default values for the AnimationInfo
   */
  public AnimationWidget(JFrame parentf, Animation anim, AnimationInfo info) {

    // Initialize sharing to true
    super("AnimationWidget", true);
    timesCbx =
        new JComboBox() {
          public String getToolTipText(MouseEvent event) {
            if (boxPanel != null) {
              return boxPanel.getToolTipText();
            }
            return " ";
          }
        };
    timesCbx.setToolTipText("");
    timesCbxMutex = timesCbx.getTreeLock();
    timesCbx.setFont(new Font("Dialog", Font.PLAIN, 9));
    timesCbx.setLightWeightPopupEnabled(false);
    // set to non-visible until items are added
    timesCbx.setVisible(false);
    timesCbx.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (!ignoreTimesCbxEvents && (anime != null)) {
              debug("got timesCbx event");
              setTimeFromUser((Real) timesCbx.getSelectedItem());
              if (boxPanel != null) {
                boxPanel.setOnIndex(timesCbx.getSelectedIndex());
              }
            }
          }
        });

    animationInfo = new AnimationInfo();
    if (anim != null) {
      setAnimation(anim);
    }
    if (anime != null) {
      animationInfo.set(anime.getAnimationInfo());
    }
    if (info != null) {
      setProperties(info);
      animationInfo.setRunning(info.getRunning());
    }

    boxPanel = new AnimationBoxPanel(this);
    if (timesArray != null) {
      updateBoxPanel(timesArray);
    }
  }
Beispiel #5
0
 /**
  * get the Java Component which is the set of controls.
  *
  * @param floatToolBar true if the toolbar should be floatable
  * @return a Java Component
  */
 public JComponent getContents(boolean floatToolBar) {
   if (contents == null) {
     initSharable();
     contents = doMakeContents(floatToolBar);
     if (animationInfo.getRunning()) {
       setRunning(true);
     }
   }
   return contents;
 }
Beispiel #6
0
 /** Start/stop autoupdating if needed */
 private void checkAutoUpdate() {
   // bumping up the timestamp will stop any previous threads
   timestamp++;
   if (animationInfo.getAnimationSetInfo().usingCurrentTime()) {
     Misc.run(
         new Runnable() {
           public void run() {
             updateAnimationSet(++timestamp);
           }
         });
   }
 }
Beispiel #7
0
 /** Share the value of the animation step. */
 protected void shareValue() {
   Animation myAnimation = anime;
   AnimationInfo myAnimationInfo = animationInfo;
   if ((myAnimation != null) && (myAnimationInfo != null)) {
     if (myAnimation.getNumSteps() > 0) {
       if (animationInfo.getShareIndex()) {
         shareIndex();
       } else {
         shareValue(myAnimation.getAniValue());
       }
     }
   }
 }
Beispiel #8
0
 /**
  * autoupdate the set of synthetic times
  *
  * @param myTimestamp used to only have on thread active
  */
 private void updateAnimationSet(int myTimestamp) {
   try {
     while (true) {
       long seconds = (long) (animationInfo.getAnimationSetInfo().getPollMinutes() * 60);
       Misc.sleepSeconds(seconds);
       DisplayMaster displayMaster = getDisplayMaster();
       if ((displayMaster == null) || (anime == null) || (myTimestamp != timestamp)) {
         break;
       }
       displayMaster.dataChange();
     }
   } catch (Exception exc) {
     LogUtil.logException("Error updating animation set", exc);
   }
 }
Beispiel #9
0
 /**
  * Sets the <CODE>ucar.visad.display.Animation</CODE> controlled by this widget. Removes any other
  * <CODE>ucar.visad.display.Animation</CODE> from the control of this widget.
  *
  * @param newAnimation ucar.visad.display.Animation to control
  */
 public void setAnimation(Animation newAnimation) {
   if (newAnimation == null) {
     throw new NullPointerException("Animation can't be null");
   }
   removeAnimationListener();
   anime = newAnimation;
   animationInfo.set(anime.getAnimationInfo());
   updateIndicator(anime.getSet());
   animationListener =
       new PropertyChangeListener() {
         public void propertyChange(PropertyChangeEvent evt) {
           handleAnimationPropertyChange(evt);
         }
       };
   anime.addPropertyChangeListener(animationListener);
 }
Beispiel #10
0
 /**
  * Set the animation state and change the start/stop widget
  *
  * @param state true to start animating
  */
 public void setRunning(boolean state) {
   // Check to make sure don't infinitely loop
   if (settingStartStop) {
     return;
   }
   settingStartStop = true;
   animationInfo.setRunning(state);
   if (anime != null) {
     anime.setAnimating(state);
   }
   if (!state) {
     doShare(CMD_STARTSTOP, new Boolean(state));
   }
   shareValue();
   updateRunButton();
   settingStartStop = false;
 }
Beispiel #11
0
 /**
  * Holds the synthetic animation set info
  *
  * @return Animation set info
  */
 public AnimationSetInfo getAnimationSetInfo() {
   return animationInfo.getAnimationSetInfo();
 }