ilog.views.prototypes
Class IlvClockValueSource

java.lang.Object
  extended by ilog.views.prototypes.IlvGroupElement
      extended by ilog.views.prototypes.IlvValueSource
          extended by ilog.views.prototypes.IlvClockValueSource
All Implemented Interfaces:
IlvPersistentObject, Serializable
Direct Known Subclasses:
IlvRandomValueSource

public class IlvClockValueSource
extends IlvValueSource

The class IlvClockValueSource is used to generate values at a specified time interval.

This class produces its own values which are:

Note: By default, the clock value sources are not in "real time" mode, so the time values may not be accurate with respect to real time. To get more realistic times, you can call setRealTimeMode(true).

See Also:
IlvValueSource, IlvRandomValueSource, Serialized Form

Field Summary
 
Fields inherited from class ilog.views.prototypes.IlvValueSource
RUNNING, STOPPED, SUSPENDED
 
Constructor Summary
IlvClockValueSource(IlvClockValueSource source)
          Creates a new value source object by copying an existing one.
IlvClockValueSource(IlvInputStream in)
          Reads the value source from an IlvInputStream stream.
IlvClockValueSource(String name, long period, long initialTime)
          Creates a new clock value source.
 
Method Summary
 IlvGroupElement copy()
          Returns a copy of the value source.
 long getInitialTime()
          Returns the initial time of the clock value source.
 long getPeriod()
          Returns the period of the clock value source.
static boolean getRealTimeMode()
          Returns the "real time" mode of all the clock value sources and animation behaviors.
 int getSynchronizationCount()
          This method returns 0: clocks are not synchronized.
 long getTimerPeriod()
          Returns getPeriod().
 String[] getValueNames(boolean publicOnly)
          Returns the values handled or produced by the clock value source.
 boolean isOutput(String name)
          Returns true if the specified name is equal to one of the time values produced by this clock value source ("time", "hours", and so on).
protected  void resume()
          Restarts the clock.
 void setInitialTime(long initialTime)
          Sets the initial time of the clock value source to a new value.
 void setPeriod(long period)
          Sets the period of the clock value source to a new value.
static void setRealTimeMode(boolean realTime)
          Sets the "real time" mode of all the clock value sources and animation behaviors.
protected  void start()
          Starts the clock.
protected  void stop()
          Interrupts the clock.
protected  void suspend()
          Suspends the clock.
protected  void tick(Vector names, Vector values)
          Called every time a set of time values is generated.
 void timerTicked()
          This method generates the time values at time intervals specified by the period parameter passed to the constructor.
 void write(IlvOutputStream out)
          Writes the value source to an IlvOutputStream.
 
Methods inherited from class ilog.views.prototypes.IlvValueSource
addPropertyChangeListener, getState, removePropertyChangeListener, set, setState
 
Methods inherited from class ilog.views.prototypes.IlvGroupElement
applyTransform, applyTransform, boundingBox, boundingBox, get, get, get, getBoolean, getDouble, getFloat, getInt, getLong, getName, getParent, getRelativePath, getString, getSubscribers, getSubscriptionValues, move, pushValue, pushValues, set, set, set, set, set, set, set, setName, subscribe, traverse, unsubscribe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvClockValueSource

public IlvClockValueSource(String name,
                           long period,
                           long initialTime)
Creates a new clock value source.

Parameters:
name - the name of the clock value source.
period - the time interval at which values are generated. The time interval is expressed in milliseconds.
initialTime - the initial time used as a basis to generate the time values. The initial time is expressed in milliseconds.

IlvClockValueSource

public IlvClockValueSource(IlvClockValueSource source)
Creates a new value source object by copying an existing one.

Parameters:
source - The behavior object to be copied.

IlvClockValueSource

public IlvClockValueSource(IlvInputStream in)
                    throws IlvReadFileException
Reads the value source 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

write

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

Specified by:
write in interface IlvPersistentObject
Overrides:
write in class IlvValueSource
Parameters:
out - The output stream.
Throws:
IOException - thrown when an exception occurs during the write operation for this object.
See Also:
IlvGroup.write(ilog.views.io.IlvOutputStream)

copy

public IlvGroupElement copy()
Returns a copy of the value source.

Overrides:
copy in class IlvValueSource
Returns:
a copy of the group element.
See Also:
IlvGroup.copy(ilog.views.prototypes.IlvGroup)

start

protected void start()
Starts the clock. The clock starts generating values. If the clock was previously stopped, the current time is reset to the initial time.

Overrides:
start in class IlvValueSource

stop

protected void stop()
Interrupts the clock. The clock stops generating values.

Overrides:
stop in class IlvValueSource

suspend

protected void suspend()
Suspends the clock. The clock stops generating values.

Overrides:
suspend in class IlvValueSource

resume

protected void resume()
Restarts the clock. The clock begins again generating values.

Overrides:
resume in class IlvValueSource

tick

protected void tick(Vector names,
                    Vector values)
Called every time a set of time values is generated. It can be overridden by subclasses to generate additional values together with the time values.

Parameters:
names - a vector containing the names of the properties that will be generated by a call to pushValues. Subclasses can add new values to this vector.
values - a vector containing the values that will be generated by a call to pushValues. Subclasses can add new values to this vector.

setPeriod

public void setPeriod(long period)
Sets the period of the clock value source to a new value.

Parameters:
period - the new period in milliseconds.

getPeriod

public long getPeriod()
Returns the period of the clock value source.


setInitialTime

public void setInitialTime(long initialTime)
Sets the initial time of the clock value source to a new value.

Parameters:
initialTime - the new initial time in milliseconds.

getInitialTime

public long getInitialTime()
Returns the initial time of the clock value source.


getValueNames

public String[] getValueNames(boolean publicOnly)
                       throws IlvValueException
Returns the values handled or produced by the clock value source.

Overrides:
getValueNames in class IlvGroupElement
Parameters:
publicOnly - ignored by this class.
Returns:
an array of value names.
Throws:
IlvValueException - if an error occurred while reading a property.

isOutput

public boolean isOutput(String name)
Returns true if the specified name is equal to one of the time values produced by this clock value source ("time", "hours", and so on).

Overrides:
isOutput in class IlvGroupElement

getTimerPeriod

public long getTimerPeriod()
Returns getPeriod().


timerTicked

public void timerTicked()
This method generates the time values at time intervals specified by the period parameter passed to the constructor.


getSynchronizationCount

public int getSynchronizationCount()
This method returns 0: clocks are not synchronized.


setRealTimeMode

public static void setRealTimeMode(boolean realTime)
Sets the "real time" mode of all the clock value sources and animation behaviors.

If realTime is true, the clock value sources will (try to) tick in real time, that is, a source with a period of one second will really tick every second, regardless of the time spent pushing the time values. Of course, real time clocks are limited by the speed of your CPU.

If realTime is false, the sources will simply wait for the specified period between two ticks, so the actual times will be late with respect to real time.

Using many and/or fast real time clocks can lead to applications running continuously and thus consuming a lot of CPU.

Note that the real time mode also affects all the animation behaviors (subclasses of IlvAnimationBehavior), which are controlled by the same thread as the clock value sources.

By default, the real time mode is set to false.

See Also:
IlvAnimationBehavior

getRealTimeMode

public static boolean getRealTimeMode()
Returns the "real time" mode of all the clock value sources and animation behaviors.

See Also:
setRealTimeMode(boolean)


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