show current timer value, even when stopped. resolves #6
This commit is contained in:
parent
234f899020
commit
5081c300cc
|
@ -103,6 +103,10 @@ public class Run implements TableModel, Serializable {
|
||||||
|
|
||||||
public static final String COMPLETED_ATTEMPT_COUNTER_PROPERTY = "run.completedAttemptCounter";
|
public static final String COMPLETED_ATTEMPT_COUNTER_PROPERTY = "run.completedAttemptCounter";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static final String DELAYED_START_PROPERTY = "run.delayedStart";
|
||||||
|
|
||||||
// ------------------------------------------------------------- ATTRIBUTES
|
// ------------------------------------------------------------- ATTRIBUTES
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -616,7 +620,9 @@ public class Run implements TableModel, Serializable {
|
||||||
public void setDelayedStart(long delayedStart) {
|
public void setDelayedStart(long delayedStart) {
|
||||||
if (delayedStart < 0)
|
if (delayedStart < 0)
|
||||||
throw new InvalidParameterException("negative delayed start");
|
throw new InvalidParameterException("negative delayed start");
|
||||||
|
long old = this.delayedStart;
|
||||||
this.delayedStart = delayedStart;
|
this.delayedStart = delayedStart;
|
||||||
|
pcSupport.firePropertyChange(DELAYED_START_PROPERTY, old, delayedStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -197,6 +197,7 @@ class Core extends JPanel implements ActionListener {
|
||||||
this.run = run;
|
this.run = run;
|
||||||
updateValues(ALL);
|
updateValues(ALL);
|
||||||
updateVisibility(ALL);
|
updateVisibility(ALL);
|
||||||
|
updateColors(ALL);
|
||||||
resize = true;
|
resize = true;
|
||||||
revalidate();
|
revalidate();
|
||||||
}
|
}
|
||||||
|
@ -366,6 +367,9 @@ class Core extends JPanel implements ActionListener {
|
||||||
} else if (Run.CURRENT_SEGMENT_PROPERTY.equals(property)) {
|
} else if (Run.CURRENT_SEGMENT_PROPERTY.equals(property)) {
|
||||||
updateValues(ALL & ~TIMER);
|
updateValues(ALL & ~TIMER);
|
||||||
updateColors(TIMER);
|
updateColors(TIMER);
|
||||||
|
} else if (Run.DELAYED_START_PROPERTY.equals(property)) {
|
||||||
|
updateValues(TIMER);
|
||||||
|
updateColors(TIMER);
|
||||||
} else if (Settings.colorForeground.equals(property)) {
|
} else if (Settings.colorForeground.equals(property)) {
|
||||||
updateColors(NAME);
|
updateColors(NAME);
|
||||||
} else if (Settings.colorTime.equals(property)) {
|
} else if (Settings.colorTime.equals(property)) {
|
||||||
|
@ -559,8 +563,7 @@ class Core extends JPanel implements ActionListener {
|
||||||
segmentLoss = false;
|
segmentLoss = false;
|
||||||
segmentTimer.setText("");
|
segmentTimer.setText("");
|
||||||
Time time = run.getTime(Segment.LIVE);
|
Time time = run.getTime(Segment.LIVE);
|
||||||
splitTimer.setText(
|
splitTimer.setText("" + (time == null ? Language.RUN_STOPPED : time));
|
||||||
"" + (time == null ? Language.RUN_STOPPED : time));
|
|
||||||
} else if (state == State.NULL) {
|
} else if (state == State.NULL) {
|
||||||
splitTimer.setText("" + Language.RUN_NULL);
|
splitTimer.setText("" + Language.RUN_NULL);
|
||||||
segmentTimer.setText("");
|
segmentTimer.setText("");
|
||||||
|
@ -568,7 +571,8 @@ class Core extends JPanel implements ActionListener {
|
||||||
timer.stop();
|
timer.stop();
|
||||||
splitLoss = false;
|
splitLoss = false;
|
||||||
segmentLoss = false;
|
segmentLoss = false;
|
||||||
splitTimer.setText("" + Language.RUN_READY);
|
String timeString = getLiveTimeString();
|
||||||
|
splitTimer.setText("" + (timeString == null ? Language.RUN_READY : timeString));
|
||||||
segmentTimer.setText("");
|
segmentTimer.setText("");
|
||||||
} else if (state == State.ONGOING) {
|
} else if (state == State.ONGOING) {
|
||||||
timer.restart();
|
timer.restart();
|
||||||
|
@ -600,6 +604,9 @@ class Core extends JPanel implements ActionListener {
|
||||||
if ((identifier & TIMER) == TIMER) {
|
if ((identifier & TIMER) == TIMER) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
Color color = Settings.colorTimer.get();
|
Color color = Settings.colorTimer.get();
|
||||||
|
if (isShowingNegativeTime() && run.getState() == State.READY)
|
||||||
|
splitTimer.setForeground(Color.GRAY);
|
||||||
|
else
|
||||||
splitTimer.setForeground(color);
|
splitTimer.setForeground(color);
|
||||||
segmentTimer.setForeground(color);
|
segmentTimer.setForeground(color);
|
||||||
}
|
}
|
||||||
|
@ -628,4 +635,31 @@ class Core extends JPanel implements ActionListener {
|
||||||
segmentTimer.setFont(Settings.coreSegmentTimerFont.get());
|
segmentTimer.setFont(Settings.coreSegmentTimerFont.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isShowingNegativeTime() {
|
||||||
|
if (run != null) {
|
||||||
|
Time time = run.getTime(Segment.LIVE);
|
||||||
|
if (time == null)
|
||||||
|
time = new Time(0 - run.getDelayedStart());
|
||||||
|
|
||||||
|
return time.getMilliseconds() < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getLiveTimeString() {
|
||||||
|
if (run != null) {
|
||||||
|
Time time = run.getTime(Segment.LIVE);
|
||||||
|
if (time == null)
|
||||||
|
time = new Time(0 - run.getDelayedStart());
|
||||||
|
|
||||||
|
if (time.getMilliseconds() < 0)
|
||||||
|
return "-" + time.toString();
|
||||||
|
else
|
||||||
|
return time.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue