diff --git a/Readme.md b/Readme.md index 38eeaba..5a17b17 100644 --- a/Readme.md +++ b/Readme.md @@ -55,16 +55,6 @@ You can stop the app, if you press the **"Exit"** button or click on the exit wi 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. -If file starttime.txt does not exist, then the default start time is 7:00. - -### .tc/overtime.txt - -This file contains the default overtime - used during the previous run of the app. -If file overtime.txt does not exist, then the default overtime is 0:00. - ### ./tc/timecalc.conf Configuration is stored here. @@ -83,7 +73,7 @@ Optional assignments of profiles to numbers is stored here. ## Features -### 3 Visibility modes +### 4 Visibility modes * STRONGLY_COLORED - many colors * WEAKLY_COLORED - darkened colors @@ -187,16 +177,17 @@ Smileys can be colored or white-black (can be set in configuration) * LEFT - switch to previous profile * RIGHT - switch to next profile * K - hide or show clock -* SHIFT + {Y,N,D,H,M,S or I} - Increase test time value -* CTRL + {Y,N,D,H,M,S or I} - Decrease test time value -* ALT + {Y,N,D,H,M,S or I} - Rest test time value +* SHIFT + {Y,N,D,H,M,S,I,K} - Increase test time value +* CTRL + {Y,N,D,H,M,S,I,K} - Decrease test time value +* ALT + {Y,N,D,H,M,S,I,K} - Rest test time value +* Y=year, N=month, D=day of month, H=hour, M=minute, S=second, I=millisecond, K=week * D - Reset custom time values to the real time * SHIFT + A - Increase arrival time * CTRL + A - Decrease arrival time * SHIFT + O - Increase overtime * CTRL + O - Decrease overtime * SHIFT + W - Increase working time -* CTRL + W - Decrease worknig time +* CTRL + W - Decrease working time * SHIFT + P - Increase pause * CTRL + P - Decrease pause * SHIFT + C - Increase or decrease of time is change by 1 hour diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcConfiguration.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcConfiguration.java index 9381dea..4cd2aa8 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcConfiguration.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcConfiguration.java @@ -162,6 +162,10 @@ public class TimeCalcConfiguration { = new BooleanProperty(TimeCalcProperty.SQUARE_VISIBLE.getKey()); public final StringProperty squareTypeProperty = new StringProperty(TimeCalcProperty.SQUARE_TYPE.getKey()); + public final BooleanProperty dotVisibleProperty + = new BooleanProperty(TimeCalcProperty.DOT_VISIBLE.getKey()); + public final StringProperty dotTypeProperty + = new StringProperty(TimeCalcProperty.DOT_TYPE.getKey()); public final BooleanProperty circleVisibleProperty = new BooleanProperty(TimeCalcProperty.CIRCLE_VISIBLE.getKey()); public final StringProperty circleTypeProperty @@ -271,6 +275,8 @@ public class TimeCalcConfiguration { smileysColoredProperty, squareVisibleProperty, squareTypeProperty, + dotVisibleProperty, + dotTypeProperty, circleVisibleProperty, circleTypeProperty, swingVisibleProperty, diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java index e4cbe0b..8e2e672 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java @@ -122,6 +122,14 @@ public class TimeCalcKeyAdapter extends KeyAdapter { Calendar.MILLISECOND); break; } + case KeyEvent.VK_K: { + //Utils.showNotification((increase ? "Increasing" : (decrease ? "Decreasing" : "Reseting")) + " millisecond."); + for (int i = 1; i <= 7; i++) { + updateProperty(timeCalcConfiguration.testDayCustomProperty, increase, decrease, reset, + Calendar.DAY_OF_MONTH); + } + break; + } case KeyEvent.VK_A: { if (increase) { diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcProperty.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcProperty.java index ce8a156..a49416b 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcProperty.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcProperty.java @@ -1,7 +1,6 @@ package org.nanoboot.utils.timecalc.app; import lombok.Getter; -import org.nanoboot.utils.timecalc.utils.common.Utils; import javax.swing.JOptionPane; import java.awt.Color; @@ -82,6 +81,8 @@ public enum TimeCalcProperty { SMILEYS_COLORED("smileys.colored", "Smileys : Colored"), SQUARE_VISIBLE("square.visible", "Square"), SQUARE_TYPE("square.type", "Square : Type"), + DOT_VISIBLE("dot.visible", "Dot"), + DOT_TYPE("dot.type", "Dot : Type"), CIRCLE_VISIBLE("circle.visible", "Circle"), CIRCLE_TYPE("circle.type", "Circle : Type"), WALKING_HUMAN_VISIBLE("walking-human.visible", "Walking Human"), diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/Battery.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/Battery.java index 4b36adb..1520dbe 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/Battery.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/Battery.java @@ -402,7 +402,7 @@ public class Battery extends Widget { @Override public int getTimerDelay() { - return 25; + return 1000; } } diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressDot.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressDot.java new file mode 100644 index 0000000..1d8fedb --- /dev/null +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressDot.java @@ -0,0 +1,89 @@ +package org.nanoboot.utils.timecalc.swing.progress; + +import org.nanoboot.utils.timecalc.entity.Visibility; +import org.nanoboot.utils.timecalc.swing.common.Widget; +import org.nanoboot.utils.timecalc.utils.common.NumberFormats; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.util.ArrayList; +import java.util.List; +import lombok.AllArgsConstructor; + +public class ProgressDot extends Widget { + + private int square; + + @AllArgsConstructor + class Dot { + + private int x, y; + } + private List enabledDots = new ArrayList<>(); + private List disabledDots = new ArrayList<>(); + + public ProgressDot() { + setPreferredSize(new Dimension(400, 400)); + } + + @Override + public void paintWidget(Graphics g) { + if (side == 0) { + this.side = Math.min(getWidth(), getHeight()); + this.square = side * side; + for (int y = 1; y <= side; y++) { + for (int x = 1; x <= side; x++) { + disabledDots.add(new Dot(x, y)); + } + } + } + Double done = donePercent(); + int enabledDotsExpectedSize = (int) (done * square); + int disabledDotsExpectedSize = square - enabledDotsExpectedSize; +// System.out.println("enabledDots.size()=" + enabledDots.size()); +// System.out.println("disabledDots.size()=" + disabledDots.size()); + while (enabledDots.size() > enabledDotsExpectedSize) { + int randomIndex = (int) (enabledDots.size() * Math.random()); + Dot randomDot = enabledDots.remove(randomIndex); + disabledDots.add(randomDot); + } + while (enabledDots.size() < enabledDotsExpectedSize) { + int randomIndex = (int) (disabledDots.size() * Math.random()); + Dot randomDot = disabledDots.remove(randomIndex); + enabledDots.add(randomDot); + } + + Graphics2D brush = (Graphics2D) g; + brush.setColor(FOREGROUND_COLOR); + brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + + int numberOfDots = (int) (donePercent() * square); + + Visibility visibility = Visibility.ofProperty(visibilityProperty); + { + if (visibility.isStronglyColored() || mouseOver) { + brush.setColor(Color.GRAY); + } + + for(Dot d:enabledDots) { + brush.drawLine(d.x, d.y, d.x, d.y); + } + brush.setColor(FOREGROUND_COLOR); + } + brush.setColor(visibility.isStronglyColored() || mouseOver ? Color.BLACK + : BACKGROUND_COLOR); + + brush.drawString(NumberFormats.FORMATTER_FIVE_DECIMAL_PLACES + .format(donePercent() * 100) + "%", + (int) (side / 8d * 3d), + (int) (side / 8d * (donePercent() > 0.5 ? 3d : 5d))); + paintSmiley(visibility, brush, (int) (side / 8d * 3d), + (int) ((side / 8d * (donePercent() > 0.5 ? 3d : 5d)) - 32d)); + + } + +} diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/ConfigWindow.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/ConfigWindow.java index 4204753..a006fae 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/ConfigWindow.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/ConfigWindow.java @@ -186,6 +186,10 @@ public class ConfigWindow extends TWindow { = new JCheckBox(TimeCalcProperty.SQUARE_VISIBLE.getKey()); private final JTextField squareTypeProperty = new JTextField(TimeCalcProperty.SQUARE_TYPE.getKey()); + private final JCheckBox dotVisibleProperty + = new JCheckBox(TimeCalcProperty.DOT_VISIBLE.getKey()); + private final JTextField dotTypeProperty + = new JTextField(TimeCalcProperty.DOT_TYPE.getKey()); private final JCheckBox circleVisibleProperty = new JCheckBox(TimeCalcProperty.CIRCLE_VISIBLE.getKey()); private final JTextField circleTypeProperty @@ -391,6 +395,7 @@ public class ConfigWindow extends TWindow { smileysVisibleOnlyIfMouseMovingOverProperty .setSelected(!enable); squareVisibleProperty.setSelected(enable); + dotVisibleProperty.setSelected(enable); lifeVisibleProperty.setSelected(enable); moneyVisibleProperty.setSelected(enable); weatherVisibleProperty.setSelected(enable); @@ -455,6 +460,8 @@ public class ConfigWindow extends TWindow { notificationsVisibleProperty, squareVisibleProperty, squareTypeProperty, + dotVisibleProperty, + dotTypeProperty, circleVisibleProperty, circleTypeProperty, swingVisibleProperty, diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/MainWindow.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/MainWindow.java index 6cfeebf..7efa2d5 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/MainWindow.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/MainWindow.java @@ -67,6 +67,7 @@ import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.stream.Collectors; +import org.nanoboot.utils.timecalc.swing.progress.ProgressDot; /** * @author Robert Vokac @@ -114,6 +115,7 @@ public class MainWindow extends TWindow { private final IntegerProperty forgetOvertimeProperty = new IntegerProperty("forgetOvertimeProperty", 0); private WeekStatistics weekStatistics = null; + private final ProgressDot progressDot; { ChangeListener valueMustBeTime = @@ -324,22 +326,6 @@ public class MainWindow extends TWindow { progressLife.setBounds(progressSwing.getX() + progressSwing.getWidth() + SwingUtils.MARGIN, progressSwing.getY(), 100, 50); - { - progressSquare.typeProperty - .bindTo(timeCalcConfiguration.squareTypeProperty); - progressCircle.typeProperty - .bindTo(timeCalcConfiguration.circleTypeProperty); - walkingHumanProgress.typeProperty - .bindTo(timeCalcConfiguration.walkingHumanTypeProperty); - progressSwing.typeProperty - .bindTo(timeCalcConfiguration.swingTypeProperty); - progressLife.typeProperty - .bindTo(timeCalcConfiguration.lifeTypeProperty); - progressLife.birthDateProperty - .bindTo(timeCalcConfiguration.lifeBirthDateProperty); - progressLife.visibleProperty - .bindTo(timeCalcConfiguration.lifeVisibleProperty); - } add(progressLife); @@ -366,7 +352,38 @@ public class MainWindow extends TWindow { progressWeather.visibleProperty .bindTo(timeCalcConfiguration.weatherVisibleProperty); add(progressWeather); + + + this.progressDot + = new ProgressDot(); + progressDot.setBounds(progressWeather.getX() + progressWeather.getWidth() + SwingUtils.MARGIN, progressWeather.getY(), + 100, 100); + progressDot.visibleProperty + .bindTo(timeCalcConfiguration.weatherVisibleProperty); + add(progressDot); + + { + progressSquare.typeProperty + .bindTo(timeCalcConfiguration.squareTypeProperty); + progressDot.typeProperty + .bindTo(timeCalcConfiguration.dotTypeProperty); + progressDot.visibleProperty + .bindTo(timeCalcConfiguration.dotVisibleProperty); + progressCircle.typeProperty + .bindTo(timeCalcConfiguration.circleTypeProperty); + walkingHumanProgress.typeProperty + .bindTo(timeCalcConfiguration.walkingHumanTypeProperty); + progressSwing.typeProperty + .bindTo(timeCalcConfiguration.swingTypeProperty); + progressLife.typeProperty + .bindTo(timeCalcConfiguration.lifeTypeProperty); + progressLife.birthDateProperty + .bindTo(timeCalcConfiguration.lifeBirthDateProperty); + progressLife.visibleProperty + .bindTo(timeCalcConfiguration.lifeVisibleProperty); + } + TLabel arrivalTextFieldLabel = new TLabel("Arrival:", 70); arrivalTextFieldLabel.setBoundsFromTop(progressSwing, 3); @@ -1055,6 +1072,7 @@ public class MainWindow extends TWindow { progressSwing.setProgress(progress); progressLife.setProgress(progress); progressMoney.setProgress(progress); + progressDot.setProgress(progress); dayBattery.setProgress(progress); monthBattery.setProgress(progress); 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 89385c3..5a17b17 100644 --- a/modules/time-calc-app/src/main/resources/help/Readme.md +++ b/modules/time-calc-app/src/main/resources/help/Readme.md @@ -36,14 +36,14 @@ Time Calc is inspired by this document: [report.ods](https://code.nanoboot.org/n ### Start of application -When "Time Calc" is started", user should fill the correct value for: -- start time ... like 7:30 -- overtime ... like 0:45 ... overtime is optional and the default value is 0:00 +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 ### 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 @@ -73,31 +73,31 @@ Optional assignments of profiles to numbers is stored here. ## Features -### 3 Visibility modes +### 4 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 @@ -177,19 +177,20 @@ Smileys can be colored or white-black (can be set in configuration) * LEFT - switch to previous profile * RIGHT - switch to next profile * K - hide or show clock -* SHIFT + {Y,N,D,H,M,S or I} - Increase test time value -* CTRL + {Y,N,D,H,M,S or I} - Decrease test time value -* ALT + {Y,N,D,H,M,S or I} - Rest test time value +* SHIFT + {Y,N,D,H,M,S,I,K} - Increase test time value +* CTRL + {Y,N,D,H,M,S,I,K} - Decrease test time value +* ALT + {Y,N,D,H,M,S,I,K} - Rest test time value +* Y=year, N=month, D=day of month, H=hour, M=minute, S=second, I=millisecond, K=week * D - Reset custom time values to the real time * SHIFT + A - Increase arrival time * CTRL + A - Decrease arrival time * SHIFT + O - Increase overtime * CTRL + O - Decrease overtime * SHIFT + W - Increase working time -* CTRL + W - Decrease worknig time +* CTRL + W - Decrease working time * SHIFT + P - Increase pause * CTRL + P - Decrease pause -* SHIFT + C - Increase or decrease of time is change by 5 minutes +* SHIFT + C - Increase or decrease of time is change by 1 hour * CTRL + C - Increase or decrease of time is change by 1 minute * CTRL + E - Save arrival, overtime, working time, pause time and note @@ -199,12 +200,12 @@ Smileys can be colored or white-black (can be set in configuration) ### New features -* Custom arrival target -* Split to Maven modules -* Junit, Mockito, etc. -* Checkstyle -* Sonarlint -* Sonarqube + * Custom arrival target + * Split to Maven modules + * Junit, Mockito, etc. + * Checkstyle + * Sonarlint + * Sonarqube ### Fix these known bugs diff --git a/modules/time-calc-app/src/main/resources/timecalc-default.conf b/modules/time-calc-app/src/main/resources/timecalc-default.conf index a40f0a2..cbc93ad 100644 --- a/modules/time-calc-app/src/main/resources/timecalc-default.conf +++ b/modules/time-calc-app/src/main/resources/timecalc-default.conf @@ -47,6 +47,8 @@ smileys.visible-only-if-mouse-moving-over=true smileys.colored=true square.visible=true square.type=day +dot.visible=true +dot.type=day circle.visible=true circle.type=day swing.visible=true