public final class Clock extends java.lang.Object implements ConstClock
Modifier and Type | Class and Description |
---|---|
static interface |
Clock.Listener
Listener to clock changes.
|
static class |
Clock.SystemTimeSource
Time source using the system time.
|
static interface |
Clock.TimeSource
Provides the time for a clock.
|
Constructor and Description |
---|
Clock() |
Clock(Clock.TimeSource timeSource) |
Modifier and Type | Method and Description |
---|---|
int |
getMovesLeft(GoColor color)
Get moves left.
|
long |
getTimeLeft(GoColor color)
Get time left.
|
TimeSettings |
getTimeSettings() |
static java.lang.String |
getTimeString(double timeLeft,
int movesLeft)
Format time left to a string.
|
java.lang.String |
getTimeString(GoColor color) |
GoColor |
getToMove()
Return color the clock is currently measuring the time for.
|
boolean |
getUseByoyomi() |
void |
halt() |
boolean |
isInByoyomi(GoColor color) |
boolean |
isInitialized() |
boolean |
isRunning() |
boolean |
lostOnTime(GoColor color) |
static long |
parseTimeString(java.lang.String s)
Parses a time string.
|
void |
reset() |
void |
reset(GoColor color) |
void |
resume()
Resume clock, if it was halted during a player's move time.
|
void |
setListener(Clock.Listener listener)
Register listener for clock changes.
|
void |
setTimeLeft(GoColor color,
long time,
int movesLeft)
Set time left.
|
void |
setTimeSettings(TimeSettings settings)
Set time settings.
|
void |
startMove(GoColor color)
Start time for a move.
|
void |
stopMove()
Stop time for a move.
|
public Clock()
public Clock(Clock.TimeSource timeSource)
public int getMovesLeft(GoColor color)
getMovesLeft
in interface ConstClock
public long getTimeLeft(GoColor color)
getTimeLeft
in interface ConstClock
public TimeSettings getTimeSettings()
getTimeSettings
in interface ConstClock
public java.lang.String getTimeString(GoColor color)
getTimeString
in interface ConstClock
public static java.lang.String getTimeString(double timeLeft, int movesLeft)
public GoColor getToMove()
getToMove
in interface ConstClock
public boolean getUseByoyomi()
getUseByoyomi
in interface ConstClock
public void halt()
public boolean isInitialized()
isInitialized
in interface ConstClock
public boolean isInByoyomi(GoColor color)
isInByoyomi
in interface ConstClock
public boolean isRunning()
isRunning
in interface ConstClock
public boolean lostOnTime(GoColor color)
lostOnTime
in interface ConstClock
public static long parseTimeString(java.lang.String s)
public void reset()
public void reset(GoColor color)
public void resume()
public void setListener(Clock.Listener listener)
public void setTimeSettings(TimeSettings settings)
public void setTimeLeft(GoColor color, long time, int movesLeft)
color
- Color to set the time for.time
- New value for time left.movesLeft
- -1, if not in byoyomi.public void startMove(GoColor color)
public void stopMove()