From bf40a636159ed3f4ac4ea8f26de55afc7b72f143 Mon Sep 17 00:00:00 2001 From: Robert Vokac Date: Sat, 3 Feb 2024 21:04:01 +0000 Subject: [PATCH] Added new improvements --- src/main/java/rvc/timecalc/Battery.java | 15 +++++++++++++++ src/main/java/rvc/timecalc/TimeCalcWindow.java | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/rvc/timecalc/Battery.java b/src/main/java/rvc/timecalc/Battery.java index 0b5a202..829c08a 100644 --- a/src/main/java/rvc/timecalc/Battery.java +++ b/src/main/java/rvc/timecalc/Battery.java @@ -27,6 +27,7 @@ public class Battery extends Widget { private int totalHeight = 0; private int width_; + private String label = null; public Battery() { setPreferredSize(new Dimension(40, 100)); @@ -105,6 +106,14 @@ public class Battery extends Widget { formatter3.format(donePercent * 100) + "%", ((int) (width_ * 0.4)), donePercent > 0.5 ? totalHeight / 4 * 3 : totalHeight / 4 * 1); + if(label!= null && !label.isEmpty()) { + g2d.drawString( + label, + ((int) (width_ * 0.4)), + (donePercent > 0.5 ? totalHeight / 4 * 3 : + totalHeight / 4 * 1)+ 20); + } + } private double[] randomDoubles = new double[]{1d,1d,1d,1d,1d,1d,1}; @@ -115,4 +124,10 @@ public class Battery extends Widget { public int getTimerDelay() { return 250; } + public void setLabel(String label) { + this.label = label; + } + public String getLabel() { + return this.label; + } } \ No newline at end of file diff --git a/src/main/java/rvc/timecalc/TimeCalcWindow.java b/src/main/java/rvc/timecalc/TimeCalcWindow.java index 6e5d52b..6f6a6b8 100644 --- a/src/main/java/rvc/timecalc/TimeCalcWindow.java +++ b/src/main/java/rvc/timecalc/TimeCalcWindow.java @@ -400,9 +400,11 @@ public class TimeCalcWindow { batteryForWeek.setDonePercent((weekDayWhenMondayIsOne == 0 || weekDayWhenMondayIsOne == 6) ? 100 : ((weekDayWhenMondayIsOne - 1) * 0.20 + done * 0.20)); + batteryForWeek.setLabel("#" + (nowIsWeekend ? 0 : (6 - weekDayWhenMondayIsOne))); batteryForMonth.setDonePercent(weekDayWhenMondayIsOne == 0 || weekDayWhenMondayIsOne == 6 ? workDaysDone/workDaysTotal : (workDaysDone + done) / workDaysTotal); + batteryForMonth.setLabel("#" + (nowIsWeekend ? workDaysTodo : (workDaysTodo + 1))); double minutesRemainsD = (double) minuteRemains; @@ -417,6 +419,9 @@ public class TimeCalcWindow { minutesRemainsD = minutesRemainsD - 1d/1000d; } batteryForHour.setDonePercent(1 - ((minutesRemainsD%60d)/60d)); + if(done < 1 && !nowIsWeekend) { + batteryForHour.setLabel("#" + ((int)(minutesRemainsD / 60d))); + } int totalSecondsRemains = (hourRemains * 60 * 60 + minuteRemains * 60