Added new improvements
This commit is contained in:
parent
56428bf9e9
commit
960fdaa593
@ -0,0 +1,23 @@
|
||||
package org.nanoboot.utils.timecalc.gui.common;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import java.awt.Component;
|
||||
import java.awt.HeadlessException;
|
||||
|
||||
/**
|
||||
* @author Robert
|
||||
* @since 21.02.2024
|
||||
*/
|
||||
public class TimeCalcWindow extends JFrame {
|
||||
public TimeCalcWindow() throws HeadlessException {
|
||||
setFocusable(true);
|
||||
}
|
||||
|
||||
public Component[] addAll(Component... comp) {
|
||||
for(Component c:comp) {
|
||||
add(c);
|
||||
}
|
||||
return comp;
|
||||
}
|
||||
|
||||
}
|
@ -53,8 +53,8 @@ public class Main {
|
||||
Utils.writeTextToFile(FileConstants.STARTTIME_TXT, newStartTime);
|
||||
Utils.writeTextToFile(FileConstants.OVERTIME_TXT, newOvertime);
|
||||
try {
|
||||
TimeCalcWindow timeCalc =
|
||||
new TimeCalcWindow(newStartTime, newOvertime);
|
||||
TimeCalcManager timeCalc =
|
||||
new TimeCalcManager(newStartTime, newOvertime);
|
||||
} catch (Exception e) {
|
||||
JOptionPane.showMessageDialog(null, "Error: " + e.getMessage(),
|
||||
e.getMessage(), JOptionPane.ERROR_MESSAGE);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.nanoboot.utils.timecalc.main;
|
||||
|
||||
import org.nanoboot.utils.timecalc.gui.common.TimeCalcButton;
|
||||
import org.nanoboot.utils.timecalc.gui.common.TimeCalcWindow;
|
||||
import org.nanoboot.utils.timecalc.gui.common.Toaster;
|
||||
import org.nanoboot.utils.timecalc.gui.common.WeatherWindow;
|
||||
import org.nanoboot.utils.timecalc.gui.progress.AnalogClock;
|
||||
@ -43,11 +44,10 @@ import static org.nanoboot.utils.timecalc.utils.FileConstants.FOCUS_TXT;
|
||||
* @author pc00289
|
||||
* @since 08.02.2024
|
||||
*/
|
||||
public class TimeCalcWindow {
|
||||
public class TimeCalcManager {
|
||||
public static final String WALL = "||";
|
||||
private static final int MARGIN = 10;
|
||||
|
||||
|
||||
private final String windowTitle;
|
||||
private final int totalMinutes;
|
||||
private final Set<Integer> alreadyShownPercents = new HashSet<>();
|
||||
@ -57,7 +57,7 @@ public class TimeCalcWindow {
|
||||
private boolean stopBeforeEnd = false;
|
||||
private boolean vtipyShown = false;
|
||||
|
||||
public TimeCalcWindow(String startTimeIn, String overTimeIn) {
|
||||
public TimeCalcManager(String startTimeIn, String overTimeIn) {
|
||||
Utils.everythingHidden
|
||||
.set(TimeCalcConf.getInstance().isEverythingHidden());
|
||||
Utils.toastsAreEnabled
|
||||
@ -72,14 +72,11 @@ public class TimeCalcWindow {
|
||||
this.endTime = new TimeHoursMinutes(startTime.getHour() + Constants.WORKING_HOURS_LENGTH + overtime.getHour(),
|
||||
startTime.getMinute() + Constants.WORKING_MINUTES_LENGTH + overtime.getMinute());
|
||||
|
||||
this.totalMinutes =
|
||||
(this.endTime.getHour() * TimeHoursMinutes.MINUTES_PER_HOUR + this.endTime.getMinute()) - (startTime.getHour() * TimeHoursMinutes.MINUTES_PER_HOUR + startTime.getMinute());
|
||||
int totalSeconds = totalMinutes * 60;
|
||||
this.totalMinutes = TimeHoursMinutes.countDiffInMinutes(startTime, endTime);
|
||||
int totalSeconds = totalMinutes * TimeHoursMinutes.SECONDS_PER_MINUTE;
|
||||
int totalMilliseconds = totalSeconds * TimeHoursMinutes.MILLISECONDS_PER_SECOND;
|
||||
|
||||
|
||||
|
||||
JFrame window = new JFrame();
|
||||
TimeCalcWindow window = new TimeCalcWindow();
|
||||
|
||||
TimeCalcButton focusButton = new TimeCalcButton("F");
|
||||
TimeCalcButton commandButton = new TimeCalcButton("Command");
|
||||
@ -105,13 +102,8 @@ public class TimeCalcWindow {
|
||||
});
|
||||
|
||||
//window.add(weatherButton);
|
||||
window.add(commandButton);
|
||||
window.add(focusButton);
|
||||
|
||||
window.add(jokeButton);
|
||||
window.add(restartButton);
|
||||
window.add(exitButton);
|
||||
window.setFocusable(true);
|
||||
window.addAll(commandButton, focusButton, jokeButton, restartButton,
|
||||
exitButton);
|
||||
window.addKeyListener(new KeyAdapter() {
|
||||
// Key Pressed method
|
||||
public void keyPressed(KeyEvent e) {
|
@ -10,6 +10,7 @@ import lombok.Setter;
|
||||
public class TimeHoursMinutes {
|
||||
public static final int MINUTES_PER_HOUR = 60;
|
||||
public static final int MILLISECONDS_PER_SECOND = 1000;
|
||||
public static final int SECONDS_PER_MINUTE = 60;
|
||||
|
||||
@Getter @Setter
|
||||
private Integer hour;
|
||||
@ -34,4 +35,8 @@ public class TimeHoursMinutes {
|
||||
hour = hour + 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static int countDiffInMinutes(TimeHoursMinutes startTime, TimeHoursMinutes endTime) {
|
||||
return (endTime.getHour() * TimeHoursMinutes.MINUTES_PER_HOUR + endTime.getMinute()) - (startTime.getHour() * TimeHoursMinutes.MINUTES_PER_HOUR + startTime.getMinute());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user