public class Stopwatch extends Observable
Constructor and Description |
---|
Stopwatch(long timeLimit,
long timeMargin,
String tag,
boolean runNow)
Notifies the observers only once the time is up.
|
Stopwatch(long timeLimit,
long timeMargin,
String tag,
boolean runNow,
ArrayList<Long> notifyTimes)
Notifies the observers when the time is up or if times defined in notifyTimes are reached.
|
Stopwatch(long timeLimit,
long timeMargin,
String tag,
boolean runNow,
HashSet<Long> notifyTimes)
Notifies the observers when the time is up or if times defined in notifyTimes are reached.
|
Stopwatch(long timeLimit,
long timeMargin,
String tag,
boolean runNow,
long delta)
Notifies the observers in regular intervals
|
Modifier and Type | Method and Description |
---|---|
boolean |
getPaused() |
String |
getTag() |
long |
getTimeLimit() |
long |
getTimeRemaining()
returns the time in milliseconds before the time limit is reached.
|
void |
pause()
Pause the watch.
|
void |
setTimeLimit(long newTimeLimit) |
void |
start()
(Re)start the watch.
|
void |
stop(boolean sendNotification)
Stop the watch.
|
void |
unpause()
Unpause the watch.
|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
public Stopwatch(long timeLimit, long timeMargin, String tag, boolean runNow)
timeLimit
- the time till the observers get notified in millisecondstimeMargin
- a margin in millisecondstag
- a tag to identify the stopwatchrunNow
- run the stopwatch immediatelypublic Stopwatch(long timeLimit, long timeMargin, String tag, boolean runNow, long delta)
timeLimit
- the time till the observers get notified in millisecondstimeMargin
- a margin in millisecondstag
- a tag to identify the stopwatchrunNow
- run the stopwatch immediatelydelta
- notify in these delta-millisecond intervalspublic Stopwatch(long timeLimit, long timeMargin, String tag, boolean runNow, ArrayList<Long> notifyTimes)
timeLimit
- the time till the observers get notified in millisecondstimeMargin
- a margin in millisecondstag
- a tag to identify the stopwatchrunNow
- run the stopwatch immediatelynotifyTimes
- time stamps on which the observers will be notified additionally, if set to null it's equivalent to not mentioning it at allpublic Stopwatch(long timeLimit, long timeMargin, String tag, boolean runNow, HashSet<Long> notifyTimes)
timeLimit
- the time till the observers get notified in millisecondstimeMargin
- a margin in millisecondstag
- a tag to identify the stopwatchrunNow
- run the stopwatch immediatelynotifyTimes
- time stamps on which the observers will be notified additionally, if set to null it's equivalent to not mentioning it at allpublic boolean getPaused()
public String getTag()
public long getTimeLimit()
public void setTimeLimit(long newTimeLimit)
public long getTimeRemaining()
public void start()
public void pause()
public void unpause()
public void stop(boolean sendNotification)
sendNotification
- : should the watch send a notification to the observers immediately?Copyright © 2017 smarTen. All rights reserved.