mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 15:37:51 +01:00
Added some improvements
This commit is contained in:
parent
d8f6796a76
commit
9afa86c0d9
@ -53,8 +53,7 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
||||
//boolean metaDown = e.isMetaDown();
|
||||
if (!shiftDown && !ctrlDown && !altDown /*&& !metaDown*/) {
|
||||
processKeyCode(keyCode);
|
||||
} else
|
||||
//if (!metaDown)
|
||||
} else //if (!metaDown)
|
||||
{
|
||||
processShifCtrlAltModeKeyCodes(keyCode, shiftDown, ctrlDown,
|
||||
altDown);
|
||||
@ -128,26 +127,28 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
||||
}
|
||||
|
||||
case KeyEvent.VK_U: {
|
||||
int ms_ = msToAdd;
|
||||
int totalMs = msToAdd;
|
||||
boolean negative = false;
|
||||
if(ms_ < 0) {
|
||||
ms_ = Math.abs(ms_);
|
||||
if (totalMs < 0) {
|
||||
totalMs = Math.abs(totalMs);
|
||||
negative = true;
|
||||
}
|
||||
//System.out.println("going to add ms:" +msToAdd);
|
||||
int s_ = msToAdd / 1000;
|
||||
ms_ = ms_ - s_ * 1000;
|
||||
int m_ = msToAdd / 1000 / 60;
|
||||
ms_ = ms_ - m_ * 1000 * 60;
|
||||
int h_ = msToAdd / 1000 / 60 / 60;
|
||||
ms_ = ms_ - h_ * 1000 * 60 * 60;
|
||||
int d_ = msToAdd / 1000 / 60 / 60 / 24;
|
||||
ms_ = ms_ - d_ * 1000 * 60 * 60 * 24;
|
||||
int ms_ = totalMs % 1000;
|
||||
totalMs = totalMs - ms_;
|
||||
int s_ = totalMs / 1000 % 60;
|
||||
totalMs = totalMs - s_ * 1000;
|
||||
int m_ = totalMs / 1000 / 60 % 60;
|
||||
totalMs = totalMs - m_ * 1000 * 60;
|
||||
int h_ = totalMs / 1000 / 60 / 60 % 60;
|
||||
totalMs = totalMs - h_ * 1000 * 60 * 60;
|
||||
int d_ = totalMs / 1000 / 60 / 60 / 24;
|
||||
totalMs = totalMs - 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_);
|
||||
updateProperty(timeCalcConfiguration.testHourCustomProperty, increase, decrease, reset,
|
||||
@ -187,16 +188,20 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
||||
if (oldSpeed != newSpeed) {
|
||||
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 ? (NumberFormats.FORMATTER_SIX_DECIMAL_PLACES.format(msDouble) + "ms") : (/*newSpeed <=21*/ t.getHour() < 24 ? t : ((long)(msDouble / 1000d / 60d / 60d / 24d) + " days")))
|
||||
Utils.showNotification("Speed was changed from "
|
||||
+ ((int) oldSpeed)
|
||||
+ " to: " + ((int) newSpeed) + " (" + (NumberFormats.FORMATTER_FIVE_DECIMAL_PLACES.format(Math.pow(2, newSpeed))) + ") ("
|
||||
+ (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));
|
||||
Utils.showNotification("Current speed cannot be decreased: "
|
||||
+ NumberFormats.FORMATTER_TWO_DECIMAL_PLACES.format(oldSpeed));
|
||||
}
|
||||
if (increase) {
|
||||
Utils.showNotification("Current speed cannot be increased: "
|
||||
+ NumberFormats.FORMATTER_TWO_DECIMAL_PLACES.format(oldSpeed));
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,6 +278,7 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
||||
boolean increase, boolean decrease, boolean reset, int timeUnit) {
|
||||
updateProperty(integerProperty, increase, decrease, reset, timeUnit, 1);
|
||||
}
|
||||
|
||||
private void updateProperty(IntegerProperty integerProperty,
|
||||
boolean increase, boolean decrease, boolean reset, int timeUnit, int value) {
|
||||
if (value == 0) {
|
||||
@ -673,8 +679,8 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
||||
newForgetOvertimeInt = new TTime(newForgetOvertime).toTotalMilliseconds() / 1000 / 60;
|
||||
} else {
|
||||
try {
|
||||
newForgetOvertimeInt =
|
||||
Integer.parseInt(newForgetOvertime);
|
||||
newForgetOvertimeInt
|
||||
= Integer.parseInt(newForgetOvertime);
|
||||
} catch (Exception e) {
|
||||
Utils.showNotification(e);
|
||||
}
|
||||
|
@ -1321,6 +1321,10 @@ public class MainWindow extends TWindow {
|
||||
if (speed == Integer.MIN_VALUE) {
|
||||
speed = 0;
|
||||
}
|
||||
if (speed == MAX_SPEED) {
|
||||
//nothing to do
|
||||
return;
|
||||
}
|
||||
++this.speed;
|
||||
timeCalcConfiguration.speedProperty.setValue(this.speed);
|
||||
}
|
||||
@ -1337,6 +1341,7 @@ public class MainWindow extends TWindow {
|
||||
timeCalcConfiguration.speedProperty.setValue(this.speed);
|
||||
}
|
||||
public static final int MIN_SPEED = -10;
|
||||
public static final int MAX_SPEED = 25;
|
||||
|
||||
public int getSpeed() {
|
||||
return speed;
|
||||
|
Loading…
x
Reference in New Issue
Block a user