Added new improvements

This commit is contained in:
Robert Vokac 2024-02-03 06:38:35 +00:00
parent ee70a247ef
commit 60ff5ecc8e
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
6 changed files with 55 additions and 11 deletions

View File

@ -1,5 +1,6 @@
package org.nanoboot.utils.timecalc.gui.progress;
import lombok.Getter;
import org.nanoboot.utils.timecalc.gui.common.Widget;
import org.nanoboot.utils.timecalc.main.TimeCalcConf;
import org.nanoboot.utils.timecalc.utils.NumberFormats;
@ -21,6 +22,8 @@ public class Battery extends Widget {
public static final Color HIGH_HIGHLIGHTED = new Color(158, 227, 158);
public static final Color HIGHEST_HIGHLIGHTED = Color.green;
public static boolean wavesOff = false;
@Getter
private final String name;
private int totalHeight = 0;
@ -28,12 +31,13 @@ public class Battery extends Widget {
private String label = null;
private final double[] randomDoubles = new double[] {1d, 1d, 1d, 1d, 1d, 1d, 1};
public Battery() {
protected Battery(String name) {
this.name = name;
setPreferredSize(new Dimension(40, 100));
}
public Battery(int i, int y, int height) {
this();
protected Battery(String name, int i, int y, int height) {
this(name);
setBounds(i, y, height);
}
@ -129,6 +133,12 @@ public class Battery extends Widget {
(donePercent > 0.5 ? totalHeight / 4 * 3 :
totalHeight / 4 * 1) + 20);
}
if (name != null && !name.isEmpty()) {
g2d.drawString(
name,
((int) (width_ * 0.4)),
(totalHeight / 4 * 3) + 20 + 20);
}
}

View File

@ -6,6 +6,6 @@ package org.nanoboot.utils.timecalc.gui.progress;
*/
public class DayBattery extends Battery{
public DayBattery(int x, int i, int i1) {
super(x, i, i1);
super("Day", x, i, i1);
}
}

View File

@ -8,7 +8,7 @@ import org.nanoboot.utils.timecalc.utils.TimeHM;
*/
public class HourBattery extends Battery{
public HourBattery(int x, int i, int i1) {
super(x, i, i1);
super("Hour", x, i, i1);
}
public static double getHourProgress(TimeHM timeRemains, int secondsRemains,
int millisecondsRemains) {

View File

@ -0,0 +1,16 @@
package org.nanoboot.utils.timecalc.gui.progress;
/**
* @author Robert
* @since 21.02.2024
*/
public class MonthBattery extends Battery{
public MonthBattery(int x, int i, int i1) {
super("Month", x, i, i1);
}
public static double getMonthProgress(int weekDayWhenMondayIsOne, double done) {
return weekDayWhenMondayIsOne == 0
|| weekDayWhenMondayIsOne == 6 ?
100 : ((weekDayWhenMondayIsOne - 1) * 0.20 + done * 0.20);
}
}

View File

@ -0,0 +1,18 @@
package org.nanoboot.utils.timecalc.gui.progress;
import org.nanoboot.utils.timecalc.utils.TimeHM;
/**
* @author Robert
* @since 21.02.2024
*/
public class WeekBattery extends Battery{
public WeekBattery(int x, int i, int i1) {
super("Week", x, i, i1);
}
public static double getWeekProgress(int weekDayWhenMondayIsOne, double done) {
return weekDayWhenMondayIsOne == 0
|| weekDayWhenMondayIsOne == 6 ?
100 : ((weekDayWhenMondayIsOne - 1) * 0.20 + done * 0.20);
}
}

View File

@ -9,9 +9,11 @@ import org.nanoboot.utils.timecalc.gui.progress.AnalogClock;
import org.nanoboot.utils.timecalc.gui.progress.Battery;
import org.nanoboot.utils.timecalc.gui.progress.DayBattery;
import org.nanoboot.utils.timecalc.gui.progress.HourBattery;
import org.nanoboot.utils.timecalc.gui.progress.MonthBattery;
import org.nanoboot.utils.timecalc.gui.progress.ProgressCircle;
import org.nanoboot.utils.timecalc.gui.progress.ProgressSquare;
import org.nanoboot.utils.timecalc.gui.progress.WalkingHumanProgressAsciiArt;
import org.nanoboot.utils.timecalc.gui.progress.WeekBattery;
import org.nanoboot.utils.timecalc.utils.Constants;
import org.nanoboot.utils.timecalc.utils.DateFormats;
import org.nanoboot.utils.timecalc.utils.Jokes;
@ -229,7 +231,7 @@ public class TimeCalcManager {
progressCircle.getY() + MARGIN + progressCircle.getHeight(), 140);
window.add(dayBattery);
Battery weekBattery = new Battery(
Battery weekBattery = new WeekBattery(
dayBattery.getBounds().x + dayBattery.getWidth(),
dayBattery.getY(), 140);
window.add(weekBattery);
@ -264,7 +266,7 @@ public class TimeCalcManager {
|| currentDayOfWeekAsString.equals("SUNDAY");
workDaysTotal = workDaysDone + (nowIsWeekend ? 0 : 1) + workDaysTodo;
Battery monthBattery = new Battery(
Battery monthBattery = new MonthBattery(
dayBattery.getBounds().x + dayBattery.getWidth(),
dayBattery.getY() + weekBattery.getHeight() + MARGIN, 140);
window.add(monthBattery);
@ -361,9 +363,7 @@ public class TimeCalcManager {
dayBattery.setDonePercent(done);
int weekDayWhenMondayIsOne = calNow.get(Calendar.DAY_OF_WEEK) - 1;
weekBattery.setDonePercent((weekDayWhenMondayIsOne == 0
|| weekDayWhenMondayIsOne == 6) ?
100 : ((weekDayWhenMondayIsOne - 1) * 0.20 + done * 0.20));
weekBattery.setDonePercent(WeekBattery.getWeekProgress(weekDayWhenMondayIsOne, done));
weekBattery.setLabel(
nowIsWeekend ? "5/5" : (weekDayWhenMondayIsOne + "/5"));
@ -444,7 +444,7 @@ public class TimeCalcManager {
window.setVisible(false);
window.dispose();
}
private String createWindowTitle() {
return "Time Calc " + Utils.getVersion();
}