public class IlvClockValueSource extends IlvValueSource
IlvClockValueSource
is used to generate values at a
specified time interval.
This class produces its own values which are:
time
- the initial time. The number of milliseconds that has
elapsed since the source was started is added to this time.
hours
- the number of hours in time
.
minutes
- the number of minutes (modulo 60) in
time
.
seconds
- the number of seconds (modulo 60) in
time
.
totalMinutes
- the total number of minutes in
time
.
totalSeconds
- the total number of seconds in
time
.
milliseconds
- time
modulo 1000.
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)
.
IlvValueSource
,
IlvRandomValueSource
,
Serialized FormRUNNING, STOPPED, SUSPENDED
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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 . |
addPropertyChangeListener, getState, removePropertyChangeListener, set, setState
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
public IlvClockValueSource(String name, long period, long initialTime)
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.public IlvClockValueSource(IlvClockValueSource source)
source
- The behavior object to be copied.public IlvClockValueSource(IlvInputStream in) throws IlvReadFileException
IlvInputStream
stream. This
constructor must be called by the input constructors of subclasses.in
- The input stream.IlvReadFileException
- if the stream format is not correct.public void write(IlvOutputStream out) throws IOException
IlvOutputStream
.write
in interface IlvPersistentObject
write
in class IlvValueSource
out
- The output stream.IOException
- thrown when an exception occurs during
the write operation for this object.IlvGroup.write(ilog.views.io.IlvOutputStream)
public IlvGroupElement copy()
copy
in class IlvValueSource
IlvGroup.copy(ilog.views.prototypes.IlvGroup)
protected void start()
start
in class IlvValueSource
protected void stop()
stop
in class IlvValueSource
protected void suspend()
suspend
in class IlvValueSource
protected void resume()
resume
in class IlvValueSource
protected void tick(Vector names, Vector values)
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.public void setPeriod(long period)
period
- the new period in milliseconds.public long getPeriod()
public void setInitialTime(long initialTime)
initialTime
- the new initial time in milliseconds.public long getInitialTime()
public String[] getValueNames(boolean publicOnly) throws IlvValueException
getValueNames
in class IlvGroupElement
publicOnly
- ignored by this class.IlvValueException
- if an error occurred while reading a property.public boolean isOutput(String name)
true
if the specified name is equal to one of the time
values produced by this clock value source ("time"
,
"hours"
, and so on).isOutput
in class IlvGroupElement
public long getTimerPeriod()
getPeriod()
.public void timerTicked()
period
parameter passed to the constructor.public int getSynchronizationCount()
public static void setRealTimeMode(boolean realTime)
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
.
IlvAnimationBehavior
public static boolean getRealTimeMode()
setRealTimeMode(boolean)
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.