mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
Added new improvements
This commit is contained in:
parent
ee70a247ef
commit
60ff5ecc8e
@ -1,5 +1,6 @@
|
|||||||
package org.nanoboot.utils.timecalc.gui.progress;
|
package org.nanoboot.utils.timecalc.gui.progress;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import org.nanoboot.utils.timecalc.gui.common.Widget;
|
import org.nanoboot.utils.timecalc.gui.common.Widget;
|
||||||
import org.nanoboot.utils.timecalc.main.TimeCalcConf;
|
import org.nanoboot.utils.timecalc.main.TimeCalcConf;
|
||||||
import org.nanoboot.utils.timecalc.utils.NumberFormats;
|
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 HIGH_HIGHLIGHTED = new Color(158, 227, 158);
|
||||||
public static final Color HIGHEST_HIGHLIGHTED = Color.green;
|
public static final Color HIGHEST_HIGHLIGHTED = Color.green;
|
||||||
public static boolean wavesOff = false;
|
public static boolean wavesOff = false;
|
||||||
|
@Getter
|
||||||
|
private final String name;
|
||||||
|
|
||||||
private int totalHeight = 0;
|
private int totalHeight = 0;
|
||||||
|
|
||||||
@ -28,12 +31,13 @@ public class Battery extends Widget {
|
|||||||
private String label = null;
|
private String label = null;
|
||||||
private final double[] randomDoubles = new double[] {1d, 1d, 1d, 1d, 1d, 1d, 1};
|
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));
|
setPreferredSize(new Dimension(40, 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Battery(int i, int y, int height) {
|
protected Battery(String name, int i, int y, int height) {
|
||||||
this();
|
this(name);
|
||||||
setBounds(i, y, height);
|
setBounds(i, y, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,6 +133,12 @@ public class Battery extends Widget {
|
|||||||
(donePercent > 0.5 ? totalHeight / 4 * 3 :
|
(donePercent > 0.5 ? totalHeight / 4 * 3 :
|
||||||
totalHeight / 4 * 1) + 20);
|
totalHeight / 4 * 1) + 20);
|
||||||
}
|
}
|
||||||
|
if (name != null && !name.isEmpty()) {
|
||||||
|
g2d.drawString(
|
||||||
|
name,
|
||||||
|
((int) (width_ * 0.4)),
|
||||||
|
(totalHeight / 4 * 3) + 20 + 20);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,6 @@ package org.nanoboot.utils.timecalc.gui.progress;
|
|||||||
*/
|
*/
|
||||||
public class DayBattery extends Battery{
|
public class DayBattery extends Battery{
|
||||||
public DayBattery(int x, int i, int i1) {
|
public DayBattery(int x, int i, int i1) {
|
||||||
super(x, i, i1);
|
super("Day", x, i, i1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import org.nanoboot.utils.timecalc.utils.TimeHM;
|
|||||||
*/
|
*/
|
||||||
public class HourBattery extends Battery{
|
public class HourBattery extends Battery{
|
||||||
public HourBattery(int x, int i, int i1) {
|
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,
|
public static double getHourProgress(TimeHM timeRemains, int secondsRemains,
|
||||||
int millisecondsRemains) {
|
int millisecondsRemains) {
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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.Battery;
|
||||||
import org.nanoboot.utils.timecalc.gui.progress.DayBattery;
|
import org.nanoboot.utils.timecalc.gui.progress.DayBattery;
|
||||||
import org.nanoboot.utils.timecalc.gui.progress.HourBattery;
|
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.ProgressCircle;
|
||||||
import org.nanoboot.utils.timecalc.gui.progress.ProgressSquare;
|
import org.nanoboot.utils.timecalc.gui.progress.ProgressSquare;
|
||||||
import org.nanoboot.utils.timecalc.gui.progress.WalkingHumanProgressAsciiArt;
|
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.Constants;
|
||||||
import org.nanoboot.utils.timecalc.utils.DateFormats;
|
import org.nanoboot.utils.timecalc.utils.DateFormats;
|
||||||
import org.nanoboot.utils.timecalc.utils.Jokes;
|
import org.nanoboot.utils.timecalc.utils.Jokes;
|
||||||
@ -229,7 +231,7 @@ public class TimeCalcManager {
|
|||||||
progressCircle.getY() + MARGIN + progressCircle.getHeight(), 140);
|
progressCircle.getY() + MARGIN + progressCircle.getHeight(), 140);
|
||||||
window.add(dayBattery);
|
window.add(dayBattery);
|
||||||
|
|
||||||
Battery weekBattery = new Battery(
|
Battery weekBattery = new WeekBattery(
|
||||||
dayBattery.getBounds().x + dayBattery.getWidth(),
|
dayBattery.getBounds().x + dayBattery.getWidth(),
|
||||||
dayBattery.getY(), 140);
|
dayBattery.getY(), 140);
|
||||||
window.add(weekBattery);
|
window.add(weekBattery);
|
||||||
@ -264,7 +266,7 @@ public class TimeCalcManager {
|
|||||||
|| currentDayOfWeekAsString.equals("SUNDAY");
|
|| currentDayOfWeekAsString.equals("SUNDAY");
|
||||||
workDaysTotal = workDaysDone + (nowIsWeekend ? 0 : 1) + workDaysTodo;
|
workDaysTotal = workDaysDone + (nowIsWeekend ? 0 : 1) + workDaysTodo;
|
||||||
|
|
||||||
Battery monthBattery = new Battery(
|
Battery monthBattery = new MonthBattery(
|
||||||
dayBattery.getBounds().x + dayBattery.getWidth(),
|
dayBattery.getBounds().x + dayBattery.getWidth(),
|
||||||
dayBattery.getY() + weekBattery.getHeight() + MARGIN, 140);
|
dayBattery.getY() + weekBattery.getHeight() + MARGIN, 140);
|
||||||
window.add(monthBattery);
|
window.add(monthBattery);
|
||||||
@ -361,9 +363,7 @@ public class TimeCalcManager {
|
|||||||
dayBattery.setDonePercent(done);
|
dayBattery.setDonePercent(done);
|
||||||
|
|
||||||
int weekDayWhenMondayIsOne = calNow.get(Calendar.DAY_OF_WEEK) - 1;
|
int weekDayWhenMondayIsOne = calNow.get(Calendar.DAY_OF_WEEK) - 1;
|
||||||
weekBattery.setDonePercent((weekDayWhenMondayIsOne == 0
|
weekBattery.setDonePercent(WeekBattery.getWeekProgress(weekDayWhenMondayIsOne, done));
|
||||||
|| weekDayWhenMondayIsOne == 6) ?
|
|
||||||
100 : ((weekDayWhenMondayIsOne - 1) * 0.20 + done * 0.20));
|
|
||||||
weekBattery.setLabel(
|
weekBattery.setLabel(
|
||||||
nowIsWeekend ? "5/5" : (weekDayWhenMondayIsOne + "/5"));
|
nowIsWeekend ? "5/5" : (weekDayWhenMondayIsOne + "/5"));
|
||||||
|
|
||||||
@ -444,7 +444,7 @@ public class TimeCalcManager {
|
|||||||
window.setVisible(false);
|
window.setVisible(false);
|
||||||
window.dispose();
|
window.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createWindowTitle() {
|
private String createWindowTitle() {
|
||||||
return "Time Calc " + Utils.getVersion();
|
return "Time Calc " + Utils.getVersion();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user