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 ConstClockpublic long getTimeLeft(GoColor color)
getTimeLeft in interface ConstClockpublic TimeSettings getTimeSettings()
getTimeSettings in interface ConstClockpublic java.lang.String getTimeString(GoColor color)
getTimeString in interface ConstClockpublic static java.lang.String getTimeString(double timeLeft,
int movesLeft)
public GoColor getToMove()
getToMove in interface ConstClockpublic boolean getUseByoyomi()
getUseByoyomi in interface ConstClockpublic void halt()
public boolean isInitialized()
isInitialized in interface ConstClockpublic boolean isInByoyomi(GoColor color)
isInByoyomi in interface ConstClockpublic boolean isRunning()
isRunning in interface ConstClockpublic boolean lostOnTime(GoColor color)
lostOnTime in interface ConstClockpublic 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()