Added some improvements

This commit is contained in:
Robert Vokac 2024-03-24 12:31:02 +01:00
parent 9a7db29509
commit d8f6796a76
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
9 changed files with 43 additions and 13 deletions

View File

@ -183,6 +183,7 @@ Smileys can be colored or white-black (can be set in configuration)
* SHIFT + Q - Increase speed of time
* CTRL + Q - Decrease speed of time
* ALT + Q - Reset speed of time
* COMMA - Switch between foreward and backward speed
* D - Reset custom time values to the real time
* SHIFT + A - Increase arrival time
* CTRL + A - Decrease arrival time

View File

@ -260,7 +260,9 @@ public class TimeCalcConfiguration {
.getKey(), Integer.MAX_VALUE);
public final IntegerProperty speedProperty = new IntegerProperty(TimeCalcProperty.SPEED
.getKey(), 1);
.getKey(), 1);
public final BooleanProperty speedNegativeProperty = new BooleanProperty(TimeCalcProperty.SPEED_NEGATIVE
.getKey(), false);
//
private final Map<TimeCalcProperty, Property> mapOfProperties
@ -337,6 +339,7 @@ public class TimeCalcConfiguration {
profileNameProperty,
activityNeededFlagsProperty,
speedProperty,
speedNegativeProperty,
clockHiddenProperty,
batteryMinuteHiddenProperty,
batteryHourHiddenProperty,

View File

@ -129,6 +129,11 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
case KeyEvent.VK_U: {
int ms_ = msToAdd;
boolean negative = false;
if(ms_ < 0) {
ms_ = Math.abs(ms_);
negative = true;
}
//System.out.println("going to add ms:" +msToAdd);
int s_ = msToAdd / 1000;
ms_ = ms_ - s_ * 1000;
@ -138,6 +143,10 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
ms_ = ms_ - h_ * 1000 * 60 * 60;
int d_ = msToAdd / 1000 / 60 / 60 / 24;
ms_ = ms_ - d_ * 1000 * 60 * 60 * 24;
if(negative && (increase || decrease)) {
increase = false;
decrease = true;
}
//Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " second.");
updateProperty(timeCalcConfiguration.testDayCustomProperty, increase, decrease, reset,
Calendar.DAY_OF_MONTH, d_);
@ -149,12 +158,6 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
Calendar.SECOND, s_);
updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset,
Calendar.MILLISECOND, ms_);
break;
}
case KeyEvent.VK_K: {
@ -182,13 +185,15 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
final double newSpeed = this.mainWindow.getSpeed();
if(oldSpeed != newSpeed) {
TTime t= TTime.ofMilliseconds(((int)(Math.pow(2,newSpeed) * 1000)));
final double msDouble = Math.pow(2,newSpeed) * 1000;
TTime t= TTime.ofMilliseconds(((int)msDouble));
Utils.showNotification("Speed was changed from " +
((int)oldSpeed) +
" to: " + ((int)newSpeed) + " (" + (NumberFormats.FORMATTER_FIVE_DECIMAL_PLACES.format(Math.pow(2, newSpeed))) + ") (" +
(newSpeed <= -10 ? "few" : (newSpeed <=21 ? t : "many"))
(newSpeed <= -10 ? (NumberFormats.FORMATTER_SIX_DECIMAL_PLACES.format(msDouble) + "ms") : (/*newSpeed <=21*/ t.getHour() < 24 ? t : ((long)(msDouble / 1000d / 60d / 60d / 24d) + " days")))
+" /1s)");
} else {
if(decrease){
Utils.showNotification("Current speed cannot be decreased: " +
NumberFormats.FORMATTER_TWO_DECIMAL_PLACES.format(oldSpeed));
@ -692,6 +697,10 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
Utils.showNotification((timeCalcConfiguration.testEnabledProperty.isEnabled()? "Enabled" : "Disabled") + " \"Test mode\".");
break;
}
case KeyEvent.VK_COMMA: {
timeCalcConfiguration.speedNegativeProperty.flip();
break;
}
default:
if (!numberKeyWasPressed) {
Utils.showNotification(

View File

@ -124,7 +124,8 @@ public enum TimeCalcProperty {
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),
SPEED("speed", "Speed", Integer.class);
SPEED("speed", "Speed", Integer.class),
SPEED_NEGATIVE("speed.negative", "Speed : Negative", Integer.class);
@Getter
private final String key;

View File

@ -228,6 +228,8 @@ public class ConfigWindow extends TWindow {
= new JTextField(TimeCalcProperty.ACTIVITY_NEEDED_FLAGS.getKey());
public final JTextField speedProperty
= new JTextField(TimeCalcProperty.SPEED.getKey());
public final JCheckBox speedNegativeProperty
= new JCheckBox(TimeCalcProperty.SPEED_NEGATIVE.getKey());
//
public final JCheckBox clockHiddenProperty
@ -546,6 +548,7 @@ public class ConfigWindow extends TWindow {
profileNameProperty,
activityNeededFlagsProperty,
speedProperty,
speedNegativeProperty,
visibilityDefaultProperty,
visibilitySupportedColoredProperty));
//

View File

@ -120,6 +120,7 @@ public class MainWindow extends TWindow {
private final ProgressDot progressDot;
private int speed = Integer.MIN_VALUE;
private final TimeCalcKeyAdapter timeCalcKeyAdapter;
private double msRemaining = 0d;
{
ChangeListener valueMustBeTime
@ -878,8 +879,10 @@ public class MainWindow extends TWindow {
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);
double msShouldBeAdded = speed < -6 ? 1 : (Math.pow(2, speed) * 100d) + this.msRemaining;
int msShouldBeAddedInt = (int)Math.floor(msShouldBeAdded);
this.msRemaining = msShouldBeAdded - msShouldBeAddedInt;
this.timeCalcKeyAdapter.setMsToAdd((timeCalcConfiguration.speedNegativeProperty.isEnabled() ? (-1) : 1) * msShouldBeAddedInt);
this.timeCalcKeyAdapter.processShifCtrlAltModeKeyCodes(KeyEvent.VK_U, true, false, false);
}).start();
@ -1333,7 +1336,7 @@ public class MainWindow extends TWindow {
--this.speed;
timeCalcConfiguration.speedProperty.setValue(this.speed);
}
public static final int MIN_SPEED = -15;
public static final int MIN_SPEED = -10;
public int getSpeed() {
return speed;

View File

@ -199,6 +199,14 @@ public class TTime implements Comparable<TTime> {
public int toTotalMilliseconds() {
return ((negative ? (-1) : 1)) * (hour * 60 * 60 * 1000 + minute * 60 * 1000 + second * 1000 + millisecond);
}
public long toTotalMillisecondsLong() {
long h = hour;
long m = minute;
long s = second;
long d = millisecond;
return ((negative ? (-1l) : 1l)) * (h * 60l * 60l * 1000l + m * 60l * 1000l + s * 1000l + d);
}
@Override
public int compareTo(TTime o) {

View File

@ -183,6 +183,7 @@ Smileys can be colored or white-black (can be set in configuration)
* SHIFT + Q - Increase speed of time
* CTRL + Q - Decrease speed of time
* ALT + Q - Reset speed of time
* COMMA - Switch between foreward and backward speed
* D - Reset custom time values to the real time
* SHIFT + A - Increase arrival time
* CTRL + A - Decrease arrival time

View File

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