mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-26 15:59:24 +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
|
||||||
|
@ -221,6 +221,9 @@ public class TimeCalcConfiguration {
|
|||||||
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
|
||||||
= new HashMap<>();
|
= new HashMap<>();
|
||||||
@ -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,8 +123,8 @@ 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);
|
||||||
@ -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,
|
||||||
@ -357,7 +356,6 @@ public class MainWindow extends TWindow {
|
|||||||
.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(),
|
||||||
@ -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);
|
||||||
|
|
||||||
@ -825,31 +822,15 @@ 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;
|
||||||
|
// }
|
||||||
|
double r = Math.pow(2, speed + 6);
|
||||||
|
if (speed < -6 && Math.random() > r) {
|
||||||
|
// System.out.println(NumberFormats.FORMATTER_EIGHT_DECIMAL_PLACES.format(r));
|
||||||
return;
|
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()) {
|
if (timeCalcConfiguration.testEnabledProperty.isDisabled()) {
|
||||||
timeCalcConfiguration.testEnabledProperty.enable();
|
timeCalcConfiguration.testEnabledProperty.enable();
|
||||||
@ -880,6 +861,19 @@ public class MainWindow extends TWindow {
|
|||||||
this.timeCalcKeyAdapter.processShifCtrlAltModeKeyCodes(KeyEvent.VK_U, true, false, false);
|
this.timeCalcKeyAdapter.processShifCtrlAltModeKeyCodes(KeyEvent.VK_U, true, false, false);
|
||||||
|
|
||||||
}).start();
|
}).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) {
|
||||||
@ -1117,11 +1111,11 @@ public class MainWindow extends TWindow {
|
|||||||
.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,16 +1279,25 @@ 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() {
|
||||||
@ -1306,8 +1309,9 @@ public class MainWindow extends TWindow {
|
|||||||
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;
|
||||||
@ -1315,5 +1319,6 @@ public class MainWindow extends TWindow {
|
|||||||
|
|
||||||
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