Added new improvements
This commit is contained in:
parent
ff211e391e
commit
83f4e130a2
2
pom.xml
2
pom.xml
@ -102,7 +102,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.22</version>
|
||||
<version>1.18.20</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -11,6 +11,7 @@ import org.nanoboot.utils.timecalc.utils.Constants;
|
||||
import org.nanoboot.utils.timecalc.utils.DateFormats;
|
||||
import org.nanoboot.utils.timecalc.utils.Jokes;
|
||||
import org.nanoboot.utils.timecalc.utils.NumberFormats;
|
||||
import org.nanoboot.utils.timecalc.utils.TimeHoursMinutes;
|
||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
@ -47,12 +48,10 @@ public class TimeCalcWindow {
|
||||
private static final int MARGIN = 10;
|
||||
|
||||
private final String windowTitle;
|
||||
private final int startHour;
|
||||
private final int startMinute;
|
||||
private final int overtimeHour;
|
||||
private final int overtimeMinute;
|
||||
private final int totalMinutes;
|
||||
private final Set<Integer> alreadyShownPercents = new HashSet<>();
|
||||
private final TimeHoursMinutes startTime;
|
||||
private final TimeHoursMinutes overtime;
|
||||
private int endHour;
|
||||
private int endMinute;
|
||||
private boolean stopBeforeEnd = false;
|
||||
@ -67,27 +66,17 @@ public class TimeCalcWindow {
|
||||
overTimeIn = (overTimeIn == null || overTimeIn.isEmpty()) ?
|
||||
Constants.DEFAULT_OVERTIME : overTimeIn;
|
||||
|
||||
String[] startTimeAsArray = startTimeIn.split(":");
|
||||
this.startHour = Integer.valueOf(startTimeAsArray[0]);
|
||||
this.startMinute = Integer.valueOf(startTimeAsArray[1]);
|
||||
this.startTime = new TimeHoursMinutes(startTimeIn);
|
||||
this.overtime = new TimeHoursMinutes(overTimeIn);
|
||||
|
||||
boolean overtimeIsNegative = overTimeIn.startsWith("-");
|
||||
if (overtimeIsNegative) {
|
||||
overTimeIn = overTimeIn.replace("-", "");
|
||||
}
|
||||
this.overtimeHour = (overtimeIsNegative ? (-1) : 1) * Integer
|
||||
.valueOf(overTimeIn.split(":")[0]);
|
||||
this.overtimeMinute = (overtimeIsNegative ? (-1) : 1) * Integer
|
||||
.valueOf(overTimeIn.split(":")[1]);
|
||||
|
||||
this.endHour = startHour + Constants.WORKING_HOURS_LENGTH + overtimeHour;
|
||||
this.endMinute = startMinute + Constants.WORKING_MINUTES_LENGTH + overtimeMinute;
|
||||
this.endHour = startTime.getHour() + Constants.WORKING_HOURS_LENGTH + overtime.getHour();
|
||||
this.endMinute = startTime.getMinute() + Constants.WORKING_MINUTES_LENGTH + overtime.getMinute();
|
||||
while (endMinute >= 60) {
|
||||
endMinute = endMinute - 60;
|
||||
endHour = endHour + 1;
|
||||
}
|
||||
this.totalMinutes =
|
||||
(endHour * 60 + endMinute) - (startHour * 60 + startMinute);
|
||||
(endHour * 60 + endMinute) - (startTime.getHour() * 60 + startTime.getMinute());
|
||||
int totalSeconds = totalMinutes * 60;
|
||||
int totalMilliseconds = totalSeconds * 1000;
|
||||
|
||||
@ -441,8 +430,8 @@ public class TimeCalcWindow {
|
||||
int secondsRemains = 60 - secondNow;
|
||||
int millisecondsRemains = 1000 - millisecondNow;
|
||||
|
||||
int hourDone = Constants.WORKING_HOURS_LENGTH + overtimeHour - hourRemains;
|
||||
int minutesDone = Constants.WORKING_MINUTES_LENGTH + overtimeMinute - minuteRemains;
|
||||
int hourDone = Constants.WORKING_HOURS_LENGTH + overtime.getHour() - hourRemains;
|
||||
int minutesDone = Constants.WORKING_MINUTES_LENGTH + overtime.getMinute() - minuteRemains;
|
||||
int secondsDone = secondNow;
|
||||
int millisecondsDone = millisecondNow;
|
||||
|
||||
|
@ -1,17 +1,25 @@
|
||||
package org.nanoboot.utils.timecalc.utils;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author Robert
|
||||
* @since 21.02.2024
|
||||
*/
|
||||
public class TimeHoursMinutes {
|
||||
|
||||
@Getter
|
||||
private final Integer hour;
|
||||
@Getter
|
||||
private final Integer minute;
|
||||
|
||||
public TimeHoursMinutes(String string) {
|
||||
boolean isNegative = string.startsWith("-");
|
||||
if (isNegative) {
|
||||
string = string.replace("-", "");
|
||||
}
|
||||
String[] array = string.split(":");
|
||||
this.hour = Integer.valueOf(array[0]);
|
||||
this.minute = Integer.valueOf(array[1]);
|
||||
this.hour = (isNegative ? (-1) : 1) * Integer.valueOf(array[0]);
|
||||
this.minute = (isNegative ? (-1) : 1) * Integer.valueOf(array[1]);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user