mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
Added support to change speed of time III
This commit is contained in:
parent
9911246ae5
commit
f3a1203e99
@ -50,7 +50,6 @@ You can restart the app, if you press the **"Restart"** button.
|
|||||||
You can stop the app, if you press the **"Exit"** button or click on the exit window button.
|
You can stop the app, if you press the **"Exit"** button or click on the exit window button.
|
||||||
- Then application is stopped.
|
- Then application is stopped.
|
||||||
|
|
||||||
|
|
||||||
## Special files
|
## Special files
|
||||||
|
|
||||||
If these files are present, something special happens.
|
If these files are present, something special happens.
|
||||||
@ -179,8 +178,11 @@ Smileys can be colored or white-black (can be set in configuration)
|
|||||||
* K - hide or show clock
|
* K - hide or show clock
|
||||||
* SHIFT + {Y,N,D,H,M,S,I,K} - Increase test time value
|
* SHIFT + {Y,N,D,H,M,S,I,K} - Increase test time value
|
||||||
* CTRL + {Y,N,D,H,M,S,I,K} - Decrease test time value
|
* CTRL + {Y,N,D,H,M,S,I,K} - Decrease test time value
|
||||||
* ALT + {Y,N,D,H,M,S,I,K} - Rest test time value
|
* ALT + {Y,N,D,H,M,S,I,K} - Reset test time value
|
||||||
* Y=year, N=month, D=day of month, H=hour, M=minute, S=second, I=millisecond, K=week
|
* Y=year, N=month, D=day of month, H=hour, M=minute, S=second, I=millisecond, K=week
|
||||||
|
* SHIFT + Q - Increase speed of time
|
||||||
|
* CTRL + Q - Decrease speed of time
|
||||||
|
* ALT + Q - Reset speed of time
|
||||||
* D - Reset custom time values to the real time
|
* D - Reset custom time values to the real time
|
||||||
* SHIFT + A - Increase arrival time
|
* SHIFT + A - Increase arrival time
|
||||||
* CTRL + A - Decrease arrival time
|
* CTRL + A - Decrease arrival time
|
||||||
|
@ -220,6 +220,9 @@ public class TimeCalcConfiguration {
|
|||||||
.getKey(), Integer.MAX_VALUE);
|
.getKey(), Integer.MAX_VALUE);
|
||||||
public final IntegerProperty testMillisecondCustomProperty = new IntegerProperty(TimeCalcProperty.TEST_CLOCK_CUSTOM_MILLISECOND
|
public final IntegerProperty testMillisecondCustomProperty = new IntegerProperty(TimeCalcProperty.TEST_CLOCK_CUSTOM_MILLISECOND
|
||||||
.getKey(), Integer.MAX_VALUE);
|
.getKey(), Integer.MAX_VALUE);
|
||||||
|
|
||||||
|
public final IntegerProperty speedProperty = new IntegerProperty(TimeCalcProperty.SPEED
|
||||||
|
.getKey(), 1);
|
||||||
|
|
||||||
//
|
//
|
||||||
private final Map<TimeCalcProperty, Property> mapOfProperties
|
private final Map<TimeCalcProperty, Property> mapOfProperties
|
||||||
@ -295,6 +298,7 @@ public class TimeCalcConfiguration {
|
|||||||
mainWindowCustomTitleProperty,
|
mainWindowCustomTitleProperty,
|
||||||
profileNameProperty,
|
profileNameProperty,
|
||||||
activityNeededFlagsProperty,
|
activityNeededFlagsProperty,
|
||||||
|
speedProperty,
|
||||||
testEnabledProperty,
|
testEnabledProperty,
|
||||||
testYearCustomProperty,
|
testYearCustomProperty,
|
||||||
testMonthCustomProperty,
|
testMonthCustomProperty,
|
||||||
|
@ -129,7 +129,7 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
|
|
||||||
case KeyEvent.VK_U: {
|
case KeyEvent.VK_U: {
|
||||||
int ms_ = msToAdd;
|
int ms_ = msToAdd;
|
||||||
System.out.println("going to add ms:" +msToAdd);
|
//System.out.println("going to add ms:" +msToAdd);
|
||||||
int s_ = msToAdd / 1000;
|
int s_ = msToAdd / 1000;
|
||||||
ms_ = ms_ - s_ * 1000;
|
ms_ = ms_ - s_ * 1000;
|
||||||
int m_ = msToAdd / 1000 / 60;
|
int m_ = msToAdd / 1000 / 60;
|
||||||
|
@ -108,7 +108,8 @@ public enum TimeCalcProperty {
|
|||||||
TEST_CLOCK_CUSTOM_MINUTE("test.clock.custom.minute", "Test : Clock : Custom : Minute", Integer.class),
|
TEST_CLOCK_CUSTOM_MINUTE("test.clock.custom.minute", "Test : Clock : Custom : Minute", Integer.class),
|
||||||
TEST_CLOCK_CUSTOM_SECOND("test.clock.custom.second", "Test : Clock : Custom : Second", Integer.class),
|
TEST_CLOCK_CUSTOM_SECOND("test.clock.custom.second", "Test : Clock : Custom : Second", Integer.class),
|
||||||
TEST_CLOCK_CUSTOM_MILLISECOND("test.clock.custom.millisecond", "Test : Clock : Custom : Millisecond", Integer.class),
|
TEST_CLOCK_CUSTOM_MILLISECOND("test.clock.custom.millisecond", "Test : Clock : Custom : Millisecond", Integer.class),
|
||||||
ACTIVITY_NEEDED_FLAGS("activity.needed-flags", "Activity : Needed flags", String.class);
|
ACTIVITY_NEEDED_FLAGS("activity.needed-flags", "Activity : Needed flags", String.class),
|
||||||
|
SPEED("speed", "Speed", Integer.class);
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final String key;
|
private final String key;
|
||||||
|
@ -14,8 +14,8 @@ import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
|||||||
public enum Cloudiness {
|
public enum Cloudiness {
|
||||||
CLOUDY("Cloudy", 7d/8d),
|
CLOUDY("Cloudy", 7d/8d),
|
||||||
MOSTLY_CLOUDY("Mostly cloudy", 5d/8d),
|
MOSTLY_CLOUDY("Mostly cloudy", 5d/8d),
|
||||||
PARTLY_CLOUDY("Partly cloudy+sunny", 3d/8d),
|
PARTLY_CLOUDY("Partly cloudy and partly sunny", 3d/8d),
|
||||||
MOSTLY_SUNNY("Mostly clear+sunny", 1d/8d),
|
MOSTLY_SUNNY("Mostly clear and mostly sunny", 1d/8d),
|
||||||
SUNNY("Clear/Sunny", 0/8);
|
SUNNY("Clear/Sunny", 0/8);
|
||||||
@Getter
|
@Getter
|
||||||
private String description;
|
private String description;
|
||||||
|
@ -226,6 +226,8 @@ public class ConfigWindow extends TWindow {
|
|||||||
= new JTextField();
|
= new JTextField();
|
||||||
public final JTextField activityNeededFlagsProperty
|
public final JTextField activityNeededFlagsProperty
|
||||||
= new JTextField(TimeCalcProperty.ACTIVITY_NEEDED_FLAGS.getKey());
|
= new JTextField(TimeCalcProperty.ACTIVITY_NEEDED_FLAGS.getKey());
|
||||||
|
public final JTextField speedProperty
|
||||||
|
= new JTextField(TimeCalcProperty.SPEED.getKey());
|
||||||
private final JCheckBox testEnabledProperty
|
private final JCheckBox testEnabledProperty
|
||||||
= new JCheckBox(TimeCalcProperty.TEST_ENABLED.getKey());
|
= new JCheckBox(TimeCalcProperty.TEST_ENABLED.getKey());
|
||||||
private final JTextField testClockCustomYearProperty
|
private final JTextField testClockCustomYearProperty
|
||||||
@ -480,6 +482,7 @@ public class ConfigWindow extends TWindow {
|
|||||||
mainWindowCustomTitleProperty,
|
mainWindowCustomTitleProperty,
|
||||||
profileNameProperty,
|
profileNameProperty,
|
||||||
activityNeededFlagsProperty,
|
activityNeededFlagsProperty,
|
||||||
|
speedProperty,
|
||||||
visibilityDefaultProperty,
|
visibilityDefaultProperty,
|
||||||
visibilitySupportedColoredProperty));
|
visibilitySupportedColoredProperty));
|
||||||
//
|
//
|
||||||
|
@ -70,6 +70,7 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressDot;
|
import org.nanoboot.utils.timecalc.swing.progress.ProgressDot;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
@ -122,12 +123,12 @@ public class MainWindow extends TWindow {
|
|||||||
private final TimeCalcKeyAdapter timeCalcKeyAdapter;
|
private final TimeCalcKeyAdapter timeCalcKeyAdapter;
|
||||||
|
|
||||||
{
|
{
|
||||||
ChangeListener valueMustBeTime =
|
ChangeListener valueMustBeTime
|
||||||
(property, oldValue, newValue) -> new TTime((String) newValue);
|
= (property, oldValue, newValue) -> new TTime((String) newValue);
|
||||||
this.arrivalTextField = new TTextField(Constants.DEFAULT_ARRIVAL_TIME, 40, true,valueMustBeTime);
|
this.arrivalTextField = new TTextField(Constants.DEFAULT_ARRIVAL_TIME, 40, true, valueMustBeTime);
|
||||||
this.overtimeTextField = new TTextField(Constants.DEFAULT_OVERTIME, 40, true,valueMustBeTime);
|
this.overtimeTextField = new TTextField(Constants.DEFAULT_OVERTIME, 40, true, valueMustBeTime);
|
||||||
this.workingTimeTextField = new TTextField("08:00", 40, true,valueMustBeTime);
|
this.workingTimeTextField = new TTextField("08:00", 40, true, valueMustBeTime);
|
||||||
this.pauseTimeTextField = new TTextField("00:30", 40, true,valueMustBeTime);
|
this.pauseTimeTextField = new TTextField("00:30", 40, true, valueMustBeTime);
|
||||||
|
|
||||||
this.noteTextField = new TTextField("", 100);
|
this.noteTextField = new TTextField("", 100);
|
||||||
this.departureTextField = new TTextField();
|
this.departureTextField = new TTextField();
|
||||||
@ -154,7 +155,7 @@ public class MainWindow extends TWindow {
|
|||||||
setTitle(getWindowTitle());
|
setTitle(getWindowTitle());
|
||||||
});
|
});
|
||||||
Time time = new Time();
|
Time time = new Time();
|
||||||
time.yearCustomProperty
|
time.yearCustomProperty
|
||||||
.bindTo(timeCalcConfiguration.testYearCustomProperty);
|
.bindTo(timeCalcConfiguration.testYearCustomProperty);
|
||||||
time.monthCustomProperty
|
time.monthCustomProperty
|
||||||
.bindTo(timeCalcConfiguration.testMonthCustomProperty);
|
.bindTo(timeCalcConfiguration.testMonthCustomProperty);
|
||||||
@ -219,7 +220,6 @@ public class MainWindow extends TWindow {
|
|||||||
|
|
||||||
AnalogClock clock = new AnalogClock();
|
AnalogClock clock = new AnalogClock();
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
arrivalTextField.valueProperty.addListener(e -> {
|
arrivalTextField.valueProperty.addListener(e -> {
|
||||||
if (!arrivalTextField.valueProperty.getValue().isEmpty()) {
|
if (!arrivalTextField.valueProperty.getValue().isEmpty()) {
|
||||||
@ -332,7 +332,6 @@ public class MainWindow extends TWindow {
|
|||||||
|
|
||||||
add(progressLife);
|
add(progressLife);
|
||||||
|
|
||||||
|
|
||||||
this.progressMoney
|
this.progressMoney
|
||||||
= new ProgressMoney();
|
= new ProgressMoney();
|
||||||
progressMoney.setBounds(progressLife.getX(), progressSwing.getY() + progressLife.getHeight() + SwingUtils.MARGIN,
|
progressMoney.setBounds(progressLife.getX(), progressSwing.getY() + progressLife.getHeight() + SwingUtils.MARGIN,
|
||||||
@ -341,11 +340,11 @@ public class MainWindow extends TWindow {
|
|||||||
progressMoney.visibleProperty
|
progressMoney.visibleProperty
|
||||||
.bindTo(timeCalcConfiguration.moneyVisibleProperty);
|
.bindTo(timeCalcConfiguration.moneyVisibleProperty);
|
||||||
progressMoney.typeProperty
|
progressMoney.typeProperty
|
||||||
.bindTo(timeCalcConfiguration.moneyTypeProperty);
|
.bindTo(timeCalcConfiguration.moneyTypeProperty);
|
||||||
progressMoney.perMonthProperty
|
progressMoney.perMonthProperty
|
||||||
.bindTo(timeCalcConfiguration.moneyPerMonthProperty);
|
.bindTo(timeCalcConfiguration.moneyPerMonthProperty);
|
||||||
progressMoney.currencyProperty
|
progressMoney.currencyProperty
|
||||||
.bindTo(timeCalcConfiguration.moneyCurrencyProperty);
|
.bindTo(timeCalcConfiguration.moneyCurrencyProperty);
|
||||||
add(progressMoney);
|
add(progressMoney);
|
||||||
|
|
||||||
this.progressWeather
|
this.progressWeather
|
||||||
@ -356,8 +355,7 @@ public class MainWindow extends TWindow {
|
|||||||
progressWeather.visibleProperty
|
progressWeather.visibleProperty
|
||||||
.bindTo(timeCalcConfiguration.weatherVisibleProperty);
|
.bindTo(timeCalcConfiguration.weatherVisibleProperty);
|
||||||
add(progressWeather);
|
add(progressWeather);
|
||||||
|
|
||||||
|
|
||||||
this.progressDot
|
this.progressDot
|
||||||
= new ProgressDot();
|
= new ProgressDot();
|
||||||
progressDot.setBounds(progressWeather.getX() + progressWeather.getWidth() + SwingUtils.MARGIN, progressWeather.getY(),
|
progressDot.setBounds(progressWeather.getX() + progressWeather.getWidth() + SwingUtils.MARGIN, progressWeather.getY(),
|
||||||
@ -367,7 +365,7 @@ public class MainWindow extends TWindow {
|
|||||||
.bindTo(timeCalcConfiguration.weatherVisibleProperty);
|
.bindTo(timeCalcConfiguration.weatherVisibleProperty);
|
||||||
add(progressDot);
|
add(progressDot);
|
||||||
|
|
||||||
{
|
{
|
||||||
progressSquare.typeProperty
|
progressSquare.typeProperty
|
||||||
.bindTo(timeCalcConfiguration.squareTypeProperty);
|
.bindTo(timeCalcConfiguration.squareTypeProperty);
|
||||||
progressDot.typeProperty
|
progressDot.typeProperty
|
||||||
@ -387,7 +385,7 @@ public class MainWindow extends TWindow {
|
|||||||
progressLife.visibleProperty
|
progressLife.visibleProperty
|
||||||
.bindTo(timeCalcConfiguration.lifeVisibleProperty);
|
.bindTo(timeCalcConfiguration.lifeVisibleProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
TLabel arrivalTextFieldLabel = new TLabel("Arrival:", 70);
|
TLabel arrivalTextFieldLabel = new TLabel("Arrival:", 70);
|
||||||
arrivalTextFieldLabel.setBoundsFromTop(progressSwing, 3);
|
arrivalTextFieldLabel.setBoundsFromTop(progressSwing, 3);
|
||||||
|
|
||||||
@ -408,7 +406,6 @@ public class MainWindow extends TWindow {
|
|||||||
overtimeDecreaseButton.setBounds(overtimeTextField.getX() + overtimeTextField.getWidth(), overtimeTextField.getY() + 15, 15, 15);
|
overtimeDecreaseButton.setBounds(overtimeTextField.getX() + overtimeTextField.getWidth(), overtimeTextField.getY() + 15, 15, 15);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
TLabel workingTimeInMinutesTextFieldLabel = new TLabel("Work:", 40);
|
TLabel workingTimeInMinutesTextFieldLabel = new TLabel("Work:", 40);
|
||||||
workingTimeInMinutesTextFieldLabel.setBoundsFromLeft(overtimeTextField, 15);
|
workingTimeInMinutesTextFieldLabel.setBoundsFromLeft(overtimeTextField, 15);
|
||||||
|
|
||||||
@ -715,19 +712,19 @@ public class MainWindow extends TWindow {
|
|||||||
+ 3 * SwingUtils.MARGIN,
|
+ 3 * SwingUtils.MARGIN,
|
||||||
focusButton.getY() + focusButton.getHeight() + SwingUtils.MARGIN
|
focusButton.getY() + focusButton.getHeight() + SwingUtils.MARGIN
|
||||||
+ focusButton.getHeight() + 2 * SwingUtils.MARGIN);
|
+ focusButton.getHeight() + 2 * SwingUtils.MARGIN);
|
||||||
|
|
||||||
saveButton.addActionListener(e -> {
|
saveButton.addActionListener(e -> {
|
||||||
|
|
||||||
TTime arrival_ = new TTime(arrivalTextField.getText());
|
TTime arrival_ = new TTime(arrivalTextField.getText());
|
||||||
TTime overtime_ = new TTime(overtimeTextField.getText());
|
TTime overtime_ = new TTime(overtimeTextField.getText());
|
||||||
TTime work_ = new TTime(workingTimeTextField.getText());
|
TTime work_ = new TTime(workingTimeTextField.getText());
|
||||||
TTime pause_ = new TTime(pauseTimeTextField.getText());
|
TTime pause_ = new TTime(pauseTimeTextField.getText());
|
||||||
|
|
||||||
Calendar cal = time.asCalendar();
|
Calendar cal = time.asCalendar();
|
||||||
int year = cal.get(Calendar.YEAR);
|
int year = cal.get(Calendar.YEAR);
|
||||||
int month = cal.get(Calendar.MONTH) + 1;
|
int month = cal.get(Calendar.MONTH) + 1;
|
||||||
int day = cal.get(Calendar.DAY_OF_MONTH);
|
int day = cal.get(Calendar.DAY_OF_MONTH);
|
||||||
|
|
||||||
timeCalcConfiguration.saveToTimeCalcProperties();
|
timeCalcConfiguration.saveToTimeCalcProperties();
|
||||||
WorkingDay workingDay = workingDayRepository.read(time.asCalendar());
|
WorkingDay workingDay = workingDayRepository.read(time.asCalendar());
|
||||||
if (workingDay == null) {
|
if (workingDay == null) {
|
||||||
@ -748,11 +745,11 @@ public class MainWindow extends TWindow {
|
|||||||
workingDay.setForgetOvertime(forgetOvertimeProperty.getValue());
|
workingDay.setForgetOvertime(forgetOvertimeProperty.getValue());
|
||||||
workingDayRepository.update(workingDay);
|
workingDayRepository.update(workingDay);
|
||||||
|
|
||||||
if(workingDaysWindow != null) {
|
if (workingDaysWindow != null) {
|
||||||
workingDaysWindow.doReloadButtonClick();
|
workingDaysWindow.doReloadButtonClick();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
WorkingDay wd = workingDayRepository.read(time.asCalendar());
|
WorkingDay wd = workingDayRepository.read(time.asCalendar());
|
||||||
|
|
||||||
if (wd != null) {
|
if (wd != null) {
|
||||||
@ -772,29 +769,29 @@ public class MainWindow extends TWindow {
|
|||||||
Calendar cal2 = Calendar.getInstance();
|
Calendar cal2 = Calendar.getInstance();
|
||||||
cal2.setTime(cal.getTime());
|
cal2.setTime(cal.getTime());
|
||||||
List<WorkingDay> arrivals = new ArrayList<>();
|
List<WorkingDay> arrivals = new ArrayList<>();
|
||||||
for(int i = 1; i <= 90; i++) {
|
for (int i = 1; i <= 90; i++) {
|
||||||
cal2.add(Calendar.DAY_OF_MONTH, -1);
|
cal2.add(Calendar.DAY_OF_MONTH, -1);
|
||||||
WorkingDay wd_ = workingDayRepository.read(cal2);
|
WorkingDay wd_ = workingDayRepository.read(cal2);
|
||||||
if(wd_ == null || wd_.isThisDayTimeOff()) {
|
if (wd_ == null || wd_.isThisDayTimeOff()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
arrivals.add(wd_);
|
arrivals.add(wd_);
|
||||||
if(arrivals.size() == 20) {
|
if (arrivals.size() == 20) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!arrivals.isEmpty()) {
|
if (!arrivals.isEmpty()) {
|
||||||
// double averageArrival = arrivals.size() == 1 ? arrivals.get(0) : arrivals.stream().mapToDouble(Double::doubleValue).sorted().average().getAsDouble();
|
// double averageArrival = arrivals.size() == 1 ? arrivals.get(0) : arrivals.stream().mapToDouble(Double::doubleValue).sorted().average().getAsDouble();
|
||||||
double medianArrival = arrivals.stream().map(a->a.getArrivalAsDouble())
|
double medianArrival = arrivals.stream().map(a -> a.getArrivalAsDouble())
|
||||||
.sorted()
|
.sorted()
|
||||||
.collect(Collectors.collectingAndThen(
|
.collect(Collectors.collectingAndThen(
|
||||||
Collectors.toList(),
|
Collectors.toList(),
|
||||||
a -> (a.size() % 2 == 0) ? ((a.get(a.size() / 2 - 1) + a.get(a.size() / 2)) / 2) : (a.get(a.size() / 2))));
|
a -> (a.size() % 2 == 0) ? ((a.get(a.size() / 2 - 1) + a.get(a.size() / 2)) / 2) : (a.get(a.size() / 2))));
|
||||||
|
|
||||||
TTime arrivalTTime = TTime.ofMilliseconds((int)(medianArrival * 60 * 60 * 1000));
|
TTime arrivalTTime = TTime.ofMilliseconds((int) (medianArrival * 60 * 60 * 1000));
|
||||||
while(arrivalTTime.getMinute() % 5 != 0) {
|
while (arrivalTTime.getMinute() % 5 != 0) {
|
||||||
arrivalTTime = arrivalTTime.add(new TTime(0,1));
|
arrivalTTime = arrivalTTime.add(new TTime(0, 1));
|
||||||
}
|
}
|
||||||
arrivalTextField.valueProperty.setValue(arrivalTTime.toString().substring(0, 5));
|
arrivalTextField.valueProperty.setValue(arrivalTTime.toString().substring(0, 5));
|
||||||
wd.setArrivalHour(arrivalTTime.getHour());
|
wd.setArrivalHour(arrivalTTime.getHour());
|
||||||
@ -824,65 +821,62 @@ public class MainWindow extends TWindow {
|
|||||||
|
|
||||||
workingDayRepository.update(wd);
|
workingDayRepository.update(wd);
|
||||||
|
|
||||||
new Timer(100, e -> {
|
new Timer(100, e -> {
|
||||||
if(speed == Integer.MIN_VALUE) {
|
// if (speed == Integer.MIN_VALUE) {
|
||||||
timeCalcConfiguration.testEnabledProperty.setValue(false);
|
// timeCalcConfiguration.testEnabledProperty.setValue(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if(speed < -6) {
|
double r = Math.pow(2, speed + 6);
|
||||||
if(speed == -7) {
|
if (speed < -6 && Math.random() > r) {
|
||||||
if(Math.random() > 0.5) {
|
// System.out.println(NumberFormats.FORMATTER_EIGHT_DECIMAL_PLACES.format(r));
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
|
||||||
if(speed == -8) {
|
|
||||||
if(Math.random() > 0.25) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(speed == -9) {
|
|
||||||
if(Math.random() > 0.125) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(speed == -10) {
|
|
||||||
if(Math.random() > 0.625) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(timeCalcConfiguration.testEnabledProperty.isDisabled()) {
|
|
||||||
timeCalcConfiguration.testEnabledProperty.enable();
|
|
||||||
}
|
|
||||||
if(time.yearCustomProperty.getValue() == Integer.MAX_VALUE) {
|
|
||||||
time.yearCustomProperty.setValue(time.yearProperty.getValue());
|
|
||||||
}
|
|
||||||
if(time.monthCustomProperty.getValue() == Integer.MAX_VALUE) {
|
|
||||||
time.monthCustomProperty.setValue(time.monthProperty.getValue());
|
|
||||||
}
|
|
||||||
if(time.dayCustomProperty.getValue() == Integer.MAX_VALUE) {
|
|
||||||
time.dayCustomProperty.setValue(time.dayProperty.getValue());
|
|
||||||
}
|
|
||||||
if(time.hourCustomProperty.getValue() == Integer.MAX_VALUE) {
|
|
||||||
time.hourCustomProperty.setValue(time.hourProperty.getValue());
|
|
||||||
}
|
|
||||||
if(time.minuteCustomProperty.getValue() == Integer.MAX_VALUE) {
|
|
||||||
time.minuteCustomProperty.setValue(time.minuteProperty.getValue());
|
|
||||||
}
|
|
||||||
if(time.secondCustomProperty.getValue() == Integer.MAX_VALUE) {
|
|
||||||
time.secondCustomProperty.setValue(time.secondProperty.getValue());
|
|
||||||
}
|
|
||||||
if(time.millisecondCustomProperty.getValue() == Integer.MAX_VALUE) {
|
|
||||||
time.millisecondCustomProperty.setValue(time.millisecondProperty.getValue());
|
|
||||||
}
|
|
||||||
int msShouldBeAdded = speed < -6 ? 1 : (int) (Math.pow(2, speed) * 100d);
|
|
||||||
this.timeCalcKeyAdapter.setMsToAdd(msShouldBeAdded);
|
|
||||||
this.timeCalcKeyAdapter.processShifCtrlAltModeKeyCodes(KeyEvent.VK_U, true, false, false);
|
|
||||||
|
|
||||||
}).start();
|
}
|
||||||
|
if (timeCalcConfiguration.testEnabledProperty.isDisabled()) {
|
||||||
|
timeCalcConfiguration.testEnabledProperty.enable();
|
||||||
|
}
|
||||||
|
if (time.yearCustomProperty.getValue() == Integer.MAX_VALUE) {
|
||||||
|
time.yearCustomProperty.setValue(time.yearProperty.getValue());
|
||||||
|
}
|
||||||
|
if (time.monthCustomProperty.getValue() == Integer.MAX_VALUE) {
|
||||||
|
time.monthCustomProperty.setValue(time.monthProperty.getValue());
|
||||||
|
}
|
||||||
|
if (time.dayCustomProperty.getValue() == Integer.MAX_VALUE) {
|
||||||
|
time.dayCustomProperty.setValue(time.dayProperty.getValue());
|
||||||
|
}
|
||||||
|
if (time.hourCustomProperty.getValue() == Integer.MAX_VALUE) {
|
||||||
|
time.hourCustomProperty.setValue(time.hourProperty.getValue());
|
||||||
|
}
|
||||||
|
if (time.minuteCustomProperty.getValue() == Integer.MAX_VALUE) {
|
||||||
|
time.minuteCustomProperty.setValue(time.minuteProperty.getValue());
|
||||||
|
}
|
||||||
|
if (time.secondCustomProperty.getValue() == Integer.MAX_VALUE) {
|
||||||
|
time.secondCustomProperty.setValue(time.secondProperty.getValue());
|
||||||
|
}
|
||||||
|
if (time.millisecondCustomProperty.getValue() == Integer.MAX_VALUE) {
|
||||||
|
time.millisecondCustomProperty.setValue(time.millisecondProperty.getValue());
|
||||||
|
}
|
||||||
|
int msShouldBeAdded = speed < -6 ? 1 : (int) (Math.pow(2, speed) * 100d);
|
||||||
|
this.timeCalcKeyAdapter.setMsToAdd(msShouldBeAdded);
|
||||||
|
this.timeCalcKeyAdapter.processShifCtrlAltModeKeyCodes(KeyEvent.VK_U, true, false, false);
|
||||||
|
|
||||||
|
}).start();
|
||||||
|
this.timeCalcConfiguration.speedProperty.addListener(e -> {
|
||||||
|
|
||||||
|
int newSpeed = Integer.valueOf(timeCalcConfiguration.speedProperty.getValue());
|
||||||
|
if(newSpeed < MIN_SPEED) {
|
||||||
|
newSpeed = MIN_SPEED;
|
||||||
|
}
|
||||||
|
this.speed = newSpeed;
|
||||||
|
});
|
||||||
|
int newSpeed = Integer.valueOf(timeCalcConfiguration.speedProperty.getValue());
|
||||||
|
if(newSpeed < MIN_SPEED) {
|
||||||
|
newSpeed = MIN_SPEED;
|
||||||
|
}
|
||||||
|
this.speed = newSpeed;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
if(Math.random() > 0.99) {
|
if (Math.random() > 0.99) {
|
||||||
File dbFileBackup = new File(
|
File dbFileBackup = new File(
|
||||||
FileConstants.DB_FILE.getAbsolutePath() + ".backup."
|
FileConstants.DB_FILE.getAbsolutePath() + ".backup."
|
||||||
+ DateFormats.DATE_TIME_FORMATTER_SHORT
|
+ DateFormats.DATE_TIME_FORMATTER_SHORT
|
||||||
@ -898,18 +892,18 @@ public class MainWindow extends TWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(Math.random() > 0.9999) {
|
if (Math.random() > 0.9999) {
|
||||||
for(File file: FileConstants.TC_DIRECTORY.listFiles()) {
|
for (File file : FileConstants.TC_DIRECTORY.listFiles()) {
|
||||||
if(file.getName().startsWith(FileConstants.DB_FILE.getName() + ".backup")) {
|
if (file.getName().startsWith(FileConstants.DB_FILE.getName() + ".backup")) {
|
||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
long diff = now - Files.getLastModifiedTime(file.toPath()).toMillis();
|
long diff = now - Files.getLastModifiedTime(file.toPath()).toMillis();
|
||||||
int fileAgeInDays = (int) (diff/ 1000 / 60 / 60 / 24);
|
int fileAgeInDays = (int) (diff / 1000 / 60 / 60 / 24);
|
||||||
System.out.println("Found backup file " + file.getName() + " with age: " + fileAgeInDays);
|
System.out.println("Found backup file " + file.getName() + " with age: " + fileAgeInDays);
|
||||||
if(fileAgeInDays > 14) {
|
if (fileAgeInDays > 14) {
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
System.err.println("Deleting old backups failed: " + ex.getMessage());
|
System.err.println("Deleting old backups failed: " + ex.getMessage());
|
||||||
@ -983,7 +977,7 @@ public class MainWindow extends TWindow {
|
|||||||
if (startTime == null || overtime == null || workDuration == null || pauseDuration == null) {
|
if (startTime == null || overtime == null || workDuration == null || pauseDuration == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TTime newDeparture = startTime.add(workDuration).add(pauseDuration);
|
TTime newDeparture = startTime.add(workDuration).add(pauseDuration);
|
||||||
if (overtime.isNegative()) {
|
if (overtime.isNegative()) {
|
||||||
TTime tmpTTime = overtime.cloneInstance();
|
TTime tmpTTime = overtime.cloneInstance();
|
||||||
@ -1041,7 +1035,7 @@ public class MainWindow extends TWindow {
|
|||||||
int secondNow = clock.secondProperty.getValue();
|
int secondNow = clock.secondProperty.getValue();
|
||||||
int millisecondNow = clock.millisecondProperty.getValue();
|
int millisecondNow = clock.millisecondProperty.getValue();
|
||||||
|
|
||||||
if(arrivalTextField.getText().isEmpty() || departureTextField.getText().isEmpty()) {
|
if (arrivalTextField.getText().isEmpty() || departureTextField.getText().isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
TTime startTime = arrivalTextField.asTTime();
|
TTime startTime = arrivalTextField.asTTime();
|
||||||
@ -1049,7 +1043,7 @@ public class MainWindow extends TWindow {
|
|||||||
TTime nowTime = TTime.of(time.asCalendar());
|
TTime nowTime = TTime.of(time.asCalendar());
|
||||||
TTime timeElapsed = TTime
|
TTime timeElapsed = TTime
|
||||||
.computeTimeDiff(startTime, nowTime);
|
.computeTimeDiff(startTime, nowTime);
|
||||||
|
|
||||||
TTime timeRemains = TTime.computeTimeDiff(nowTime, endTime);
|
TTime timeRemains = TTime.computeTimeDiff(nowTime, endTime);
|
||||||
TTime timeTotal = TTime.computeTimeDiff(startTime, endTime);
|
TTime timeTotal = TTime.computeTimeDiff(startTime, endTime);
|
||||||
String timeElapsedString = timeElapsed.toString();
|
String timeElapsedString = timeElapsed.toString();
|
||||||
@ -1073,10 +1067,10 @@ public class MainWindow extends TWindow {
|
|||||||
|
|
||||||
int totalMillisecondsDone
|
int totalMillisecondsDone
|
||||||
= timeElapsed.toTotalMilliseconds();
|
= timeElapsed.toTotalMilliseconds();
|
||||||
int totalHoursDone = totalMillisecondsDone / 1000 / 60 /60;
|
int totalHoursDone = totalMillisecondsDone / 1000 / 60 / 60;
|
||||||
|
|
||||||
int totalMilliseconds = timeTotal.toTotalMilliseconds();
|
int totalMilliseconds = timeTotal.toTotalMilliseconds();
|
||||||
int totalMinutes = totalMilliseconds / 1000 / 60 ;
|
int totalMinutes = totalMilliseconds / 1000 / 60;
|
||||||
|
|
||||||
double done = ((double) totalMillisecondsDone)
|
double done = ((double) totalMillisecondsDone)
|
||||||
/ ((double) totalMilliseconds);
|
/ ((double) totalMilliseconds);
|
||||||
@ -1110,18 +1104,18 @@ public class MainWindow extends TWindow {
|
|||||||
int weekDayWhenMondayIsOne = clock.dayOfWeekProperty.getValue();
|
int weekDayWhenMondayIsOne = clock.dayOfWeekProperty.getValue();
|
||||||
double weekProgress = Progress.getWeekProgress(weekDayWhenMondayIsOne, done);
|
double weekProgress = Progress.getWeekProgress(weekDayWhenMondayIsOne, done);
|
||||||
weekBattery.setProgress(progress);
|
weekBattery.setProgress(progress);
|
||||||
weekBattery.setLabel(
|
weekBattery.setLabel(
|
||||||
nowIsWeekend ? "5/5" : (weekDayWhenMondayIsOne + "/5"));
|
nowIsWeekend ? "5/5" : (weekDayWhenMondayIsOne + "/5"));
|
||||||
|
|
||||||
double monthProgress = Progress
|
double monthProgress = Progress
|
||||||
.getMonthProgress(weekDayWhenMondayIsOne, workDaysDone,
|
.getMonthProgress(weekDayWhenMondayIsOne, workDaysDone,
|
||||||
workDaysTotal, done);
|
workDaysTotal, done);
|
||||||
progress.set(WidgetType.MONTH, monthProgress);
|
progress.set(WidgetType.MONTH, monthProgress);
|
||||||
double hourProgress =
|
double hourProgress
|
||||||
Progress.getHourProgress(timeRemains, secondsRemains,
|
= Progress.getHourProgress(timeRemains, secondsRemains,
|
||||||
millisecondsRemains);
|
millisecondsRemains);
|
||||||
double minuteProgress =
|
double minuteProgress
|
||||||
Progress.getMinuteProgress(secondNow, millisecondNow);
|
= Progress.getMinuteProgress(secondNow, millisecondNow);
|
||||||
double yearProgress = Progress.getYearProgress(clock, monthProgress);
|
double yearProgress = Progress.getYearProgress(clock, monthProgress);
|
||||||
progress.set(WidgetType.HOUR, hourProgress);
|
progress.set(WidgetType.HOUR, hourProgress);
|
||||||
progress.set(WidgetType.WEEK, weekProgress);
|
progress.set(WidgetType.WEEK, weekProgress);
|
||||||
@ -1244,8 +1238,8 @@ public class MainWindow extends TWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void increaseArrival(TTime tTime) {
|
public void increaseArrival(TTime tTime) {
|
||||||
TTime oldTime =
|
TTime oldTime
|
||||||
new TTime(this.arrivalTextField.valueProperty.getValue());
|
= new TTime(this.arrivalTextField.valueProperty.getValue());
|
||||||
TTime newTime = oldTime.add(tTime);
|
TTime newTime = oldTime.add(tTime);
|
||||||
// System.out.println("oldTime=" + oldTime);
|
// System.out.println("oldTime=" + oldTime);
|
||||||
// System.out.println("newTime=" + newTime);
|
// System.out.println("newTime=" + newTime);
|
||||||
@ -1285,35 +1279,46 @@ public class MainWindow extends TWindow {
|
|||||||
new TTime(this.pauseTimeTextField.valueProperty.getValue())
|
new TTime(this.pauseTimeTextField.valueProperty.getValue())
|
||||||
.remove(tTime).toString().substring(0, 5));
|
.remove(tTime).toString().substring(0, 5));
|
||||||
}
|
}
|
||||||
public void doSaveButtonClick(){
|
|
||||||
|
public void doSaveButtonClick() {
|
||||||
this.saveButton.doClick();
|
this.saveButton.doClick();
|
||||||
}
|
}
|
||||||
public int getForgetOvertime() {return this.forgetOvertimeProperty.getValue();}
|
|
||||||
public void setForgetOvertime(int minutes) {this.forgetOvertimeProperty.setValue(minutes);}
|
public int getForgetOvertime() {
|
||||||
|
return this.forgetOvertimeProperty.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setForgetOvertime(int minutes) {
|
||||||
|
this.forgetOvertimeProperty.setValue(minutes);
|
||||||
|
}
|
||||||
|
|
||||||
public void increaseSpeed() {
|
public void increaseSpeed() {
|
||||||
if(speed == Integer.MIN_VALUE) {
|
if (speed == Integer.MIN_VALUE) {
|
||||||
speed = 0;
|
speed = 0;
|
||||||
}
|
}
|
||||||
++this.speed;
|
++this.speed;
|
||||||
|
timeCalcConfiguration.speedProperty.setValue(this.speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decreaseSpeed() {
|
public void decreaseSpeed() {
|
||||||
if(speed == Integer.MIN_VALUE) {
|
if (speed == Integer.MIN_VALUE) {
|
||||||
speed = 0;
|
speed = 0;
|
||||||
}
|
}
|
||||||
if(speed == MIN_SPEED){
|
if (speed == MIN_SPEED) {
|
||||||
//nothing to do
|
//nothing to do
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
--this.speed;
|
--this.speed;
|
||||||
|
timeCalcConfiguration.speedProperty.setValue(this.speed);
|
||||||
}
|
}
|
||||||
public static final int MIN_SPEED = -10;
|
public static final int MIN_SPEED = -15;
|
||||||
|
|
||||||
public int getSpeed() {
|
public int getSpeed() {
|
||||||
return speed;
|
return speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetSpeed() {
|
public void resetSpeed() {
|
||||||
this.speed = Integer.MIN_VALUE;
|
this.speed = Integer.MIN_VALUE;
|
||||||
|
timeCalcConfiguration.speedProperty.setValue(this.speed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,6 @@ You can restart the app, if you press the **"Restart"** button.
|
|||||||
You can stop the app, if you press the **"Exit"** button or click on the exit window button.
|
You can stop the app, if you press the **"Exit"** button or click on the exit window button.
|
||||||
- Then application is stopped.
|
- Then application is stopped.
|
||||||
|
|
||||||
|
|
||||||
## Special files
|
## Special files
|
||||||
|
|
||||||
If these files are present, something special happens.
|
If these files are present, something special happens.
|
||||||
@ -179,8 +178,11 @@ Smileys can be colored or white-black (can be set in configuration)
|
|||||||
* K - hide or show clock
|
* K - hide or show clock
|
||||||
* SHIFT + {Y,N,D,H,M,S,I,K} - Increase test time value
|
* SHIFT + {Y,N,D,H,M,S,I,K} - Increase test time value
|
||||||
* CTRL + {Y,N,D,H,M,S,I,K} - Decrease test time value
|
* CTRL + {Y,N,D,H,M,S,I,K} - Decrease test time value
|
||||||
* ALT + {Y,N,D,H,M,S,I,K} - Rest test time value
|
* ALT + {Y,N,D,H,M,S,I,K} - Reset test time value
|
||||||
* Y=year, N=month, D=day of month, H=hour, M=minute, S=second, I=millisecond, K=week
|
* Y=year, N=month, D=day of month, H=hour, M=minute, S=second, I=millisecond, K=week
|
||||||
|
* SHIFT + Q - Increase speed of time
|
||||||
|
* CTRL + Q - Decrease speed of time
|
||||||
|
* ALT + Q - Reset speed of time
|
||||||
* D - Reset custom time values to the real time
|
* D - Reset custom time values to the real time
|
||||||
* SHIFT + A - Increase arrival time
|
* SHIFT + A - Increase arrival time
|
||||||
* CTRL + A - Decrease arrival time
|
* CTRL + A - Decrease arrival time
|
||||||
|
@ -76,6 +76,7 @@ test.clock.custom.minute=2147483647
|
|||||||
test.clock.custom.second=2147483647
|
test.clock.custom.second=2147483647
|
||||||
test.clock.custom.millisecond=2147483647
|
test.clock.custom.millisecond=2147483647
|
||||||
activity.needed-flags=
|
activity.needed-flags=
|
||||||
|
speed=0
|
||||||
#TODO:
|
#TODO:
|
||||||
logs.detailed=false
|
logs.detailed=false
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user