Added new improvements

This commit is contained in:
Robert Vokac 2024-02-03 21:04:01 +00:00
parent 3e0440624b
commit bf40a63615
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
2 changed files with 20 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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