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
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.STARTTIME_TXT, newStartTime);
|
||||||
Utils.writeTextToFile(FileConstants.OVERTIME_TXT, newOvertime);
|
Utils.writeTextToFile(FileConstants.OVERTIME_TXT, newOvertime);
|
||||||
try {
|
try {
|
||||||
TimeCalcWindow timeCalc =
|
TimeCalcManager timeCalc =
|
||||||
new TimeCalcWindow(newStartTime, newOvertime);
|
new TimeCalcManager(newStartTime, newOvertime);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
JOptionPane.showMessageDialog(null, "Error: " + e.getMessage(),
|
JOptionPane.showMessageDialog(null, "Error: " + e.getMessage(),
|
||||||
e.getMessage(), JOptionPane.ERROR_MESSAGE);
|
e.getMessage(), JOptionPane.ERROR_MESSAGE);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.nanoboot.utils.timecalc.main;
|
package org.nanoboot.utils.timecalc.main;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.gui.common.TimeCalcButton;
|
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.Toaster;
|
||||||
import org.nanoboot.utils.timecalc.gui.common.WeatherWindow;
|
import org.nanoboot.utils.timecalc.gui.common.WeatherWindow;
|
||||||
import org.nanoboot.utils.timecalc.gui.progress.AnalogClock;
|
import org.nanoboot.utils.timecalc.gui.progress.AnalogClock;
|
||||||
@ -43,11 +44,10 @@ import static org.nanoboot.utils.timecalc.utils.FileConstants.FOCUS_TXT;
|
|||||||
* @author pc00289
|
* @author pc00289
|
||||||
* @since 08.02.2024
|
* @since 08.02.2024
|
||||||
*/
|
*/
|
||||||
public class TimeCalcWindow {
|
public class TimeCalcManager {
|
||||||
public static final String WALL = "||";
|
public static final String WALL = "||";
|
||||||
private static final int MARGIN = 10;
|
private static final int MARGIN = 10;
|
||||||
|
|
||||||
|
|
||||||
private final String windowTitle;
|
private final String windowTitle;
|
||||||
private final int totalMinutes;
|
private final int totalMinutes;
|
||||||
private final Set<Integer> alreadyShownPercents = new HashSet<>();
|
private final Set<Integer> alreadyShownPercents = new HashSet<>();
|
||||||
@ -57,7 +57,7 @@ public class TimeCalcWindow {
|
|||||||
private boolean stopBeforeEnd = false;
|
private boolean stopBeforeEnd = false;
|
||||||
private boolean vtipyShown = false;
|
private boolean vtipyShown = false;
|
||||||
|
|
||||||
public TimeCalcWindow(String startTimeIn, String overTimeIn) {
|
public TimeCalcManager(String startTimeIn, String overTimeIn) {
|
||||||
Utils.everythingHidden
|
Utils.everythingHidden
|
||||||
.set(TimeCalcConf.getInstance().isEverythingHidden());
|
.set(TimeCalcConf.getInstance().isEverythingHidden());
|
||||||
Utils.toastsAreEnabled
|
Utils.toastsAreEnabled
|
||||||
@ -72,14 +72,11 @@ public class TimeCalcWindow {
|
|||||||
this.endTime = new TimeHoursMinutes(startTime.getHour() + Constants.WORKING_HOURS_LENGTH + overtime.getHour(),
|
this.endTime = new TimeHoursMinutes(startTime.getHour() + Constants.WORKING_HOURS_LENGTH + overtime.getHour(),
|
||||||
startTime.getMinute() + Constants.WORKING_MINUTES_LENGTH + overtime.getMinute());
|
startTime.getMinute() + Constants.WORKING_MINUTES_LENGTH + overtime.getMinute());
|
||||||
|
|
||||||
this.totalMinutes =
|
this.totalMinutes = TimeHoursMinutes.countDiffInMinutes(startTime, endTime);
|
||||||
(this.endTime.getHour() * TimeHoursMinutes.MINUTES_PER_HOUR + this.endTime.getMinute()) - (startTime.getHour() * TimeHoursMinutes.MINUTES_PER_HOUR + startTime.getMinute());
|
int totalSeconds = totalMinutes * TimeHoursMinutes.SECONDS_PER_MINUTE;
|
||||||
int totalSeconds = totalMinutes * 60;
|
|
||||||
int totalMilliseconds = totalSeconds * TimeHoursMinutes.MILLISECONDS_PER_SECOND;
|
int totalMilliseconds = totalSeconds * TimeHoursMinutes.MILLISECONDS_PER_SECOND;
|
||||||
|
|
||||||
|
TimeCalcWindow window = new TimeCalcWindow();
|
||||||
|
|
||||||
JFrame window = new JFrame();
|
|
||||||
|
|
||||||
TimeCalcButton focusButton = new TimeCalcButton("F");
|
TimeCalcButton focusButton = new TimeCalcButton("F");
|
||||||
TimeCalcButton commandButton = new TimeCalcButton("Command");
|
TimeCalcButton commandButton = new TimeCalcButton("Command");
|
||||||
@ -105,13 +102,8 @@ public class TimeCalcWindow {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//window.add(weatherButton);
|
//window.add(weatherButton);
|
||||||
window.add(commandButton);
|
window.addAll(commandButton, focusButton, jokeButton, restartButton,
|
||||||
window.add(focusButton);
|
exitButton);
|
||||||
|
|
||||||
window.add(jokeButton);
|
|
||||||
window.add(restartButton);
|
|
||||||
window.add(exitButton);
|
|
||||||
window.setFocusable(true);
|
|
||||||
window.addKeyListener(new KeyAdapter() {
|
window.addKeyListener(new KeyAdapter() {
|
||||||
// Key Pressed method
|
// Key Pressed method
|
||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
@ -10,6 +10,7 @@ import lombok.Setter;
|
|||||||
public class TimeHoursMinutes {
|
public class TimeHoursMinutes {
|
||||||
public static final int MINUTES_PER_HOUR = 60;
|
public static final int MINUTES_PER_HOUR = 60;
|
||||||
public static final int MILLISECONDS_PER_SECOND = 1000;
|
public static final int MILLISECONDS_PER_SECOND = 1000;
|
||||||
|
public static final int SECONDS_PER_MINUTE = 60;
|
||||||
|
|
||||||
@Getter @Setter
|
@Getter @Setter
|
||||||
private Integer hour;
|
private Integer hour;
|
||||||
@ -34,4 +35,8 @@ public class TimeHoursMinutes {
|
|||||||
hour = hour + 1;
|
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