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
ac4d52cf0f
commit
05accee591
@ -1,13 +0,0 @@
|
|||||||
package org.nanoboot.utils.timecalc.gui;
|
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robert
|
|
||||||
* @since 21.02.2024
|
|
||||||
*/
|
|
||||||
public class TimeCalcButton extends JButton {
|
|
||||||
public TimeCalcButton(String label) {
|
|
||||||
super(label);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,18 @@
|
|||||||
|
package org.nanoboot.utils.timecalc.gui.common;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert
|
||||||
|
* @since 21.02.2024
|
||||||
|
*/
|
||||||
|
public class TimeCalcButton extends JButton {
|
||||||
|
private static final int BUTTON_WIDTH = 100;
|
||||||
|
private static final int BUTTON_HEIGHT = 30;
|
||||||
|
public TimeCalcButton(String label) {
|
||||||
|
super(label);
|
||||||
|
}
|
||||||
|
public void setBounds(int x, int y) {
|
||||||
|
setBounds(x, y, BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package org.nanoboot.utils.timecalc.gui;
|
package org.nanoboot.utils.timecalc.gui.common;
|
||||||
/**
|
/**
|
||||||
* Java Toaster is a java utility class for your swing applications
|
* Java Toaster is a java utility class for your swing applications
|
||||||
* that show an animate box coming from the bottom of your screen
|
* that show an animate box coming from the bottom of your screen
|
@ -1,4 +1,4 @@
|
|||||||
package org.nanoboot.utils.timecalc.gui;
|
package org.nanoboot.utils.timecalc.gui.common;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.nanoboot.utils.timecalc.gui;
|
package org.nanoboot.utils.timecalc.gui.common;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||||
|
|
||||||
@ -58,5 +58,7 @@ public class Widget extends JPanel {
|
|||||||
}
|
}
|
||||||
this.donePercent = donePercent;
|
this.donePercent = donePercent;
|
||||||
}
|
}
|
||||||
|
public void setBounds(int x, int y, int side) {
|
||||||
|
setBounds(x, y, side, side);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package org.nanoboot.utils.timecalc.gui;
|
package org.nanoboot.utils.timecalc.gui.progress;
|
||||||
|
|
||||||
|
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.Utils;
|
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||||
|
|
||||||
@ -133,4 +134,5 @@ public class AnalogClock extends Widget {
|
|||||||
public int getTimerDelay() {
|
public int getTimerDelay() {
|
||||||
return 20;
|
return 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package org.nanoboot.utils.timecalc.gui;
|
package org.nanoboot.utils.timecalc.gui.progress;
|
||||||
|
|
||||||
|
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.Utils;
|
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||||
|
|
@ -1,5 +1,6 @@
|
|||||||
package org.nanoboot.utils.timecalc.gui;
|
package org.nanoboot.utils.timecalc.gui.progress;
|
||||||
|
|
||||||
|
import org.nanoboot.utils.timecalc.gui.common.Widget;
|
||||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
@ -1,5 +1,6 @@
|
|||||||
package org.nanoboot.utils.timecalc.gui;
|
package org.nanoboot.utils.timecalc.gui.progress;
|
||||||
|
|
||||||
|
import org.nanoboot.utils.timecalc.gui.common.Widget;
|
||||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
@ -1,19 +1,19 @@
|
|||||||
package org.nanoboot.utils.timecalc.main;
|
package org.nanoboot.utils.timecalc.main;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.gui.TimeCalcButton;
|
import org.nanoboot.utils.timecalc.gui.common.TimeCalcButton;
|
||||||
import org.nanoboot.utils.timecalc.gui.Toaster;
|
import org.nanoboot.utils.timecalc.gui.common.Toaster;
|
||||||
import org.nanoboot.utils.timecalc.gui.WeatherWindow;
|
import org.nanoboot.utils.timecalc.gui.common.WeatherWindow;
|
||||||
import org.nanoboot.utils.timecalc.gui.AnalogClock;
|
import org.nanoboot.utils.timecalc.gui.progress.AnalogClock;
|
||||||
import org.nanoboot.utils.timecalc.gui.Battery;
|
import org.nanoboot.utils.timecalc.gui.progress.Battery;
|
||||||
import org.nanoboot.utils.timecalc.gui.ProgressCircle;
|
import org.nanoboot.utils.timecalc.gui.progress.ProgressCircle;
|
||||||
import org.nanoboot.utils.timecalc.gui.ProgressSquare;
|
import org.nanoboot.utils.timecalc.gui.progress.ProgressSquare;
|
||||||
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.Jokes;
|
import org.nanoboot.utils.timecalc.utils.Jokes;
|
||||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JTextPane;
|
import javax.swing.JTextPane;
|
||||||
@ -32,7 +32,6 @@ import java.text.NumberFormat;
|
|||||||
import java.time.DayOfWeek;
|
import java.time.DayOfWeek;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -49,11 +48,9 @@ public class TimeCalcWindow {
|
|||||||
private static final int WORKING_HOURS_LENGTH = 8;
|
private static final int WORKING_HOURS_LENGTH = 8;
|
||||||
private static final int WORKING_MINUTES_LENGTH = 30;
|
private static final int WORKING_MINUTES_LENGTH = 30;
|
||||||
private static final String NEW_LINE = "\n";
|
private static final String NEW_LINE = "\n";
|
||||||
private final static DateTimeFormatter DATE_TIME_FORMATTER =
|
|
||||||
DateTimeFormatter.ofPattern("HH:mm:ss:SSS");
|
|
||||||
private static final int MARGIN = 10;
|
private static final int MARGIN = 10;
|
||||||
public static final int BUTTON_WIDTH = 100;
|
|
||||||
public static final int BUTTON_HEIGHT = 30;
|
|
||||||
private final String startTime;
|
private final String startTime;
|
||||||
private final String windowTitle;
|
private final String windowTitle;
|
||||||
private String overTime;
|
private String overTime;
|
||||||
@ -62,7 +59,6 @@ public class TimeCalcWindow {
|
|||||||
private final int overtimeHour;
|
private final int overtimeHour;
|
||||||
private final int overtimeMinute;
|
private final int overtimeMinute;
|
||||||
private final int totalMinutes;
|
private final int totalMinutes;
|
||||||
private final Set<String> alreadyShownTimes = new HashSet<>();
|
|
||||||
private final Set<Integer> alreadyShownPercents = new HashSet<>();
|
private final Set<Integer> alreadyShownPercents = new HashSet<>();
|
||||||
private int endHour;
|
private int endHour;
|
||||||
private int endMinute;
|
private int endMinute;
|
||||||
@ -196,20 +192,18 @@ public class TimeCalcWindow {
|
|||||||
|
|
||||||
window.add(text);
|
window.add(text);
|
||||||
weatherButton
|
weatherButton
|
||||||
.setBounds(20, text.getY() + text.getHeight() + MARGIN, BUTTON_WIDTH,
|
.setBounds(20, text.getY() + text.getHeight() + MARGIN);
|
||||||
BUTTON_HEIGHT);
|
commandButton.setBounds(20, text.getY() + text.getHeight() + MARGIN);
|
||||||
commandButton.setBounds(20, text.getY() + text.getHeight() + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT);
|
|
||||||
|
|
||||||
jokeButton.setBounds(140, text.getY() + text.getHeight() + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT);
|
jokeButton.setBounds(140, text.getY() + text.getHeight() + MARGIN);
|
||||||
restartButton
|
restartButton
|
||||||
.setBounds(280, text.getY() + text.getHeight() + MARGIN,
|
.setBounds(280, text.getY() + text.getHeight() + MARGIN);
|
||||||
BUTTON_WIDTH, BUTTON_HEIGHT);
|
exitButton.setBounds(390, text.getY() + text.getHeight() + MARGIN);
|
||||||
exitButton.setBounds(390, text.getY() + text.getHeight() + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT);
|
aboutButton.setBounds(exitButton.getX(), exitButton.getY() + exitButton.getHeight() + MARGIN);
|
||||||
aboutButton.setBounds(exitButton.getX(), exitButton.getY() + exitButton.getHeight() + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT);
|
|
||||||
|
|
||||||
focusButton.setBounds(exitButton.getX() + 3 * MARGIN + exitButton.getWidth() + 20, MARGIN, 60, BUTTON_HEIGHT);
|
focusButton.setBounds(exitButton.getX() + 3 * MARGIN + exitButton.getWidth() + 20, MARGIN, 60, aboutButton.getHeight());
|
||||||
|
|
||||||
window.setSize(520 + 20 + 100, 580 + MARGIN + BUTTON_WIDTH);
|
window.setSize(520 + 20 + 100, 580 + MARGIN + aboutButton.getHeight());
|
||||||
window.setLayout(null);
|
window.setLayout(null);
|
||||||
window.setVisible(true);
|
window.setVisible(true);
|
||||||
this.windowTitle = createWindowTitle();
|
this.windowTitle = createWindowTitle();
|
||||||
@ -271,23 +265,23 @@ public class TimeCalcWindow {
|
|||||||
});
|
});
|
||||||
|
|
||||||
AnalogClock analogClock = new AnalogClock();
|
AnalogClock analogClock = new AnalogClock();
|
||||||
analogClock.setBounds(10, 10, 200, 200);
|
analogClock.setBounds(MARGIN, MARGIN, 200);
|
||||||
window.add(analogClock);
|
window.add(analogClock);
|
||||||
|
|
||||||
ProgressSquare progressSquare = new ProgressSquare();
|
ProgressSquare progressSquare = new ProgressSquare();
|
||||||
progressSquare
|
progressSquare
|
||||||
.setBounds(10 + analogClock.getWidth() + 10, 10, 200, 200);
|
.setBounds(MARGIN + analogClock.getWidth() + MARGIN, MARGIN, 200);
|
||||||
window.add(progressSquare);
|
window.add(progressSquare);
|
||||||
|
|
||||||
ProgressCircle progressCircle = new ProgressCircle();
|
ProgressCircle progressCircle = new ProgressCircle();
|
||||||
progressCircle
|
progressCircle
|
||||||
.setBounds(10 + progressSquare.getBounds().x + progressSquare
|
.setBounds(MARGIN + progressSquare.getBounds().x + progressSquare
|
||||||
.getWidth() + 10, 10, 80, 80);
|
.getWidth() + MARGIN, MARGIN, 80);
|
||||||
window.add(progressCircle);
|
window.add(progressCircle);
|
||||||
|
|
||||||
Battery batteryForDay = new Battery();
|
Battery batteryForDay = new Battery();
|
||||||
batteryForDay.setBounds(progressCircle.getBounds().x,
|
batteryForDay.setBounds(progressCircle.getBounds().x,
|
||||||
progressCircle.getY() + 10 + progressCircle.getHeight(), 90,
|
progressCircle.getY() + MARGIN + progressCircle.getHeight(), 90,
|
||||||
140);
|
140);
|
||||||
window.add(batteryForDay);
|
window.add(batteryForDay);
|
||||||
|
|
||||||
@ -327,12 +321,12 @@ public class TimeCalcWindow {
|
|||||||
|
|
||||||
Battery batteryForMonth = new Battery();
|
Battery batteryForMonth = new Battery();
|
||||||
batteryForMonth.setBounds(batteryForDay.getBounds().x + batteryForDay.getWidth(),
|
batteryForMonth.setBounds(batteryForDay.getBounds().x + batteryForDay.getWidth(),
|
||||||
batteryForDay.getY() + batteryForWeek.getHeight() + 10, 90, 140);
|
batteryForDay.getY() + batteryForWeek.getHeight() + MARGIN, 90, 140);
|
||||||
window.add(batteryForMonth);
|
window.add(batteryForMonth);
|
||||||
|
|
||||||
Battery batteryForHour = new Battery();
|
Battery batteryForHour = new Battery();
|
||||||
batteryForHour.setBounds(batteryForMonth.getBounds().x,
|
batteryForHour.setBounds(batteryForMonth.getBounds().x,
|
||||||
batteryForMonth.getY() + batteryForMonth.getHeight() + 10, 90, 140);
|
batteryForMonth.getY() + batteryForMonth.getHeight() + MARGIN, 90, 140);
|
||||||
window.add(batteryForHour);
|
window.add(batteryForHour);
|
||||||
Rectangle hourRectangle = batteryForHour.getBounds();
|
Rectangle hourRectangle = batteryForHour.getBounds();
|
||||||
Rectangle dayRectangle = batteryForDay.getBounds();
|
Rectangle dayRectangle = batteryForDay.getBounds();
|
||||||
@ -377,10 +371,10 @@ public class TimeCalcWindow {
|
|||||||
commandButton.setVisible(!Utils.everythingHidden.get());
|
commandButton.setVisible(!Utils.everythingHidden.get());
|
||||||
restartButton.setVisible(!Utils.everythingHidden.get());
|
restartButton.setVisible(!Utils.everythingHidden.get());
|
||||||
exitButton.setVisible(!Utils.everythingHidden.get());
|
exitButton.setVisible(!Utils.everythingHidden.get());
|
||||||
window.setTitle(Utils.everythingHidden.get() ? "" : "Time Calc");
|
window.setTitle(Utils.everythingHidden.get() ? "" : windowTitle);
|
||||||
sb = new StringBuilder();
|
sb = new StringBuilder();
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
String nowString = DATE_TIME_FORMATTER.format(now);
|
String nowString = DateFormats.DATE_TIME_FORMATTER_HHmmssSSS.format(now);
|
||||||
// if (alreadyShownTimes.contains(nowString)) {
|
// if (alreadyShownTimes.contains(nowString)) {
|
||||||
// //nothing to do
|
// //nothing to do
|
||||||
// try {
|
// try {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package org.nanoboot.utils.timecalc.utils;
|
package org.nanoboot.utils.timecalc.utils;
|
||||||
|
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert
|
* @author Robert
|
||||||
* @since 21.02.2024
|
* @since 21.02.2024
|
||||||
@ -8,4 +10,6 @@ public class DateFormats {
|
|||||||
private DateFormats() {
|
private DateFormats() {
|
||||||
//Not meant to be instantiated.
|
//Not meant to be instantiated.
|
||||||
}
|
}
|
||||||
|
public final static DateTimeFormatter DATE_TIME_FORMATTER_HHmmssSSS =
|
||||||
|
DateTimeFormatter.ofPattern("HH:mm:ss:SSS");
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.nanoboot.utils.timecalc.utils;
|
package org.nanoboot.utils.timecalc.utils;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.gui.Toaster;
|
import org.nanoboot.utils.timecalc.gui.common.Toaster;
|
||||||
import org.nanoboot.utils.timecalc.main.TimeCalcConf;
|
import org.nanoboot.utils.timecalc.main.TimeCalcConf;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user