Added support to change speed of time III

This commit is contained in:
Robert Vokac 2024-03-23 21:07:33 +01:00
parent 9911246ae5
commit f3a1203e99
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
9 changed files with 146 additions and 128 deletions

View File

@ -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.
- Then application is stopped.
## Special files
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
* 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
* 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
* 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
* SHIFT + A - Increase arrival time
* CTRL + A - Decrease arrival time

View File

@ -221,6 +221,9 @@ public class TimeCalcConfiguration {
public final IntegerProperty testMillisecondCustomProperty = new IntegerProperty(TimeCalcProperty.TEST_CLOCK_CUSTOM_MILLISECOND
.getKey(), Integer.MAX_VALUE);
public final IntegerProperty speedProperty = new IntegerProperty(TimeCalcProperty.SPEED
.getKey(), 1);
//
private final Map<TimeCalcProperty, Property> mapOfProperties
= new HashMap<>();
@ -295,6 +298,7 @@ public class TimeCalcConfiguration {
mainWindowCustomTitleProperty,
profileNameProperty,
activityNeededFlagsProperty,
speedProperty,
testEnabledProperty,
testYearCustomProperty,
testMonthCustomProperty,

View File

@ -129,7 +129,7 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
case KeyEvent.VK_U: {
int ms_ = msToAdd;
System.out.println("going to add ms:" +msToAdd);
//System.out.println("going to add ms:" +msToAdd);
int s_ = msToAdd / 1000;
ms_ = ms_ - s_ * 1000;
int m_ = msToAdd / 1000 / 60;

View File

@ -108,7 +108,8 @@ public enum TimeCalcProperty {
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_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
private final String key;

View File

@ -14,8 +14,8 @@ import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
public enum Cloudiness {
CLOUDY("Cloudy", 7d/8d),
MOSTLY_CLOUDY("Mostly cloudy", 5d/8d),
PARTLY_CLOUDY("Partly cloudy+sunny", 3d/8d),
MOSTLY_SUNNY("Mostly clear+sunny", 1d/8d),
PARTLY_CLOUDY("Partly cloudy and partly sunny", 3d/8d),
MOSTLY_SUNNY("Mostly clear and mostly sunny", 1d/8d),
SUNNY("Clear/Sunny", 0/8);
@Getter
private String description;

View File

@ -226,6 +226,8 @@ public class ConfigWindow extends TWindow {
= new JTextField();
public final JTextField activityNeededFlagsProperty
= new JTextField(TimeCalcProperty.ACTIVITY_NEEDED_FLAGS.getKey());
public final JTextField speedProperty
= new JTextField(TimeCalcProperty.SPEED.getKey());
private final JCheckBox testEnabledProperty
= new JCheckBox(TimeCalcProperty.TEST_ENABLED.getKey());
private final JTextField testClockCustomYearProperty
@ -480,6 +482,7 @@ public class ConfigWindow extends TWindow {
mainWindowCustomTitleProperty,
profileNameProperty,
activityNeededFlagsProperty,
speedProperty,
visibilityDefaultProperty,
visibilitySupportedColoredProperty));
//

View File

@ -70,6 +70,7 @@ import java.util.List;
import java.util.stream.Collectors;
import javax.swing.Timer;
import org.nanoboot.utils.timecalc.swing.progress.ProgressDot;
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
/**
* @author Robert Vokac
@ -122,8 +123,8 @@ public class MainWindow extends TWindow {
private final TimeCalcKeyAdapter timeCalcKeyAdapter;
{
ChangeListener valueMustBeTime =
(property, oldValue, newValue) -> new TTime((String) newValue);
ChangeListener valueMustBeTime
= (property, oldValue, newValue) -> new TTime((String) newValue);
this.arrivalTextField = new TTextField(Constants.DEFAULT_ARRIVAL_TIME, 40, true, valueMustBeTime);
this.overtimeTextField = new TTextField(Constants.DEFAULT_OVERTIME, 40, true, valueMustBeTime);
this.workingTimeTextField = new TTextField("08:00", 40, true, valueMustBeTime);
@ -219,7 +220,6 @@ public class MainWindow extends TWindow {
AnalogClock clock = new AnalogClock();
{
arrivalTextField.valueProperty.addListener(e -> {
if (!arrivalTextField.valueProperty.getValue().isEmpty()) {
@ -332,7 +332,6 @@ public class MainWindow extends TWindow {
add(progressLife);
this.progressMoney
= new ProgressMoney();
progressMoney.setBounds(progressLife.getX(), progressSwing.getY() + progressLife.getHeight() + SwingUtils.MARGIN,
@ -357,7 +356,6 @@ public class MainWindow extends TWindow {
.bindTo(timeCalcConfiguration.weatherVisibleProperty);
add(progressWeather);
this.progressDot
= new ProgressDot();
progressDot.setBounds(progressWeather.getX() + progressWeather.getWidth() + SwingUtils.MARGIN, progressWeather.getY(),
@ -408,7 +406,6 @@ public class MainWindow extends TWindow {
overtimeDecreaseButton.setBounds(overtimeTextField.getX() + overtimeTextField.getWidth(), overtimeTextField.getY() + 15, 15, 15);
//
TLabel workingTimeInMinutesTextFieldLabel = new TLabel("Work:", 40);
workingTimeInMinutesTextFieldLabel.setBoundsFromLeft(overtimeTextField, 15);
@ -825,31 +822,15 @@ public class MainWindow extends TWindow {
workingDayRepository.update(wd);
new Timer(100, e -> {
if(speed == Integer.MIN_VALUE) {
timeCalcConfiguration.testEnabledProperty.setValue(false);
// if (speed == Integer.MIN_VALUE) {
// timeCalcConfiguration.testEnabledProperty.setValue(false);
// return;
// }
double r = Math.pow(2, speed + 6);
if (speed < -6 && Math.random() > r) {
// System.out.println(NumberFormats.FORMATTER_EIGHT_DECIMAL_PLACES.format(r));
return;
}
if(speed < -6) {
if(speed == -7) {
if(Math.random() > 0.5) {
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();
@ -880,6 +861,19 @@ public class MainWindow extends TWindow {
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) {
if (Math.random() > 0.99) {
@ -1117,11 +1111,11 @@ public class MainWindow extends TWindow {
.getMonthProgress(weekDayWhenMondayIsOne, workDaysDone,
workDaysTotal, done);
progress.set(WidgetType.MONTH, monthProgress);
double hourProgress =
Progress.getHourProgress(timeRemains, secondsRemains,
double hourProgress
= Progress.getHourProgress(timeRemains, secondsRemains,
millisecondsRemains);
double minuteProgress =
Progress.getMinuteProgress(secondNow, millisecondNow);
double minuteProgress
= Progress.getMinuteProgress(secondNow, millisecondNow);
double yearProgress = Progress.getYearProgress(clock, monthProgress);
progress.set(WidgetType.HOUR, hourProgress);
progress.set(WidgetType.WEEK, weekProgress);
@ -1244,8 +1238,8 @@ public class MainWindow extends TWindow {
}
public void increaseArrival(TTime tTime) {
TTime oldTime =
new TTime(this.arrivalTextField.valueProperty.getValue());
TTime oldTime
= new TTime(this.arrivalTextField.valueProperty.getValue());
TTime newTime = oldTime.add(tTime);
// System.out.println("oldTime=" + oldTime);
// System.out.println("newTime=" + newTime);
@ -1285,16 +1279,25 @@ public class MainWindow extends TWindow {
new TTime(this.pauseTimeTextField.valueProperty.getValue())
.remove(tTime).toString().substring(0, 5));
}
public void doSaveButtonClick() {
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() {
if (speed == Integer.MIN_VALUE) {
speed = 0;
}
++this.speed;
timeCalcConfiguration.speedProperty.setValue(this.speed);
}
public void decreaseSpeed() {
@ -1306,8 +1309,9 @@ public class MainWindow extends TWindow {
return;
}
--this.speed;
timeCalcConfiguration.speedProperty.setValue(this.speed);
}
public static final int MIN_SPEED = -10;
public static final int MIN_SPEED = -15;
public int getSpeed() {
return speed;
@ -1315,5 +1319,6 @@ public class MainWindow extends TWindow {
public void resetSpeed() {
this.speed = Integer.MIN_VALUE;
timeCalcConfiguration.speedProperty.setValue(this.speed);
}
}

View File

@ -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.
- Then application is stopped.
## Special files
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
* 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
* 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
* 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
* SHIFT + A - Increase arrival time
* CTRL + A - Decrease arrival time

View File

@ -76,6 +76,7 @@ test.clock.custom.minute=2147483647
test.clock.custom.second=2147483647
test.clock.custom.millisecond=2147483647
activity.needed-flags=
speed=0
#TODO:
logs.detailed=false