Formatted code

This commit is contained in:
Robert Vokac 2024-03-09 19:31:05 +00:00
parent e12d5aaf25
commit 6930b3e8ed
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
45 changed files with 706 additions and 607 deletions

View File

@ -44,14 +44,14 @@ public class CommandActionListener
case "color": case "color":
timeCalcApp.visibilityProperty.setValue( timeCalcApp.visibilityProperty.setValue(
commandsAsArray[1].equals("1") commandsAsArray[1].equals("1")
? Visibility.STRONGLY_COLORED.name() ? Visibility.STRONGLY_COLORED.name()
: Visibility.WEAKLY_COLORED.name()); : Visibility.WEAKLY_COLORED.name());
break; break;
case "gray": case "gray":
timeCalcApp.visibilityProperty.setValue( timeCalcApp.visibilityProperty.setValue(
commandsAsArray[1].equals("1") commandsAsArray[1].equals("1")
? Visibility.GRAY.name() ? Visibility.GRAY.name()
: Visibility.WEAKLY_COLORED.name()); : Visibility.WEAKLY_COLORED.name());
break; break;
case "waves": case "waves":
timeCalcConfiguration.batteryWavesVisibleProperty timeCalcConfiguration.batteryWavesVisibleProperty

View File

@ -18,7 +18,7 @@ public class TimeCalcApp {
public StringProperty visibilityProperty public StringProperty visibilityProperty
= new StringProperty("timeCalcApp.visibilityProperty", = new StringProperty("timeCalcApp.visibilityProperty",
Visibility.WEAKLY_COLORED.name()); Visibility.WEAKLY_COLORED.name());
private long startNanoTime = 0l; private long startNanoTime = 0l;
public void start(String[] args) throws IOException { public void start(String[] args) throws IOException {
@ -26,7 +26,7 @@ public class TimeCalcApp {
throw new TimeCalcException("TimeCalcApp was already started."); throw new TimeCalcException("TimeCalcApp was already started.");
} }
startNanoTime = System.nanoTime(); startNanoTime = System.nanoTime();
if(!FileConstants.TC_DIRECTORY.exists()) { if (!FileConstants.TC_DIRECTORY.exists()) {
FileConstants.TC_DIRECTORY.mkdir(); FileConstants.TC_DIRECTORY.mkdir();
} }
while (true) { while (true) {
@ -37,37 +37,37 @@ public class TimeCalcApp {
FileConstants.OVERTIME_TXT); FileConstants.OVERTIME_TXT);
String newStartTime String newStartTime
= test ? (oldStartTime != null ? oldStartTime = test ? (oldStartTime != null ? oldStartTime
: Constants.DEFAULT_START_TIME) : Constants.DEFAULT_START_TIME)
: (String) JOptionPane.showInputDialog( : (String) JOptionPane.showInputDialog(
null, null,
"Start Time:", "Start Time:",
"Start Time", "Start Time",
JOptionPane.PLAIN_MESSAGE, JOptionPane.PLAIN_MESSAGE,
null, null,
null, null,
oldStartTime == null oldStartTime == null
? Constants.DEFAULT_START_TIME ? Constants.DEFAULT_START_TIME
: oldStartTime : oldStartTime
); );
if(newStartTime == null) { if (newStartTime == null) {
break; break;
} }
String newOvertime String newOvertime
= test ? (oldOvertime != null ? oldOvertime = test ? (oldOvertime != null ? oldOvertime
: Constants.DEFAULT_OVERTIME) : Constants.DEFAULT_OVERTIME)
: (String) JOptionPane.showInputDialog( : (String) JOptionPane.showInputDialog(
null, null,
"Overtime:", "Overtime:",
"Overtime", "Overtime",
JOptionPane.PLAIN_MESSAGE, JOptionPane.PLAIN_MESSAGE,
null, null,
null, null,
oldOvertime == null oldOvertime == null
? Constants.DEFAULT_OVERTIME ? Constants.DEFAULT_OVERTIME
: oldOvertime : oldOvertime
); );
if(newOvertime == null) { if (newOvertime == null) {
break; break;
} }
Utils.writeTextToFile(FileConstants.STARTTIME_TXT, newStartTime); Utils.writeTextToFile(FileConstants.STARTTIME_TXT, newStartTime);

View File

@ -17,132 +17,129 @@ import java.util.Properties;
*/ */
public class TimeCalcConfiguration { public class TimeCalcConfiguration {
public final StringProperty visibilityDefaultProperty = public final StringProperty visibilityDefaultProperty
new StringProperty(TimeCalcProperty.VISIBILITY_DEFAULT = new StringProperty(TimeCalcProperty.VISIBILITY_DEFAULT
.getKey()); .getKey());
public final BooleanProperty visibilitySupportedColoredProperty public final BooleanProperty visibilitySupportedColoredProperty
= new BooleanProperty(TimeCalcProperty.VISIBILITY_SUPPORTED_COLORED = new BooleanProperty(TimeCalcProperty.VISIBILITY_SUPPORTED_COLORED
.getKey()); .getKey());
// //
public final BooleanProperty clockVisibleProperty public final BooleanProperty clockVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_VISIBLE = new BooleanProperty(TimeCalcProperty.CLOCK_VISIBLE
.getKey()); .getKey());
public final BooleanProperty clockHandsLongVisibleProperty public final BooleanProperty clockHandsLongVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_LONG_VISIBLE = new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_LONG_VISIBLE
.getKey()); .getKey());
public final BooleanProperty clockHandsColoredProperty public final BooleanProperty clockHandsColoredProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_COLORED = new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_COLORED
.getKey()); .getKey());
public final BooleanProperty clockHandsHourVisibleProperty public final BooleanProperty clockHandsHourVisibleProperty
= new BooleanProperty( = new BooleanProperty(
TimeCalcProperty.CLOCK_HANDS_HOUR_VISIBLE.getKey()); TimeCalcProperty.CLOCK_HANDS_HOUR_VISIBLE.getKey());
public final BooleanProperty clockHandsMinuteVisibleProperty public final BooleanProperty clockHandsMinuteVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_MINUTE_VISIBLE = new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_MINUTE_VISIBLE
.getKey()); .getKey());
public final BooleanProperty clockHandsSecondVisibleProperty public final BooleanProperty clockHandsSecondVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_SECOND_VISIBLE = new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_SECOND_VISIBLE
.getKey()); .getKey());
public final BooleanProperty clockHandsMillisecondVisibleProperty public final BooleanProperty clockHandsMillisecondVisibleProperty
= = new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_MILLISECOND_VISIBLE
new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_MILLISECOND_VISIBLE
.getKey()); .getKey());
public final BooleanProperty clockBorderVisibleProperty public final BooleanProperty clockBorderVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_VISIBLE = new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_VISIBLE
.getKey()); .getKey());
public final BooleanProperty clockBorderOnlyHoursProperty public final BooleanProperty clockBorderOnlyHoursProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_ONLY_HOURS = new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_ONLY_HOURS
.getKey()); .getKey());
public final BooleanProperty clockNumbersVisibleProperty public final BooleanProperty clockNumbersVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_NUMBERS_VISIBLE = new BooleanProperty(TimeCalcProperty.CLOCK_NUMBERS_VISIBLE
.getKey()); .getKey());
public final BooleanProperty clockCircleVisibleProperty public final BooleanProperty clockCircleVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_VISIBLE = new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_VISIBLE
.getKey()); .getKey());
public final BooleanProperty clockCircleStrongBorderProperty public final BooleanProperty clockCircleStrongBorderProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_STRONG_BORDER = new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_STRONG_BORDER
.getKey()); .getKey());
public final StringProperty clockCircleBorderColorProperty public final StringProperty clockCircleBorderColorProperty
= new StringProperty(TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR = new StringProperty(TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR
.getKey()); .getKey());
public final BooleanProperty clockCentreCircleVisibleProperty public final BooleanProperty clockCentreCircleVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_VISIBLE = new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_VISIBLE
.getKey()); .getKey());
public final BooleanProperty clockCentreCircleBlackProperty public final BooleanProperty clockCentreCircleBlackProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK = new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK
.getKey());
public final BooleanProperty
clockProgressVisibleOnlyIfMouseMovingOverProperty
= new BooleanProperty(
TimeCalcProperty.CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
.getKey()); .getKey());
public final BooleanProperty clockProgressVisibleOnlyIfMouseMovingOverProperty
= new BooleanProperty(
TimeCalcProperty.CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
.getKey());
public final BooleanProperty clockDateVisibleOnlyIfMouseMovingOverProperty public final BooleanProperty clockDateVisibleOnlyIfMouseMovingOverProperty
= new BooleanProperty( = new BooleanProperty(
TimeCalcProperty.CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER TimeCalcProperty.CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
.getKey()); .getKey());
// //
public final BooleanProperty batteryWavesVisibleProperty public final BooleanProperty batteryWavesVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE = new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE
.getKey()); .getKey());
public final BooleanProperty batteryCircleProgressProperty public final BooleanProperty batteryCircleProgressProperty
= = new BooleanProperty(TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE
new BooleanProperty(TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE
.getKey()); .getKey());
public final BooleanProperty batteryPercentProgressProperty public final BooleanProperty batteryPercentProgressProperty
= new BooleanProperty( = new BooleanProperty(
TimeCalcProperty.BATTERY_PERCENT_PROGRESS_VISIBLE TimeCalcProperty.BATTERY_PERCENT_PROGRESS_VISIBLE
.getKey()); .getKey());
public final BooleanProperty batteryChargingCharacterVisibleProperty public final BooleanProperty batteryChargingCharacterVisibleProperty
= new BooleanProperty( = new BooleanProperty(
TimeCalcProperty.BATTERY_CHARGING_CHARACTER_VISIBLE TimeCalcProperty.BATTERY_CHARGING_CHARACTER_VISIBLE
.getKey()); .getKey());
public final BooleanProperty batteryNameVisibleProperty public final BooleanProperty batteryNameVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_NAME_VISIBLE = new BooleanProperty(TimeCalcProperty.BATTERY_NAME_VISIBLE
.getKey()); .getKey());
public final BooleanProperty batteryLabelVisibleProperty public final BooleanProperty batteryLabelVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_LABEL_VISIBLE = new BooleanProperty(TimeCalcProperty.BATTERY_LABEL_VISIBLE
.getKey()); .getKey());
public final BooleanProperty batteryVisibleProperty public final BooleanProperty batteryVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_VISIBLE = new BooleanProperty(TimeCalcProperty.BATTERY_VISIBLE
.getKey()); .getKey());
public final BooleanProperty batteryMinuteVisibleProperty public final BooleanProperty batteryMinuteVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_MINUTE_VISIBLE = new BooleanProperty(TimeCalcProperty.BATTERY_MINUTE_VISIBLE
.getKey()); .getKey());
public final BooleanProperty batteryHourVisibleProperty public final BooleanProperty batteryHourVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_HOUR_VISIBLE = new BooleanProperty(TimeCalcProperty.BATTERY_HOUR_VISIBLE
.getKey()); .getKey());
public final BooleanProperty batteryDayVisibleProperty public final BooleanProperty batteryDayVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_DAY_VISIBLE = new BooleanProperty(TimeCalcProperty.BATTERY_DAY_VISIBLE
.getKey()); .getKey());
public final BooleanProperty batteryWeekVisibleProperty public final BooleanProperty batteryWeekVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_WEEK_VISIBLE = new BooleanProperty(TimeCalcProperty.BATTERY_WEEK_VISIBLE
.getKey()); .getKey());
public final BooleanProperty batteryMonthVisibleProperty public final BooleanProperty batteryMonthVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_MONTH_VISIBLE = new BooleanProperty(TimeCalcProperty.BATTERY_MONTH_VISIBLE
.getKey()); .getKey());
public final BooleanProperty batteryYearVisibleProperty public final BooleanProperty batteryYearVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_YEAR_VISIBLE = new BooleanProperty(TimeCalcProperty.BATTERY_YEAR_VISIBLE
.getKey()); .getKey());
public final BooleanProperty batteryBlinkingIfCriticalLowVisibleProperty public final BooleanProperty batteryBlinkingIfCriticalLowVisibleProperty
= new BooleanProperty( = new BooleanProperty(
TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW
.getKey()); .getKey());
public final BooleanProperty jokesVisibleProperty public final BooleanProperty jokesVisibleProperty
= new BooleanProperty(TimeCalcProperty.JOKES_VISIBLE = new BooleanProperty(TimeCalcProperty.JOKES_VISIBLE
.getKey()); .getKey());
public final BooleanProperty commandsVisibleProperty public final BooleanProperty commandsVisibleProperty
= new BooleanProperty(TimeCalcProperty.COMMANDS_VISIBLE = new BooleanProperty(TimeCalcProperty.COMMANDS_VISIBLE
.getKey()); .getKey());
public final BooleanProperty notificationsVisibleProperty public final BooleanProperty notificationsVisibleProperty
= new BooleanProperty(TimeCalcProperty.NOTIFICATIONS_VISIBLE = new BooleanProperty(TimeCalcProperty.NOTIFICATIONS_VISIBLE
.getKey()); .getKey());
public final BooleanProperty smileysVisibleProperty public final BooleanProperty smileysVisibleProperty
= new BooleanProperty(TimeCalcProperty.SMILEYS_VISIBLE.getKey()); = new BooleanProperty(TimeCalcProperty.SMILEYS_VISIBLE.getKey());
public final BooleanProperty smileysVisibleOnlyIfMouseMovingOverProperty public final BooleanProperty smileysVisibleOnlyIfMouseMovingOverProperty
= new BooleanProperty( = new BooleanProperty(
TimeCalcProperty.SMILEYS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER TimeCalcProperty.SMILEYS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
.getKey()); .getKey());
public final BooleanProperty smileysColoredProperty public final BooleanProperty smileysColoredProperty
= new BooleanProperty(TimeCalcProperty.SMILEYS_COLORED.getKey()); = new BooleanProperty(TimeCalcProperty.SMILEYS_COLORED.getKey());
@ -152,10 +149,10 @@ public class TimeCalcConfiguration {
= new BooleanProperty(TimeCalcProperty.CIRCLE_VISIBLE.getKey()); = new BooleanProperty(TimeCalcProperty.CIRCLE_VISIBLE.getKey());
public final BooleanProperty walkingHumanVisibleProperty public final BooleanProperty walkingHumanVisibleProperty
= new BooleanProperty( = new BooleanProperty(
TimeCalcProperty.WALKING_HUMAN_VISIBLE.getKey()); TimeCalcProperty.WALKING_HUMAN_VISIBLE.getKey());
public final StringProperty mainWindowCustomTitleProperty public final StringProperty mainWindowCustomTitleProperty
= new StringProperty( = new StringProperty(
TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE.getKey()); TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE.getKey());
public final BooleanProperty testModeProperty public final BooleanProperty testModeProperty
= new BooleanProperty("testModeProperty", false); = new BooleanProperty("testModeProperty", false);
public final StringProperty profileNameProperty public final StringProperty profileNameProperty
@ -176,66 +173,65 @@ public class TimeCalcConfiguration {
.getKey(), Integer.MAX_VALUE); .getKey(), Integer.MAX_VALUE);
// //
private final Map<TimeCalcProperty, Property> mapOfProperties = private final Map<TimeCalcProperty, Property> mapOfProperties
new HashMap<>(); = new HashMap<>();
private final List<Property> allProperties = new ArrayList<>(); private final List<Property> allProperties = new ArrayList<>();
private TimeCalcProperties timeCalcProperties; private TimeCalcProperties timeCalcProperties;
public TimeCalcConfiguration() { public TimeCalcConfiguration() {
for (Property p : new Property[] { for (Property p : new Property[]{
visibilityDefaultProperty, visibilityDefaultProperty,
visibilitySupportedColoredProperty, visibilitySupportedColoredProperty,
clockVisibleProperty, clockVisibleProperty,
clockHandsLongVisibleProperty, clockHandsLongVisibleProperty,
clockHandsColoredProperty, clockHandsColoredProperty,
clockHandsHourVisibleProperty, clockHandsHourVisibleProperty,
clockHandsMinuteVisibleProperty, clockHandsMinuteVisibleProperty,
clockHandsSecondVisibleProperty, clockHandsSecondVisibleProperty,
clockHandsMillisecondVisibleProperty, clockHandsMillisecondVisibleProperty,
clockBorderVisibleProperty, clockBorderVisibleProperty,
clockBorderOnlyHoursProperty, clockBorderOnlyHoursProperty,
clockNumbersVisibleProperty, clockNumbersVisibleProperty,
clockCircleVisibleProperty, clockCircleVisibleProperty,
clockCircleStrongBorderProperty, clockCircleStrongBorderProperty,
clockCircleBorderColorProperty, clockCircleBorderColorProperty,
clockCentreCircleVisibleProperty, clockCentreCircleVisibleProperty,
clockCentreCircleBlackProperty, clockCentreCircleBlackProperty,
clockProgressVisibleOnlyIfMouseMovingOverProperty, clockProgressVisibleOnlyIfMouseMovingOverProperty,
clockDateVisibleOnlyIfMouseMovingOverProperty, clockDateVisibleOnlyIfMouseMovingOverProperty,
batteryWavesVisibleProperty, batteryWavesVisibleProperty,
batteryCircleProgressProperty, batteryCircleProgressProperty,
batteryPercentProgressProperty, batteryPercentProgressProperty,
batteryChargingCharacterVisibleProperty, batteryChargingCharacterVisibleProperty,
batteryNameVisibleProperty, batteryNameVisibleProperty,
batteryLabelVisibleProperty, batteryLabelVisibleProperty,
batteryVisibleProperty, batteryVisibleProperty,
batteryMinuteVisibleProperty, batteryMinuteVisibleProperty,
batteryHourVisibleProperty, batteryHourVisibleProperty,
batteryDayVisibleProperty, batteryDayVisibleProperty,
batteryWeekVisibleProperty, batteryWeekVisibleProperty,
batteryMonthVisibleProperty, batteryMonthVisibleProperty,
batteryYearVisibleProperty, batteryYearVisibleProperty,
batteryBlinkingIfCriticalLowVisibleProperty, batteryBlinkingIfCriticalLowVisibleProperty,
jokesVisibleProperty, jokesVisibleProperty,
commandsVisibleProperty, commandsVisibleProperty,
notificationsVisibleProperty, notificationsVisibleProperty,
smileysVisibleProperty, smileysVisibleProperty,
smileysVisibleOnlyIfMouseMovingOverProperty, smileysVisibleOnlyIfMouseMovingOverProperty,
smileysColoredProperty, smileysColoredProperty,
squareVisibleProperty, squareVisibleProperty,
circleVisibleProperty, circleVisibleProperty,
walkingHumanVisibleProperty, walkingHumanVisibleProperty,
mainWindowCustomTitleProperty, mainWindowCustomTitleProperty,
profileNameProperty, profileNameProperty,
testYearCustomProperty, testYearCustomProperty,
testMonthCustomProperty, testMonthCustomProperty,
testDayCustomProperty, testDayCustomProperty,
testHourCustomProperty, testHourCustomProperty,
testMinuteCustomProperty, testMinuteCustomProperty,
testSecondCustomProperty, testSecondCustomProperty,
testMillisecondCustomProperty, testMillisecondCustomProperty,}) {
}) {
allProperties.add(p); allProperties.add(p);
} }
allProperties.stream().forEach(p -> mapOfProperties allProperties.stream().forEach(p -> mapOfProperties
@ -264,10 +260,11 @@ public class TimeCalcConfiguration {
} }
return mapOfProperties.get(timeCalcProperty); return mapOfProperties.get(timeCalcProperty);
} }
public String print() { public String print() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for(Property p: allProperties) { for (Property p : allProperties) {
if(!p.getName().startsWith("test")) { if (!p.getName().startsWith("test")) {
continue; continue;
} }
sb.append(p.getName()).append("=").append(p.getValue()) sb.append(p.getName()).append("=").append(p.getValue())

View File

@ -44,7 +44,7 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
boolean ctrlDown = e.isControlDown(); boolean ctrlDown = e.isControlDown();
boolean altDown = e.isAltDown(); boolean altDown = e.isAltDown();
boolean metaDown = e.isMetaDown(); boolean metaDown = e.isMetaDown();
if(!shiftDown && !ctrlDown && !altDown) { if (!shiftDown && !ctrlDown && !altDown) {
processKeyCode(keyCode); processKeyCode(keyCode);
} else { } else {
processTestModeKeyCode(keyCode, shiftDown, ctrlDown, altDown); processTestModeKeyCode(keyCode, shiftDown, ctrlDown, altDown);
@ -114,20 +114,20 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
} }
case KeyEvent.VK_A: { case KeyEvent.VK_A: {
//Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " millisecond."); //Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " millisecond.");
if(increase) { if (increase) {
window.increaseArrivalByOneMinute(); window.increaseArrivalByOneMinute();
} }
if(decrease) { if (decrease) {
window.decreaseArrivalByOneMinute(); window.decreaseArrivalByOneMinute();
} }
break; break;
} }
case KeyEvent.VK_O: { case KeyEvent.VK_O: {
//Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " millisecond."); //Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " millisecond.");
if(increase) { if (increase) {
window.increaseOvertimeByOneMinute(); window.increaseOvertimeByOneMinute();
} }
if(decrease) { if (decrease) {
window.decreaseOvertimeByOneMinute(); window.decreaseOvertimeByOneMinute();
} }
break; break;
@ -143,16 +143,31 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
boolean increase, boolean decrease, boolean reset, int timeUnit) { boolean increase, boolean decrease, boolean reset, int timeUnit) {
int currentValue = integerProperty.getValue(); int currentValue = integerProperty.getValue();
if((increase || decrease) && currentValue == Integer.MAX_VALUE) { if ((increase || decrease) && currentValue == Integer.MAX_VALUE) {
switch(timeUnit) { switch (timeUnit) {
case Calendar.YEAR: integerProperty.setValue(time.yearProperty.getValue());break; case Calendar.YEAR:
case Calendar.MONTH:integerProperty.setValue(time.monthProperty.getValue());break; integerProperty.setValue(time.yearProperty.getValue());
case Calendar.DAY_OF_MONTH:integerProperty.setValue(time.dayProperty.getValue());break; break;
case Calendar.HOUR_OF_DAY:integerProperty.setValue(time.hourProperty.getValue());break; case Calendar.MONTH:
case Calendar.MINUTE:integerProperty.setValue(time.minuteProperty.getValue());break; integerProperty.setValue(time.monthProperty.getValue());
case Calendar.SECOND:integerProperty.setValue(time.secondProperty.getValue());break; break;
case Calendar.MILLISECOND:integerProperty.setValue(time.millisecondProperty.getValue());break; case Calendar.DAY_OF_MONTH:
default: throw new TimeCalcException("Unsupported time unit: " + timeUnit); integerProperty.setValue(time.dayProperty.getValue());
break;
case Calendar.HOUR_OF_DAY:
integerProperty.setValue(time.hourProperty.getValue());
break;
case Calendar.MINUTE:
integerProperty.setValue(time.minuteProperty.getValue());
break;
case Calendar.SECOND:
integerProperty.setValue(time.secondProperty.getValue());
break;
case Calendar.MILLISECOND:
integerProperty.setValue(time.millisecondProperty.getValue());
break;
default:
throw new TimeCalcException("Unsupported time unit: " + timeUnit);
} }
} }
Calendar cal = time.asCalendar(); Calendar cal = time.asCalendar();
@ -165,10 +180,10 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
int oldMillisecond = cal.get(Calendar.MILLISECOND); int oldMillisecond = cal.get(Calendar.MILLISECOND);
cal.add(timeUnit, increase ? 1 : (-1)); cal.add(timeUnit, increase ? 1 : (-1));
int newValue = cal.get(timeUnit); int newValue = cal.get(timeUnit);
if(Calendar.MONTH == timeUnit) { if (Calendar.MONTH == timeUnit) {
newValue ++; newValue++;
} }
if(reset) { if (reset) {
newValue = Integer.MAX_VALUE; newValue = Integer.MAX_VALUE;
} }
integerProperty.setValue(newValue); integerProperty.setValue(newValue);
@ -179,28 +194,80 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
int newMinute = cal.get(Calendar.MINUTE); int newMinute = cal.get(Calendar.MINUTE);
int newSecond = cal.get(Calendar.SECOND); int newSecond = cal.get(Calendar.SECOND);
int newMillisecond = cal.get(Calendar.MILLISECOND); int newMillisecond = cal.get(Calendar.MILLISECOND);
if(increase){ if (increase) {
switch(timeUnit) { switch (timeUnit) {
case Calendar.YEAR: break; case Calendar.YEAR:
case Calendar.MONTH: if(oldYear != newYear) { updateProperty(timeCalcConfiguration.testYearCustomProperty, increase, decrease, reset, Calendar.YEAR);}break; break;
case Calendar.DAY_OF_MONTH:if(oldMonth != newMonth) { updateProperty(timeCalcConfiguration.testMonthCustomProperty, increase, decrease, reset, Calendar.MONTH);}break; case Calendar.MONTH:
case Calendar.HOUR_OF_DAY:if(oldDay != newDay) { updateProperty(timeCalcConfiguration.testDayCustomProperty, increase, decrease, reset, Calendar.DAY_OF_MONTH);}break; if (oldYear != newYear) {
case Calendar.MINUTE:if(oldHour != newHour) { updateProperty(timeCalcConfiguration.testHourCustomProperty, increase, decrease, reset, Calendar.HOUR_OF_DAY);}break; updateProperty(timeCalcConfiguration.testYearCustomProperty, increase, decrease, reset, Calendar.YEAR);
case Calendar.SECOND:if(oldMinute != newMinute) { updateProperty(timeCalcConfiguration.testMinuteCustomProperty, increase, decrease, reset, Calendar.MINUTE);}break; }
case Calendar.MILLISECOND:if(oldSecond != newSecond) { updateProperty(timeCalcConfiguration.testSecondCustomProperty, increase, decrease, reset, Calendar.SECOND);}break; break;
default: throw new TimeCalcException("Unsupported time unit: " + timeUnit); case Calendar.DAY_OF_MONTH:
if (oldMonth != newMonth) {
updateProperty(timeCalcConfiguration.testMonthCustomProperty, increase, decrease, reset, Calendar.MONTH);
}
break;
case Calendar.HOUR_OF_DAY:
if (oldDay != newDay) {
updateProperty(timeCalcConfiguration.testDayCustomProperty, increase, decrease, reset, Calendar.DAY_OF_MONTH);
}
break;
case Calendar.MINUTE:
if (oldHour != newHour) {
updateProperty(timeCalcConfiguration.testHourCustomProperty, increase, decrease, reset, Calendar.HOUR_OF_DAY);
}
break;
case Calendar.SECOND:
if (oldMinute != newMinute) {
updateProperty(timeCalcConfiguration.testMinuteCustomProperty, increase, decrease, reset, Calendar.MINUTE);
}
break;
case Calendar.MILLISECOND:
if (oldSecond != newSecond) {
updateProperty(timeCalcConfiguration.testSecondCustomProperty, increase, decrease, reset, Calendar.SECOND);
}
break;
default:
throw new TimeCalcException("Unsupported time unit: " + timeUnit);
}
} }
} if (decrease) {
if(decrease){ switch (timeUnit) {
switch(timeUnit) { case Calendar.YEAR:
case Calendar.YEAR: break; break;
case Calendar.MONTH:if(oldYear != newYear) { updateProperty(timeCalcConfiguration.testYearCustomProperty, increase, decrease, reset, Calendar.YEAR);}break; case Calendar.MONTH:
case Calendar.DAY_OF_MONTH:if(oldMonth != newMonth) { updateProperty(timeCalcConfiguration.testMinuteCustomProperty, increase, decrease, reset, Calendar.MONTH);}break; if (oldYear != newYear) {
case Calendar.HOUR_OF_DAY:if(oldDay != newDay) { updateProperty(timeCalcConfiguration.testSecondCustomProperty, increase, decrease, reset, Calendar.DAY_OF_MONTH);}break; updateProperty(timeCalcConfiguration.testYearCustomProperty, increase, decrease, reset, Calendar.YEAR);
case Calendar.MINUTE:if(oldHour != newHour) { updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.HOUR_OF_DAY);}break; }
case Calendar.SECOND:if(oldMinute != newMinute) { updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.MINUTE);}break; break;
case Calendar.MILLISECOND: if(oldSecond != newSecond) { updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.SECOND);}break; case Calendar.DAY_OF_MONTH:
default: throw new TimeCalcException("Unsupported time unit: " + timeUnit); if (oldMonth != newMonth) {
updateProperty(timeCalcConfiguration.testMinuteCustomProperty, increase, decrease, reset, Calendar.MONTH);
}
break;
case Calendar.HOUR_OF_DAY:
if (oldDay != newDay) {
updateProperty(timeCalcConfiguration.testSecondCustomProperty, increase, decrease, reset, Calendar.DAY_OF_MONTH);
}
break;
case Calendar.MINUTE:
if (oldHour != newHour) {
updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.HOUR_OF_DAY);
}
break;
case Calendar.SECOND:
if (oldMinute != newMinute) {
updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.MINUTE);
}
break;
case Calendar.MILLISECOND:
if (oldSecond != newSecond) {
updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.SECOND);
}
break;
default:
throw new TimeCalcException("Unsupported time unit: " + timeUnit);
} }
} }
@ -209,19 +276,19 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
private void processKeyCode(int keyCode) { private void processKeyCode(int keyCode) {
boolean onlyGreyOrNone boolean onlyGreyOrNone
= timeCalcConfiguration.visibilitySupportedColoredProperty = timeCalcConfiguration.visibilitySupportedColoredProperty
.isDisabled(); .isDisabled();
Visibility visibility = Visibility Visibility visibility = Visibility
.valueOf(timeCalcApp.visibilityProperty.getValue()); .valueOf(timeCalcApp.visibilityProperty.getValue());
boolean numberKeyWasPressed = keyCode == KeyEvent.VK_0 || boolean numberKeyWasPressed = keyCode == KeyEvent.VK_0
keyCode == KeyEvent.VK_1 || || keyCode == KeyEvent.VK_1
keyCode == KeyEvent.VK_2 || || keyCode == KeyEvent.VK_2
keyCode == KeyEvent.VK_3 || || keyCode == KeyEvent.VK_3
keyCode == KeyEvent.VK_4 || || keyCode == KeyEvent.VK_4
keyCode == KeyEvent.VK_5 || || keyCode == KeyEvent.VK_5
keyCode == KeyEvent.VK_6 || || keyCode == KeyEvent.VK_6
keyCode == KeyEvent.VK_7 || || keyCode == KeyEvent.VK_7
keyCode == KeyEvent.VK_8 || || keyCode == KeyEvent.VK_8
keyCode == KeyEvent.VK_9; || keyCode == KeyEvent.VK_9;
if (numberKeyWasPressed && !FileConstants.TIME_CALC_PROFILES_TXT_FILE if (numberKeyWasPressed && !FileConstants.TIME_CALC_PROFILES_TXT_FILE
.exists()) { .exists()) {
@ -398,7 +465,7 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
case KeyEvent.VK_Y: { case KeyEvent.VK_Y: {
timeCalcConfiguration.smileysVisibleOnlyIfMouseMovingOverProperty timeCalcConfiguration.smileysVisibleOnlyIfMouseMovingOverProperty
.flip(); .flip();
if(timeCalcConfiguration.smileysVisibleOnlyIfMouseMovingOverProperty.isDisabled() && timeCalcConfiguration.smileysVisibleProperty.isDisabled()){ if (timeCalcConfiguration.smileysVisibleOnlyIfMouseMovingOverProperty.isDisabled() && timeCalcConfiguration.smileysVisibleProperty.isDisabled()) {
timeCalcConfiguration.smileysVisibleProperty.enable(); timeCalcConfiguration.smileysVisibleProperty.enable();
} }
break; break;
@ -428,31 +495,31 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
} }
case KeyEvent.VK_K: { case KeyEvent.VK_K: {
if(timeCalcConfiguration.clockVisibleProperty.isEnabled()) { if (timeCalcConfiguration.clockVisibleProperty.isEnabled()) {
timeCalcConfiguration.clockVisibleProperty.disable(); timeCalcConfiguration.clockVisibleProperty.disable();
} else { } else {
timeCalcConfiguration.clockVisibleProperty.enable(); timeCalcConfiguration.clockVisibleProperty.enable();
timeCalcConfiguration. clockHandsLongVisibleProperty.enable(); timeCalcConfiguration.clockHandsLongVisibleProperty.enable();
timeCalcConfiguration.clockHandsColoredProperty.enable(); timeCalcConfiguration.clockHandsColoredProperty.enable();
timeCalcConfiguration.clockHandsHourVisibleProperty.enable(); timeCalcConfiguration.clockHandsHourVisibleProperty.enable();
timeCalcConfiguration.clockHandsMinuteVisibleProperty.enable(); timeCalcConfiguration.clockHandsMinuteVisibleProperty.enable();
timeCalcConfiguration.clockHandsSecondVisibleProperty.enable(); timeCalcConfiguration.clockHandsSecondVisibleProperty.enable();
timeCalcConfiguration.clockHandsMillisecondVisibleProperty.enable(); timeCalcConfiguration.clockHandsMillisecondVisibleProperty.enable();
timeCalcConfiguration.clockBorderVisibleProperty.enable(); timeCalcConfiguration.clockBorderVisibleProperty.enable();
timeCalcConfiguration.clockBorderOnlyHoursProperty.disable(); timeCalcConfiguration.clockBorderOnlyHoursProperty.disable();
timeCalcConfiguration.clockNumbersVisibleProperty.enable(); timeCalcConfiguration.clockNumbersVisibleProperty.enable();
timeCalcConfiguration.clockCircleVisibleProperty.enable(); timeCalcConfiguration.clockCircleVisibleProperty.enable();
timeCalcConfiguration.clockCircleStrongBorderProperty.disable(); timeCalcConfiguration.clockCircleStrongBorderProperty.disable();
timeCalcConfiguration.clockCircleBorderColorProperty.setValue("0,0,255"); timeCalcConfiguration.clockCircleBorderColorProperty.setValue("0,0,255");
timeCalcConfiguration.clockCentreCircleVisibleProperty.enable(); timeCalcConfiguration.clockCentreCircleVisibleProperty.enable();
timeCalcConfiguration.clockCentreCircleBlackProperty.disable(); timeCalcConfiguration.clockCentreCircleBlackProperty.disable();
timeCalcConfiguration.clockProgressVisibleOnlyIfMouseMovingOverProperty.disable(); timeCalcConfiguration.clockProgressVisibleOnlyIfMouseMovingOverProperty.disable();
timeCalcConfiguration.clockDateVisibleOnlyIfMouseMovingOverProperty.disable(); timeCalcConfiguration.clockDateVisibleOnlyIfMouseMovingOverProperty.disable();
} }
break; break;
} }
default: default:
if(!numberKeyWasPressed) { if (!numberKeyWasPressed) {
Utils.showNotification( Utils.showNotification(
"Unsupported key was pressed. There is no key shortcut for this key: " "Unsupported key was pressed. There is no key shortcut for this key: "
+ keyCode); + keyCode);
@ -508,12 +575,11 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
if (profileName if (profileName
.equals(timeCalcConfiguration.profileNameProperty)) { .equals(timeCalcConfiguration.profileNameProperty)) {
Utils.showNotification("Profile \"" + profileName Utils.showNotification("Profile \"" + profileName
+ "\" is already active. Nothing to do", + "\" is already active. Nothing to do",
5000); 5000);
} else { } else {
Utils.showNotification("Info: Changing profile to: #" + profileNumber + " " + (( Utils.showNotification("Info: Changing profile to: #" + profileNumber + " " + ((profileName.isEmpty() ? "{Default profile}"
profileName.isEmpty() ? "{Default profile}" : : profileName)), 5000);
profileName)), 5000);
timeCalcConfiguration.saveToTimeCalcProperties(); timeCalcConfiguration.saveToTimeCalcProperties();
TimeCalcProperties.getInstance().loadProfile(profileName); TimeCalcProperties.getInstance().loadProfile(profileName);
timeCalcConfiguration.loadFromTimeCalcProperties( timeCalcConfiguration.loadFromTimeCalcProperties(
@ -532,14 +598,14 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
} }
private void switchProfile(boolean previous, boolean next) { private void switchProfile(boolean previous, boolean next) {
if((previous && next) || (!previous && !next)) { if ((previous && next) || (!previous && !next)) {
//nothing to do //nothing to do
return; return;
} }
Properties profiles = new Properties(); Properties profiles = new Properties();
try { try {
final String readTextFromFile = Utils.readTextFromFile(FileConstants.TIME_CALC_PROFILES_TXT_FILE); final String readTextFromFile = Utils.readTextFromFile(FileConstants.TIME_CALC_PROFILES_TXT_FILE);
if(readTextFromFile == null || readTextFromFile.isEmpty()) { if (readTextFromFile == null || readTextFromFile.isEmpty()) {
return; return;
} }
@ -549,7 +615,7 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
} catch (IOException ioException) { } catch (IOException ioException) {
ioException.printStackTrace(); ioException.printStackTrace();
} }
if(profiles.size() == 1) { if (profiles.size() == 1) {
return; return;
} }
@ -570,17 +636,17 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
} }
int numberOfCurrentProfile = next ? -1 : 9; int numberOfCurrentProfile = next ? -1 : 9;
for(Object number:profiles.keySet()) { for (Object number : profiles.keySet()) {
String profileName = (String) profiles.get(number); String profileName = (String) profiles.get(number);
if(profileName.equals(currentProfileName)) { if (profileName.equals(currentProfileName)) {
numberOfCurrentProfile = Integer.valueOf( numberOfCurrentProfile = Integer.valueOf(
(String) number); (String) number);
break; break;
} }
} }
for(int i = (numberOfCurrentProfile + (next ? 1 : -1)); next ? i <=9 : i >=0; i= next ? (i +1) : (i -1)) { for (int i = (numberOfCurrentProfile + (next ? 1 : -1)); next ? i <= 9 : i >= 0; i = next ? (i + 1) : (i - 1)) {
String number = String.valueOf(i); String number = String.valueOf(i);
if(!profiles.containsKey(number)) { if (!profiles.containsKey(number)) {
continue; continue;
} }

View File

@ -28,11 +28,11 @@ public class TimeCalcProperties {
System.out.println("Loading configuration - start"); System.out.println("Loading configuration - start");
String profileName = ""; String profileName = "";
try { try {
profileName = profileName
FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE.exists() ? = FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE.exists()
Utils.readTextFromFile( ? Utils.readTextFromFile(
FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE) : FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE)
""; : "";
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
throw new TimeCalcException(e); throw new TimeCalcException(e);
@ -115,6 +115,7 @@ public class TimeCalcProperties {
} }
return (String) properties.get(key); return (String) properties.get(key);
} }
public int getIntegerProperty(TimeCalcProperty timeCalcProperty) { public int getIntegerProperty(TimeCalcProperty timeCalcProperty) {
return getIntegerProperty(timeCalcProperty, return getIntegerProperty(timeCalcProperty,
Integer.valueOf(getDefaultStringValue(timeCalcProperty))); Integer.valueOf(getDefaultStringValue(timeCalcProperty)));
@ -128,6 +129,7 @@ public class TimeCalcProperties {
} }
return Integer.valueOf((String) properties.get(key)); return Integer.valueOf((String) properties.get(key));
} }
private String getVisibilityProperty(TimeCalcProperty timeCalcProperty) { private String getVisibilityProperty(TimeCalcProperty timeCalcProperty) {
return getStringProperty(timeCalcProperty, return getStringProperty(timeCalcProperty,
Visibility.STRONGLY_COLORED.name()); Visibility.STRONGLY_COLORED.name());
@ -153,15 +155,15 @@ public class TimeCalcProperties {
public void save(Properties properties, String profileName) { public void save(Properties properties, String profileName) {
properties.entrySet().stream().forEach(e properties.entrySet().stream().forEach(e
-> { -> {
if (this.properties.containsKey(e.getKey())) { if (this.properties.containsKey(e.getKey())) {
this.properties this.properties
.replace(e.getKey(), e.getValue().toString()); .replace(e.getKey(), e.getValue().toString());
} else { } else {
this.properties this.properties
.put(e.getKey(), e.getValue().toString()); .put(e.getKey(), e.getValue().toString());
} }
} }
); );
File file = getFile(profileName); File file = getFile(profileName);
try { try {
@ -178,9 +180,9 @@ public class TimeCalcProperties {
} }
private File getFile(String profileName) { private File getFile(String profileName) {
return profileName == null || profileName.isEmpty() ? return profileName == null || profileName.isEmpty()
FileConstants.FILE_WITHOUT_ANY_PROFILE : ? FileConstants.FILE_WITHOUT_ANY_PROFILE
new File(FileConstants.FILE_WITHOUT_ANY_PROFILE.getParentFile(), : new File(FileConstants.FILE_WITHOUT_ANY_PROFILE.getParentFile(),
"timecalc." + profileName + ".conf"); "timecalc." + profileName + ".conf");
} }

View File

@ -45,19 +45,16 @@ public enum TimeCalcProperty {
CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER( CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER(
"clock.date.visible-only-if-mouse-moving-over", "clock.date.visible-only-if-mouse-moving-over",
"Clock : Date visible only, if mouse moving over"), "Clock : Date visible only, if mouse moving over"),
// //
BATTERY_WAVES_VISIBLE("battery.waves.visible", "Battery : Waves"), BATTERY_WAVES_VISIBLE("battery.waves.visible", "Battery : Waves"),
BATTERY_CIRCLE_PROGRESS_VISIBLE("battery.circle-progress.visible", BATTERY_CIRCLE_PROGRESS_VISIBLE("battery.circle-progress.visible",
"Battery : Circle Progress"), "Battery : Circle Progress"),
BATTERY_PERCENT_PROGRESS_VISIBLE("battery.percent-progress.visible", BATTERY_PERCENT_PROGRESS_VISIBLE("battery.percent-progress.visible",
"Battery : Percent Progress"), "Battery : Percent Progress"),
BATTERY_CHARGING_CHARACTER_VISIBLE("battery.charging-character.visible", BATTERY_CHARGING_CHARACTER_VISIBLE("battery.charging-character.visible",
"Battery : Charging Character"), "Battery : Charging Character"),
BATTERY_NAME_VISIBLE("battery.name.visible", "Battery : Name"), BATTERY_NAME_VISIBLE("battery.name.visible", "Battery : Name"),
BATTERY_LABEL_VISIBLE("battery.label.visible", "Battery : Label"), BATTERY_LABEL_VISIBLE("battery.label.visible", "Battery : Label"),
BATTERY_VISIBLE("battery.visible", "Battery"), BATTERY_VISIBLE("battery.visible", "Battery"),
BATTERY_MINUTE_VISIBLE("battery.minute.visible", "Battery : Minute"), BATTERY_MINUTE_VISIBLE("battery.minute.visible", "Battery : Minute"),
BATTERY_HOUR_VISIBLE("battery.hour.visible", "Battery : Hour"), BATTERY_HOUR_VISIBLE("battery.hour.visible", "Battery : Hour"),
@ -67,7 +64,6 @@ public enum TimeCalcProperty {
BATTERY_YEAR_VISIBLE("battery.year.visible", "Battery : Year"), BATTERY_YEAR_VISIBLE("battery.year.visible", "Battery : Year"),
BATTERY_BLINKING_IF_CRITICAL_LOW("battery.blinking-if-critical-low", BATTERY_BLINKING_IF_CRITICAL_LOW("battery.blinking-if-critical-low",
"Battery : Blinking, if critical low"), "Battery : Blinking, if critical low"),
JOKES_VISIBLE("jokes.visible", "Jokes"), JOKES_VISIBLE("jokes.visible", "Jokes"),
COMMANDS_VISIBLE("commands.visible", "Commands"), COMMANDS_VISIBLE("commands.visible", "Commands"),
NOTIFICATIONS_VISIBLE("notifications.visible", "Notifications"), NOTIFICATIONS_VISIBLE("notifications.visible", "Notifications"),
@ -76,7 +72,6 @@ public enum TimeCalcProperty {
"smileys.visible-only-if-mouse-moving-over", "smileys.visible-only-if-mouse-moving-over",
"Smileys : Visible only, if mouse moving over"), "Smileys : Visible only, if mouse moving over"),
SMILEYS_COLORED("smileys.colored", "Smileys : Colored"), SMILEYS_COLORED("smileys.colored", "Smileys : Colored"),
SQUARE_VISIBLE("square.visible", "Square"), SQUARE_VISIBLE("square.visible", "Square"),
CIRCLE_VISIBLE("circle.visible", "Circle"), CIRCLE_VISIBLE("circle.visible", "Circle"),
WALKING_HUMAN_VISIBLE("walking-human.visible", "Walking Human"), WALKING_HUMAN_VISIBLE("walking-human.visible", "Walking Human"),
@ -109,8 +104,8 @@ public enum TimeCalcProperty {
} }
public static TimeCalcProperty forKey(String key) { public static TimeCalcProperty forKey(String key) {
Optional<TimeCalcProperty> timeCalcPropertyOptional = Optional<TimeCalcProperty> timeCalcPropertyOptional
Arrays.stream(values()).filter(t -> t.getKey().equals(key)) = Arrays.stream(values()).filter(t -> t.getKey().equals(key))
.findFirst(); .findFirst();
if (timeCalcPropertyOptional.isPresent()) { if (timeCalcPropertyOptional.isPresent()) {
return timeCalcPropertyOptional.get(); return timeCalcPropertyOptional.get();

View File

@ -33,9 +33,9 @@ public class Activity {
public String createBugzillaComment() { public String createBugzillaComment() {
return ticket + SUBJECT_FIELD_SEPARATOR + year + "-" + month + "-" + day return ticket + SUBJECT_FIELD_SEPARATOR + year + "-" + month + "-" + day
+ SUBJECT_FIELD_SEPARATOR + ((spentHours + spentMinutes / 60d) + SUBJECT_FIELD_SEPARATOR + ((spentHours + spentMinutes / 60d)
+ "h") + SUBJECT_FIELD_SEPARATOR + "h") + SUBJECT_FIELD_SEPARATOR
+ comment; + comment;
} }
} }

View File

@ -16,6 +16,7 @@ public class ActivityForStats extends Activity {
public ActivityForStats() { public ActivityForStats() {
} }
public List<ActivityForStats> createList(List<Activity> list) { public List<ActivityForStats> createList(List<Activity> list) {
return null;//todo return null;//todo
} }

View File

@ -10,9 +10,13 @@ import java.util.List;
* @since 23.02.2024 * @since 23.02.2024
*/ */
public interface ActivityRepositoryApi { public interface ActivityRepositoryApi {
void create(Activity activity); void create(Activity activity);
List<Activity> list(int year, int month, int day); List<Activity> list(int year, int month, int day);
void update(Activity activity); void update(Activity activity);
WorkingDay read(String id); WorkingDay read(String id);
} }

View File

@ -22,7 +22,7 @@ import java.sql.Connection;
/** /**
* *
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a> * @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
*/ */
public interface ConnectionFactory { public interface ConnectionFactory {

View File

@ -9,9 +9,13 @@ import java.util.List;
* @since 23.02.2024 * @since 23.02.2024
*/ */
public interface WorkingDayRepositoryApi { public interface WorkingDayRepositoryApi {
void create(WorkingDay workingDay); void create(WorkingDay workingDay);
List<WorkingDay> list(int year, int month); List<WorkingDay> list(int year, int month);
void update(WorkingDay workingDay); void update(WorkingDay workingDay);
WorkingDay read(int year, int month, int day); WorkingDay read(int year, int month, int day);
} }

View File

@ -18,7 +18,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.utils.timecalc.persistence.impl.sqlite; package org.nanoboot.utils.timecalc.persistence.impl.sqlite;
import org.nanoboot.utils.timecalc.persistence.api.ConnectionFactory; import org.nanoboot.utils.timecalc.persistence.api.ConnectionFactory;
import org.nanoboot.utils.timecalc.utils.common.FileConstants; import org.nanoboot.utils.timecalc.utils.common.FileConstants;
@ -31,14 +30,17 @@ import java.sql.SQLException;
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a> * @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
*/ */
public class SqliteConnectionFactory implements ConnectionFactory { public class SqliteConnectionFactory implements ConnectionFactory {
private final String jdbcUrl; private final String jdbcUrl;
private static String createJdbcUrl(String directoryWhereSqliteFileIs) { private static String createJdbcUrl(String directoryWhereSqliteFileIs) {
return "jdbc:sqlite:" + directoryWhereSqliteFileIs + "/" + ".time-calc.sqlite3?foreign_keys=on;"; return "jdbc:sqlite:" + directoryWhereSqliteFileIs + "/" + ".time-calc.sqlite3?foreign_keys=on;";
} }
public SqliteConnectionFactory() { public SqliteConnectionFactory() {
this(FileConstants.TC_DIRECTORY.getName()); this(FileConstants.TC_DIRECTORY.getName());
} }
public SqliteConnectionFactory(String directoryWhereSqliteFileIs) { public SqliteConnectionFactory(String directoryWhereSqliteFileIs) {
this.jdbcUrl = createJdbcUrl(directoryWhereSqliteFileIs); this.jdbcUrl = createJdbcUrl(directoryWhereSqliteFileIs);
} }

View File

@ -10,6 +10,7 @@ import java.util.List;
* @since 23.02.2024 * @since 23.02.2024
*/ */
public class WorkingDayRepositorySQLiteImpl implements WorkingDayRepositoryApi { public class WorkingDayRepositorySQLiteImpl implements WorkingDayRepositoryApi {
@Override @Override
public void create(WorkingDay workingDay) { public void create(WorkingDay workingDay) {
@ -31,9 +32,6 @@ public class WorkingDayRepositorySQLiteImpl implements WorkingDayRepositoryApi {
} }
} }
// private org.nanoboot.bitinspector.persistence.impl.sqlite.SqliteConnectionFactory // private org.nanoboot.bitinspector.persistence.impl.sqlite.SqliteConnectionFactory
// sqliteConnectionFactory; // sqliteConnectionFactory;
// //

View File

@ -20,9 +20,10 @@ package org.nanoboot.utils.timecalc.persistence.impl.sqlite;
/** /**
* *
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a> * @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
*/ */
class WorkingDayTable { class WorkingDayTable {
public static final String TABLE_NAME = "WORKING_DAY"; public static final String TABLE_NAME = "WORKING_DAY";
public static final String ID = "ID"; public static final String ID = "ID";
@ -44,5 +45,4 @@ class WorkingDayTable {
//Not meant to be instantiated. //Not meant to be instantiated.
} }
} }

View File

@ -36,7 +36,7 @@ public class ComponentRegistry<T extends Component> {
public void setVisible(Predicate<Component> predicate, boolean b) { public void setVisible(Predicate<Component> predicate, boolean b) {
for (T c : set) { for (T c : set) {
if (c instanceof TButton || c instanceof TTextField || c instanceof TLabel || c instanceof TCheckBox) { if (c instanceof TButton || c instanceof TTextField || c instanceof TLabel || c instanceof TCheckBox) {
if (!MainWindow.hideShowFormsCheckBox.isSelected() && b) { if (!MainWindow.hideShowFormsCheckBox.isSelected() && b) {
continue; continue;
} }

View File

@ -42,8 +42,8 @@ public class ConfigWindow extends TWindow {
public static final int WIDTH1 = 600; public static final int WIDTH1 = 600;
public static final int HEIGHT1 = 30; public static final int HEIGHT1 = 30;
public static final String CLIENT_PROPERTY_KEY = public static final String CLIENT_PROPERTY_KEY
TimeCalcProperty.class.getName(); = TimeCalcProperty.class.getName();
public static final String THREE_DASHES = "---"; public static final String THREE_DASHES = "---";
private static final Font BIG_FONT = new Font("sans", Font.BOLD, 24); private static final Font BIG_FONT = new Font("sans", Font.BOLD, 24);
private static final String FIVE_SPACES = " "; private static final String FIVE_SPACES = " ";
@ -55,13 +55,13 @@ public class ConfigWindow extends TWindow {
private int currentY = SwingUtils.MARGIN; private int currentY = SwingUtils.MARGIN;
private final List<JComponent> propertiesList = new ArrayList<>(); private final List<JComponent> propertiesList = new ArrayList<>();
private final Map<TimeCalcProperty, JComponent> propertiesMap = new HashMap<>(); private final Map<TimeCalcProperty, JComponent> propertiesMap = new HashMap<>();
private final TButton enableAsMuchAsPossible = private final TButton enableAsMuchAsPossible
new TButton("Enable as much as possible"); = new TButton("Enable as much as possible");
private final TButton disableAsMuchAsPossible = private final TButton disableAsMuchAsPossible
new TButton("Disable as much as possible"); = new TButton("Disable as much as possible");
private final JCheckBox visibilitySupportedColoredProperty private final JCheckBox visibilitySupportedColoredProperty
= new JCheckBox( = new JCheckBox(
TimeCalcProperty.VISIBILITY_SUPPORTED_COLORED.getKey()); TimeCalcProperty.VISIBILITY_SUPPORTED_COLORED.getKey());
private final JCheckBox clockVisibleProperty private final JCheckBox clockVisibleProperty
= new JCheckBox(TimeCalcProperty.CLOCK_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.CLOCK_VISIBLE.getKey());
private final JCheckBox clockHandsLongVisibleProperty private final JCheckBox clockHandsLongVisibleProperty
@ -71,14 +71,12 @@ public class ConfigWindow extends TWindow {
private final JCheckBox clockHandsHourVisibleProperty private final JCheckBox clockHandsHourVisibleProperty
= new JCheckBox(TimeCalcProperty.CLOCK_HANDS_HOUR_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.CLOCK_HANDS_HOUR_VISIBLE.getKey());
private final JCheckBox clockHandsMinuteVisibleProperty private final JCheckBox clockHandsMinuteVisibleProperty
= = new JCheckBox(TimeCalcProperty.CLOCK_HANDS_MINUTE_VISIBLE.getKey());
new JCheckBox(TimeCalcProperty.CLOCK_HANDS_MINUTE_VISIBLE.getKey());
private final JCheckBox clockHandsSecondVisibleProperty private final JCheckBox clockHandsSecondVisibleProperty
= = new JCheckBox(TimeCalcProperty.CLOCK_HANDS_SECOND_VISIBLE.getKey());
new JCheckBox(TimeCalcProperty.CLOCK_HANDS_SECOND_VISIBLE.getKey());
private final JCheckBox clockHandsMillisecondVisibleProperty private final JCheckBox clockHandsMillisecondVisibleProperty
= new JCheckBox( = new JCheckBox(
TimeCalcProperty.CLOCK_HANDS_MILLISECOND_VISIBLE.getKey()); TimeCalcProperty.CLOCK_HANDS_MILLISECOND_VISIBLE.getKey());
private final JCheckBox clockBorderVisibleProperty private final JCheckBox clockBorderVisibleProperty
= new JCheckBox(TimeCalcProperty.CLOCK_BORDER_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.CLOCK_BORDER_VISIBLE.getKey());
private final JCheckBox clockBorderOnlyHoursProperty private final JCheckBox clockBorderOnlyHoursProperty
@ -88,56 +86,54 @@ public class ConfigWindow extends TWindow {
private final JCheckBox clockCircleVisibleProperty private final JCheckBox clockCircleVisibleProperty
= new JCheckBox(TimeCalcProperty.CLOCK_CIRCLE_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.CLOCK_CIRCLE_VISIBLE.getKey());
private final JCheckBox clockCircleStrongBorderProperty private final JCheckBox clockCircleStrongBorderProperty
= = new JCheckBox(TimeCalcProperty.CLOCK_CIRCLE_STRONG_BORDER.getKey());
new JCheckBox(TimeCalcProperty.CLOCK_CIRCLE_STRONG_BORDER.getKey());
private final JColorChooser clockCircleBorderColorProperty private final JColorChooser clockCircleBorderColorProperty
= new JColorChooser(Color.BLACK); = new JColorChooser(Color.BLACK);
private final JCheckBox clockCentreCircleVisibleProperty private final JCheckBox clockCentreCircleVisibleProperty
= new JCheckBox( = new JCheckBox(
TimeCalcProperty.CLOCK_CENTRE_CIRCLE_VISIBLE.getKey()); TimeCalcProperty.CLOCK_CENTRE_CIRCLE_VISIBLE.getKey());
private final JCheckBox clockCentreCircleBlackProperty private final JCheckBox clockCentreCircleBlackProperty
= = new JCheckBox(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK.getKey());
new JCheckBox(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK.getKey());
private final JCheckBox clockProgressVisibleOnlyIfMouseMovingOverProperty private final JCheckBox clockProgressVisibleOnlyIfMouseMovingOverProperty
= new JCheckBox( = new JCheckBox(
TimeCalcProperty.CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER TimeCalcProperty.CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
.getKey()); .getKey());
private final JCheckBox clockDateVisibleOnlyIfMouseMovingOverProperty private final JCheckBox clockDateVisibleOnlyIfMouseMovingOverProperty
= new JCheckBox( = new JCheckBox(
TimeCalcProperty.CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER TimeCalcProperty.CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
.getKey()); .getKey());
// //
private final JCheckBox batteryWavesVisibleProperty private final JCheckBox batteryWavesVisibleProperty
= new JCheckBox(TimeCalcProperty.BATTERY_WAVES_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.BATTERY_WAVES_VISIBLE.getKey());
private final JCheckBox batteryCircleProgressVisibleProperty private final JCheckBox batteryCircleProgressVisibleProperty
= new JCheckBox( = new JCheckBox(
TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE.getKey()); TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE.getKey());
private final JCheckBox batteryPercentProgressProperty private final JCheckBox batteryPercentProgressProperty
= new JCheckBox( = new JCheckBox(
TimeCalcProperty.BATTERY_PERCENT_PROGRESS_VISIBLE.getKey()); TimeCalcProperty.BATTERY_PERCENT_PROGRESS_VISIBLE.getKey());
private final JCheckBox batteryChargingCharacterVisibleProperty private final JCheckBox batteryChargingCharacterVisibleProperty
= new JCheckBox( = new JCheckBox(
TimeCalcProperty.BATTERY_CHARGING_CHARACTER_VISIBLE.getKey()); TimeCalcProperty.BATTERY_CHARGING_CHARACTER_VISIBLE.getKey());
private final JCheckBox batteryNameVisibleProperty private final JCheckBox batteryNameVisibleProperty
= new JCheckBox(TimeCalcProperty.BATTERY_NAME_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.BATTERY_NAME_VISIBLE.getKey());
private final JCheckBox batteryLabelVisibleProperty = private final JCheckBox batteryLabelVisibleProperty
new JCheckBox(TimeCalcProperty.BATTERY_LABEL_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.BATTERY_LABEL_VISIBLE.getKey());
private final JCheckBox batteryVisibleProperty = private final JCheckBox batteryVisibleProperty
new JCheckBox(TimeCalcProperty.BATTERY_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.BATTERY_VISIBLE.getKey());
private final JCheckBox batteryMinuteVisibleProperty = private final JCheckBox batteryMinuteVisibleProperty
new JCheckBox(TimeCalcProperty.BATTERY_MINUTE_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.BATTERY_MINUTE_VISIBLE.getKey());
private final JCheckBox batteryHourVisibleProperty = private final JCheckBox batteryHourVisibleProperty
new JCheckBox(TimeCalcProperty.BATTERY_HOUR_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.BATTERY_HOUR_VISIBLE.getKey());
private final JCheckBox batteryDayVisibleProperty = private final JCheckBox batteryDayVisibleProperty
new JCheckBox(TimeCalcProperty.BATTERY_DAY_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.BATTERY_DAY_VISIBLE.getKey());
private final JCheckBox batteryWeekVisibleProperty = private final JCheckBox batteryWeekVisibleProperty
new JCheckBox(TimeCalcProperty.BATTERY_WEEK_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.BATTERY_WEEK_VISIBLE.getKey());
private final JCheckBox batteryMonthVisibleProperty = private final JCheckBox batteryMonthVisibleProperty
new JCheckBox(TimeCalcProperty.BATTERY_MONTH_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.BATTERY_MONTH_VISIBLE.getKey());
private final JCheckBox batteryYearVisibleProperty = private final JCheckBox batteryYearVisibleProperty
new JCheckBox(TimeCalcProperty.BATTERY_YEAR_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.BATTERY_YEAR_VISIBLE.getKey());
private final JCheckBox batteryBlinkingIfCriticalLowVisibleProperty = private final JCheckBox batteryBlinkingIfCriticalLowVisibleProperty
new JCheckBox( = new JCheckBox(
TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW.getKey()); TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW.getKey());
private final JCheckBox jokesVisibleProperty private final JCheckBox jokesVisibleProperty
= new JCheckBox(TimeCalcProperty.JOKES_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.JOKES_VISIBLE.getKey());
@ -147,8 +143,8 @@ public class ConfigWindow extends TWindow {
= new JCheckBox(TimeCalcProperty.NOTIFICATIONS_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.NOTIFICATIONS_VISIBLE.getKey());
private final JCheckBox smileysVisibleOnlyIfMouseMovingOverProperty private final JCheckBox smileysVisibleOnlyIfMouseMovingOverProperty
= new JCheckBox( = new JCheckBox(
TimeCalcProperty.SMILEYS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER TimeCalcProperty.SMILEYS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
.getKey()); .getKey());
private final JCheckBox smileysVisibleProperty private final JCheckBox smileysVisibleProperty
= new JCheckBox(TimeCalcProperty.SMILEYS_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.SMILEYS_VISIBLE.getKey());
private final JCheckBox smileysColoredProperty private final JCheckBox smileysColoredProperty
@ -177,6 +173,7 @@ public class ConfigWindow extends TWindow {
= new JTextField(TimeCalcProperty.TEST_CLOCK_CUSTOM_SECOND.getKey()); = new JTextField(TimeCalcProperty.TEST_CLOCK_CUSTOM_SECOND.getKey());
private final JTextField testClockCustomMillisecondProperty private final JTextField testClockCustomMillisecondProperty
= new JTextField(TimeCalcProperty.TEST_CLOCK_CUSTOM_MILLISECOND.getKey()); = new JTextField(TimeCalcProperty.TEST_CLOCK_CUSTOM_MILLISECOND.getKey());
public ConfigWindow(TimeCalcConfiguration timeCalcConfiguration) { public ConfigWindow(TimeCalcConfiguration timeCalcConfiguration) {
this.timeCalcConfiguration = timeCalcConfiguration; this.timeCalcConfiguration = timeCalcConfiguration;
setTitle("Configuration"); setTitle("Configuration");
@ -186,8 +183,8 @@ public class ConfigWindow extends TWindow {
mainPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, mainPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE,
getHeight() - 6 * SwingUtils.MARGIN)); getHeight() - 6 * SwingUtils.MARGIN));
this.panelInsideScrollPane = new JPanel(); this.panelInsideScrollPane = new JPanel();
final BoxLayout boxLayout = final BoxLayout boxLayout
new BoxLayout(panelInsideScrollPane, BoxLayout.Y_AXIS); = new BoxLayout(panelInsideScrollPane, BoxLayout.Y_AXIS);
panelInsideScrollPane.setAlignmentX(LEFT_ALIGNMENT); panelInsideScrollPane.setAlignmentX(LEFT_ALIGNMENT);
mainPanel.setAlignmentX(LEFT_ALIGNMENT); mainPanel.setAlignmentX(LEFT_ALIGNMENT);
@ -216,18 +213,18 @@ public class ConfigWindow extends TWindow {
mainPanel.add(disableAsMuchAsPossible); mainPanel.add(disableAsMuchAsPossible);
disableAsMuchAsPossible.setBounds( disableAsMuchAsPossible.setBounds(
enableAsMuchAsPossible.getX() + enableAsMuchAsPossible enableAsMuchAsPossible.getX() + enableAsMuchAsPossible
.getWidth() + SwingUtils.MARGIN, SwingUtils.MARGIN, 250, .getWidth() + SwingUtils.MARGIN, SwingUtils.MARGIN, 250,
HEIGHT1); HEIGHT1);
scrollPane.setBounds(enableAsMuchAsPossible.getX(), scrollPane.setBounds(enableAsMuchAsPossible.getX(),
enableAsMuchAsPossible.getY() + enableAsMuchAsPossible enableAsMuchAsPossible.getY() + enableAsMuchAsPossible
.getHeight() + SwingUtils.MARGIN, Integer.MAX_VALUE, .getHeight() + SwingUtils.MARGIN, Integer.MAX_VALUE,
Integer.MAX_VALUE); Integer.MAX_VALUE);
mainPanel.add(scrollPane); mainPanel.add(scrollPane);
for (boolean enable : new boolean[] {true, false}) { for (boolean enable : new boolean[]{true, false}) {
TButton button = TButton button
enable ? enableAsMuchAsPossible : disableAsMuchAsPossible; = enable ? enableAsMuchAsPossible : disableAsMuchAsPossible;
button.addActionListener(e -> { button.addActionListener(e -> {
visibilityDefaultProperty visibilityDefaultProperty
@ -376,8 +373,8 @@ public class ConfigWindow extends TWindow {
JComboBox jComboBox = ((JComboBox) p); JComboBox jComboBox = ((JComboBox) p);
jComboBox.setMaximumSize(new Dimension(150, 25)); jComboBox.setMaximumSize(new Dimension(150, 25));
String timeCalcPropertyKey = String timeCalcPropertyKey
(String) jComboBox.getClientProperty( = (String) jComboBox.getClientProperty(
CLIENT_PROPERTY_KEY); CLIENT_PROPERTY_KEY);
TimeCalcProperty timeCalcProperty TimeCalcProperty timeCalcProperty
= TimeCalcProperty.forKey(timeCalcPropertyKey); = TimeCalcProperty.forKey(timeCalcPropertyKey);
@ -404,7 +401,7 @@ public class ConfigWindow extends TWindow {
BooleanProperty property BooleanProperty property
= (BooleanProperty) timeCalcConfiguration = (BooleanProperty) timeCalcConfiguration
.getProperty(timeCalcProperty); .getProperty(timeCalcProperty);
property.addListener( property.addListener(
e -> checkBox.setSelected(property.isEnabled())); e -> checkBox.setSelected(property.isEnabled()));
checkBox.setSelected(property.isEnabled()); checkBox.setSelected(property.isEnabled());
@ -415,8 +412,8 @@ public class ConfigWindow extends TWindow {
String[] array = checkBox.getText().split(" : "); String[] array = checkBox.getText().split(" : ");
String groupName = array[0]; String groupName = array[0];
if (groupName.equals("Clock") || groupName.equals("Battery") if (groupName.equals("Clock") || groupName.equals("Battery")
|| groupName.equals("Smileys") || groupName.equals("Smileys")
|| groupName.equals("Test")) { || groupName.equals("Test")) {
checkBox.setText(array.length > 1 ? (checkBox.getText() checkBox.setText(array.length > 1 ? (checkBox.getText()
.substring(groupName.length() + 3)) : "Visible"); .substring(groupName.length() + 3)) : "Visible");
@ -428,11 +425,8 @@ public class ConfigWindow extends TWindow {
panelInsideScrollPane.add(label); panelInsideScrollPane.add(label);
} }
} }
if ( if (timeCalcProperty == TimeCalcProperty.VISIBILITY_DEFAULT
timeCalcProperty == TimeCalcProperty.VISIBILITY_DEFAULT || timeCalcProperty == TimeCalcProperty.JOKES_VISIBLE) {
||
timeCalcProperty == TimeCalcProperty.JOKES_VISIBLE
) {
JLabel label = new JLabel("Misc"); JLabel label = new JLabel("Misc");
label.setFont(BIG_FONT); label.setFont(BIG_FONT);
panelInsideScrollPane.add(label); panelInsideScrollPane.add(label);
@ -442,8 +436,8 @@ public class ConfigWindow extends TWindow {
JColorChooser colorChooser = ((JColorChooser) p); JColorChooser colorChooser = ((JColorChooser) p);
//jColorChooser.setMaximumSize(new Dimension(150, 25)); //jColorChooser.setMaximumSize(new Dimension(150, 25));
String timeCalcPropertyKey = String timeCalcPropertyKey
(String) colorChooser.getClientProperty( = (String) colorChooser.getClientProperty(
CLIENT_PROPERTY_KEY); CLIENT_PROPERTY_KEY);
TimeCalcProperty timeCalcProperty TimeCalcProperty timeCalcProperty
= TimeCalcProperty.forKey(timeCalcPropertyKey); = TimeCalcProperty.forKey(timeCalcPropertyKey);
@ -499,7 +493,7 @@ public class ConfigWindow extends TWindow {
} }
if (p instanceof JTextField) { if (p instanceof JTextField) {
JTextField textField = ((JTextField) p); JTextField textField = ((JTextField) p);
if(textField.getText().startsWith("test.clock.custom.")) { if (textField.getText().startsWith("test.clock.custom.")) {
String key = textField.getText(); String key = textField.getText();
textField.setText(""); textField.setText("");
textField.putClientProperty(CLIENT_PROPERTY_KEY, key); textField.putClientProperty(CLIENT_PROPERTY_KEY, key);
@ -507,8 +501,8 @@ public class ConfigWindow extends TWindow {
} }
textField.setMaximumSize(new Dimension(150, 25)); textField.setMaximumSize(new Dimension(150, 25));
String timeCalcPropertyKey = String timeCalcPropertyKey
(String) textField.getClientProperty( = (String) textField.getClientProperty(
CLIENT_PROPERTY_KEY); CLIENT_PROPERTY_KEY);
TimeCalcProperty timeCalcProperty TimeCalcProperty timeCalcProperty
= TimeCalcProperty.forKey(timeCalcPropertyKey); = TimeCalcProperty.forKey(timeCalcPropertyKey);
@ -517,20 +511,16 @@ public class ConfigWindow extends TWindow {
.getProperty(timeCalcProperty).addListener(e -> { .getProperty(timeCalcProperty).addListener(e -> {
textField.setText(isInteger textField.setText(isInteger
? ? String.valueOf(timeCalcConfiguration
String.valueOf(timeCalcConfiguration
.getProperty(timeCalcProperty).getValue()) .getProperty(timeCalcProperty).getValue())
: : (String) timeCalcConfiguration
(String) timeCalcConfiguration
.getProperty(timeCalcProperty).getValue()); .getProperty(timeCalcProperty).getValue());
}); });
textField.setText(isInteger textField.setText(isInteger
? ? String.valueOf(timeCalcConfiguration
String.valueOf(timeCalcConfiguration
.getProperty(timeCalcProperty).getValue()) .getProperty(timeCalcProperty).getValue())
: : (String) timeCalcConfiguration
(String) timeCalcConfiguration .getProperty(timeCalcProperty).getValue());
.getProperty(timeCalcProperty).getValue());
textField.getDocument() textField.getDocument()
.addDocumentListener(new DocumentListener() { .addDocumentListener(new DocumentListener() {
@ -543,13 +533,14 @@ public class ConfigWindow extends TWindow {
public void insertUpdate(DocumentEvent e) { public void insertUpdate(DocumentEvent e) {
update(e); update(e);
} }
private void update(DocumentEvent e) { private void update(DocumentEvent e) {
String text = textField.getText(); String text = textField.getText();
boolean isInteger = Integer.class == timeCalcProperty.getClazz(); boolean isInteger = Integer.class == timeCalcProperty.getClazz();
timeCalcConfiguration timeCalcConfiguration
.getProperty(timeCalcProperty) .getProperty(timeCalcProperty)
.setValue(isInteger ? Integer.valueOf(text): .setValue(isInteger ? Integer.valueOf(text)
text); : text);
} }
}); });
} }

View File

@ -30,11 +30,11 @@ public class HelpWindow extends TWindow {
} }
helpHtml = "<div style=\"font-family:sans;margin-bottom:20px;\">" helpHtml = "<div style=\"font-family:sans;margin-bottom:20px;\">"
+ helpHtml + "</div>"; + helpHtml + "</div>";
this.setLayout(null); this.setLayout(null);
JScrollPane scrollPane = JScrollPane scrollPane
new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setBounds(1, 1, scrollPane.setBounds(1, 1,
getWidth() - 2 * SwingUtils.MARGIN, getWidth() - 2 * SwingUtils.MARGIN,

View File

@ -80,6 +80,7 @@ public class MainWindow extends TWindow {
this.elapsedTextField = new TTextField("", 100); this.elapsedTextField = new TTextField("", 100);
this.remainingTextField = new TTextField("", 100); this.remainingTextField = new TTextField("", 100);
} }
public MainWindow(String startTimeIn, String overTimeIn, public MainWindow(String startTimeIn, String overTimeIn,
TimeCalcApp timeCalcApp) { TimeCalcApp timeCalcApp) {
setFocusable(true); setFocusable(true);
@ -104,21 +105,21 @@ public class MainWindow extends TWindow {
arrivalTextField.addVetoableChangeListener(e -> { arrivalTextField.addVetoableChangeListener(e -> {
String newValue = (String) e.getNewValue(); String newValue = (String) e.getNewValue();
if(newValue.isEmpty()) { if (newValue.isEmpty()) {
throw new PropertyVetoException("Arrival must not be empty.", new PropertyChangeEvent(e.getSource(), e.getPropertyName(), e.getOldValue(), e.getNewValue())); throw new PropertyVetoException("Arrival must not be empty.", new PropertyChangeEvent(e.getSource(), e.getPropertyName(), e.getOldValue(), e.getNewValue()));
} }
}); });
overtimeTextField.addVetoableChangeListener(e -> { overtimeTextField.addVetoableChangeListener(e -> {
String newValue = (String) e.getNewValue(); String newValue = (String) e.getNewValue();
if(newValue.isEmpty()) { if (newValue.isEmpty()) {
throw new PropertyVetoException("Overtime must not be empty.", new PropertyChangeEvent(e.getSource(), e.getPropertyName(), e.getOldValue(), e.getNewValue())); throw new PropertyVetoException("Overtime must not be empty.", new PropertyChangeEvent(e.getSource(), e.getPropertyName(), e.getOldValue(), e.getNewValue()));
} }
}); });
this.configButton = new TButton("Config"); this.configButton = new TButton("Config");
this.workDaysButton = new TButton("Work Days"); this.workDaysButton = new TButton("Work Days");
this.activitiesButton = new TButton("Activities" this.activitiesButton = new TButton("Activities"
+ ""); + "");
this.restartButton = new TButton("Restart"); this.restartButton = new TButton("Restart");
this.exitButton = new TButton("Exit"); this.exitButton = new TButton("Exit");
this.focusButton = new TButton("Focus"); this.focusButton = new TButton("Focus");
@ -139,14 +140,14 @@ public class MainWindow extends TWindow {
.isEnabled()) { .isEnabled()) {
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name()); timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
} }
if(Toaster.notificationsVisibleProperty.isBound()) { if (Toaster.notificationsVisibleProperty.isBound()) {
Toaster.notificationsVisibleProperty.unBound(); Toaster.notificationsVisibleProperty.unBound();
} }
Toaster.notificationsVisibleProperty.bindTo(timeCalcConfiguration.notificationsVisibleProperty); Toaster.notificationsVisibleProperty.bindTo(timeCalcConfiguration.notificationsVisibleProperty);
Time time = new Time(); Time time = new Time();
TimeCalcKeyAdapter timeCalcKeyAdapter = TimeCalcKeyAdapter timeCalcKeyAdapter
new TimeCalcKeyAdapter(timeCalcConfiguration, timeCalcApp, = new TimeCalcKeyAdapter(timeCalcConfiguration, timeCalcApp,
this, time); this, time);
addKeyListener(timeCalcKeyAdapter); addKeyListener(timeCalcKeyAdapter);
@ -182,8 +183,8 @@ public class MainWindow extends TWindow {
clock.setBounds(SwingUtils.MARGIN, SwingUtils.MARGIN, 200); clock.setBounds(SwingUtils.MARGIN, SwingUtils.MARGIN, 200);
add(clock); add(clock);
MinuteBattery minuteBattery = MinuteBattery minuteBattery
new MinuteBattery(clock.getBounds().x + clock.getWidth() + SwingUtils.MARGIN, = new MinuteBattery(clock.getBounds().x + clock.getWidth() + SwingUtils.MARGIN,
clock.getY(), BATTERY_WIDTH); clock.getY(), BATTERY_WIDTH);
add(minuteBattery); add(minuteBattery);
Battery hourBattery = new HourBattery( Battery hourBattery = new HourBattery(
@ -226,7 +227,7 @@ public class MainWindow extends TWindow {
.bindTo(timeCalcConfiguration.walkingHumanVisibleProperty); .bindTo(timeCalcConfiguration.walkingHumanVisibleProperty);
weatherButton weatherButton
.setBounds(SwingUtils.MARGIN, walkingHumanProgress.getY() .setBounds(SwingUtils.MARGIN, walkingHumanProgress.getY()
+ walkingHumanProgress.getHeight()); + walkingHumanProgress.getHeight());
// //
ProgressSquare progressSquare = new ProgressSquare(); ProgressSquare progressSquare = new ProgressSquare();
@ -241,7 +242,7 @@ public class MainWindow extends TWindow {
progressCircle progressCircle
.setBounds( .setBounds(
progressSquare.getX(), progressSquare.getY() + progressSquare.getHeight() progressSquare.getX(), progressSquare.getY() + progressSquare.getHeight()
+ SwingUtils.MARGIN, 100); + SwingUtils.MARGIN, 100);
add(progressCircle); add(progressCircle);
progressCircle.visibleProperty progressCircle.visibleProperty
.bindTo(timeCalcConfiguration.circleVisibleProperty); .bindTo(timeCalcConfiguration.circleVisibleProperty);
@ -317,9 +318,9 @@ public class MainWindow extends TWindow {
add(remainingTextField); add(remainingTextField);
add(saveButton); add(saveButton);
saveButton.addActionListener(e -> { saveButton.addActionListener(e -> {
TTime overtime_ =overtimeTextField.asTTime(); TTime overtime_ = overtimeTextField.asTTime();
Utils.writeTextToFile(FileConstants.STARTTIME_TXT, arrivalTextField.asTTime().toString().substring(0,5)); Utils.writeTextToFile(FileConstants.STARTTIME_TXT, arrivalTextField.asTTime().toString().substring(0, 5));
Utils.writeTextToFile(FileConstants.OVERTIME_TXT, overtime_.toString().substring(0,overtime_.isNegative() ? 6 : 5)); Utils.writeTextToFile(FileConstants.OVERTIME_TXT, overtime_.toString().substring(0, overtime_.isNegative() ? 6 : 5));
timeCalcConfiguration.saveToTimeCalcProperties(); timeCalcConfiguration.saveToTimeCalcProperties();
}); });
// //
@ -327,10 +328,9 @@ public class MainWindow extends TWindow {
workDaysButton.setBoundsFromLeft(configButton); workDaysButton.setBoundsFromLeft(configButton);
activitiesButton.setBoundsFromLeft(workDaysButton); activitiesButton.setBoundsFromLeft(workDaysButton);
exitButton.setBounds(saveButton.getX() + saveButton.getWidth() - activitiesButton.getWidth() , workDaysButton.getY(), activitiesButton.getWidth(), activitiesButton.getHeight()); exitButton.setBounds(saveButton.getX() + saveButton.getWidth() - activitiesButton.getWidth(), workDaysButton.getY(), activitiesButton.getWidth(), activitiesButton.getHeight());
restartButton.setBounds(exitButton.getX() - SwingUtils.MARGIN - activitiesButton.getWidth(), activitiesButton.getY(), activitiesButton.getWidth(), activitiesButton.getHeight()); restartButton.setBounds(exitButton.getX() - SwingUtils.MARGIN - activitiesButton.getWidth(), activitiesButton.getY(), activitiesButton.getWidth(), activitiesButton.getHeight());
// //
helpButton.setBoundsFromTop(exitButton, 2); helpButton.setBoundsFromTop(exitButton, 2);
focusButton.setBoundsFromLeft(helpButton); focusButton.setBoundsFromLeft(helpButton);
@ -462,8 +462,8 @@ public class MainWindow extends TWindow {
clock.visibleProperty clock.visibleProperty
.bindTo(timeCalcConfiguration.clockVisibleProperty); .bindTo(timeCalcConfiguration.clockVisibleProperty);
ComponentRegistry<Component> componentRegistry = ComponentRegistry<Component> componentRegistry
new ComponentRegistry(); = new ComponentRegistry();
componentRegistry.addAll(this.getContentPane().getComponents()); componentRegistry.addAll(this.getContentPane().getComponents());
ComponentRegistry<TButton> buttonRegistry = new ComponentRegistry(); ComponentRegistry<TButton> buttonRegistry = new ComponentRegistry();
@ -534,15 +534,15 @@ public class MainWindow extends TWindow {
componentRegistry.getSet().stream().filter(c -> c instanceof Widget) componentRegistry.getSet().stream().filter(c -> c instanceof Widget)
.forEach(c .forEach(c
-> { -> {
Widget widget = (Widget) c; Widget widget = (Widget) c;
widget.smileysVisibleProperty widget.smileysVisibleProperty
.bindTo(timeCalcConfiguration.smileysVisibleProperty); .bindTo(timeCalcConfiguration.smileysVisibleProperty);
widget.smileysVisibleOnlyIfMouseMovingOverProperty widget.smileysVisibleOnlyIfMouseMovingOverProperty
.bindTo(timeCalcConfiguration.smileysVisibleOnlyIfMouseMovingOverProperty); .bindTo(timeCalcConfiguration.smileysVisibleOnlyIfMouseMovingOverProperty);
widget.smileysColoredProperty widget.smileysColoredProperty
.bindTo(timeCalcConfiguration.smileysColoredProperty); .bindTo(timeCalcConfiguration.smileysColoredProperty);
} }
); );
setSize(progressSquare.getX() + progressSquare.getWidth() setSize(progressSquare.getX() + progressSquare.getWidth()
+ 3 * SwingUtils.MARGIN, + 3 * SwingUtils.MARGIN,
@ -608,7 +608,7 @@ public class MainWindow extends TWindow {
ComponentRegistry<Component> componentRegistry, TLabel arrivalTextFieldLabel) { ComponentRegistry<Component> componentRegistry, TLabel arrivalTextFieldLabel) {
//System.out.println("timeCalcConfiguration.handsLongProperty=" + timeCalcConfiguration.clockHandLongProperty.isEnabled()); //System.out.println("timeCalcConfiguration.handsLongProperty=" + timeCalcConfiguration.clockHandLongProperty.isEnabled());
if(!departureTextField.valueProperty.getValue().isEmpty() && !arrivalTextField.valueProperty.getValue().isEmpty()){ if (!departureTextField.valueProperty.getValue().isEmpty() && !arrivalTextField.valueProperty.getValue().isEmpty()) {
TTime startTime = arrivalTextField.asTTime(); TTime startTime = arrivalTextField.asTTime();
TTime endTime = departureTextField.asTTime(); TTime endTime = departureTextField.asTTime();
clock.startHourProperty.setValue(startTime.getHour()); clock.startHourProperty.setValue(startTime.getHour());
@ -626,11 +626,11 @@ public class MainWindow extends TWindow {
} catch (Exception e) { } catch (Exception e) {
} }
if(startTime == null || overtime == null) { if (startTime == null || overtime == null) {
return false; return false;
} }
TTime newDeparture = startTime.add(new TTime(8,30)); TTime newDeparture = startTime.add(new TTime(8, 30));
if(overtime.isNegative()) { if (overtime.isNegative()) {
TTime tmpTTime = overtime.cloneInstance(); TTime tmpTTime = overtime.cloneInstance();
tmpTTime.setNegative(false); tmpTTime.setNegative(false);
newDeparture = newDeparture.remove(tmpTTime); newDeparture = newDeparture.remove(tmpTTime);
@ -671,8 +671,8 @@ public class MainWindow extends TWindow {
} }
componentRegistry.setVisible(c -> (!(c instanceof Widget) componentRegistry.setVisible(c -> (!(c instanceof Widget)
|| ((Widget) c).visibleProperty || ((Widget) c).visibleProperty
.isEnabled()) /*|| (c instanceof TButton ? ((Widget)c).visibleProperty.isEnabled() .isEnabled()) /*|| (c instanceof TButton ? ((Widget)c).visibleProperty.isEnabled()
: true)*/, currentVisibility.isNotNone()); : true)*/, currentVisibility.isNotNone());
jokeButton.setVisible( jokeButton.setVisible(
@ -714,7 +714,7 @@ public class MainWindow extends TWindow {
TTime overtime = overtimeTextField.asTTime(); TTime overtime = overtimeTextField.asTTime();
int hourDone = (int) (Constants.WORKING_HOURS_LENGTH + overtime.getHour() int hourDone = (int) (Constants.WORKING_HOURS_LENGTH + overtime.getHour()
- timeRemains.getHour()); - timeRemains.getHour());
int totalMillisecondsDone int totalMillisecondsDone
= timeElapsed.toTotalMilliseconds(); = timeElapsed.toTotalMilliseconds();
@ -724,11 +724,11 @@ public class MainWindow extends TWindow {
int totalMilliseconds = timeTotal.toTotalMilliseconds(); int totalMilliseconds = timeTotal.toTotalMilliseconds();
double done = ((double) totalMillisecondsDone) double done = ((double) totalMillisecondsDone)
/ ((double) totalMilliseconds); / ((double) totalMilliseconds);
if(done < 0) { if (done < 0) {
done = 0; done = 0;
} }
if(done > 1) { if (done > 1) {
done = 1; done = 1;
} }
progressSquare.setDonePercent(done); progressSquare.setDonePercent(done);
@ -858,18 +858,22 @@ public class MainWindow extends TWindow {
this.configWindow.doDisableAlmostEverything(); this.configWindow.doDisableAlmostEverything();
} }
public void increaseArrivalByOneMinute() { public void increaseArrivalByOneMinute() {
arrivalTextField.valueProperty.setValue(new TTime(this.arrivalTextField.valueProperty.getValue()).add(new TTime(0, 1)).toString().substring(0, 5)); arrivalTextField.valueProperty.setValue(new TTime(this.arrivalTextField.valueProperty.getValue()).add(new TTime(0, 1)).toString().substring(0, 5));
} }
public void decreaseArrivalByOneMinute() { public void decreaseArrivalByOneMinute() {
arrivalTextField.valueProperty.setValue(new TTime(this.arrivalTextField.valueProperty.getValue()).remove(new TTime(0, 1)).toString().substring(0, 5)); arrivalTextField.valueProperty.setValue(new TTime(this.arrivalTextField.valueProperty.getValue()).remove(new TTime(0, 1)).toString().substring(0, 5));
} }
public void increaseOvertimeByOneMinute() { public void increaseOvertimeByOneMinute() {
TTime newOvertime = new TTime(this.overtimeTextField.valueProperty.getValue()).add(new TTime(0, 1)); TTime newOvertime = new TTime(this.overtimeTextField.valueProperty.getValue()).add(new TTime(0, 1));
overtimeTextField.valueProperty.setValue(newOvertime.toString().substring(0, newOvertime.isNegative() ? 6 :5)); overtimeTextField.valueProperty.setValue(newOvertime.toString().substring(0, newOvertime.isNegative() ? 6 : 5));
} }
public void decreaseOvertimeByOneMinute() { public void decreaseOvertimeByOneMinute() {
TTime newOvertime = new TTime(this.overtimeTextField.valueProperty.getValue()).remove(new TTime(0, 1)); TTime newOvertime = new TTime(this.overtimeTextField.valueProperty.getValue()).remove(new TTime(0, 1));
overtimeTextField.valueProperty.setValue(newOvertime.toString().substring(0, newOvertime.isNegative() ? 6 :5)); overtimeTextField.valueProperty.setValue(newOvertime.toString().substring(0, newOvertime.isNegative() ? 6 : 5));
} }
} }

View File

@ -11,8 +11,8 @@ public class SwingUtils {
public static final int MARGIN = 10; public static final int MARGIN = 10;
public static final Font SMALL_FONT = new Font("sans", Font.BOLD, 10); public static final Font SMALL_FONT = new Font("sans", Font.BOLD, 10);
public static final Font MEDIUM_MONOSPACE_FONT = public static final Font MEDIUM_MONOSPACE_FONT
new Font(Font.MONOSPACED, Font.PLAIN, 12); = new Font(Font.MONOSPACED, Font.PLAIN, 12);
private SwingUtils() { private SwingUtils() {
//Not meant to be instantiated. //Not meant to be instantiated.

View File

@ -25,7 +25,7 @@ public class TButton extends JButton implements GetProperty {
= new BooleanProperty("visibleProperty", true); = new BooleanProperty("visibleProperty", true);
public StringProperty visibilityProperty public StringProperty visibilityProperty
= new StringProperty("visibilityProperty", = new StringProperty("visibilityProperty",
Visibility.STRONGLY_COLORED.name()); Visibility.STRONGLY_COLORED.name());
private Color originalBackground; private Color originalBackground;
private Color originalForeground; private Color originalForeground;
private int customWidth = 0; private int customWidth = 0;
@ -33,6 +33,7 @@ public class TButton extends JButton implements GetProperty {
public TButton(String label) { public TButton(String label) {
this(label, 0); this(label, 0);
} }
public TButton(String label, int customWidth) { public TButton(String label, int customWidth) {
super(label); super(label);
this.customWidth = customWidth; this.customWidth = customWidth;
@ -81,8 +82,8 @@ public class TButton extends JButton implements GetProperty {
public void setBoundsFromTop(JComponent jComponent, int marginCount) { public void setBoundsFromTop(JComponent jComponent, int marginCount) {
setBounds(SwingUtils.MARGIN, jComponent.getY() setBounds(SwingUtils.MARGIN, jComponent.getY()
+ jComponent.getHeight() + jComponent.getHeight()
+ marginCount * SwingUtils.MARGIN); + marginCount * SwingUtils.MARGIN);
} }
@Override @Override

View File

@ -21,6 +21,7 @@ public class TCheckBox extends JCheckBox implements GetProperty {
private static final int HEIGHT = 30; private static final int HEIGHT = 30;
private Color originalBackground; private Color originalBackground;
private Color originalForeground; private Color originalForeground;
public TCheckBox(String text) { public TCheckBox(String text) {
this(text, false); this(text, false);
} }
@ -30,15 +31,16 @@ public class TCheckBox extends JCheckBox implements GetProperty {
= new BooleanProperty("visibleProperty", true); = new BooleanProperty("visibleProperty", true);
public StringProperty visibilityProperty public StringProperty visibilityProperty
= new StringProperty("visibilityProperty", = new StringProperty("visibilityProperty",
Visibility.STRONGLY_COLORED.name()); Visibility.STRONGLY_COLORED.name());
public TCheckBox(String text, boolean b) { public TCheckBox(String text, boolean b) {
super(text, b); super(text, b);
valueProperty.setValue(b); valueProperty.setValue(b);
addActionListener( e -> valueProperty.setValue(isSelected())); addActionListener(e -> valueProperty.setValue(isSelected()));
valueProperty.addListener(e -> valueProperty.addListener(e
{ -> {
if (valueProperty.getValue().equals(getText())) { if (valueProperty.getValue().equals(getText())) {
setSelected(valueProperty.isEnabled()); setSelected(valueProperty.isEnabled());
} }
@ -64,6 +66,7 @@ public class TCheckBox extends JCheckBox implements GetProperty {
}).start(); }).start();
} }
public final BooleanProperty valueProperty = new BooleanProperty(""); public final BooleanProperty valueProperty = new BooleanProperty("");
public void setBounds(int x, int y) { public void setBounds(int x, int y) {
setBounds(x, y, WIDTH, HEIGHT); setBounds(x, y, WIDTH, HEIGHT);
this.originalBackground = getBackground(); this.originalBackground = getBackground();
@ -81,9 +84,10 @@ public class TCheckBox extends JCheckBox implements GetProperty {
public void setBoundsFromTop(JComponent jComponent, int marginCount) { public void setBoundsFromTop(JComponent jComponent, int marginCount) {
setBounds(SwingUtils.MARGIN, jComponent.getY() setBounds(SwingUtils.MARGIN, jComponent.getY()
+ jComponent.getHeight() + jComponent.getHeight()
+ marginCount * SwingUtils.MARGIN); + marginCount * SwingUtils.MARGIN);
} }
public void setOriginalBackground() { public void setOriginalBackground() {
this.setBackground(originalBackground); this.setBackground(originalBackground);
} }
@ -91,6 +95,7 @@ public class TCheckBox extends JCheckBox implements GetProperty {
public void setOriginalForeground() { public void setOriginalForeground() {
this.setForeground(originalForeground); this.setForeground(originalForeground);
} }
@Override @Override
public Property getVisibilityProperty() { public Property getVisibilityProperty() {
return visibilityProperty; return visibilityProperty;

View File

@ -28,10 +28,12 @@ public class TLabel extends JLabel implements GetProperty {
= new BooleanProperty("visibleProperty", true); = new BooleanProperty("visibleProperty", true);
public StringProperty visibilityProperty public StringProperty visibilityProperty
= new StringProperty("visibilityProperty", = new StringProperty("visibilityProperty",
Visibility.STRONGLY_COLORED.name()); Visibility.STRONGLY_COLORED.name());
public TLabel(String text) { public TLabel(String text) {
this(text, 0); this(text, 0);
} }
public TLabel(String text, int customWidth) { public TLabel(String text, int customWidth) {
super(text); super(text);
this.customWidth = customWidth; this.customWidth = customWidth;
@ -61,7 +63,6 @@ public class TLabel extends JLabel implements GetProperty {
this.originalForeground = getForeground(); this.originalForeground = getForeground();
} }
public void setBoundsFromLeft(JComponent jComponent) { public void setBoundsFromLeft(JComponent jComponent) {
setBounds(jComponent.getX() + jComponent.getWidth() + SwingUtils.MARGIN, setBounds(jComponent.getX() + jComponent.getWidth() + SwingUtils.MARGIN,
jComponent.getY()); jComponent.getY());
@ -73,9 +74,10 @@ public class TLabel extends JLabel implements GetProperty {
public void setBoundsFromTop(JComponent jComponent, int marginCount) { public void setBoundsFromTop(JComponent jComponent, int marginCount) {
setBounds(SwingUtils.MARGIN, jComponent.getY() setBounds(SwingUtils.MARGIN, jComponent.getY()
+ jComponent.getHeight() + jComponent.getHeight()
+ marginCount * SwingUtils.MARGIN); + marginCount * SwingUtils.MARGIN);
} }
public void setOriginalBackground() { public void setOriginalBackground() {
this.setBackground(originalBackground); this.setBackground(originalBackground);
} }
@ -83,6 +85,7 @@ public class TLabel extends JLabel implements GetProperty {
public void setOriginalForeground() { public void setOriginalForeground() {
this.setForeground(originalForeground); this.setForeground(originalForeground);
} }
@Override @Override
public Property getVisibilityProperty() { public Property getVisibilityProperty() {
return visibilityProperty; return visibilityProperty;

View File

@ -31,14 +31,17 @@ public class TTextField extends JTextField implements GetProperty {
= new BooleanProperty("visibleProperty", true); = new BooleanProperty("visibleProperty", true);
public StringProperty visibilityProperty public StringProperty visibilityProperty
= new StringProperty("visibilityProperty", = new StringProperty("visibilityProperty",
Visibility.STRONGLY_COLORED.name()); Visibility.STRONGLY_COLORED.name());
public final StringProperty valueProperty = new StringProperty(); public final StringProperty valueProperty = new StringProperty();
public TTextField() { public TTextField() {
this("", 0); this("", 0);
} }
public TTextField(String s) { public TTextField(String s) {
this(s, 0); this(s, 0);
} }
public TTextField(String s, int customWidth) { public TTextField(String s, int customWidth) {
super(s); super(s);
this.customWidth = customWidth; this.customWidth = customWidth;
@ -56,13 +59,14 @@ public class TTextField extends JTextField implements GetProperty {
public void insertUpdate(DocumentEvent e) { public void insertUpdate(DocumentEvent e) {
update(e); update(e);
} }
private void update(DocumentEvent e) { private void update(DocumentEvent e) {
valueProperty.setValue(getText()); valueProperty.setValue(getText());
} }
}); });
valueProperty.addListener(e -> valueProperty.addListener(e
{ -> {
if (!valueProperty.getValue().equals(getText())) { if (!valueProperty.getValue().equals(getText())) {
setText(valueProperty.getValue()); setText(valueProperty.getValue());
} }
@ -93,9 +97,11 @@ public class TTextField extends JTextField implements GetProperty {
this.originalBackground = getBackground(); this.originalBackground = getBackground();
this.originalForeground = getForeground(); this.originalForeground = getForeground();
} }
public void setBoundsFromLeft(JComponent jComponent) { public void setBoundsFromLeft(JComponent jComponent) {
setBoundsFromLeft(jComponent, 0); setBoundsFromLeft(jComponent, 0);
} }
public void setBoundsFromLeft(JComponent jComponent, int additionalY) { public void setBoundsFromLeft(JComponent jComponent, int additionalY) {
setBounds(jComponent.getX() + jComponent.getWidth() + SwingUtils.MARGIN, setBounds(jComponent.getX() + jComponent.getWidth() + SwingUtils.MARGIN,
jComponent.getY() + additionalY); jComponent.getY() + additionalY);
@ -107,9 +113,10 @@ public class TTextField extends JTextField implements GetProperty {
public void setBoundsFromTop(JComponent jComponent, int marginCount) { public void setBoundsFromTop(JComponent jComponent, int marginCount) {
setBounds(SwingUtils.MARGIN, jComponent.getY() setBounds(SwingUtils.MARGIN, jComponent.getY()
+ jComponent.getHeight() + jComponent.getHeight()
+ marginCount * SwingUtils.MARGIN); + marginCount * SwingUtils.MARGIN);
} }
public void setOriginalBackground() { public void setOriginalBackground() {
this.setBackground(originalBackground); this.setBackground(originalBackground);
} }
@ -117,6 +124,7 @@ public class TTextField extends JTextField implements GetProperty {
public void setOriginalForeground() { public void setOriginalForeground() {
this.setForeground(originalForeground); this.setForeground(originalForeground);
} }
@Override @Override
public Property getVisibilityProperty() { public Property getVisibilityProperty() {
return visibilityProperty; return visibilityProperty;
@ -126,9 +134,9 @@ public class TTextField extends JTextField implements GetProperty {
public Property getVisibilitySupportedColoredProperty() { public Property getVisibilitySupportedColoredProperty() {
return visibilitySupportedColoredProperty; return visibilitySupportedColoredProperty;
} }
public TTime asTTime() { public TTime asTTime() {
return new TTime(valueProperty.getValue()); return new TTime(valueProperty.getValue());
} }
} }

View File

@ -24,7 +24,6 @@ package org.nanoboot.utils.timecalc.swing.common;
* // Show a simple toaster toasterManager.showToaster( new ImageIcon( * // Show a simple toaster toasterManager.showToaster( new ImageIcon(
* "mylogo.gif" ), "A simple toaster with an image" ); } } * "mylogo.gif" ), "A simple toaster with an image" ); } }
*/ */
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JButton; import javax.swing.JButton;
@ -437,9 +436,8 @@ public class Toaster {
stopYPosition = startYPosition - toasterHeight - 1; stopYPosition = startYPosition - toasterHeight - 1;
if (currentNumberOfToaster > 0) { if (currentNumberOfToaster > 0) {
stopYPosition stopYPosition
= = stopYPosition - (maxToaster % maxToasterInSceen
stopYPosition - (maxToaster % maxToasterInSceen * toasterHeight);
* toasterHeight);
} else { } else {
maxToaster = 0; maxToaster = 0;
} }
@ -449,9 +447,8 @@ public class Toaster {
if (currentNumberOfToaster > 0) { if (currentNumberOfToaster > 0) {
stopYPosition stopYPosition
= = stopYPosition + (maxToaster % maxToasterInSceen
stopYPosition + (maxToaster % maxToasterInSceen * toasterHeight);
* toasterHeight);
} else { } else {
maxToaster = 0; maxToaster = 0;
} }

View File

@ -86,7 +86,7 @@ public class WeatherWindow extends JFrame {
jep.setContentType("text/html"); jep.setContentType("text/html");
jep.setText("<html><head><meta charset=\"UTF-8\"></head><body>" jep.setText("<html><head><meta charset=\"UTF-8\"></head><body>"
+ pocasiHtml + "</body></html>"); + pocasiHtml + "</body></html>");
Utils.writeTextToFile(new File("aaa"), Utils.writeTextToFile(new File("aaa"),
"<html><head><meta charset=\"UTF-8\"></head><body>" "<html><head><meta charset=\"UTF-8\"></head><body>"
+ pocasiHtml + "</body></html>"); + pocasiHtml + "</body></html>");

View File

@ -14,6 +14,7 @@ import java.util.Calendar;
*/ */
@Getter @Getter
public class WeekStatistics { public class WeekStatistics {
private final boolean nowIsWeekend; private final boolean nowIsWeekend;
private final int workDaysDone; private final int workDaysDone;
private final int workDaysTotal; private final int workDaysTotal;
@ -26,11 +27,11 @@ public class WeekStatistics {
int currentDayOfMonth = analogClock.dayProperty.getValue(); int currentDayOfMonth = analogClock.dayProperty.getValue();
for (int dayOfMonth = 1; for (int dayOfMonth = 1;
dayOfMonth <= time.asCalendar() dayOfMonth <= time.asCalendar()
.getActualMaximum(Calendar.DAY_OF_MONTH); .getActualMaximum(Calendar.DAY_OF_MONTH);
dayOfMonth++) { dayOfMonth++) {
DayOfWeek dayOfWeek = DayOfWeek dayOfWeek
LocalDate.of(analogClock.yearProperty.getValue(), = LocalDate.of(analogClock.yearProperty.getValue(),
analogClock.monthProperty.getValue(), analogClock.monthProperty.getValue(),
dayOfMonth) dayOfMonth)
.getDayOfWeek(); .getDayOfWeek();
@ -52,9 +53,9 @@ public class WeekStatistics {
analogClock.dayProperty.getValue()).getDayOfWeek() analogClock.dayProperty.getValue()).getDayOfWeek()
.toString(); .toString();
this.nowIsWeekend = currentDayOfWeekAsString.equals("SATURDAY") this.nowIsWeekend = currentDayOfWeekAsString.equals("SATURDAY")
|| currentDayOfWeekAsString.equals("SUNDAY"); || currentDayOfWeekAsString.equals("SUNDAY");
workDaysTotalTmp = workDaysTotalTmp
workDaysDoneTmp + (nowIsWeekend ? 0 : 1) + workDaysTodoTmp; = workDaysDoneTmp + (nowIsWeekend ? 0 : 1) + workDaysTodoTmp;
this.workDaysDone = workDaysDoneTmp; this.workDaysDone = workDaysDoneTmp;
this.workDaysTotal = workDaysTotalTmp; this.workDaysTotal = workDaysTotalTmp;
// System.out.println("currentDayOfWeekAsString=" + currentDayOfWeekAsString); // System.out.println("currentDayOfWeekAsString=" + currentDayOfWeekAsString);

View File

@ -36,8 +36,8 @@ public class Widget extends JPanel implements
protected static final Font BIG_FONT = new Font("sans", Font.BOLD, 24); protected static final Font BIG_FONT = new Font("sans", Font.BOLD, 24);
protected static final Font MEDIUM_FONT = new Font("sans", Font.BOLD, 16); protected static final Font MEDIUM_FONT = new Font("sans", Font.BOLD, 16);
public static final Color CLOSE_BUTTON_FOREGROUND_COLOR = public static final Color CLOSE_BUTTON_FOREGROUND_COLOR
new Color(127, 127, 127); = new Color(127, 127, 127);
public static final Color CLOSE_BUTTON_BACKGROUND_COLOR = Color.LIGHT_GRAY; public static final Color CLOSE_BUTTON_BACKGROUND_COLOR = Color.LIGHT_GRAY;
public static final Color CLOSE_BUTTON_BACKGROUND_COLOR_MOUSE_OVER_CLOSE_ICON = new Color(255, 153, 153); public static final Color CLOSE_BUTTON_BACKGROUND_COLOR_MOUSE_OVER_CLOSE_ICON = new Color(255, 153, 153);
public final BooleanProperty visibilitySupportedColoredProperty public final BooleanProperty visibilitySupportedColoredProperty
@ -48,13 +48,13 @@ public class Widget extends JPanel implements
= new BooleanProperty(TimeCalcProperty.SMILEYS_VISIBLE.getKey()); = new BooleanProperty(TimeCalcProperty.SMILEYS_VISIBLE.getKey());
public final BooleanProperty smileysVisibleOnlyIfMouseMovingOverProperty public final BooleanProperty smileysVisibleOnlyIfMouseMovingOverProperty
= new BooleanProperty( = new BooleanProperty(
TimeCalcProperty.SMILEYS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER TimeCalcProperty.SMILEYS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
.getKey()); .getKey());
public final BooleanProperty smileysColoredProperty public final BooleanProperty smileysColoredProperty
= new BooleanProperty("smileysColoredProperty", true); = new BooleanProperty("smileysColoredProperty", true);
public StringProperty visibilityProperty public StringProperty visibilityProperty
= new StringProperty("widget.visibilityProperty", = new StringProperty("widget.visibilityProperty",
Visibility.STRONGLY_COLORED.name()); Visibility.STRONGLY_COLORED.name());
protected int side = 0; protected int side = 0;
protected double donePercent = 0; protected double donePercent = 0;
protected boolean mouseOver = false; protected boolean mouseOver = false;
@ -77,7 +77,7 @@ public class Widget extends JPanel implements
int x = e.getX(); int x = e.getX();
int y = e.getY(); int y = e.getY();
mouseOverCloseButton = x >= getWidth() - CLOSE_BUTTON_SIDE mouseOverCloseButton = x >= getWidth() - CLOSE_BUTTON_SIDE
&& y <= CLOSE_BUTTON_SIDE; && y <= CLOSE_BUTTON_SIDE;
} }
}); });
addMouseListener(new MouseListener() { addMouseListener(new MouseListener() {
@ -185,7 +185,7 @@ public class Widget extends JPanel implements
private static void paintCloseIcon(Graphics brush, int width, private static void paintCloseIcon(Graphics brush, int width,
boolean mouseOver, boolean mouseOverCloseButton) { boolean mouseOver, boolean mouseOverCloseButton) {
if(!mouseOver) { if (!mouseOver) {
//nothing to do //nothing to do
return; return;
} }
@ -194,7 +194,7 @@ public class Widget extends JPanel implements
// return; // return;
// } // }
brush.setColor(mouseOverCloseButton ? CLOSE_BUTTON_BACKGROUND_COLOR_MOUSE_OVER_CLOSE_ICON : CLOSE_BUTTON_BACKGROUND_COLOR); brush.setColor(mouseOverCloseButton ? CLOSE_BUTTON_BACKGROUND_COLOR_MOUSE_OVER_CLOSE_ICON : CLOSE_BUTTON_BACKGROUND_COLOR);
// if(!mouseOverCloseButton) { // if(!mouseOverCloseButton) {
// brush.drawRect(width - CLOSE_BUTTON_SIDE - 1, 0 + 1, CLOSE_BUTTON_SIDE, // brush.drawRect(width - CLOSE_BUTTON_SIDE - 1, 0 + 1, CLOSE_BUTTON_SIDE,
@ -203,7 +203,6 @@ public class Widget extends JPanel implements
// CLOSE_BUTTON_SIDE - 2); // CLOSE_BUTTON_SIDE - 2);
// return; // return;
// } // }
brush.fillOval(width - CLOSE_BUTTON_SIDE - 1, 0 + 1, CLOSE_BUTTON_SIDE, brush.fillOval(width - CLOSE_BUTTON_SIDE - 1, 0 + 1, CLOSE_BUTTON_SIDE,
CLOSE_BUTTON_SIDE); CLOSE_BUTTON_SIDE);
brush.setColor(CLOSE_BUTTON_FOREGROUND_COLOR); brush.setColor(CLOSE_BUTTON_FOREGROUND_COLOR);
@ -234,8 +233,8 @@ public class Widget extends JPanel implements
protected void paintSmiley(Visibility visibility, Graphics2D brush, int x, protected void paintSmiley(Visibility visibility, Graphics2D brush, int x,
int y) { int y) {
if (smileysVisibleProperty.isDisabled() || (!mouseOver if (smileysVisibleProperty.isDisabled() || (!mouseOver
&& smileysVisibleOnlyIfMouseMovingOverProperty && smileysVisibleOnlyIfMouseMovingOverProperty
.isEnabled())) { .isEnabled())) {
if (this.smileyIcon != null) { if (this.smileyIcon != null) {
this.remove(smileyIcon); this.remove(smileyIcon);
this.smileyIcon = null; this.smileyIcon = null;
@ -264,8 +263,8 @@ public class Widget extends JPanel implements
brush.setColor(Color.BLACK); brush.setColor(Color.BLACK);
} }
Color currentColor = brush.getColor(); Color currentColor = brush.getColor();
brush.setColor(visibility.isStronglyColored() ? Color.WHITE : brush.setColor(visibility.isStronglyColored() ? Color.WHITE
BACKGROUND_COLOR); : BACKGROUND_COLOR);
brush.fillRect( brush.fillRect(
x, y, x, y,
20, 20,
@ -291,6 +290,7 @@ public class Widget extends JPanel implements
this.add(smileyIcon); this.add(smileyIcon);
} }
} }
protected boolean changedInTheLastXMilliseconds(int milliseconds) { protected boolean changedInTheLastXMilliseconds(int milliseconds) {
return (System.nanoTime() - lastUpdate) < milliseconds * 1000000; return (System.nanoTime() - lastUpdate) < milliseconds * 1000000;
} }

View File

@ -26,39 +26,39 @@ public class AnalogClock extends Widget {
public static final Color COLOR_FOR_MILLISECOND_HAND_STRONGLY_COLORED public static final Color COLOR_FOR_MILLISECOND_HAND_STRONGLY_COLORED
= new Color(246, = new Color(246,
152, 51); 152, 51);
public final BooleanProperty borderVisibleProperty public final BooleanProperty borderVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_VISIBLE = new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_VISIBLE
.getKey()); .getKey());
public final BooleanProperty borderOnlyHoursProperty public final BooleanProperty borderOnlyHoursProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_ONLY_HOURS = new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_ONLY_HOURS
.getKey()); .getKey());
public final BooleanProperty numbersVisibleProperty public final BooleanProperty numbersVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_NUMBERS_VISIBLE = new BooleanProperty(TimeCalcProperty.CLOCK_NUMBERS_VISIBLE
.getKey()); .getKey());
public final BooleanProperty circleVisibleProperty public final BooleanProperty circleVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_VISIBLE = new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_VISIBLE
.getKey()); .getKey());
public final BooleanProperty circleStrongBorderProperty public final BooleanProperty circleStrongBorderProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_STRONG_BORDER = new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_STRONG_BORDER
.getKey()); .getKey());
public final BooleanProperty centreCircleVisibleProperty public final BooleanProperty centreCircleVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_VISIBLE = new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_VISIBLE
.getKey()); .getKey());
public final StringProperty centreCircleBorderColorProperty public final StringProperty centreCircleBorderColorProperty
= new StringProperty(TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR = new StringProperty(TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR
.getKey()); .getKey());
public final BooleanProperty centreCircleBlackProperty public final BooleanProperty centreCircleBlackProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK = new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK
.getKey()); .getKey());
public final BooleanProperty progressVisibleOnlyIfMouseMovingOverProperty public final BooleanProperty progressVisibleOnlyIfMouseMovingOverProperty
= new BooleanProperty( = new BooleanProperty(
TimeCalcProperty.CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER TimeCalcProperty.CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
.getKey()); .getKey());
public final BooleanProperty dateVisibleOnlyIfMouseMovingOverProperty public final BooleanProperty dateVisibleOnlyIfMouseMovingOverProperty
= new BooleanProperty( = new BooleanProperty(
TimeCalcProperty.CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER TimeCalcProperty.CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
.getKey()); .getKey());
public IntegerProperty startHourProperty public IntegerProperty startHourProperty
= new IntegerProperty("startHourProperty"); = new IntegerProperty("startHourProperty");
@ -100,24 +100,29 @@ public class AnalogClock extends Widget {
centreCircleBorderColorProperty.addListener(property centreCircleBorderColorProperty.addListener(property
-> customCircleColor = SwingUtils.getColorFromString( -> customCircleColor = SwingUtils.getColorFromString(
centreCircleBorderColorProperty.getValue())); centreCircleBorderColorProperty.getValue()));
} }
private int computeStartAngle() { private int computeStartAngle() {
return computeAngle(startHourProperty.getValue(), startMinuteProperty.getValue()); return computeAngle(startHourProperty.getValue(), startMinuteProperty.getValue());
} }
private int computeEndAngle() { private int computeEndAngle() {
return computeAngle(endHourProperty.getValue(), endMinuteProperty.getValue()); return computeAngle(endHourProperty.getValue(), endMinuteProperty.getValue());
} }
private int computeAngle(TTime TTime) { private int computeAngle(TTime TTime) {
if (TTime.getHour() > 12) { if (TTime.getHour() > 12) {
TTime.setHour(TTime.getHour() - 12); TTime.setHour(TTime.getHour() - 12);
} }
return computeAngle(TTime.getHour(), TTime.getMinute()); return computeAngle(TTime.getHour(), TTime.getMinute());
} }
private int computeAngle(int hour, int minute) { private int computeAngle(int hour, int minute) {
return (int) ((hour + minute / 60d) / 12d return (int) ((hour + minute / 60d) / 12d
* 360d); * 360d);
} }
public static void main(String[] args) { public static void main(String[] args) {
JFrame window = new JFrame("Analog Clock"); JFrame window = new JFrame("Analog Clock");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@ -136,7 +141,7 @@ public class AnalogClock extends Widget {
clock.yearProperty.bindTo(time.yearProperty); clock.yearProperty.bindTo(time.yearProperty);
clock.hourProperty.bindTo(time.hourProperty); clock.hourProperty.bindTo(time.hourProperty);
clock.minuteProperty.bindTo(time.minuteProperty); clock.minuteProperty.bindTo(time.minuteProperty);
clock.secondProperty.bindTo( time.secondProperty); clock.secondProperty.bindTo(time.secondProperty);
clock.millisecondProperty.bindTo(time.millisecondProperty); clock.millisecondProperty.bindTo(time.millisecondProperty);
clock.dayOfWeekProperty.bindTo(time.dayOfWeekProperty); clock.dayOfWeekProperty.bindTo(time.dayOfWeekProperty);
clock.visibilityProperty.setValue(Visibility.GRAY.name()); clock.visibilityProperty.setValue(Visibility.GRAY.name());
@ -187,7 +192,6 @@ public class AnalogClock extends Widget {
if ((mouseOver || progressVisibleOnlyIfMouseMovingOverProperty if ((mouseOver || progressVisibleOnlyIfMouseMovingOverProperty
.isDisabled()) && visibility.isStronglyColored()) { .isDisabled()) && visibility.isStronglyColored()) {
Color currentColor = g2d.getColor(); Color currentColor = g2d.getColor();
g2d.setColor(Color.YELLOW); g2d.setColor(Color.YELLOW);
int startAngle = computeStartAngle(); int startAngle = computeStartAngle();
@ -201,7 +205,7 @@ public class AnalogClock extends Widget {
// //
if (millisecondEnabledProperty.isEnabled() && secondEnabledProperty if (millisecondEnabledProperty.isEnabled() && secondEnabledProperty
.isEnabled() && minuteEnabledProperty.isEnabled() .isEnabled() && minuteEnabledProperty.isEnabled()
&& hourEnabledProperty.isEnabled()) { && hourEnabledProperty.isEnabled()) {
drawHand(g2d, side / 2 - 10, millisecond / 1000.0, 1.0f, drawHand(g2d, side / 2 - 10, millisecond / 1000.0, 1.0f,
COLOR_FOR_MILLISECOND_HAND_STRONGLY_COLORED, visibility); COLOR_FOR_MILLISECOND_HAND_STRONGLY_COLORED, visibility);
@ -239,8 +243,8 @@ public class AnalogClock extends Widget {
} }
} }
if (hourEnabledProperty.isEnabled()) { if (hourEnabledProperty.isEnabled()) {
double hours = double hours
hour / 12.0 + minute / 60.0 / 12 + second / 60 / 60 / 12; = hour / 12.0 + minute / 60.0 / 12 + second / 60 / 60 / 12;
drawHand(g2d, side / 2 - 40, drawHand(g2d, side / 2 - 40,
hours, 4.0f, hours, 4.0f,
Color.BLACK, visibility); Color.BLACK, visibility);
@ -256,8 +260,8 @@ public class AnalogClock extends Widget {
if (borderOnlyHoursProperty.isEnabled() && minuteI % 5 != 0) { if (borderOnlyHoursProperty.isEnabled() && minuteI % 5 != 0) {
continue; continue;
} }
drawBorder(g2d, minuteI, minuteI % 5 == 0 ? drawBorder(g2d, minuteI, minuteI % 5 == 0
(numbersVisibleProperty.isEnabled() ? 2f : 4f) : 1f, ? (numbersVisibleProperty.isEnabled() ? 2f : 4f) : 1f,
Color.BLACK, visibility); Color.BLACK, visibility);
} }
} }
@ -273,9 +277,9 @@ public class AnalogClock extends Widget {
Color currentColor = brush.getColor(); Color currentColor = brush.getColor();
Visibility visibility Visibility visibility
= Visibility.valueOf(visibilityProperty.getValue()); = Visibility.valueOf(visibilityProperty.getValue());
brush.setColor(visibility.isStronglyColored() || mouseOver ? brush.setColor(visibility.isStronglyColored() || mouseOver
(centreCircleBlackProperty.isEnabled() ? Color.BLACK : ? (centreCircleBlackProperty.isEnabled() ? Color.BLACK
Color.RED) : Color.RED)
: FOREGROUND_COLOR); : FOREGROUND_COLOR);
brush.fillOval(centerX - 3, centerY - 3, 8, 8); brush.fillOval(centerX - 3, centerY - 3, 8, 8);
brush.setColor(currentColor); brush.setColor(currentColor);
@ -285,19 +289,19 @@ public class AnalogClock extends Widget {
float stroke, Color color, Visibility visibility) { float stroke, Color color, Visibility visibility) {
double value = ((double) forMinute) / 60d; double value = ((double) forMinute) / 60d;
boolean hourAngle = forMinute % 5 == 0; boolean hourAngle = forMinute % 5 == 0;
int length = side / (numbersVisibleProperty.isEnabled() ? 18 : int length = side / (numbersVisibleProperty.isEnabled() ? 18
(hourAngle ? 12 : 18)); : (hourAngle ? 12 : 18));
double angle = Math.PI * 2 * (value - 0.25); double angle = Math.PI * 2 * (value - 0.25);
int startX = int startX
(int) (getWidth() / 2 + (side / 2 - length) * Math.cos(angle)); = (int) (getWidth() / 2 + (side / 2 - length) * Math.cos(angle));
int startY = int startY
(int) (getHeight() / 2 + (side / 2 - length) * Math.sin(angle)); = (int) (getHeight() / 2 + (side / 2 - length) * Math.sin(angle));
int endX = (int) (getWidth() / 2 int endX = (int) (getWidth() / 2
+ (side / 2 - length * 0.50d * (hourAngle ? 0.25 : 1)) + (side / 2 - length * 0.50d * (hourAngle ? 0.25 : 1))
* Math.cos(angle)); * Math.cos(angle));
int endY = (int) (getHeight() / 2 int endY = (int) (getHeight() / 2
+ (side / 2 - length * 0.50d * (hourAngle ? 0.25 : 1)) + (side / 2 - length * 0.50d * (hourAngle ? 0.25 : 1))
* Math.sin(angle)); * Math.sin(angle));
brush.setColor((visibility.isStronglyColored() || mouseOver) ? color brush.setColor((visibility.isStronglyColored() || mouseOver) ? color
: FOREGROUND_COLOR); : FOREGROUND_COLOR);
@ -312,8 +316,8 @@ public class AnalogClock extends Widget {
int endX = (int) (getWidth() / 2 + length * Math.cos(angle)); int endX = (int) (getWidth() / 2 + length * Math.cos(angle));
int endY = (int) (getHeight() / 2 + length * Math.sin(angle)); int endY = (int) (getHeight() / 2 + length * Math.sin(angle));
brush.setColor((visibility.isStronglyColored() || mouseOver) ? brush.setColor((visibility.isStronglyColored() || mouseOver)
(handsColoredProperty.isEnabled() ? color : Color.BLACK) ? (handsColoredProperty.isEnabled() ? color : Color.BLACK)
: FOREGROUND_COLOR); : FOREGROUND_COLOR);
brush.setStroke(new BasicStroke(stroke)); brush.setStroke(new BasicStroke(stroke));
brush.drawLine(getWidth() / 2, getHeight() / 2, endX, endY); brush.drawLine(getWidth() / 2, getHeight() / 2, endX, endY);

View File

@ -37,31 +37,31 @@ public class Battery extends Widget {
@Getter @Getter
private final String name; private final String name;
private final double[] randomDoubles private final double[] randomDoubles
= new double[] {1d, 1d, 1d, 1d, 1d, 1d, 1}; = new double[]{1d, 1d, 1d, 1d, 1d, 1d, 1};
private final BooleanProperty blinking = new BooleanProperty("blinking"); private final BooleanProperty blinking = new BooleanProperty("blinking");
public BooleanProperty wavesVisibleProperty = public BooleanProperty wavesVisibleProperty
new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE = new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE
.getKey(), true); .getKey(), true);
public BooleanProperty circleProgressVisibleProperty = public BooleanProperty circleProgressVisibleProperty
new BooleanProperty(TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE = new BooleanProperty(TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE
.getKey(), true); .getKey(), true);
public BooleanProperty percentProgressVisibleProperty = new BooleanProperty( public BooleanProperty percentProgressVisibleProperty = new BooleanProperty(
TimeCalcProperty.BATTERY_PERCENT_PROGRESS_VISIBLE TimeCalcProperty.BATTERY_PERCENT_PROGRESS_VISIBLE
.getKey(), true); .getKey(), true);
public BooleanProperty chargingCharacterVisibleProperty = public BooleanProperty chargingCharacterVisibleProperty
new BooleanProperty( = new BooleanProperty(
TimeCalcProperty.BATTERY_CHARGING_CHARACTER_VISIBLE TimeCalcProperty.BATTERY_CHARGING_CHARACTER_VISIBLE
.getKey(), true); .getKey(), true);
public BooleanProperty nameVisibleProperty = public BooleanProperty nameVisibleProperty
new BooleanProperty(TimeCalcProperty.BATTERY_NAME_VISIBLE = new BooleanProperty(TimeCalcProperty.BATTERY_NAME_VISIBLE
.getKey(), true); .getKey(), true);
public BooleanProperty labelVisibleProperty = public BooleanProperty labelVisibleProperty
new BooleanProperty(TimeCalcProperty.BATTERY_LABEL_VISIBLE = new BooleanProperty(TimeCalcProperty.BATTERY_LABEL_VISIBLE
.getKey(), true); .getKey(), true);
public BooleanProperty blinkingIfCriticalLowVisibleProperty public BooleanProperty blinkingIfCriticalLowVisibleProperty
= new BooleanProperty( = new BooleanProperty(
TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW
.getKey(), true); .getKey(), true);
private long tmpNanoTime = 0l; private long tmpNanoTime = 0l;
private int totalHeight = 0; private int totalHeight = 0;
private int totalWidth; private int totalWidth;
@ -85,7 +85,7 @@ public class Battery extends Widget {
} }
if (blinkingIfCriticalLowVisibleProperty.isEnabled()) { if (blinkingIfCriticalLowVisibleProperty.isEnabled()) {
if (donePercent > 0 && donePercent <= CRITICAL_LOW_ENERGY if (donePercent > 0 && donePercent <= CRITICAL_LOW_ENERGY
&& (System.nanoTime() - tmpNanoTime) > (1000000000l) / 2l) { && (System.nanoTime() - tmpNanoTime) > (1000000000l) / 2l) {
blinking.flip(); blinking.flip();
tmpNanoTime = System.nanoTime(); tmpNanoTime = System.nanoTime();
} }
@ -107,7 +107,7 @@ public class Battery extends Widget {
= Visibility.valueOf(visibilityProperty.getValue()); = Visibility.valueOf(visibilityProperty.getValue());
brush.setColor( brush.setColor(
visibility.isStronglyColored() || mouseOver ? Color.YELLOW visibility.isStronglyColored() || mouseOver ? Color.YELLOW
: FOREGROUND_COLOR); : FOREGROUND_COLOR);
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING, brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON); RenderingHints.VALUE_ANTIALIAS_ON);
@ -119,15 +119,15 @@ public class Battery extends Widget {
brush.setColor( brush.setColor(
donePercent < LOW_ENERGY ? LOW_HIGHLIGHTED donePercent < LOW_ENERGY ? LOW_HIGHLIGHTED
: (donePercent < HIGH_ENERGY : (donePercent < HIGH_ENERGY
? MEDIUM_HIGHLIGHTED ? MEDIUM_HIGHLIGHTED
: (donePercent < VERY_HIGH_ENERGY : (donePercent < VERY_HIGH_ENERGY
? HIGH_HIGHLIGHTED ? HIGH_HIGHLIGHTED
: HIGHEST_HIGHLIGHTED))); : HIGHEST_HIGHLIGHTED)));
} else { } else {
brush.setColor(donePercent < LOW_ENERGY ? LOW brush.setColor(donePercent < LOW_ENERGY ? LOW
: (donePercent < HIGH_ENERGY : (donePercent < HIGH_ENERGY
? MEDIUM ? MEDIUM
: (donePercent < VERY_HIGH_ENERGY ? HIGH : HIGHEST))); : (donePercent < VERY_HIGH_ENERGY ? HIGH : HIGHEST)));
} }
if (visibility.isGray()) { if (visibility.isGray()) {
brush.setColor(Utils.ULTRA_LIGHT_GRAY); brush.setColor(Utils.ULTRA_LIGHT_GRAY);
@ -139,8 +139,7 @@ public class Battery extends Widget {
int intX = 1; int intX = 1;
int todoHeight = totalHeight - doneHeight; int todoHeight = totalHeight - doneHeight;
double surfacePower double surfacePower
= = 1;//donePercent < 0.5 ? 0.5 : donePercent;// (donePercent * 100 - ((int)(donePercent * 100)));
1;//donePercent < 0.5 ? 0.5 : donePercent;// (donePercent * 100 - ((int)(donePercent * 100)));
int waterSurfaceHeight int waterSurfaceHeight
= (int) (4 * surfacePower);//2 + (int) (Math.random() * 3); = (int) (4 * surfacePower);//2 + (int) (Math.random() * 3);
if (waterSurfaceHeight <= 2 || wavesVisibleProperty.isDisabled() || !changedInTheLastXMilliseconds(1000)) { if (waterSurfaceHeight <= 2 || wavesVisibleProperty.isDisabled() || !changedInTheLastXMilliseconds(1000)) {
@ -155,32 +154,32 @@ public class Battery extends Widget {
? doneHeight : doneHeight - waterSurfaceHeight + 1); ? doneHeight : doneHeight - waterSurfaceHeight + 1);
int pointCount = 8; int pointCount = 8;
if (doneHeight >= waterSurfaceHeight if (doneHeight >= waterSurfaceHeight
&& donePercent < 1) {// && todoHeight > waterSurfaceHeight) { && donePercent < 1) {// && todoHeight > waterSurfaceHeight) {
//g2d.fillArc(intX, intY, width_, intHeight - waterSurfaceHeight, 30, 60); //g2d.fillArc(intX, intY, width_, intHeight - waterSurfaceHeight, 30, 60);
brush.fillPolygon( brush.fillPolygon(
new int[] {intX, new int[]{intX,
(int) (intX + totalWidth / pointCount * 0.5), (int) (intX + totalWidth / pointCount * 0.5),
intX + totalWidth / pointCount * 3, intX + totalWidth / pointCount * 3,
intX + totalWidth / pointCount * 4, intX + totalWidth / pointCount * 4,
intX + totalWidth / pointCount * 5, intX + totalWidth / pointCount * 5,
intX + totalWidth / pointCount * 6, intX + totalWidth / pointCount * 6,
intX + totalWidth / pointCount * 7, intX + totalWidth / pointCount * 7,
intX + totalWidth / pointCount * 8}, intX + totalWidth / pointCount * 8},
new int[] {todoHeight + (waterSurfaceHeight * 1), new int[]{todoHeight + (waterSurfaceHeight * 1),
todoHeight + (int) (waterSurfaceHeight * getRandom( todoHeight + (int) (waterSurfaceHeight * getRandom(
0)), 0)),
todoHeight + (int) (waterSurfaceHeight * getRandom( todoHeight + (int) (waterSurfaceHeight * getRandom(
1)), 1)),
todoHeight + (int) (waterSurfaceHeight * getRandom( todoHeight + (int) (waterSurfaceHeight * getRandom(
2)), 2)),
todoHeight + (int) (waterSurfaceHeight * getRandom( todoHeight + (int) (waterSurfaceHeight * getRandom(
3)), 3)),
todoHeight + (int) (waterSurfaceHeight * getRandom( todoHeight + (int) (waterSurfaceHeight * getRandom(
4)), 4)),
todoHeight + (int) (waterSurfaceHeight * getRandom( todoHeight + (int) (waterSurfaceHeight * getRandom(
5)), 5)),
todoHeight + (waterSurfaceHeight * 1)}, todoHeight + (waterSurfaceHeight * 1)},
pointCount); pointCount);
brush.setColor( brush.setColor(
@ -190,28 +189,28 @@ public class Battery extends Widget {
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING, brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_OFF); RenderingHints.VALUE_ANTIALIAS_OFF);
brush.drawPolyline( brush.drawPolyline(
new int[] {intX, new int[]{intX,
(int) (intX + totalWidth / pointCount * 0.5), (int) (intX + totalWidth / pointCount * 0.5),
intX + totalWidth / pointCount * 3, intX + totalWidth / pointCount * 3,
intX + totalWidth / pointCount * 4, intX + totalWidth / pointCount * 4,
intX + totalWidth / pointCount * 5, intX + totalWidth / pointCount * 5,
intX + totalWidth / pointCount * 6, intX + totalWidth / pointCount * 6,
intX + totalWidth / pointCount * 7, intX + totalWidth / pointCount * 7,
intX + totalWidth / pointCount * 8}, intX + totalWidth / pointCount * 8},
new int[] {todoHeight + (waterSurfaceHeight * 1), new int[]{todoHeight + (waterSurfaceHeight * 1),
todoHeight + (int) (waterSurfaceHeight * getRandom( todoHeight + (int) (waterSurfaceHeight * getRandom(
0, true)), 0, true)),
todoHeight + (int) (waterSurfaceHeight * getRandom( todoHeight + (int) (waterSurfaceHeight * getRandom(
1, true)), 1, true)),
todoHeight + (int) (waterSurfaceHeight * getRandom( todoHeight + (int) (waterSurfaceHeight * getRandom(
2, true)), 2, true)),
todoHeight + (int) (waterSurfaceHeight * getRandom( todoHeight + (int) (waterSurfaceHeight * getRandom(
3, true)), 3, true)),
todoHeight + (int) (waterSurfaceHeight * getRandom( todoHeight + (int) (waterSurfaceHeight * getRandom(
4, true)), 4, true)),
todoHeight + (int) (waterSurfaceHeight * getRandom( todoHeight + (int) (waterSurfaceHeight * getRandom(
5, true)), 5, true)),
todoHeight + (waterSurfaceHeight * 1)}, todoHeight + (waterSurfaceHeight * 1)},
pointCount); pointCount);
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING, brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON); RenderingHints.VALUE_ANTIALIAS_ON);
@ -248,10 +247,10 @@ public class Battery extends Widget {
if (percentProgressVisibleProperty.isEnabled()) { if (percentProgressVisibleProperty.isEnabled()) {
brush.drawString( brush.drawString(
(donePercent == 1 ? 100 : (NumberFormats.FORMATTER_THREE_DECIMAL_PLACES (donePercent == 1 ? 100 : (NumberFormats.FORMATTER_THREE_DECIMAL_PLACES
.format(donePercent * 100))) + "%", .format(donePercent * 100))) + "%",
((int) (totalWidth * 0.15)), ((int) (totalWidth * 0.15)),
donePercent > 0.5 ? totalHeight / 4 * 3 : donePercent > 0.5 ? totalHeight / 4 * 3
totalHeight / 4 * 1); : totalHeight / 4 * 1);
} }
if (labelVisibleProperty.isEnabled() && label != null && !label if (labelVisibleProperty.isEnabled() && label != null && !label
@ -286,9 +285,9 @@ public class Battery extends Widget {
private void paintCircleProgress(Graphics2D brush, Visibility visibility) { private void paintCircleProgress(Graphics2D brush, Visibility visibility) {
Color currentColor = brush.getColor(); Color currentColor = brush.getColor();
brush.setColor( brush.setColor(
visibility.isStronglyColored() ? HIGH_HIGHLIGHTED : visibility.isStronglyColored() ? HIGH_HIGHLIGHTED
(visibility.isWeaklyColored() ? HIGH : : (visibility.isWeaklyColored() ? HIGH
Color.lightGray)); : Color.lightGray));
double angleDouble = donePercent * 360; double angleDouble = donePercent * 360;
@ -297,9 +296,8 @@ public class Battery extends Widget {
15, 15, 90, -(int) angleDouble); 15, 15, 90, -(int) angleDouble);
brush.setColor( brush.setColor(
visibility.isStronglyColored() ? LIGHT_RED visibility.isStronglyColored() ? LIGHT_RED
: : visibility.isWeaklyColored() ? ULTRA_LIGHT_RED
visibility.isWeaklyColored() ? ULTRA_LIGHT_RED : : BACKGROUND_COLOR);
BACKGROUND_COLOR);
brush.fillArc(((int) (totalWidth * 0.45)) + 15, brush.fillArc(((int) (totalWidth * 0.45)) + 15,
totalHeight / 4 * 3 + 28, totalHeight / 4 * 3 + 28,
15, 15, 90, +(int) (360 - angleDouble)); 15, 15, 90, +(int) (360 - angleDouble));

View File

@ -17,7 +17,7 @@ public class HourBattery extends Battery {
public static double getHourProgress(TTime timeRemains, int secondsRemains, public static double getHourProgress(TTime timeRemains, int secondsRemains,
int millisecondsRemains) { int millisecondsRemains) {
if (secondsRemains < 0 || millisecondsRemains < 0 if (secondsRemains < 0 || millisecondsRemains < 0
|| timeRemains.getHour() < 0 || timeRemains.getMinute() < 0) { || timeRemains.getHour() < 0 || timeRemains.getMinute() < 0) {
return 1; return 1;
} }
double minutesRemainsD = timeRemains.getMinute(); double minutesRemainsD = timeRemains.getMinute();

View File

@ -19,9 +19,9 @@ public class MonthBattery extends Battery {
done = 1; done = 1;
} }
double result = weekDayWhenMondayIsOne == 6 double result = weekDayWhenMondayIsOne == 6
|| weekDayWhenMondayIsOne == 7 || weekDayWhenMondayIsOne == 7
? (double) workDaysDone / workDaysTotal ? (double) workDaysDone / workDaysTotal
: (workDaysDone + done) / workDaysTotal; : (workDaysDone + done) / workDaysTotal;
// System.out.println("result=" + result); // System.out.println("result=" + result);
return result; return result;
} }

View File

@ -26,7 +26,7 @@ public class ProgressCircle extends Widget {
Graphics2D brush = (Graphics2D) g; Graphics2D brush = (Graphics2D) g;
brush.setColor( brush.setColor(
visibility.isStronglyColored() || mouseOver ? Color.darkGray visibility.isStronglyColored() || mouseOver ? Color.darkGray
: FOREGROUND_COLOR); : FOREGROUND_COLOR);
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING, brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON); RenderingHints.VALUE_ANTIALIAS_ON);

View File

@ -14,8 +14,8 @@ import java.util.Map;
*/ */
public class ProgressSmileyIcon extends javax.swing.ImageIcon { public class ProgressSmileyIcon extends javax.swing.ImageIcon {
private static final Map<ProgressSmiley, ProgressSmileyIcon> cache = private static final Map<ProgressSmiley, ProgressSmileyIcon> cache
new HashMap<>(); = new HashMap<>();
@Getter @Getter
private final ProgressSmiley progressSmiley; private final ProgressSmiley progressSmiley;
@Getter @Getter

View File

@ -78,7 +78,7 @@ public class ProgressSquare extends Widget {
: BACKGROUND_COLOR); : BACKGROUND_COLOR);
brush.drawString(NumberFormats.FORMATTER_FIVE_DECIMAL_PLACES brush.drawString(NumberFormats.FORMATTER_FIVE_DECIMAL_PLACES
.format(donePercent * 100) + "%", .format(donePercent * 100) + "%",
(int) (side / 8d * 3d), (int) (side / 8d * 3d),
(int) (side / 8d * (donePercent > 0.5 ? 3d : 5d))); (int) (side / 8d * (donePercent > 0.5 ? 3d : 5d)));
paintSmiley(visibility, brush, (int) (side / 8d * 3d), paintSmiley(visibility, brush, (int) (side / 8d * 3d),

View File

@ -8,6 +8,7 @@ import java.util.Calendar;
import java.util.Date; import java.util.Date;
public class Time extends Thread { public class Time extends Thread {
private final IntegerProperty yearReadWriteProperty private final IntegerProperty yearReadWriteProperty
= new IntegerProperty("yearProperty"); = new IntegerProperty("yearProperty");
private final IntegerProperty monthReadWriteProperty private final IntegerProperty monthReadWriteProperty
@ -66,7 +67,7 @@ public class Time extends Thread {
public Calendar asCalendar() { public Calendar asCalendar() {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, yearProperty.getValue()); cal.set(Calendar.YEAR, yearProperty.getValue());
cal.set(Calendar.MONTH, monthProperty.getValue() -1); cal.set(Calendar.MONTH, monthProperty.getValue() - 1);
cal.set(Calendar.DAY_OF_MONTH, dayProperty.getValue()); cal.set(Calendar.DAY_OF_MONTH, dayProperty.getValue());
cal.set(Calendar.HOUR_OF_DAY, hourProperty.getValue()); cal.set(Calendar.HOUR_OF_DAY, hourProperty.getValue());
cal.set(Calendar.MINUTE, minuteProperty.getValue()); cal.set(Calendar.MINUTE, minuteProperty.getValue());
@ -74,6 +75,7 @@ public class Time extends Thread {
cal.set(Calendar.MILLISECOND, millisecondProperty.getValue()); cal.set(Calendar.MILLISECOND, millisecondProperty.getValue());
return cal; return cal;
} }
public void run() { public void run() {
while (true) { while (true) {
@ -114,13 +116,14 @@ public class Time extends Thread {
+ dayOfWeekProperty.getValue() + " " + dayOfWeekProperty.getValue() + " "
); );
} }
private int returnCustomValueIfNeeded(Calendar cal, int timeUnit, private int returnCustomValueIfNeeded(Calendar cal, int timeUnit,
IntegerProperty custom, IntegerProperty custom,
ReadOnlyProperty<Integer> real) { ReadOnlyProperty<Integer> real) {
boolean allow = allowCustomValuesProperty.isEnabled(); boolean allow = allowCustomValuesProperty.isEnabled();
Integer customValue = custom.getValue(); Integer customValue = custom.getValue();
if(allow && customValue != Integer.MAX_VALUE) { if (allow && customValue != Integer.MAX_VALUE) {
return custom.getValue(); return custom.getValue();
} else { } else {
return timeUnit == Calendar.MONTH ? (cal.get(timeUnit) + 1) : cal.get(timeUnit); return timeUnit == Calendar.MONTH ? (cal.get(timeUnit) + 1) : cal.get(timeUnit);

View File

@ -75,9 +75,9 @@ public class WalkingHumanProgress extends Widget implements
Visibility visibility Visibility visibility
= Visibility.valueOf(visibilityProperty.getValue()); = Visibility.valueOf(visibilityProperty.getValue());
brush.setColor(visibility.isStronglyColored() ? Color.BLUE : brush.setColor(visibility.isStronglyColored() ? Color.BLUE
visibility.isWeaklyColored() ? Color.GRAY : : visibility.isWeaklyColored() ? Color.GRAY
Color.LIGHT_GRAY); : Color.LIGHT_GRAY);
// if(mouseOver) { // if(mouseOver) {
// brush.drawRect(1,1,getWidth() - 2, getHeight() - 2); // brush.drawRect(1,1,getWidth() - 2, getHeight() - 2);
// } // }
@ -149,15 +149,15 @@ public class WalkingHumanProgress extends Widget implements
sb.append( sb.append(
WALL + createSpaces(spacesDone) + " () " + createSpaces( WALL + createSpaces(spacesDone) + " () " + createSpaces(
spacesTodo) + (spacesTodo == 0 spacesTodo) + (spacesTodo == 0
? " \\☼☼☼☼/ " ? " \\☼☼☼☼/ "
: "| _ |") + Constants.NEW_LINE : "| _ |") + Constants.NEW_LINE
+ WALL + createSpaces(spacesDone) + "/||\\" + createSpaces( + WALL + createSpaces(spacesDone) + "/||\\" + createSpaces(
spacesTodo) + (spacesTodo == 0 spacesTodo) + (spacesTodo == 0
? " ☼☼☼☼☼☼ " ? " ☼☼☼☼☼☼ "
: "| | |") + Constants.NEW_LINE : "| | |") + Constants.NEW_LINE
+ WALL + createSpaces(spacesDone) + " /\\ " + createSpaces( + WALL + createSpaces(spacesDone) + " /\\ " + createSpaces(
spacesTodo) + (spacesTodo == 0 spacesTodo) + (spacesTodo == 0
? " /☼☼☼☼\\ " ? " /☼☼☼☼\\ "
: "| |") + Constants.NEW_LINE : "| |") + Constants.NEW_LINE
+ createRepeatedString(spacesTotal + 14, '=') + createRepeatedString(spacesTotal + 14, '=')

View File

@ -18,7 +18,7 @@ public class WeekBattery extends Battery {
done = 1; done = 1;
} }
return weekDayWhenMondayIsOne == 0 return weekDayWhenMondayIsOne == 0
|| weekDayWhenMondayIsOne == 6 || weekDayWhenMondayIsOne == 6
? 100 : ((weekDayWhenMondayIsOne - 1) * 0.20 + done * 0.20); ? 100 : ((weekDayWhenMondayIsOne - 1) * 0.20 + done * 0.20);
} }
} }

View File

@ -7,18 +7,19 @@ import java.io.File;
* @since 21.02.2024 * @since 21.02.2024
*/ */
public class FileConstants { public class FileConstants {
public static final File TC_DIRECTORY = new File(".tc"); public static final File TC_DIRECTORY = new File(".tc");
public static final File STARTTIME_TXT = public static final File STARTTIME_TXT
new File(TC_DIRECTORY, "starttime.txt"); = new File(TC_DIRECTORY, "starttime.txt");
public static final File OVERTIME_TXT = public static final File OVERTIME_TXT
new File(TC_DIRECTORY, "overtime.txt"); = new File(TC_DIRECTORY, "overtime.txt");
public static final File TEST_TXT = new File(TC_DIRECTORY, "test.txt"); public static final File TEST_TXT = new File(TC_DIRECTORY, "test.txt");
public static final File TIME_CALC_PROFILES_TXT_FILE = public static final File TIME_CALC_PROFILES_TXT_FILE
new File(TC_DIRECTORY, "time-calc-profiles.txt"); = new File(TC_DIRECTORY, "time-calc-profiles.txt");
public static final File TIME_CALC_CURRENT_PROFILE_TXT_FILE = public static final File TIME_CALC_CURRENT_PROFILE_TXT_FILE
new File(TC_DIRECTORY, "time-calc-current-profile.txt"); = new File(TC_DIRECTORY, "time-calc-current-profile.txt");
public static final File FILE_WITHOUT_ANY_PROFILE = public static final File FILE_WITHOUT_ANY_PROFILE
new File(TC_DIRECTORY, "timecalc.conf"); = new File(TC_DIRECTORY, "timecalc.conf");
public static final File JOKES_TXT = new File(TC_DIRECTORY, "time-calc-jokes.txt"); public static final File JOKES_TXT = new File(TC_DIRECTORY, "time-calc-jokes.txt");
private FileConstants() { private FileConstants() {

View File

@ -33,17 +33,17 @@ public class Jokes {
static { static {
try { try {
array = JokesTxt.getAsArray(); array = JokesTxt.getAsArray();
if(array.length > 0) { if (array.length > 0) {
Set<String> set = new HashSet<>(); Set<String> set = new HashSet<>();
for (String vtip : array) { for (String vtip : array) {
if (vtip.trim().isEmpty()) { if (vtip.trim().isEmpty()) {
//nothing to do //nothing to do
continue; continue;
}
set.add(vtip.trim());
} }
set.add(vtip.trim()); array = new String[set.size()];
} array = set.toArray(array);
array = new String[set.size()];
array = set.toArray(array);
} }
} catch (IOException e) { } catch (IOException e) {

View File

@ -17,7 +17,7 @@ public class JokesTxt {
File jokeTxtFile = FileConstants.JOKES_TXT; File jokeTxtFile = FileConstants.JOKES_TXT;
if (!jokeTxtFile.exists()) { if (!jokeTxtFile.exists()) {
//nothing to do //nothing to do
return new String[] {}; return new String[]{};
} }
return Utils.readTextFromFile(jokeTxtFile).split("-----SEPARATOR-----"); return Utils.readTextFromFile(jokeTxtFile).split("-----SEPARATOR-----");
} }

View File

@ -50,7 +50,7 @@ public enum ProgressSmiley {
public static ProgressSmiley forProgress(double progress) { public static ProgressSmiley forProgress(double progress) {
progress = progress * 100; progress = progress * 100;
if(progress <0) { if (progress < 0) {
return SMILEY_1; return SMILEY_1;
} }
for (int i = 1; i < 16; i++) { for (int i = 1; i < 16; i++) {

View File

@ -35,7 +35,7 @@ public class TTime implements Comparable<TTime> {
private Integer millisecond; private Integer millisecond;
public TTime(long hour, long minute, long second, long millisecond) { public TTime(long hour, long minute, long second, long millisecond) {
this((int)hour, (int)minute, (int)second, (int)millisecond); this((int) hour, (int) minute, (int) second, (int) millisecond);
} }
public TTime(int hour, int minute) { public TTime(int hour, int minute) {
@ -74,6 +74,7 @@ public class TTime implements Comparable<TTime> {
return sb.toString(); return sb.toString();
} }
public static TTime of(Calendar cal) { public static TTime of(Calendar cal) {
return new TTime( return new TTime(
cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.HOUR_OF_DAY),
@ -81,6 +82,7 @@ public class TTime implements Comparable<TTime> {
cal.get(Calendar.SECOND), cal.get(Calendar.SECOND),
cal.get(Calendar.MILLISECOND)); cal.get(Calendar.MILLISECOND));
} }
public static TTime of(Duration duration) { public static TTime of(Duration duration) {
return new TTime( return new TTime(
duration.get(ChronoUnit.HOURS), duration.get(ChronoUnit.HOURS),
@ -88,6 +90,7 @@ public class TTime implements Comparable<TTime> {
duration.get(ChronoUnit.SECONDS), duration.get(ChronoUnit.SECONDS),
duration.get(ChronoUnit.MILLIS)); duration.get(ChronoUnit.MILLIS));
} }
public TTime(String string) { public TTime(String string) {
this.negative = string.startsWith("-"); this.negative = string.startsWith("-");
if (negative) { if (negative) {
@ -99,9 +102,11 @@ public class TTime implements Comparable<TTime> {
this.second = array.length >= 3 ? ((negative ? (1) : 1) * Integer.valueOf(array[2])) : 0; this.second = array.length >= 3 ? ((negative ? (1) : 1) * Integer.valueOf(array[2])) : 0;
this.millisecond = array.length >= 4 ? ((negative ? (1) : 1) * Integer.valueOf(array[3])) : 0; this.millisecond = array.length >= 4 ? ((negative ? (1) : 1) * Integer.valueOf(array[3])) : 0;
} }
public TTime(int hourIn, int minuteIn, int secondIn, int millisecondIn) { public TTime(int hourIn, int minuteIn, int secondIn, int millisecondIn) {
this(false, hourIn, minuteIn, secondIn, millisecondIn); this(false, hourIn, minuteIn, secondIn, millisecondIn);
} }
public TTime(boolean negative, int hourIn, int minuteIn, int secondIn, int millisecondIn) { public TTime(boolean negative, int hourIn, int minuteIn, int secondIn, int millisecondIn) {
this.hour = Math.abs(hourIn); this.hour = Math.abs(hourIn);
this.minute = Math.abs(minuteIn); this.minute = Math.abs(minuteIn);
@ -117,6 +122,7 @@ public class TTime implements Comparable<TTime> {
hour = hour - 1; hour = hour - 1;
} }
} }
public TTime remove(TTime tTimeToBeRemoved) { public TTime remove(TTime tTimeToBeRemoved) {
int s1 = this.toTotalMilliseconds(); int s1 = this.toTotalMilliseconds();
int s2 = tTimeToBeRemoved.toTotalMilliseconds(); int s2 = tTimeToBeRemoved.toTotalMilliseconds();
@ -138,7 +144,7 @@ public class TTime implements Comparable<TTime> {
public TTime add(TTime tTimeToBeAdded) { public TTime add(TTime tTimeToBeAdded) {
TTime result = this.cloneInstance(); TTime result = this.cloneInstance();
if(result.isNegative()) { if (result.isNegative()) {
result.setNegative(false); result.setNegative(false);
result = result.remove(tTimeToBeAdded); result = result.remove(tTimeToBeAdded);
result.setNegative(result.toTotalMilliseconds() != 0); result.setNegative(result.toTotalMilliseconds() != 0);
@ -156,7 +162,7 @@ public class TTime implements Comparable<TTime> {
public static int countDiffInMinutes(TTime startTime, TTime endTime) { public static int countDiffInMinutes(TTime startTime, TTime endTime) {
return (endTime.getHour() * TTime.MINUTES_PER_HOUR + endTime return (endTime.getHour() * TTime.MINUTES_PER_HOUR + endTime
.getMinute()) - (startTime.getHour() * TTime.MINUTES_PER_HOUR .getMinute()) - (startTime.getHour() * TTime.MINUTES_PER_HOUR
+ startTime.getMinute()); + startTime.getMinute());
} }
public TTime cloneInstance() { public TTime cloneInstance() {
@ -164,8 +170,9 @@ public class TTime implements Comparable<TTime> {
} }
public String toString() { public String toString() {
return (negative ? "-" : "") + (hour < 10 ? "0" : "") + hour + ":" + (minute < 10 ? "0" : "") + minute + ":" + (second < 10 ? "0" : "") + second + ":" + (millisecond < 10 ? "00" : (millisecond < 100 ? "0": "")) + millisecond; return (negative ? "-" : "") + (hour < 10 ? "0" : "") + hour + ":" + (minute < 10 ? "0" : "") + minute + ":" + (second < 10 ? "0" : "") + second + ":" + (millisecond < 10 ? "00" : (millisecond < 100 ? "0" : "")) + millisecond;
} }
public Calendar asCalendar() { public Calendar asCalendar() {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, hour); cal.set(Calendar.HOUR_OF_DAY, hour);
@ -174,17 +181,19 @@ public class TTime implements Comparable<TTime> {
cal.set(Calendar.MILLISECOND, millisecond); cal.set(Calendar.MILLISECOND, millisecond);
return cal; return cal;
} }
public Date asDate() { public Date asDate() {
return asCalendar().getTime(); return asCalendar().getTime();
} }
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);
} }
@Override @Override
public int compareTo(TTime o) { public int compareTo(TTime o) {
int result = Integer.valueOf(toTotalMilliseconds()).compareTo(o.toTotalMilliseconds()); int result = Integer.valueOf(toTotalMilliseconds()).compareTo(o.toTotalMilliseconds());
if(this.isNegative()) { if (this.isNegative()) {
System.out.println("this.toTotalMilliseconds()=" + this.toTotalMilliseconds()); System.out.println("this.toTotalMilliseconds()=" + this.toTotalMilliseconds());
System.out.println("o.toTotalMilliseconds()=" + o.toTotalMilliseconds()); System.out.println("o.toTotalMilliseconds()=" + o.toTotalMilliseconds());
System.out.println("comparing: " + this + " " + o + " = " + result); System.out.println("comparing: " + this + " " + o + " = " + result);

View File

@ -107,7 +107,7 @@ public class Utils {
} }
String manifestPath String manifestPath
= classPath.substring(0, classPath.lastIndexOf("!") + 1) = classPath.substring(0, classPath.lastIndexOf("!") + 1)
+ "/META-INF/MANIFEST.MF"; + "/META-INF/MANIFEST.MF";
Manifest manifest; Manifest manifest;
try { try {
manifest = new Manifest(new URL(manifestPath).openStream()); manifest = new Manifest(new URL(manifestPath).openStream());
@ -134,7 +134,7 @@ public class Utils {
BufferedReader in = new BufferedReader(streamReader); BufferedReader in = new BufferedReader(streamReader);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (String line; (line = in.readLine()) != null; ) { for (String line; (line = in.readLine()) != null;) {
sb.append(line).append("\n"); sb.append(line).append("\n");
} }
return sb.toString(); return sb.toString();

View File

@ -14,6 +14,11 @@ public class IntegerProperty extends Property<Integer> {
this(name, 0); this(name, 0);
} }
public void increment() {this.setValue(getValue() + 1);} public void increment() {
public void decrement() {this.setValue(getValue() - 1);} this.setValue(getValue() + 1);
}
public void decrement() {
this.setValue(getValue() - 1);
}
} }

View File

@ -16,8 +16,8 @@ public class Property<T> {
private final String name; private final String name;
private final List<InvalidationListener> invalidationListeners private final List<InvalidationListener> invalidationListeners
= new ArrayList<>(); = new ArrayList<>();
private final List<ChangeListener<T>> changeListeners = private final List<ChangeListener<T>> changeListeners
new ArrayList<ChangeListener<T>>(); = new ArrayList<ChangeListener<T>>();
private boolean valid = true; private boolean valid = true;
private T value; private T value;
private Property<T> boundToProperty = null; private Property<T> boundToProperty = null;
@ -51,7 +51,7 @@ public class Property<T> {
} }
public void bindTo(Property<T> anotherProperty) { public void bindTo(Property<T> anotherProperty) {
if(this == anotherProperty) { if (this == anotherProperty) {
new RuntimeException().printStackTrace(); new RuntimeException().printStackTrace();
throw new TimeCalcException("Cannot bind to self: " + getName()); throw new TimeCalcException("Cannot bind to self: " + getName());
} }
@ -59,10 +59,10 @@ public class Property<T> {
this.boundToProperty = anotherProperty; this.boundToProperty = anotherProperty;
this.boundChangeListener this.boundChangeListener
= (Property<T> p, T oldValue, T newValue) -> { = (Property<T> p, T oldValue, T newValue) -> {
this.markInvalid(); this.markInvalid();
this.fireValueChangedEvent(oldValue); this.fireValueChangedEvent(oldValue);
//System.out.println("bindTo markInvalid " + p.getName() + " " + p.getValue()); //System.out.println("bindTo markInvalid " + p.getName() + " " + p.getValue());
}; };
this.boundToProperty this.boundToProperty
.addListener(boundChangeListener); .addListener(boundChangeListener);