ucar.visad.display
Class Animation

java.lang.Object
  extended by ucar.visad.display.Displayable
      extended by ucar.visad.display.Animation

public class Animation
extends Displayable

Provides support for a Displayable that needs a map to Display.Animation

Version:
$Revision: 1.75 $
Author:
IDV development Team

Field Summary
static String ANI_REAL_TYPE
          The name of the animation real-type property.
static String ANI_SET
          The name of the set-of-times property.
static String ANI_VALUE
          The name of the current time property.
static int FORWARD
          The "forward" animation value.
static int REVERSE
          The "reverse" animation value.
 
Fields inherited from class ucar.visad.display.Displayable
DISPLAY, parent, SCALAR_MAP_SET
 
Constructor Summary
  Animation()
          Constructs from nothing.
protected Animation(Animation that)
          Construct a new Animation from another one
  Animation(RealType aniRealType)
          Constructs from the type of the VisAD parameter to animate over, typically RealType.Time.
 
Method Summary
 Displayable cloneForDisplay()
          Returns a clone of this instance suitable for another VisAD display.
 boolean equals(Object obj)
          Checks the equality of this Animation with the object in question.
protected  void finalize()
          Method called when class is destroyed
 AnimationInfo getAnimationInfo()
          Get the AnimationInfo associated with this Animation.
 RealType getAnimationRealType()
          Returns the RealType of the Animation parameter.
 Real getAniValue()
          Returns the value of the "aniValue" property.
 long[] getBackSteps()
          Returns an array of the backward dwell times for all the steps in integer milliseconds.
 int getCurrent()
          Returns the origin-0 index of the current time being shown.
 Real getCurrentAnimationValue()
           
static DateTime[] getDateTimeArray(Set timeSet)
          Utility to create an array of DateTime from the given time set
 boolean getEnabled()
          Get the Enabled property.
 long[] getFwdSteps()
          Returns an array of the dwell times for all the steps in integer milliseconds.
 int getNumSteps()
          Returns the number of time steps
 Set getSet()
          Returns the set of animation time-values.
 long[] getSteps()
          Deprecated. Use getFwdSteps
 DateTime[] getTimes()
           
 boolean isAnimating()
          Indicates if looping is on.
 void myAddDataReferences()
          Adds the DataReferences associated with this instance to the display.
 void myRemoveDataReferences()
          Removes the DataReferences associated with this instance from the display.
 void reCalculateAnimationSet()
          Force recalculation of animation time steps based on all data with domains mapped to this Animation's RealType.
 void setAnimating(boolean on)
          Begin animating or looping.
 void setAnimationInfo(AnimationInfo ai)
          Explicitly sets the animation parameters of this instance.
 void setAnimationRealType(RealType realType)
          Sets the RealType of the VisAD Animation parameter, such as RealType.Time.
 void setAniValue(Real newTime)
          Sets the current time being shown to the value of the Real.
 void setBackSteps(long[] newTimes)
          Sets an integer array in milliseconds of time delay AFTER display each loop step when animating backward.
 void setCurrent(int newIndex)
          Sets the current time being shown.
 void setCurrent(int newIndex, boolean checkUserFrames)
          Sets the current time being shown.
 void setDirection(int direction)
          Set looping direction.
 void setEnabled(boolean value)
          Set the Enabled property.
 void setFwdSteps(long[] newTimes)
          Sets an integer array in milliseconds of time delay AFTER display each loop step.
 void setSet(Set newSet)
          Sets the animation times for this instance to use.
 void setSet(Set newSet, boolean transform)
          Sets the animation times for this instance to use.
 void setSteps(long[] newTimes)
          Deprecated. Use setFwdSteps
 void setStepsOk(boolean[] stepsOk)
          Set the steps ok.
 boolean shouldBeAnimating()
          Indicates if looping is on.
 boolean shouldShow(Real timeValue)
          Check if the animationSet.valueToIndex of the given time value is equals to the current time step.
 void takeStep()
          Step one time in the current direction (foward or reverse).
 void takeStep(int direction)
          Step one time in whatever direction is specified.
 void takeStepBackward()
          Step one time backward.
 void takeStepForward()
          Step one time forward.
 
Methods inherited from class ucar.visad.display.Displayable
addConstantMap, addConstantMaps, addDataReferences, addPropertyChangeListener, addPropertyChangeListener, addRefsInvoked, addScalarMap, addScalarMaps, applyColorUnit, applyDisplayUnit, checkUnit, combineConstantMaps, destroy, firePropertyChange, firePropertyChange, fireScalarMapSetChange, getAnimationSet, getColorUnit, getConstantMaps, getData, getDisplay, getDisplayMaster, getDisplayUnit, getPointMode, getScalarMap, getScalarMap, getScalarMap, getScalarMapSet, getUseFastRendering, getUseTimesInAnimation, getVisible, hasDataObject, isActive, isUnitCompatible, isVisible, logException, myAddConstantMaps, removeConstantMap, removeDataReferences, removePropertyChangeListener, removePropertyChangeListener, removeScalarMap, replaceScalarMap, setAdjustFlow, setColor, setColorPalette, setColorPalette, setColorUnit, setConstantPosition, setContourInfo, setDisplay, setDisplayActive, setDisplayInactive, setDisplayMaster, setDisplayUnit, setLineWidth, setOverrideAnimationSet, setOverrideAnimationSet, setParent, setPointMode, setPointSize, setRangeForColor, setRangeForColor, setScalarMapSet, setSelectedRange, setSelectedRange, setUseFastRendering, setUseTimesInAnimation, setVisible, toFront
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANI_REAL_TYPE

public static final String ANI_REAL_TYPE
The name of the animation real-type property.

See Also:
Constant Field Values

ANI_VALUE

public static final String ANI_VALUE
The name of the current time property.

See Also:
Constant Field Values

ANI_SET

public static final String ANI_SET
The name of the set-of-times property.

See Also:
Constant Field Values

FORWARD

public static final int FORWARD
The "forward" animation value.

See Also:
Constant Field Values

REVERSE

public static final int REVERSE
The "reverse" animation value.

See Also:
Constant Field Values
Constructor Detail

Animation

public Animation()
          throws VisADException,
                 RemoteException
Constructs from nothing. Uses RealType.Time for the animation RealType.

Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

Animation

public Animation(RealType aniRealType)
          throws VisADException,
                 RemoteException
Constructs from the type of the VisAD parameter to animate over, typically RealType.Time.

Parameters:
aniRealType - The type of the animation parameter or null.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

Animation

protected Animation(Animation that)
             throws VisADException,
                    RemoteException
Construct a new Animation from another one

Parameters:
that - the other Animation object
Throws:
RemoteException - Java RMI failure
VisADException - VisAD failure
Method Detail

finalize

protected void finalize()
                 throws Throwable
Method called when class is destroyed

Overrides:
finalize in class Object
Throws:
Throwable

setAnimationRealType

public void setAnimationRealType(RealType realType)
                          throws RemoteException,
                                 VisADException
Sets the RealType of the VisAD Animation parameter, such as RealType.Time.

Parameters:
realType - The RealType of the animation parameter.
Throws:
NullPointerException - if realType is null.
VisADException - VisAD failure.
RemoteException - Java RMI failure.

getAnimationRealType

public RealType getAnimationRealType()
Returns the RealType of the Animation parameter.

Returns:
The RealType of the Animation parameter. May be null.

getAniValue

public final Real getAniValue()
Returns the value of the "aniValue" property. Returns null if no such value exists.

Returns:
The value of the property or null.

cloneForDisplay

public Displayable cloneForDisplay()
                            throws RemoteException,
                                   VisADException
Returns a clone of this instance suitable for another VisAD display. Underlying data objects are not cloned.

Specified by:
cloneForDisplay in class Displayable
Returns:
A semi-deep clone of this instance.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

myAddDataReferences

public final void myAddDataReferences()

Adds the DataReferences associated with this instance to the display.

This implementation does nothing.

Specified by:
myAddDataReferences in class Displayable

myRemoveDataReferences

public final void myRemoveDataReferences()

Removes the DataReferences associated with this instance from the display.

This implementation does nothing.

Specified by:
myRemoveDataReferences in class Displayable

setAnimationInfo

public void setAnimationInfo(AnimationInfo ai)
                      throws RemoteException,
                             VisADException
Explicitly sets the animation parameters of this instance. The parameters are copied.

Parameters:
ai - The animation parameters.
Throws:
NullPointerException - if the argument is null.
RemoteException - Java RMI error
VisADException - VisADError

getAnimationInfo

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

Returns:
the AnimationInfo

setAnimating

public void setAnimating(boolean on)
Begin animating or looping.

Parameters:
on - Whether or not looping should be on.

shouldShow

public boolean shouldShow(Real timeValue)
                   throws VisADException,
                          RemoteException
Check if the animationSet.valueToIndex of the given time value is equals to the current time step.

Parameters:
timeValue - The time value to check
Returns:
Is the time value the current one being displayed
Throws:
VisADException
RemoteException

isAnimating

public boolean isAnimating()
Indicates if looping is on.

Returns:
true if looping; false if not looping.

shouldBeAnimating

public boolean shouldBeAnimating()
Indicates if looping is on.

Returns:
true if looping; false if not looping.

getSet

public Set getSet()
Returns the set of animation time-values.

Returns:
The set if animation times.

setSet

public void setSet(Set newSet)
            throws VisADException,
                   RemoteException
Sets the animation times for this instance to use.

Parameters:
newSet - New animation times.
Throws:
VisADException - if the set isn't 1-D or doesn't have the same RealType as the animation ScalarMap.
RemoteException - if a Java RMI failure occurs.

getCurrentAnimationValue

public Real getCurrentAnimationValue()

getTimes

public DateTime[] getTimes()

setSet

public void setSet(Set newSet,
                   boolean transform)
            throws VisADException,
                   RemoteException
Sets the animation times for this instance to use.

Parameters:
newSet - New animation times.
transform - true to transform
Throws:
VisADException - if the set isn't 1-D or doesn't have the same RealType as the animation ScalarMap.
RemoteException - if a Java RMI failure occurs.

getSteps

public long[] getSteps()
Deprecated. Use getFwdSteps

Returns an array of the dwell times for all the steps in integer milliseconds. Returns null if no such times exist; otherwise, each time value is the delay AFTER each loop step: the first time in list is time delay AFTER the display of the first data.

Returns:
Dwell delays in milliseconds or null.

setSteps

public void setSteps(long[] newTimes)
Deprecated. Use setFwdSteps

Sets an integer array in milliseconds of time delay AFTER display each loop step.

Parameters:
newTimes - Dwell delays in milliseconds.

getFwdSteps

public long[] getFwdSteps()
Returns an array of the dwell times for all the steps in integer milliseconds. Returns null if no such times exist; otherwise, each time value is the delay AFTER each loop step: the first time in list is time delay AFTER the display of the first data.

Returns:
Dwell delays in milliseconds or null.

setFwdSteps

public void setFwdSteps(long[] newTimes)
Sets an integer array in milliseconds of time delay AFTER display each loop step.

Parameters:
newTimes - Dwell delays in milliseconds.

getBackSteps

public long[] getBackSteps()
Returns an array of the backward dwell times for all the steps in integer milliseconds. Returns null if no such times exist; otherwise, each time value is the delay AFTER each loop step: the first time in list is time delay AFTER the display of the first data.

Returns:
Dwell delays in milliseconds or null.

setBackSteps

public void setBackSteps(long[] newTimes)
Sets an integer array in milliseconds of time delay AFTER display each loop step when animating backward.

Parameters:
newTimes - Dwell delays in milliseconds.

getNumSteps

public int getNumSteps()
Returns the number of time steps

Returns:
The number of time steps

getCurrent

public int getCurrent()
Returns the origin-0 index of the current time being shown. Returns 0 if there is no such time.

Returns:
The index of current time or 0.

setAniValue

public void setAniValue(Real newTime)
Sets the current time being shown to the value of the Real.

Parameters:
newTime - Real of the newTime.

setCurrent

public void setCurrent(int newIndex)
Sets the current time being shown.

Parameters:
newIndex - The origin-0 index of the desired time.

setCurrent

public void setCurrent(int newIndex,
                       boolean checkUserFrames)
Sets the current time being shown.

Parameters:
newIndex - The origin-0 index of the desired time.
checkUserFrames - If true then go to the next "on" frame.

takeStep

public void takeStep()
Step one time in the current direction (foward or reverse).


takeStep

public void takeStep(int direction)
Step one time in whatever direction is specified. Remeber to keep direction same as before step was made; taking step does not mean to change direction of looping; that is done through properties.

Parameters:
direction - an int (0=FORWARD, 1=REVERSE)

setStepsOk

public void setStepsOk(boolean[] stepsOk)
                throws RemoteException,
                       VisADException
Set the steps ok. Reset the animation.

Parameters:
stepsOk - What steps are ok
Throws:
RemoteException - On badness
VisADException - On badness

setDirection

public void setDirection(int direction)
Set looping direction.

Parameters:
direction - an int, 0 = FORWARD, 1 = REVERSE

takeStepForward

public void takeStepForward()
Step one time forward.


takeStepBackward

public void takeStepBackward()
Step one time backward.


reCalculateAnimationSet

public void reCalculateAnimationSet()
Force recalculation of animation time steps based on all data with domains mapped to this Animation's RealType.


equals

public boolean equals(Object obj)
Checks the equality of this Animation with the object in question.

Overrides:
equals in class Object
Parameters:
obj - The object to check. Animations are equal if their AnimationControls and RealTypes are equal.
Returns:
true if they are equal

getDateTimeArray

public static DateTime[] getDateTimeArray(Set timeSet)
Utility to create an array of DateTime from the given time set

Parameters:
timeSet - The time set
Returns:
The array

setEnabled

public void setEnabled(boolean value)
Set the Enabled property.

Parameters:
value - The new value for Enabled

getEnabled

public boolean getEnabled()
Get the Enabled property.

Returns:
The Enabled