ilog.views.prototypes
Class IlvAnimationBehavior

java.lang.Object
  extended by ilog.views.prototypes.IlvBehavior
      extended by ilog.views.prototypes.IlvSingleBehavior
          extended by ilog.views.prototypes.IlvAnimationBehavior
All Implemented Interfaces:
IlvPersistentObject, Serializable
Direct Known Subclasses:
IlvBlinkBehavior, IlvInvertBehavior, IlvRotateBehavior, IlvTimerBehavior

public abstract class IlvAnimationBehavior
extends IlvSingleBehavior

The class IlvAnimationBehavior is the base class for all the behavior objects used to produce animation effects. These objects handle a Boolean property. When this property is set to true, the behavior object repeatedly calls the doit method at a specified time interval. Animation stops when the value is set to false.

By default, animation behaviors do not tick in real time. For example, an animation behavior with a period of one second will:

Therefore, the period is augmented by the time spent in the doit method. If your application relies on animation behaviors ticking in real time, use the IlvClockValueSource#setRealTimeMode method.

See Also:
IlvBlinkBehavior, IlvInvertBehavior, IlvRotateBehavior, IlvClockValueSource.setRealTimeMode(boolean), Serialized Form

Constructor Summary
IlvAnimationBehavior(IlvAnimationBehavior source)
          Creates a new behavior object by copying an existing one.
IlvAnimationBehavior(IlvInputStream in)
          Reads the behavior from an IlvInputStream stream.
IlvAnimationBehavior(String name, String period)
          Creates a new animation behavior.
 
Method Summary
protected  void attach(IlvGroup group)
          Called when this behavior object is added to the specified group.
protected  void detach(IlvGroup group)
          Called when this behavior object is removed from the specified group.
protected abstract  void doit()
          Called at the time interval specified by the period parameter passed to the constructor when the value handled by the behavior object is set to true.
protected  Object get(IlvGroup group, String name)
          Returns the current animation state of the behavior.
 String getPeriod()
          Gets the period parameter.
 int getSynchronizationCount()
          This method is defined in this class so that existing subclasses developed with ILOG JViews 2.0 will still work.
 long getTimerPeriod()
          Returns getPeriodValue().
protected  void set(IlvGroup group, String name, Object value)
          If value can be converted to the boolean value true, the animation starts.
 void setPeriod(String period)
          Sets the period parameter.
static void start()
          Starts or restarts the thread that triggers all animations.
static void stop()
          Stops the thread that triggers all animations.
 void timerTicked()
          Calls doit().
 void write(IlvOutputStream out)
          Writes the behavior to an IlvOutputStream.
 
Methods inherited from class ilog.views.prototypes.IlvSingleBehavior
get, getName, getValueNames, set, setName
 
Methods inherited from class ilog.views.prototypes.IlvBehavior
copy, getParameter, isOutput, isReadable, isWritable, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlvAnimationBehavior

public IlvAnimationBehavior(String name,
                            String period)
Creates a new animation behavior.

Parameters:
name - the name of the behavior, which is the name of the boolean value used to start or stop the animation.
period - the animation period in milliseconds. This value can be either a direct value (for example, 100), the name of another property, or an expression.

IlvAnimationBehavior

public IlvAnimationBehavior(IlvAnimationBehavior source)
Creates a new behavior object by copying an existing one.

Parameters:
source - the behavior object to be copied.

IlvAnimationBehavior

public IlvAnimationBehavior(IlvInputStream in)
                     throws IlvReadFileException
Reads the behavior from an IlvInputStream stream. This constructor must be called by the input constructors of subclasses.

Parameters:
in - The input stream.
Throws:
IlvReadFileException - if the stream format is not correct.
Method Detail

doit

protected abstract void doit()
                      throws IlvValueException
Called at the time interval specified by the period parameter passed to the constructor when the value handled by the behavior object is set to true.

Throws:
IlvValueException - indicates a value error.

write

public void write(IlvOutputStream out)
           throws IOException
Writes the behavior to an IlvOutputStream.

Specified by:
write in interface IlvPersistentObject
Overrides:
write in class IlvSingleBehavior
Parameters:
out - The output stream.
Throws:
IOException - thrown when an exception occurs during the write operation for this object.

set

protected void set(IlvGroup group,
                   String name,
                   Object value)
            throws IlvValueException
If value can be converted to the boolean value true, the animation starts. Otherwise, it stops.

Overrides:
set in class IlvSingleBehavior
Parameters:
group - the group to which the behavior is attached.
name - the name of the property (which is also the name of the behavior).
value - the value to which the property handled by the behavior object should be set.
Throws:
IlvValueException - if the value caused an error.
See Also:
IlvSingleBehavior.set(ilog.views.prototypes.IlvGroup, java.lang.String[], java.lang.Object[], boolean[])

get

protected Object get(IlvGroup group,
                     String name)
              throws IlvValueException
Returns the current animation state of the behavior.

Overrides:
get in class IlvSingleBehavior
Parameters:
group - the group to which this behavior object is attached.
name - the name of the property to be read.
Returns:
true if animation is running and false otherwise.
Throws:
IlvValueException - if the value caused an error.
See Also:
IlvSingleBehavior.get(ilog.views.prototypes.IlvGroup, java.lang.String[], java.lang.Object[], boolean[])

attach

protected void attach(IlvGroup group)
Called when this behavior object is added to the specified group.

Overrides:
attach in class IlvBehavior
Parameters:
group - the group to which this behavior object is attached.
See Also:
IlvGroup.addBehavior(ilog.views.prototypes.IlvBehavior)

detach

protected void detach(IlvGroup group)
Called when this behavior object is removed from the specified group.

Overrides:
detach in class IlvBehavior
Parameters:
group - the group to which this behavior object is attached.
See Also:
IlvGroup.removeBehavior(ilog.views.prototypes.IlvBehavior)

setPeriod

public void setPeriod(String period)
Sets the period parameter.


getPeriod

public String getPeriod()
Gets the period parameter.


getTimerPeriod

public long getTimerPeriod()
Returns getPeriodValue().


timerTicked

public void timerTicked()
Calls doit().


getSynchronizationCount

public int getSynchronizationCount()
This method is defined in this class so that existing subclasses developed with ILOG JViews 2.0 will still work. This method returns 0.


start

public static void start()
Starts or restarts the thread that triggers all animations.

If you use animated prototypes in an applet, you must call this method in the applet's start() method to make sure that the thread is restarted when you re-enter the applet's page.


stop

public static void stop()
Stops the thread that triggers all animations.

If you use animated prototypes in an applet, you must call this method in the applet's stop() method to make sure the thread is stopped when you leave the applet's page.



Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.