mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
Added some improvements
This commit is contained in:
parent
9a7db29509
commit
d8f6796a76
@ -183,6 +183,7 @@ Smileys can be colored or white-black (can be set in configuration)
|
|||||||
* SHIFT + Q - Increase speed of time
|
* SHIFT + Q - Increase speed of time
|
||||||
* CTRL + Q - Decrease speed of time
|
* CTRL + Q - Decrease speed of time
|
||||||
* ALT + Q - Reset 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
|
* 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
|
||||||
|
@ -260,7 +260,9 @@ public class TimeCalcConfiguration {
|
|||||||
.getKey(), Integer.MAX_VALUE);
|
.getKey(), Integer.MAX_VALUE);
|
||||||
|
|
||||||
public final IntegerProperty speedProperty = new IntegerProperty(TimeCalcProperty.SPEED
|
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
|
private final Map<TimeCalcProperty, Property> mapOfProperties
|
||||||
@ -337,6 +339,7 @@ public class TimeCalcConfiguration {
|
|||||||
profileNameProperty,
|
profileNameProperty,
|
||||||
activityNeededFlagsProperty,
|
activityNeededFlagsProperty,
|
||||||
speedProperty,
|
speedProperty,
|
||||||
|
speedNegativeProperty,
|
||||||
clockHiddenProperty,
|
clockHiddenProperty,
|
||||||
batteryMinuteHiddenProperty,
|
batteryMinuteHiddenProperty,
|
||||||
batteryHourHiddenProperty,
|
batteryHourHiddenProperty,
|
||||||
|
@ -129,6 +129,11 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
|
|
||||||
case KeyEvent.VK_U: {
|
case KeyEvent.VK_U: {
|
||||||
int ms_ = msToAdd;
|
int ms_ = msToAdd;
|
||||||
|
boolean negative = false;
|
||||||
|
if(ms_ < 0) {
|
||||||
|
ms_ = Math.abs(ms_);
|
||||||
|
negative = true;
|
||||||
|
}
|
||||||
//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;
|
||||||
@ -138,6 +143,10 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
ms_ = ms_ - h_ * 1000 * 60 * 60;
|
ms_ = ms_ - h_ * 1000 * 60 * 60;
|
||||||
int d_ = msToAdd / 1000 / 60 / 60 / 24;
|
int d_ = msToAdd / 1000 / 60 / 60 / 24;
|
||||||
ms_ = ms_ - d_ * 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.");
|
//Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " second.");
|
||||||
updateProperty(timeCalcConfiguration.testDayCustomProperty, increase, decrease, reset,
|
updateProperty(timeCalcConfiguration.testDayCustomProperty, increase, decrease, reset,
|
||||||
Calendar.DAY_OF_MONTH, d_);
|
Calendar.DAY_OF_MONTH, d_);
|
||||||
@ -149,12 +158,6 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
Calendar.SECOND, s_);
|
Calendar.SECOND, s_);
|
||||||
updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset,
|
updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset,
|
||||||
Calendar.MILLISECOND, ms_);
|
Calendar.MILLISECOND, ms_);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_K: {
|
case KeyEvent.VK_K: {
|
||||||
@ -182,13 +185,15 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
final double newSpeed = this.mainWindow.getSpeed();
|
final double newSpeed = this.mainWindow.getSpeed();
|
||||||
|
|
||||||
if(oldSpeed != newSpeed) {
|
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 " +
|
Utils.showNotification("Speed was changed from " +
|
||||||
((int)oldSpeed) +
|
((int)oldSpeed) +
|
||||||
" to: " + ((int)newSpeed) + " (" + (NumberFormats.FORMATTER_FIVE_DECIMAL_PLACES.format(Math.pow(2, newSpeed))) + ") (" +
|
" 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)");
|
+" /1s)");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if(decrease){
|
if(decrease){
|
||||||
Utils.showNotification("Current speed cannot be decreased: " +
|
Utils.showNotification("Current speed cannot be decreased: " +
|
||||||
NumberFormats.FORMATTER_TWO_DECIMAL_PLACES.format(oldSpeed));
|
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\".");
|
Utils.showNotification((timeCalcConfiguration.testEnabledProperty.isEnabled()? "Enabled" : "Disabled") + " \"Test mode\".");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case KeyEvent.VK_COMMA: {
|
||||||
|
timeCalcConfiguration.speedNegativeProperty.flip();
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
if (!numberKeyWasPressed) {
|
if (!numberKeyWasPressed) {
|
||||||
Utils.showNotification(
|
Utils.showNotification(
|
||||||
|
@ -124,7 +124,8 @@ public enum TimeCalcProperty {
|
|||||||
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);
|
SPEED("speed", "Speed", Integer.class),
|
||||||
|
SPEED_NEGATIVE("speed.negative", "Speed : Negative", Integer.class);
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final String key;
|
private final String key;
|
||||||
|
@ -228,6 +228,8 @@ public class ConfigWindow extends TWindow {
|
|||||||
= new JTextField(TimeCalcProperty.ACTIVITY_NEEDED_FLAGS.getKey());
|
= new JTextField(TimeCalcProperty.ACTIVITY_NEEDED_FLAGS.getKey());
|
||||||
public final JTextField speedProperty
|
public final JTextField speedProperty
|
||||||
= new JTextField(TimeCalcProperty.SPEED.getKey());
|
= new JTextField(TimeCalcProperty.SPEED.getKey());
|
||||||
|
public final JCheckBox speedNegativeProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.SPEED_NEGATIVE.getKey());
|
||||||
|
|
||||||
//
|
//
|
||||||
public final JCheckBox clockHiddenProperty
|
public final JCheckBox clockHiddenProperty
|
||||||
@ -546,6 +548,7 @@ public class ConfigWindow extends TWindow {
|
|||||||
profileNameProperty,
|
profileNameProperty,
|
||||||
activityNeededFlagsProperty,
|
activityNeededFlagsProperty,
|
||||||
speedProperty,
|
speedProperty,
|
||||||
|
speedNegativeProperty,
|
||||||
visibilityDefaultProperty,
|
visibilityDefaultProperty,
|
||||||
visibilitySupportedColoredProperty));
|
visibilitySupportedColoredProperty));
|
||||||
//
|
//
|
||||||
|
@ -120,6 +120,7 @@ public class MainWindow extends TWindow {
|
|||||||
private final ProgressDot progressDot;
|
private final ProgressDot progressDot;
|
||||||
private int speed = Integer.MIN_VALUE;
|
private int speed = Integer.MIN_VALUE;
|
||||||
private final TimeCalcKeyAdapter timeCalcKeyAdapter;
|
private final TimeCalcKeyAdapter timeCalcKeyAdapter;
|
||||||
|
private double msRemaining = 0d;
|
||||||
|
|
||||||
{
|
{
|
||||||
ChangeListener valueMustBeTime
|
ChangeListener valueMustBeTime
|
||||||
@ -878,8 +879,10 @@ public class MainWindow extends TWindow {
|
|||||||
if (time.millisecondCustomProperty.getValue() == Integer.MAX_VALUE) {
|
if (time.millisecondCustomProperty.getValue() == Integer.MAX_VALUE) {
|
||||||
time.millisecondCustomProperty.setValue(time.millisecondProperty.getValue());
|
time.millisecondCustomProperty.setValue(time.millisecondProperty.getValue());
|
||||||
}
|
}
|
||||||
int msShouldBeAdded = speed < -6 ? 1 : (int) (Math.pow(2, speed) * 100d);
|
double msShouldBeAdded = speed < -6 ? 1 : (Math.pow(2, speed) * 100d) + this.msRemaining;
|
||||||
this.timeCalcKeyAdapter.setMsToAdd(msShouldBeAdded);
|
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);
|
this.timeCalcKeyAdapter.processShifCtrlAltModeKeyCodes(KeyEvent.VK_U, true, false, false);
|
||||||
|
|
||||||
}).start();
|
}).start();
|
||||||
@ -1333,7 +1336,7 @@ public class MainWindow extends TWindow {
|
|||||||
--this.speed;
|
--this.speed;
|
||||||
timeCalcConfiguration.speedProperty.setValue(this.speed);
|
timeCalcConfiguration.speedProperty.setValue(this.speed);
|
||||||
}
|
}
|
||||||
public static final int MIN_SPEED = -15;
|
public static final int MIN_SPEED = -10;
|
||||||
|
|
||||||
public int getSpeed() {
|
public int getSpeed() {
|
||||||
return speed;
|
return speed;
|
||||||
|
@ -199,6 +199,14 @@ public class TTime implements Comparable<TTime> {
|
|||||||
public int toTotalMilliseconds() {
|
public int toTotalMilliseconds() {
|
||||||
return ((negative ? (-1) : 1)) * (hour * 60 * 60 * 1000 + minute * 60 * 1000 + second * 1000 + millisecond);
|
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
|
@Override
|
||||||
public int compareTo(TTime o) {
|
public int compareTo(TTime o) {
|
||||||
|
@ -183,6 +183,7 @@ Smileys can be colored or white-black (can be set in configuration)
|
|||||||
* SHIFT + Q - Increase speed of time
|
* SHIFT + Q - Increase speed of time
|
||||||
* CTRL + Q - Decrease speed of time
|
* CTRL + Q - Decrease speed of time
|
||||||
* ALT + Q - Reset 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
|
* 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
|
||||||
|
@ -92,6 +92,7 @@ test.clock.custom.second=2147483647
|
|||||||
test.clock.custom.millisecond=2147483647
|
test.clock.custom.millisecond=2147483647
|
||||||
activity.needed-flags=
|
activity.needed-flags=
|
||||||
speed=0
|
speed=0
|
||||||
|
speed.negative=false
|
||||||
#TODO:
|
#TODO:
|
||||||
logs.detailed=false
|
logs.detailed=false
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user