From e553ecb6a6e1c7951b2b6bf6badc895f65816de6 Mon Sep 17 00:00:00 2001 From: Robert Vokac Date: Sat, 9 Mar 2024 11:02:33 +0000 Subject: [PATCH] Added several improvements --- Readme.md | 2 - .../timecalc/swing/common/MainWindow.java | 4 +- .../timecalc/swing/progress/AnalogClock.java | 11 +++++ .../utils/timecalc/swing/progress/Time.java | 4 +- .../src/main/resources/help/Readme.md | 48 +++++++++---------- 5 files changed, 39 insertions(+), 30 deletions(-) diff --git a/Readme.md b/Readme.md index aff119a..3ccd92d 100644 --- a/Readme.md +++ b/Readme.md @@ -44,8 +44,6 @@ If file overtime.txt does not exist, then the default overtime is 0:00. ### .tc/test.txt If file test.txt exists, then user is not asked for start time and overtime. Instead, the values in files starttime.txt and overtime.txt are used. -This file can be also used to define custom current time - for testing purposes. - ### ./tc/timecalc.conf Configuration is stored here. diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/MainWindow.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/MainWindow.java index 4372eae..755b139 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/MainWindow.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/MainWindow.java @@ -195,7 +195,9 @@ public class MainWindow extends TWindow { } }); hideShowCheckBox.addItemListener(e -> + { + this.requestFocus(); }); exitButton.addActionListener(e -> { @@ -253,7 +255,7 @@ public class MainWindow extends TWindow { analogClock.secondProperty.bindTo( time.secondProperty); analogClock.millisecondProperty.bindTo(time.millisecondProperty); - analogClock.dayOfWeekProperty.bindTo(time.dayOfWeek); + analogClock.dayOfWeekProperty.bindTo(time.dayOfWeekProperty); analogClock.millisecondEnabledProperty .bindTo(timeCalcConfiguration.clockHandsMillisecondVisibleProperty); diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/AnalogClock.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/AnalogClock.java index 0fd2b97..fbba849 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/AnalogClock.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/AnalogClock.java @@ -127,6 +127,17 @@ public class AnalogClock extends Widget { = new AnalogClock(new TimeHM("6:30"), new TimeHM("19:00")); window.add(clock); window.pack(); + Time time = new Time(); + time.allowCustomValuesProperty.setValue(true); + clock.dayProperty.bindTo(time.dayProperty); + clock.monthProperty.bindTo(time.monthProperty); + clock.yearProperty.bindTo(time.yearProperty); + clock.hourProperty.bindTo(time.hourProperty); + clock.minuteProperty.bindTo(time.minuteProperty); + clock.secondProperty.bindTo( time.secondProperty); + clock.millisecondProperty.bindTo(time.millisecondProperty); + clock.dayOfWeekProperty.bindTo(time.dayOfWeekProperty); + clock.visibilityProperty.setValue(Visibility.GRAY.name()); window.setVisible(true); // window.addKeyListener(new KeyAdapter() { // // Key Pressed method diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/Time.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/Time.java index 88c22f2..2dcf48e 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/Time.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/Time.java @@ -38,7 +38,7 @@ public class Time extends Thread { = secondReadWriteProperty.asReadOnlyProperty(); public ReadOnlyProperty millisecondProperty = millisecondReadWriteProperty.asReadOnlyProperty(); - public ReadOnlyProperty dayOfWeek + public ReadOnlyProperty dayOfWeekProperty = dayOfWeekReadWriteProperty.asReadOnlyProperty(); public final IntegerProperty yearCustomProperty = new IntegerProperty("yearCustomProperty", Integer.MAX_VALUE); @@ -111,7 +111,7 @@ public class Time extends Thread { + minuteProperty.getValue() + " " + secondProperty.getValue() + " " + millisecondProperty.getValue() + " " - + dayOfWeek.getValue() + " " + + dayOfWeekProperty.getValue() + " " ); } private int returnCustomValueIfNeeded(Calendar cal, int timeUnit, diff --git a/modules/time-calc-app/src/main/resources/help/Readme.md b/modules/time-calc-app/src/main/resources/help/Readme.md index 7317bfb..3ccd92d 100644 --- a/modules/time-calc-app/src/main/resources/help/Readme.md +++ b/modules/time-calc-app/src/main/resources/help/Readme.md @@ -13,13 +13,13 @@ _Time Calc is written in Java programming language and uses the Swing framework. ### Start of application When "Time Calc" is started", user is asked for: -- start time ... like 7:30 -- overtime ... like 0:45 ... overtime is optional and the default value is 0:00 + - start time ... like 7:30 + - overtime ... like 0:45 ... overtime is optional and the default value is 0:00 ### Restart of application You can restart the app, if you press the **"Restart"** button. -- Then you are asked again for start time and overtime. + - Then you are asked again for start time and overtime. ### End of application @@ -33,7 +33,7 @@ If these files are present, something special happens. ### .tc/starttime.txt -This file contains the default start time - used during the previous run of the app. +This file contains the default start time - used during the previous run of the app. If file starttime.txt does not exist, then the default start time is 7:00. ### .tc/overtime.txt @@ -44,8 +44,6 @@ If file overtime.txt does not exist, then the default overtime is 0:00. ### .tc/test.txt If file test.txt exists, then user is not asked for start time and overtime. Instead, the values in files starttime.txt and overtime.txt are used. -This file can be also used to define custom current time - for testing purposes. - ### ./tc/timecalc.conf Configuration is stored here. @@ -66,29 +64,29 @@ Optional assignments of profiles to numbers is stored here. ### 3 Visibility modes -* STRONGLY_COLORED - many colors -* WEAKLY_COLORED - darkened colors -* GRAY - gray colors -* NONE - widgets are hidden + * STRONGLY_COLORED - many colors + * WEAKLY_COLORED - darkened colors + * GRAY - gray colors + * NONE - widgets are hidden ### Widgets #### Analog Clock -* hour hand -* minute hand (can be disabled in configuration) -* second hand (can be disabled in configuration) -* millisecond hand (can be disabled in configuration) -* shows current year, month, day of month and day of week, if analog clock is hovered by mouse cursor and Visibility is STRONGLY_COLORED -* shows yellow highlighted remaining time until end of today working hours, if analog clock is hovered by mouse cursor and Visibility is STRONGLY_COLORED -* hands can be long or shorter (can be set in configuration) + * hour hand + * minute hand (can be disabled in configuration) + * second hand (can be disabled in configuration) + * millisecond hand (can be disabled in configuration) + * shows current year, month, day of month and day of week, if analog clock is hovered by mouse cursor and Visibility is STRONGLY_COLORED + * shows yellow highlighted remaining time until end of today working hours, if analog clock is hovered by mouse cursor and Visibility is STRONGLY_COLORED + * hands can be long or shorter (can be set in configuration) #### Progress Square -* Show graphically day progress + * Show graphically day progress #### Progress Circle -* Show graphically day progress + * Show graphically day progress #### Hour Battery @@ -176,12 +174,12 @@ Smileys can be colored or white-black (can be set in configuration) ## Todos -* Split to Maven modules -* Junit, Mockito, etc. -* Checkstyle -* Sonarlint -* Sonarqube -* Add SQLite support and store times of arrivals and departures and time of activities + * Split to Maven modules + * Junit, Mockito, etc. + * Checkstyle + * Sonarlint + * Sonarqube + * Add SQLite support and store times of arrivals and departures and time of activities ## For Developers