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":
timeCalcApp.visibilityProperty.setValue(
commandsAsArray[1].equals("1")
? Visibility.STRONGLY_COLORED.name()
: Visibility.WEAKLY_COLORED.name());
? Visibility.STRONGLY_COLORED.name()
: Visibility.WEAKLY_COLORED.name());
break;
case "gray":
timeCalcApp.visibilityProperty.setValue(
commandsAsArray[1].equals("1")
? Visibility.GRAY.name()
: Visibility.WEAKLY_COLORED.name());
? Visibility.GRAY.name()
: Visibility.WEAKLY_COLORED.name());
break;
case "waves":
timeCalcConfiguration.batteryWavesVisibleProperty

View File

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

View File

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

View File

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

View File

@ -28,11 +28,11 @@ public class TimeCalcProperties {
System.out.println("Loading configuration - start");
String profileName = "";
try {
profileName =
FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE.exists() ?
Utils.readTextFromFile(
FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE) :
"";
profileName
= FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE.exists()
? Utils.readTextFromFile(
FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE)
: "";
} catch (IOException e) {
e.printStackTrace();
throw new TimeCalcException(e);
@ -115,6 +115,7 @@ public class TimeCalcProperties {
}
return (String) properties.get(key);
}
public int getIntegerProperty(TimeCalcProperty timeCalcProperty) {
return getIntegerProperty(timeCalcProperty,
Integer.valueOf(getDefaultStringValue(timeCalcProperty)));
@ -128,6 +129,7 @@ public class TimeCalcProperties {
}
return Integer.valueOf((String) properties.get(key));
}
private String getVisibilityProperty(TimeCalcProperty timeCalcProperty) {
return getStringProperty(timeCalcProperty,
Visibility.STRONGLY_COLORED.name());
@ -153,15 +155,15 @@ public class TimeCalcProperties {
public void save(Properties properties, String profileName) {
properties.entrySet().stream().forEach(e
-> {
if (this.properties.containsKey(e.getKey())) {
this.properties
.replace(e.getKey(), e.getValue().toString());
} else {
this.properties
.put(e.getKey(), e.getValue().toString());
}
}
-> {
if (this.properties.containsKey(e.getKey())) {
this.properties
.replace(e.getKey(), e.getValue().toString());
} else {
this.properties
.put(e.getKey(), e.getValue().toString());
}
}
);
File file = getFile(profileName);
try {
@ -178,9 +180,9 @@ public class TimeCalcProperties {
}
private File getFile(String profileName) {
return profileName == null || profileName.isEmpty() ?
FileConstants.FILE_WITHOUT_ANY_PROFILE :
new File(FileConstants.FILE_WITHOUT_ANY_PROFILE.getParentFile(),
return profileName == null || profileName.isEmpty()
? FileConstants.FILE_WITHOUT_ANY_PROFILE
: new File(FileConstants.FILE_WITHOUT_ANY_PROFILE.getParentFile(),
"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"),
//
BATTERY_WAVES_VISIBLE("battery.waves.visible", "Battery : Waves"),
BATTERY_CIRCLE_PROGRESS_VISIBLE("battery.circle-progress.visible",
"Battery : Circle Progress"),
BATTERY_PERCENT_PROGRESS_VISIBLE("battery.percent-progress.visible",
"Battery : Percent Progress"),
BATTERY_CHARGING_CHARACTER_VISIBLE("battery.charging-character.visible",
"Battery : Charging Character"),
BATTERY_NAME_VISIBLE("battery.name.visible", "Battery : Name"),
BATTERY_LABEL_VISIBLE("battery.label.visible", "Battery : Label"),
BATTERY_VISIBLE("battery.visible", "Battery"),
BATTERY_MINUTE_VISIBLE("battery.minute.visible", "Battery : Minute"),
BATTERY_HOUR_VISIBLE("battery.hour.visible", "Battery : Hour"),
@ -67,7 +64,6 @@ public enum TimeCalcProperty {
BATTERY_YEAR_VISIBLE("battery.year.visible", "Battery : Year"),
BATTERY_BLINKING_IF_CRITICAL_LOW("battery.blinking-if-critical-low",
"Battery : Blinking, if critical low"),
JOKES_VISIBLE("jokes.visible", "Jokes"),
COMMANDS_VISIBLE("commands.visible", "Commands"),
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_COLORED("smileys.colored", "Smileys : Colored"),
SQUARE_VISIBLE("square.visible", "Square"),
CIRCLE_VISIBLE("circle.visible", "Circle"),
WALKING_HUMAN_VISIBLE("walking-human.visible", "Walking Human"),
@ -109,8 +104,8 @@ public enum TimeCalcProperty {
}
public static TimeCalcProperty forKey(String key) {
Optional<TimeCalcProperty> timeCalcPropertyOptional =
Arrays.stream(values()).filter(t -> t.getKey().equals(key))
Optional<TimeCalcProperty> timeCalcPropertyOptional
= Arrays.stream(values()).filter(t -> t.getKey().equals(key))
.findFirst();
if (timeCalcPropertyOptional.isPresent()) {
return timeCalcPropertyOptional.get();

View File

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

View File

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

View File

@ -10,9 +10,13 @@ import java.util.List;
* @since 23.02.2024
*/
public interface ActivityRepositoryApi {
void create(Activity activity);
List<Activity> list(int year, int month, int day);
void update(Activity activity);
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 {

View File

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

View File

@ -18,7 +18,6 @@
///////////////////////////////////////////////////////////////////////////////////////////////
package org.nanoboot.utils.timecalc.persistence.impl.sqlite;
import org.nanoboot.utils.timecalc.persistence.api.ConnectionFactory;
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>
*/
public class SqliteConnectionFactory implements ConnectionFactory {
private final String jdbcUrl;
private static String createJdbcUrl(String directoryWhereSqliteFileIs) {
return "jdbc:sqlite:" + directoryWhereSqliteFileIs + "/" + ".time-calc.sqlite3?foreign_keys=on;";
}
public SqliteConnectionFactory() {
this(FileConstants.TC_DIRECTORY.getName());
}
public SqliteConnectionFactory(String directoryWhereSqliteFileIs) {
this.jdbcUrl = createJdbcUrl(directoryWhereSqliteFileIs);
}

View File

@ -10,6 +10,7 @@ import java.util.List;
* @since 23.02.2024
*/
public class WorkingDayRepositorySQLiteImpl implements WorkingDayRepositoryApi {
@Override
public void create(WorkingDay workingDay) {
@ -31,9 +32,6 @@ public class WorkingDayRepositorySQLiteImpl implements WorkingDayRepositoryApi {
}
}
// private org.nanoboot.bitinspector.persistence.impl.sqlite.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 {
public static final String TABLE_NAME = "WORKING_DAY";
public static final String ID = "ID";
@ -43,6 +44,5 @@ class WorkingDayTable {
private WorkingDayTable() {
//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) {
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) {
continue;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,14 +31,17 @@ public class TTextField extends JTextField implements GetProperty {
= new BooleanProperty("visibleProperty", true);
public StringProperty visibilityProperty
= new StringProperty("visibilityProperty",
Visibility.STRONGLY_COLORED.name());
Visibility.STRONGLY_COLORED.name());
public final StringProperty valueProperty = new StringProperty();
public TTextField() {
this("", 0);
}
public TTextField(String s) {
this(s, 0);
}
public TTextField(String s, int customWidth) {
super(s);
this.customWidth = customWidth;
@ -56,13 +59,14 @@ public class TTextField extends JTextField implements GetProperty {
public void insertUpdate(DocumentEvent e) {
update(e);
}
private void update(DocumentEvent e) {
valueProperty.setValue(getText());
}
});
valueProperty.addListener(e ->
{
valueProperty.addListener(e
-> {
if (!valueProperty.getValue().equals(getText())) {
setText(valueProperty.getValue());
}
@ -93,9 +97,11 @@ public class TTextField extends JTextField implements GetProperty {
this.originalBackground = getBackground();
this.originalForeground = getForeground();
}
public void setBoundsFromLeft(JComponent jComponent) {
setBoundsFromLeft(jComponent, 0);
}
public void setBoundsFromLeft(JComponent jComponent, int additionalY) {
setBounds(jComponent.getX() + jComponent.getWidth() + SwingUtils.MARGIN,
jComponent.getY() + additionalY);
@ -107,9 +113,10 @@ public class TTextField extends JTextField implements GetProperty {
public void setBoundsFromTop(JComponent jComponent, int marginCount) {
setBounds(SwingUtils.MARGIN, jComponent.getY()
+ jComponent.getHeight()
+ marginCount * SwingUtils.MARGIN);
+ jComponent.getHeight()
+ marginCount * SwingUtils.MARGIN);
}
public void setOriginalBackground() {
this.setBackground(originalBackground);
}
@ -117,6 +124,7 @@ public class TTextField extends JTextField implements GetProperty {
public void setOriginalForeground() {
this.setForeground(originalForeground);
}
@Override
public Property getVisibilityProperty() {
return visibilityProperty;
@ -126,9 +134,9 @@ public class TTextField extends JTextField implements GetProperty {
public Property getVisibilitySupportedColoredProperty() {
return visibilitySupportedColoredProperty;
}
public TTime asTTime() {
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(
* "mylogo.gif" ), "A simple toaster with an image" ); } }
*/
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JButton;
@ -52,11 +51,11 @@ import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
public class Toaster {
private static final long serialVersionUID = 1L;
public static final BooleanProperty notificationsVisibleProperty
= new BooleanProperty(TimeCalcProperty.NOTIFICATIONS_VISIBLE
.getKey());
// Set the margin
int margin;
// Flag that indicate if use alwaysOnTop or not.
@ -437,9 +436,8 @@ public class Toaster {
stopYPosition = startYPosition - toasterHeight - 1;
if (currentNumberOfToaster > 0) {
stopYPosition
=
stopYPosition - (maxToaster % maxToasterInSceen
* toasterHeight);
= stopYPosition - (maxToaster % maxToasterInSceen
* toasterHeight);
} else {
maxToaster = 0;
}
@ -449,9 +447,8 @@ public class Toaster {
if (currentNumberOfToaster > 0) {
stopYPosition
=
stopYPosition + (maxToaster % maxToasterInSceen
* toasterHeight);
= stopYPosition + (maxToaster % maxToasterInSceen
* toasterHeight);
} else {
maxToaster = 0;
}

View File

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

View File

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

View File

@ -35,9 +35,9 @@ public class Widget extends JPanel implements
protected static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
protected static final Font BIG_FONT = new Font("sans", Font.BOLD, 24);
protected static final Font MEDIUM_FONT = new Font("sans", Font.BOLD, 16);
public static final Color CLOSE_BUTTON_FOREGROUND_COLOR =
new Color(127, 127, 127);
public static final Color CLOSE_BUTTON_FOREGROUND_COLOR
= new Color(127, 127, 127);
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 final BooleanProperty visibilitySupportedColoredProperty
@ -48,13 +48,13 @@ public class Widget extends JPanel implements
= new BooleanProperty(TimeCalcProperty.SMILEYS_VISIBLE.getKey());
public final BooleanProperty smileysVisibleOnlyIfMouseMovingOverProperty
= new BooleanProperty(
TimeCalcProperty.SMILEYS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
.getKey());
TimeCalcProperty.SMILEYS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
.getKey());
public final BooleanProperty smileysColoredProperty
= new BooleanProperty("smileysColoredProperty", true);
public StringProperty visibilityProperty
= new StringProperty("widget.visibilityProperty",
Visibility.STRONGLY_COLORED.name());
Visibility.STRONGLY_COLORED.name());
protected int side = 0;
protected double donePercent = 0;
protected boolean mouseOver = false;
@ -77,7 +77,7 @@ public class Widget extends JPanel implements
int x = e.getX();
int y = e.getY();
mouseOverCloseButton = x >= getWidth() - CLOSE_BUTTON_SIDE
&& y <= CLOSE_BUTTON_SIDE;
&& y <= CLOSE_BUTTON_SIDE;
}
});
addMouseListener(new MouseListener() {
@ -181,11 +181,11 @@ public class Widget extends JPanel implements
paintCloseIcon(brush, getWidth(), mouseOver, mouseOverCloseButton);
}
private static void paintCloseIcon(Graphics brush, int width,
boolean mouseOver, boolean mouseOverCloseButton) {
if(!mouseOver) {
if (!mouseOver) {
//nothing to do
return;
}
@ -194,7 +194,7 @@ public class Widget extends JPanel implements
// 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) {
// 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);
// return;
// }
brush.fillOval(width - CLOSE_BUTTON_SIDE - 1, 0 + 1, CLOSE_BUTTON_SIDE,
CLOSE_BUTTON_SIDE);
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,
int y) {
if (smileysVisibleProperty.isDisabled() || (!mouseOver
&& smileysVisibleOnlyIfMouseMovingOverProperty
.isEnabled())) {
&& smileysVisibleOnlyIfMouseMovingOverProperty
.isEnabled())) {
if (this.smileyIcon != null) {
this.remove(smileyIcon);
this.smileyIcon = null;
@ -264,8 +263,8 @@ public class Widget extends JPanel implements
brush.setColor(Color.BLACK);
}
Color currentColor = brush.getColor();
brush.setColor(visibility.isStronglyColored() ? Color.WHITE :
BACKGROUND_COLOR);
brush.setColor(visibility.isStronglyColored() ? Color.WHITE
: BACKGROUND_COLOR);
brush.fillRect(
x, y,
20,
@ -291,6 +290,7 @@ public class Widget extends JPanel implements
this.add(smileyIcon);
}
}
protected boolean changedInTheLastXMilliseconds(int milliseconds) {
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
= new Color(246,
152, 51);
152, 51);
public final BooleanProperty borderVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_VISIBLE
.getKey());
.getKey());
public final BooleanProperty borderOnlyHoursProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_ONLY_HOURS
.getKey());
.getKey());
public final BooleanProperty numbersVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_NUMBERS_VISIBLE
.getKey());
.getKey());
public final BooleanProperty circleVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_VISIBLE
.getKey());
.getKey());
public final BooleanProperty circleStrongBorderProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_STRONG_BORDER
.getKey());
.getKey());
public final BooleanProperty centreCircleVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_VISIBLE
.getKey());
.getKey());
public final StringProperty centreCircleBorderColorProperty
= new StringProperty(TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR
.getKey());
.getKey());
public final BooleanProperty centreCircleBlackProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK
.getKey());
.getKey());
public final BooleanProperty progressVisibleOnlyIfMouseMovingOverProperty
= new BooleanProperty(
TimeCalcProperty.CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
.getKey());
TimeCalcProperty.CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
.getKey());
public final BooleanProperty dateVisibleOnlyIfMouseMovingOverProperty
= new BooleanProperty(
TimeCalcProperty.CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
.getKey());
TimeCalcProperty.CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
.getKey());
public IntegerProperty startHourProperty
= new IntegerProperty("startHourProperty");
@ -100,24 +100,29 @@ public class AnalogClock extends Widget {
centreCircleBorderColorProperty.addListener(property
-> customCircleColor = SwingUtils.getColorFromString(
centreCircleBorderColorProperty.getValue()));
centreCircleBorderColorProperty.getValue()));
}
private int computeStartAngle() {
return computeAngle(startHourProperty.getValue(), startMinuteProperty.getValue());
}
private int computeEndAngle() {
return computeAngle(endHourProperty.getValue(), endMinuteProperty.getValue());
}
private int computeAngle(TTime TTime) {
if (TTime.getHour() > 12) {
TTime.setHour(TTime.getHour() - 12);
}
return computeAngle(TTime.getHour(), TTime.getMinute());
}
private int computeAngle(int hour, int minute) {
return (int) ((hour + minute / 60d) / 12d
* 360d);
* 360d);
}
public static void main(String[] args) {
JFrame window = new JFrame("Analog Clock");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@ -136,7 +141,7 @@ public class AnalogClock extends Widget {
clock.yearProperty.bindTo(time.yearProperty);
clock.hourProperty.bindTo(time.hourProperty);
clock.minuteProperty.bindTo(time.minuteProperty);
clock.secondProperty.bindTo( time.secondProperty);
clock.secondProperty.bindTo(time.secondProperty);
clock.millisecondProperty.bindTo(time.millisecondProperty);
clock.dayOfWeekProperty.bindTo(time.dayOfWeekProperty);
clock.visibilityProperty.setValue(Visibility.GRAY.name());
@ -187,7 +192,6 @@ public class AnalogClock extends Widget {
if ((mouseOver || progressVisibleOnlyIfMouseMovingOverProperty
.isDisabled()) && visibility.isStronglyColored()) {
Color currentColor = g2d.getColor();
g2d.setColor(Color.YELLOW);
int startAngle = computeStartAngle();
@ -201,7 +205,7 @@ public class AnalogClock extends Widget {
//
if (millisecondEnabledProperty.isEnabled() && secondEnabledProperty
.isEnabled() && minuteEnabledProperty.isEnabled()
&& hourEnabledProperty.isEnabled()) {
&& hourEnabledProperty.isEnabled()) {
drawHand(g2d, side / 2 - 10, millisecond / 1000.0, 1.0f,
COLOR_FOR_MILLISECOND_HAND_STRONGLY_COLORED, visibility);
@ -239,8 +243,8 @@ public class AnalogClock extends Widget {
}
}
if (hourEnabledProperty.isEnabled()) {
double hours =
hour / 12.0 + minute / 60.0 / 12 + second / 60 / 60 / 12;
double hours
= hour / 12.0 + minute / 60.0 / 12 + second / 60 / 60 / 12;
drawHand(g2d, side / 2 - 40,
hours, 4.0f,
Color.BLACK, visibility);
@ -256,8 +260,8 @@ public class AnalogClock extends Widget {
if (borderOnlyHoursProperty.isEnabled() && minuteI % 5 != 0) {
continue;
}
drawBorder(g2d, minuteI, minuteI % 5 == 0 ?
(numbersVisibleProperty.isEnabled() ? 2f : 4f) : 1f,
drawBorder(g2d, minuteI, minuteI % 5 == 0
? (numbersVisibleProperty.isEnabled() ? 2f : 4f) : 1f,
Color.BLACK, visibility);
}
}
@ -273,9 +277,9 @@ public class AnalogClock extends Widget {
Color currentColor = brush.getColor();
Visibility visibility
= Visibility.valueOf(visibilityProperty.getValue());
brush.setColor(visibility.isStronglyColored() || mouseOver ?
(centreCircleBlackProperty.isEnabled() ? Color.BLACK :
Color.RED)
brush.setColor(visibility.isStronglyColored() || mouseOver
? (centreCircleBlackProperty.isEnabled() ? Color.BLACK
: Color.RED)
: FOREGROUND_COLOR);
brush.fillOval(centerX - 3, centerY - 3, 8, 8);
brush.setColor(currentColor);
@ -285,19 +289,19 @@ public class AnalogClock extends Widget {
float stroke, Color color, Visibility visibility) {
double value = ((double) forMinute) / 60d;
boolean hourAngle = forMinute % 5 == 0;
int length = side / (numbersVisibleProperty.isEnabled() ? 18 :
(hourAngle ? 12 : 18));
int length = side / (numbersVisibleProperty.isEnabled() ? 18
: (hourAngle ? 12 : 18));
double angle = Math.PI * 2 * (value - 0.25);
int startX =
(int) (getWidth() / 2 + (side / 2 - length) * Math.cos(angle));
int startY =
(int) (getHeight() / 2 + (side / 2 - length) * Math.sin(angle));
int startX
= (int) (getWidth() / 2 + (side / 2 - length) * Math.cos(angle));
int startY
= (int) (getHeight() / 2 + (side / 2 - length) * Math.sin(angle));
int endX = (int) (getWidth() / 2
+ (side / 2 - length * 0.50d * (hourAngle ? 0.25 : 1))
* Math.cos(angle));
+ (side / 2 - length * 0.50d * (hourAngle ? 0.25 : 1))
* Math.cos(angle));
int endY = (int) (getHeight() / 2
+ (side / 2 - length * 0.50d * (hourAngle ? 0.25 : 1))
* Math.sin(angle));
+ (side / 2 - length * 0.50d * (hourAngle ? 0.25 : 1))
* Math.sin(angle));
brush.setColor((visibility.isStronglyColored() || mouseOver) ? color
: FOREGROUND_COLOR);
@ -312,8 +316,8 @@ public class AnalogClock extends Widget {
int endX = (int) (getWidth() / 2 + length * Math.cos(angle));
int endY = (int) (getHeight() / 2 + length * Math.sin(angle));
brush.setColor((visibility.isStronglyColored() || mouseOver) ?
(handsColoredProperty.isEnabled() ? color : Color.BLACK)
brush.setColor((visibility.isStronglyColored() || mouseOver)
? (handsColoredProperty.isEnabled() ? color : Color.BLACK)
: FOREGROUND_COLOR);
brush.setStroke(new BasicStroke(stroke));
brush.drawLine(getWidth() / 2, getHeight() / 2, endX, endY);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -33,19 +33,19 @@ public class Jokes {
static {
try {
array = JokesTxt.getAsArray();
if(array.length > 0) {
if (array.length > 0) {
Set<String> set = new HashSet<>();
for (String vtip : array) {
if (vtip.trim().isEmpty()) {
//nothing to do
continue;
for (String vtip : array) {
if (vtip.trim().isEmpty()) {
//nothing to do
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) {
System.err.println(e);
}

View File

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

View File

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

View File

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

View File

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

View File

@ -14,6 +14,11 @@ public class IntegerProperty extends Property<Integer> {
this(name, 0);
}
public void increment() {this.setValue(getValue() + 1);}
public void decrement() {this.setValue(getValue() - 1);}
public void increment() {
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 List<InvalidationListener> invalidationListeners
= new ArrayList<>();
private final List<ChangeListener<T>> changeListeners =
new ArrayList<ChangeListener<T>>();
private final List<ChangeListener<T>> changeListeners
= new ArrayList<ChangeListener<T>>();
private boolean valid = true;
private T value;
private Property<T> boundToProperty = null;
@ -51,7 +51,7 @@ public class Property<T> {
}
public void bindTo(Property<T> anotherProperty) {
if(this == anotherProperty) {
if (this == anotherProperty) {
new RuntimeException().printStackTrace();
throw new TimeCalcException("Cannot bind to self: " + getName());
}
@ -59,10 +59,10 @@ public class Property<T> {
this.boundToProperty = anotherProperty;
this.boundChangeListener
= (Property<T> p, T oldValue, T newValue) -> {
this.markInvalid();
this.fireValueChangedEvent(oldValue);
//System.out.println("bindTo markInvalid " + p.getName() + " " + p.getValue());
};
this.markInvalid();
this.fireValueChangedEvent(oldValue);
//System.out.println("bindTo markInvalid " + p.getName() + " " + p.getValue());
};
this.boundToProperty
.addListener(boundChangeListener);