ucar.visad.display
Class AnimationWidget

java.lang.Object
  extended by ucar.unidata.collab.SharableImpl
      extended by ucar.visad.display.AnimationWidget
All Implemented Interfaces:
ActionListener, EventListener, Sharable

public class AnimationWidget
extends SharableImpl
implements ActionListener

A widget to control animation in a VisAD display. Allows user to set loop position at first frame, step backward one step, step forward one step, set loop position at last frame, toggle looping on and off, and invoke an AnimationPropertiesDialogWidget. Uses several image icons in "auxdata.jar, making a kind of GUI wrapper for a set of ucar.visad.Animation "displayables"; uses methods of ucar.visad.display Animation which invoke VisAD Animation class methods.

Version:
$Revision: 1.115 $
Author:
IDV Development Team

Field Summary
static boolean bigIcon
          Do we show the big icon
static String CMD_BACKWARD
          property for setting the widget to the loop in reverse
static String CMD_BEGINNING
          property for setting the widget to the first frame
static String CMD_END
          property for setting the widget to the last frame
static String CMD_FORWARD
          property for setting the widget to the loop forward
static String CMD_INDEX
          Flag for changing the INDEX
static String CMD_PROPS
          property for properties
static String CMD_STARTSTOP
          property for setting the widget to the start or stop
static String SHARE_INDEX
          The property for sharing the animation index
static String SHARE_VALUE
          The property for sharing the animation value
 
Constructor Summary
AnimationWidget()
          Default Constructor
AnimationWidget(AnimationInfo info)
          Contruct an AnimationWidget using the info supplied.
AnimationWidget(JFrame parentf)
          Construct an AnimationWidget using the parent supplied.
AnimationWidget(JFrame parentf, Animation anim)
          Construct an AnimationWidget using the parent, the Animation
AnimationWidget(JFrame parentf, Animation anim, AnimationInfo info)
          Contruct a new AnimationWidget.
 
Method Summary
 void actionPerformed(ActionEvent e)
          Public by implementing ActionListener.
 void actionPerformed(String cmd)
          Handle the action
 void addAnimation(Animation anim)
          Deprecated. use setAnimation();
protected  void applyProperties(AnimationInfo info, boolean andShare)
          Apply the info from the dialog
protected  void boxPanelChanged(AnimationBoxPanel boxPanel)
          Called when the box panel has changed through a user drag or click
 void destroy()
          Method called when destroying this object.
 AnimationInfo getAnimationInfo()
          Get the AnimationInfo associated with this widget.
 AnimationSetInfo getAnimationSetInfo()
          Holds the synthetic animation set info
 boolean getBoxPanelVisible()
          Get the BoxPanelVisible property.
 JComponent getContents()
          Get the Java Component which is the set of controls.
 JComponent getContents(boolean floatToolBar)
          get the Java Component which is the set of controls.
protected  DisplayMaster getDisplayMaster()
          Get the display master that the animation is in
 Component getIndicatorComponent()
          Get the component used to display the time step value.
 DateTime getTimeAtIndex(int index)
          Get the time at the given index.
 DateTime[] getTimes()
          Get the array of times
 void gotoBeginning()
          Go to the beginning of the animation sequence.
protected  void gotoEnd()
          Go to the end of the animation sequence.
protected  void gotoIndex(int index)
          Set the current frame to the index supplied.
protected  void handleSharedTime(Real time)
          We got the tiem from another animation widget.
 boolean isRunning()
          Are we running
static void main(String[] args)
          Main method for testing
 void receiveShareData(Sharable from, Object dataId, Object[] data)
          Method called when sharing is turned on.
 void resetProperties()
          Force the existing animation properties, held in the animation widget's "animationInfo" member data, into this widget's set of Animation objects.
 void setAnimation(Animation newAnimation)
          Sets the ucar.visad.display.Animation controlled by this widget.
 void setBaseTimes(Set times)
          Set the times that should be used.
 void setBoxPanelVisible(boolean value)
          Set the BoxPanelVisible property.
 void setProperties(AnimationInfo transfer)
          From the "animationInfo" set of animation properties, set all these values into all the Animation objects held as memeber data.
 void setRunning(boolean state)
          Set the animation state and change the start/stop widget
 void setTimeFromUser(Real time)
          THis allows external code to set the time.
protected  void shareIndex()
          Share the index of the animation step.
protected  void shareValue()
          Share the value of the animation step.
protected  void shareValue(Real time)
          Share the time value
protected  void showPropertiesDialog()
          Make and show an AnimationPropertiesDialog; if that returns animationInfo ok, set the new animationInfo data into the the Animations.
protected  void stepBackward()
          Take one step backward in the animation sequence.
 void stepForward()
          Take one step forward in the animation sequence.
 void stepsOkChanged(boolean[] stepsOk)
          The user has clicked on the box.
 void updateIndicator(Set timeSet)
          Update the indicator with the list of times
 
Methods inherited from class ucar.unidata.collab.SharableImpl
applySharableProperties, doShare, doShare, doShareExternal, doShareInternal, getSharablePropertiesComponent, getShareGroup, getSharing, getUniqueId, initSharable, removeSharable, setShareGroup, setSharing, setUniqueId, showSharableDialog
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bigIcon

public static boolean bigIcon
Do we show the big icon


CMD_INDEX

public static final String CMD_INDEX
Flag for changing the INDEX

See Also:
Constant Field Values

CMD_BEGINNING

public static final String CMD_BEGINNING
property for setting the widget to the first frame

See Also:
Constant Field Values

CMD_BACKWARD

public static final String CMD_BACKWARD
property for setting the widget to the loop in reverse

See Also:
Constant Field Values

CMD_STARTSTOP

public static final String CMD_STARTSTOP
property for setting the widget to the start or stop

See Also:
Constant Field Values

CMD_FORWARD

public static final String CMD_FORWARD
property for setting the widget to the loop forward

See Also:
Constant Field Values

CMD_END

public static final String CMD_END
property for setting the widget to the last frame

See Also:
Constant Field Values

CMD_PROPS

public static final String CMD_PROPS
property for properties

See Also:
Constant Field Values

SHARE_VALUE

public static final String SHARE_VALUE
The property for sharing the animation value

See Also:
Constant Field Values

SHARE_INDEX

public static final String SHARE_INDEX
The property for sharing the animation index

See Also:
Constant Field Values
Constructor Detail

AnimationWidget

public AnimationWidget()
Default Constructor


AnimationWidget

public AnimationWidget(AnimationInfo info)
Contruct an AnimationWidget using the info supplied.

Parameters:
info - default state to use.

AnimationWidget

public AnimationWidget(JFrame parentf)
Construct an AnimationWidget using the parent supplied.

Parameters:
parentf - the parent JFrame

AnimationWidget

public AnimationWidget(JFrame parentf,
                       Animation anim)
Construct an AnimationWidget using the parent, the Animation

Parameters:
parentf - the parent JFrame
anim - a ucar.visad.display.Animation object to manage

AnimationWidget

public AnimationWidget(JFrame parentf,
                       Animation anim,
                       AnimationInfo info)
Contruct a new AnimationWidget.

Parameters:
parentf - the parent JFrame
anim - a ucar.visad.display.Animation object to manage
info - Default values for the AnimationInfo
Method Detail

setBaseTimes

public void setBaseTimes(Set times)
                  throws VisADException,
                         RemoteException
Set the times that should be used. If this is set we don't go to the displaymaster to get the times.

Parameters:
times - List of times
Throws:
RemoteException - On badness
VisADException - On badness

getContents

public JComponent getContents()
Get the Java Component which is the set of controls.

Returns:
a Java Component

getContents

public JComponent getContents(boolean floatToolBar)
get the Java Component which is the set of controls.

Parameters:
floatToolBar - true if the toolbar should be floatable
Returns:
a Java Component

getIndicatorComponent

public Component getIndicatorComponent()
Get the component used to display the time step value.

Returns:
indicator component

applyProperties

protected void applyProperties(AnimationInfo info,
                               boolean andShare)
Apply the info from the dialog

Parameters:
info - The info
andShare - Share the state with other widgets

showPropertiesDialog

protected void showPropertiesDialog()
Make and show an AnimationPropertiesDialog; if that returns animationInfo ok, set the new animationInfo data into the the Animations.


boxPanelChanged

protected void boxPanelChanged(AnimationBoxPanel boxPanel)
Called when the box panel has changed through a user drag or click

Parameters:
boxPanel - The changed box panel

resetProperties

public void resetProperties()
Force the existing animation properties, held in the animation widget's "animationInfo" member data, into this widget's set of Animation objects.


setProperties

public void setProperties(AnimationInfo transfer)
From the "animationInfo" set of animation properties, set all these values into all the Animation objects held as memeber data.

Parameters:
transfer - AnimationInfo to get properties from

getDisplayMaster

protected DisplayMaster getDisplayMaster()
Get the display master that the animation is in

Returns:
The display master or null

actionPerformed

public void actionPerformed(ActionEvent e)
Public by implementing ActionListener.

Specified by:
actionPerformed in interface ActionListener
Parameters:
e - ActionEvent to check

actionPerformed

public void actionPerformed(String cmd)
Handle the action

Parameters:
cmd - The action

handleSharedTime

protected void handleSharedTime(Real time)
We got the tiem from another animation widget.

Parameters:
time - The time.

setTimeFromUser

public void setTimeFromUser(Real time)
THis allows external code to set the time. It sets the time on the animation and it does a doShare.

Parameters:
time - The time

receiveShareData

public void receiveShareData(Sharable from,
                             Object dataId,
                             Object[] data)
Method called when sharing is turned on.

Specified by:
receiveShareData in interface Sharable
Overrides:
receiveShareData in class SharableImpl
Parameters:
from - source of shareable information
dataId - ID for the data
data - the shareable data

setRunning

public void setRunning(boolean state)
Set the animation state and change the start/stop widget

Parameters:
state - true to start animating

isRunning

public boolean isRunning()
Are we running

Returns:
Is running

getAnimationInfo

public AnimationInfo getAnimationInfo()
Get the AnimationInfo associated with this widget.

Returns:
AnimationInfo used by this widget.

getAnimationSetInfo

public AnimationSetInfo getAnimationSetInfo()
Holds the synthetic animation set info

Returns:
Animation set info

shareIndex

protected void shareIndex()
Share the index of the animation step.


shareValue

protected void shareValue()
Share the value of the animation step.


shareValue

protected void shareValue(Real time)
Share the time value

Parameters:
time - The value to share

stepForward

public void stepForward()
Take one step forward in the animation sequence.


stepBackward

protected void stepBackward()
Take one step backward in the animation sequence.


gotoIndex

protected void gotoIndex(int index)
Set the current frame to the index supplied. Turn off animation This ignores any frames the user may have turned off

Parameters:
index - index into the animation set

gotoBeginning

public void gotoBeginning()
Go to the beginning of the animation sequence.


getTimes

public DateTime[] getTimes()
Get the array of times

Returns:
times

gotoEnd

protected void gotoEnd()
Go to the end of the animation sequence.


stepsOkChanged

public void stepsOkChanged(boolean[] stepsOk)
The user has clicked on the box. Pass this through to the animation

Parameters:
stepsOk - What time steps are ok

setAnimation

public void setAnimation(Animation newAnimation)
Sets the ucar.visad.display.Animation controlled by this widget. Removes any other ucar.visad.display.Animation from the control of this widget.

Parameters:
newAnimation - ucar.visad.display.Animation to control

destroy

public void destroy()
Method called when destroying this object.


addAnimation

public void addAnimation(Animation anim)
Deprecated. use setAnimation();

Adds an ucar.visad.display.Animation to be controlled by this widget.

Parameters:
anim - ucar.visad.display.Animation to control (must not be null)
Throws:
NullPointerException - if anim is null

updateIndicator

public void updateIndicator(Set timeSet)
Update the indicator with the list of times

Parameters:
timeSet - set of times

getTimeAtIndex

public DateTime getTimeAtIndex(int index)
Get the time at the given index. May return null.

Parameters:
index - Index
Returns:
Time

setBoxPanelVisible

public void setBoxPanelVisible(boolean value)
Set the BoxPanelVisible property.

Parameters:
value - The new value for BoxPanelVisible

getBoxPanelVisible

public boolean getBoxPanelVisible()
Get the BoxPanelVisible property.

Returns:
The BoxPanelVisible

main

public static void main(String[] args)
Main method for testing

Parameters:
args - arguments