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