mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-28 00:25:22 +01:00
Added minute and year batteries
This commit is contained in:
parent
42f19ad7ba
commit
a12df0214a
@ -1,8 +1,7 @@
|
|||||||
package org.nanoboot.utils.timecalc.app;
|
package org.nanoboot.utils.timecalc.app;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.TimeCalcButton;
|
import org.nanoboot.utils.timecalc.swing.common.MainWindow;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.TimeCalcWindow;
|
|
||||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||||
|
|
||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.KeyAdapter;
|
||||||
@ -15,18 +14,15 @@ import java.awt.event.KeyEvent;
|
|||||||
public class TimeCalcKeyAdapter extends KeyAdapter {
|
public class TimeCalcKeyAdapter extends KeyAdapter {
|
||||||
private final TimeCalcConfiguration timeCalcConfiguration;
|
private final TimeCalcConfiguration timeCalcConfiguration;
|
||||||
private final TimeCalcApp timeCalcApp;
|
private final TimeCalcApp timeCalcApp;
|
||||||
private final TimeCalcButton commandButton;
|
private final MainWindow window;
|
||||||
private final TimeCalcWindow window;
|
|
||||||
|
|
||||||
public TimeCalcKeyAdapter(
|
public TimeCalcKeyAdapter(
|
||||||
TimeCalcConfiguration timeCalcConfiguration,
|
TimeCalcConfiguration timeCalcConfiguration,
|
||||||
TimeCalcApp timeCalcApp,
|
TimeCalcApp timeCalcApp,
|
||||||
TimeCalcButton commandButton,
|
MainWindow window
|
||||||
TimeCalcWindow window
|
|
||||||
) {
|
) {
|
||||||
this.timeCalcConfiguration = timeCalcConfiguration;
|
this.timeCalcConfiguration = timeCalcConfiguration;
|
||||||
this.timeCalcApp = timeCalcApp;
|
this.timeCalcApp = timeCalcApp;
|
||||||
this.commandButton = commandButton;
|
|
||||||
this.window = window;
|
this.window = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,12 +106,28 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
Visibility.STRONGLY_COLORED.name());
|
Visibility.STRONGLY_COLORED.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (e.getKeyCode() == KeyEvent.VK_F2) {
|
||||||
|
window.doCommand();
|
||||||
|
}
|
||||||
if (e.getKeyCode() == KeyEvent.VK_R) {
|
if (e.getKeyCode() == KeyEvent.VK_R) {
|
||||||
commandButton.doClick();
|
window.doRestart();
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == KeyEvent.VK_T) {
|
if (e.getKeyCode() == KeyEvent.VK_T) {
|
||||||
Utils.toastsAreEnabled.flip();
|
Utils.toastsAreEnabled.flip();
|
||||||
}
|
}
|
||||||
|
if (e.getKeyCode() == KeyEvent.VK_W) {
|
||||||
|
window.openWorkDaysWindow();
|
||||||
|
}
|
||||||
|
if (e.getKeyCode() == KeyEvent.VK_A) {
|
||||||
|
window.openActivitiesWindow();
|
||||||
|
}
|
||||||
|
if (e.getKeyCode() == KeyEvent.VK_X) {
|
||||||
|
window.doExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.getKeyCode() == KeyEvent.VK_S) {
|
||||||
|
window.openConfigWindow();
|
||||||
|
}
|
||||||
|
|
||||||
window.repaint();
|
window.repaint();
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import javax.swing.JOptionPane;
|
|||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
* @since 21.02.2024
|
* @since 21.02.2024
|
||||||
*/
|
*/
|
||||||
public class AboutButton extends TimeCalcButton {
|
public class AboutButton extends TButton {
|
||||||
public AboutButton() {
|
public AboutButton() {
|
||||||
super("About");
|
super("About");
|
||||||
addActionListener(e -> {
|
addActionListener(e -> {
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package org.nanoboot.utils.timecalc.swing.common;
|
package org.nanoboot.utils.timecalc.swing.common;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
* @since 16.02.2024
|
* @since 16.02.2024
|
||||||
*/
|
*/
|
||||||
public class ActivitiesWindow extends TimeCalcWindow {
|
public class ActivitiesWindow extends TWindow {
|
||||||
|
|
||||||
public ActivitiesWindow() {
|
public ActivitiesWindow() {
|
||||||
setSize(800, 600);
|
setSize(800, 600);
|
||||||
|
@ -18,14 +18,13 @@ import java.util.Arrays;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
* @since 16.02.2024
|
* @since 16.02.2024
|
||||||
*/
|
*/
|
||||||
public class ConfigWindow extends TimeCalcWindow {
|
public class ConfigWindow extends TWindow {
|
||||||
public static final int WIDTH1 = 600;
|
public static final int WIDTH1 = 600;
|
||||||
public static final int HEIGHT1 = 30;
|
public static final int HEIGHT1 = 30;
|
||||||
public static final String CLIENT_PROPERTY_KEY = TimeCalcProperty.class.getName();
|
public static final String CLIENT_PROPERTY_KEY = TimeCalcProperty.class.getName();
|
||||||
|
@ -4,7 +4,7 @@ package org.nanoboot.utils.timecalc.swing.common;
|
|||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
* @since 16.02.2024
|
* @since 16.02.2024
|
||||||
*/
|
*/
|
||||||
public class HelpWindow extends TimeCalcWindow {
|
public class HelpWindow extends TWindow {
|
||||||
|
|
||||||
public HelpWindow() {
|
public HelpWindow() {
|
||||||
setSize(800, 600);
|
setSize(800, 600);
|
||||||
|
@ -12,12 +12,14 @@ import org.nanoboot.utils.timecalc.swing.progress.AnalogClock;
|
|||||||
import org.nanoboot.utils.timecalc.swing.progress.Battery;
|
import org.nanoboot.utils.timecalc.swing.progress.Battery;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.DayBattery;
|
import org.nanoboot.utils.timecalc.swing.progress.DayBattery;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.HourBattery;
|
import org.nanoboot.utils.timecalc.swing.progress.HourBattery;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.progress.MinuteBattery;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.MonthBattery;
|
import org.nanoboot.utils.timecalc.swing.progress.MonthBattery;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressCircle;
|
import org.nanoboot.utils.timecalc.swing.progress.ProgressCircle;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressSquare;
|
import org.nanoboot.utils.timecalc.swing.progress.ProgressSquare;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.Time;
|
import org.nanoboot.utils.timecalc.swing.progress.Time;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.WalkingHumanProgressAsciiArt;
|
import org.nanoboot.utils.timecalc.swing.progress.WalkingHumanProgressAsciiArt;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.WeekBattery;
|
import org.nanoboot.utils.timecalc.swing.progress.WeekBattery;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.progress.YearBattery;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.Constants;
|
import org.nanoboot.utils.timecalc.utils.common.Constants;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.Jokes;
|
import org.nanoboot.utils.timecalc.utils.common.Jokes;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.TimeHM;
|
import org.nanoboot.utils.timecalc.utils.common.TimeHM;
|
||||||
@ -43,14 +45,25 @@ import java.util.logging.Logger;
|
|||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
* @since 08.02.2024
|
* @since 08.02.2024
|
||||||
*/
|
*/
|
||||||
public class MainWindow extends TimeCalcWindow{
|
public class MainWindow extends TWindow {
|
||||||
|
|
||||||
public static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
public static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
||||||
public static final Color FOREGROUND_COLOR = new Color(210, 210, 210);
|
public static final Color FOREGROUND_COLOR = new Color(210, 210, 210);
|
||||||
|
private final TButton workDaysButton;
|
||||||
|
private final TButton activitiesButton;
|
||||||
|
private final TButton exitButton;
|
||||||
|
private final TButton configButton;
|
||||||
|
private final TButton restartButton;
|
||||||
|
private final TButton focusButton;
|
||||||
|
private final TButton helpButton;
|
||||||
|
private final TButton weatherButton;
|
||||||
|
private final TButton commandButton;
|
||||||
|
private final TButton jokeButton;
|
||||||
|
private final AboutButton aboutButton;
|
||||||
private HelpWindow helpWindow = null;
|
private HelpWindow helpWindow = null;
|
||||||
private WorkDaysWindow workDaysWindow = null;
|
|
||||||
private ConfigWindow configWindow = null;
|
private ConfigWindow configWindow = null;
|
||||||
private ActivitiesWindow activitiesWindow = null;
|
private ActivitiesWindow activitiesWindow = null;
|
||||||
|
private WorkDaysWindow workDaysWindow = null;
|
||||||
|
|
||||||
private boolean stopBeforeEnd = false;
|
private boolean stopBeforeEnd = false;
|
||||||
private final TimeCalcConfiguration timeCalcConfiguration =
|
private final TimeCalcConfiguration timeCalcConfiguration =
|
||||||
@ -86,18 +99,18 @@ public class MainWindow extends TimeCalcWindow{
|
|||||||
int totalSeconds = totalMinutes * TimeHM.SECONDS_PER_MINUTE;
|
int totalSeconds = totalMinutes * TimeHM.SECONDS_PER_MINUTE;
|
||||||
int totalMilliseconds = totalSeconds * TimeHM.MILLISECONDS_PER_SECOND;
|
int totalMilliseconds = totalSeconds * TimeHM.MILLISECONDS_PER_SECOND;
|
||||||
|
|
||||||
TimeCalcButton configButton = new TimeCalcButton("Config");
|
this.configButton = new TButton("Config");
|
||||||
TimeCalcButton workDaysButton = new TimeCalcButton("Work Days");
|
this.workDaysButton = new TButton("Work Days");
|
||||||
TimeCalcButton activitiesButton = new TimeCalcButton("Activities"
|
this.activitiesButton = new TButton("Activities"
|
||||||
+ "");
|
+ "");
|
||||||
TimeCalcButton restartButton = new TimeCalcButton("Restart");
|
this.restartButton = new TButton("Restart");
|
||||||
TimeCalcButton exitButton = new TimeCalcButton("Exit");
|
this.exitButton = new TButton("Exit");
|
||||||
TimeCalcButton focusButton = new TimeCalcButton("Focus");
|
this.focusButton = new TButton("Focus");
|
||||||
TimeCalcButton helpButton = new TimeCalcButton("Help");
|
this.helpButton = new TButton("Help");
|
||||||
TimeCalcButton weatherButton = new TimeCalcButton("Weather");
|
this.weatherButton = new TButton("Weather");
|
||||||
TimeCalcButton commandButton = new TimeCalcButton("Command");
|
this.commandButton = new TButton("Command");
|
||||||
TimeCalcButton jokeButton = new TimeCalcButton("Joke");
|
this.jokeButton = new TButton("Joke");
|
||||||
AboutButton aboutButton = new AboutButton();
|
this.aboutButton = new AboutButton();
|
||||||
|
|
||||||
//window.add(weatherButton);
|
//window.add(weatherButton);
|
||||||
addAll(configButton, workDaysButton, activitiesButton, restartButton,
|
addAll(configButton, workDaysButton, activitiesButton, restartButton,
|
||||||
@ -108,7 +121,7 @@ public class MainWindow extends TimeCalcWindow{
|
|||||||
if(!timeCalcConfiguration.visibilitySupportedColoredProperty.isEnabled()) {
|
if(!timeCalcConfiguration.visibilitySupportedColoredProperty.isEnabled()) {
|
||||||
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
|
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
|
||||||
}
|
}
|
||||||
TimeCalcKeyAdapter timeCalcKeyAdapter = new TimeCalcKeyAdapter(timeCalcConfiguration, timeCalcApp, commandButton, this);
|
TimeCalcKeyAdapter timeCalcKeyAdapter = new TimeCalcKeyAdapter(timeCalcConfiguration, timeCalcApp, this);
|
||||||
addKeyListener(timeCalcKeyAdapter);
|
addKeyListener(timeCalcKeyAdapter);
|
||||||
|
|
||||||
AnalogClock analogClock = new AnalogClock(startTime, endTime);
|
AnalogClock analogClock = new AnalogClock(startTime, endTime);
|
||||||
@ -240,8 +253,11 @@ public class MainWindow extends TimeCalcWindow{
|
|||||||
analogClock.handsLongProperty
|
analogClock.handsLongProperty
|
||||||
.bindTo(timeCalcConfiguration.clockHandsLongVisibleProperty);
|
.bindTo(timeCalcConfiguration.clockHandsLongVisibleProperty);
|
||||||
|
|
||||||
Battery hourBattery = new HourBattery(progressCircle.getBounds().x,
|
MinuteBattery minuteBattery = new MinuteBattery(progressCircle.getBounds().x,
|
||||||
progressCircle.getY() + SwingUtils.MARGIN + progressCircle.getHeight(),
|
progressCircle.getY() + SwingUtils.MARGIN + progressCircle.getHeight(),140);
|
||||||
|
add(minuteBattery);
|
||||||
|
Battery hourBattery = new HourBattery(minuteBattery.getBounds().x + minuteBattery.getWidth() + SwingUtils.MARGIN,
|
||||||
|
minuteBattery.getY(),
|
||||||
140);
|
140);
|
||||||
add(hourBattery);
|
add(hourBattery);
|
||||||
|
|
||||||
@ -251,7 +267,7 @@ public class MainWindow extends TimeCalcWindow{
|
|||||||
add(dayBattery);
|
add(dayBattery);
|
||||||
|
|
||||||
Battery weekBattery = new WeekBattery(
|
Battery weekBattery = new WeekBattery(
|
||||||
hourBattery.getBounds().x,
|
minuteBattery.getBounds().x,
|
||||||
dayBattery.getY() + dayBattery.getHeight() + SwingUtils.MARGIN, 140);
|
dayBattery.getY() + dayBattery.getHeight() + SwingUtils.MARGIN, 140);
|
||||||
add(weekBattery);
|
add(weekBattery);
|
||||||
|
|
||||||
@ -283,16 +299,20 @@ public class MainWindow extends TimeCalcWindow{
|
|||||||
workDaysTotal = workDaysDone + (nowIsWeekend ? 0 : 1) + workDaysTodo;
|
workDaysTotal = workDaysDone + (nowIsWeekend ? 0 : 1) + workDaysTodo;
|
||||||
|
|
||||||
Battery monthBattery = new MonthBattery(
|
Battery monthBattery = new MonthBattery(
|
||||||
dayBattery.getBounds().x,
|
weekBattery.getBounds().x + weekBattery.getWidth() + SwingUtils.MARGIN,
|
||||||
weekBattery.getY(), 140);
|
weekBattery.getY(), 140);
|
||||||
add(monthBattery);
|
add(monthBattery);
|
||||||
|
Battery yearBattery = new YearBattery(
|
||||||
|
monthBattery.getBounds().x + monthBattery.getWidth() + SwingUtils.MARGIN,
|
||||||
|
monthBattery.getY(), 140);
|
||||||
|
add(yearBattery);
|
||||||
|
|
||||||
ComponentRegistry<Component> componentRegistry = new ComponentRegistry();
|
ComponentRegistry<Component> componentRegistry = new ComponentRegistry();
|
||||||
componentRegistry.addAll(this.getContentPane().getComponents());
|
componentRegistry.addAll(this.getContentPane().getComponents());
|
||||||
|
|
||||||
ComponentRegistry<TimeCalcButton> buttonRegistry = new ComponentRegistry();
|
ComponentRegistry<TButton> buttonRegistry = new ComponentRegistry();
|
||||||
componentRegistry.getSet().stream().filter(c-> c instanceof TimeCalcButton).forEach(c->
|
componentRegistry.getSet().stream().filter(c-> c instanceof TButton).forEach(c->
|
||||||
buttonRegistry.add((TimeCalcButton)c));
|
buttonRegistry.add((TButton)c));
|
||||||
componentRegistry.getSet().stream().filter(c ->
|
componentRegistry.getSet().stream().filter(c ->
|
||||||
GetProperty.class.isAssignableFrom(c.getClass())).forEach(c->
|
GetProperty.class.isAssignableFrom(c.getClass())).forEach(c->
|
||||||
{
|
{
|
||||||
@ -320,7 +340,7 @@ public class MainWindow extends TimeCalcWindow{
|
|||||||
if(activitiesWindow != null) {activitiesWindow.setVisible(false);activitiesWindow.dispose();}
|
if(activitiesWindow != null) {activitiesWindow.setVisible(false);activitiesWindow.dispose();}
|
||||||
if(helpWindow != null) {helpWindow.setVisible(false);helpWindow.dispose();}
|
if(helpWindow != null) {helpWindow.setVisible(false);helpWindow.dispose();}
|
||||||
|
|
||||||
timeCalcConfiguration.saveToTimeCalcProperties();
|
//timeCalcConfiguration.saveToTimeCalcProperties();
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
dispose();
|
dispose();
|
||||||
|
|
||||||
@ -382,12 +402,16 @@ public class MainWindow extends TimeCalcWindow{
|
|||||||
hourBattery.setDonePercent(
|
hourBattery.setDonePercent(
|
||||||
HourBattery.getHourProgress(timeRemains, secondsRemains,
|
HourBattery.getHourProgress(timeRemains, secondsRemains,
|
||||||
millisecondsRemains));
|
millisecondsRemains));
|
||||||
|
|
||||||
if (!nowIsWeekend) {
|
if (!nowIsWeekend) {
|
||||||
hourBattery.setLabel(
|
hourBattery.setLabel(
|
||||||
hourDone + "/" + (
|
hourDone + "/" + (
|
||||||
totalMinutes / 60));
|
totalMinutes / 60));
|
||||||
}
|
}
|
||||||
|
minuteBattery.setDonePercent(MinuteBattery.getMinuteProgress(secondNow, millisecondNow));
|
||||||
|
yearBattery.setDonePercent(YearBattery.getYearProgress(analogClock));
|
||||||
|
yearBattery.setLabel("");
|
||||||
|
//yearBattery.setDonePercent(YearBattery.getYearProgress(2024,0,1,0,0,0,0));
|
||||||
int totalSecondsRemains =
|
int totalSecondsRemains =
|
||||||
(timeRemains.getHour() * 60 * 60
|
(timeRemains.getHour() * 60 * 60
|
||||||
+ timeRemains.getMinute() * 60
|
+ timeRemains.getMinute() * 60
|
||||||
@ -452,4 +476,26 @@ public class MainWindow extends TimeCalcWindow{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void openWorkDaysWindow() {
|
||||||
|
workDaysButton.doClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openActivitiesWindow() {
|
||||||
|
activitiesButton.doClick();
|
||||||
|
}
|
||||||
|
public void doExit() {
|
||||||
|
exitButton.doClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openConfigWindow() {
|
||||||
|
configButton.doClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doRestart() {
|
||||||
|
restartButton.doClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doCommand() {
|
||||||
|
commandButton.doClick();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import java.awt.Color;
|
|||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
* @since 21.02.2024
|
* @since 21.02.2024
|
||||||
*/
|
*/
|
||||||
public class TimeCalcButton extends JButton implements GetProperty {
|
public class TButton extends JButton implements GetProperty {
|
||||||
private static final int BUTTON_WIDTH = 100;
|
private static final int BUTTON_WIDTH = 100;
|
||||||
private static final int BUTTON_HEIGHT = 30;
|
private static final int BUTTON_HEIGHT = 30;
|
||||||
public StringProperty visibilityProperty =
|
public StringProperty visibilityProperty =
|
||||||
@ -27,7 +27,7 @@ public class TimeCalcButton extends JButton implements GetProperty {
|
|||||||
private Color originalBackground;
|
private Color originalBackground;
|
||||||
private Color originalForeground;
|
private Color originalForeground;
|
||||||
|
|
||||||
public TimeCalcButton(String label) {
|
public TButton(String label) {
|
||||||
super(label);
|
super(label);
|
||||||
new Timer(100, e -> {
|
new Timer(100, e -> {
|
||||||
Visibility visibility =
|
Visibility visibility =
|
@ -8,8 +8,8 @@ import java.awt.HeadlessException;
|
|||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
* @since 21.02.2024
|
* @since 21.02.2024
|
||||||
*/
|
*/
|
||||||
public class TimeCalcWindow extends JFrame {
|
public class TWindow extends JFrame {
|
||||||
public TimeCalcWindow() throws HeadlessException {
|
public TWindow() throws HeadlessException {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,25 +1,10 @@
|
|||||||
package org.nanoboot.utils.timecalc.swing.common;
|
package org.nanoboot.utils.timecalc.swing.common;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcConfiguration;
|
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JComponent;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
* @since 16.02.2024
|
* @since 16.02.2024
|
||||||
*/
|
*/
|
||||||
public class WorkDaysWindow extends TimeCalcWindow {
|
public class WorkDaysWindow extends TWindow {
|
||||||
public WorkDaysWindow() {
|
public WorkDaysWindow() {
|
||||||
setSize(800, 600);
|
setSize(800, 600);
|
||||||
setTitle("Work Days");
|
setTitle("Work Days");
|
||||||
|
@ -229,7 +229,6 @@ public class Battery extends Widget {
|
|||||||
brush.setColor(currentColor);
|
brush.setColor(currentColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
brush.drawString(
|
brush.drawString(
|
||||||
NumberFormats.FORMATTER_THREE_DECIMAL_PLACES
|
NumberFormats.FORMATTER_THREE_DECIMAL_PLACES
|
||||||
.format(donePercent * 100) + "%",
|
.format(donePercent * 100) + "%",
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package org.nanoboot.utils.timecalc.swing.progress;
|
||||||
|
|
||||||
|
import org.nanoboot.utils.timecalc.utils.common.TimeHM;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert Vokac
|
||||||
|
* @since 21.02.2024
|
||||||
|
*/
|
||||||
|
public class MinuteBattery extends Battery {
|
||||||
|
public MinuteBattery(int x, int i, int i1) {
|
||||||
|
super("Minute", x, i, i1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getMinuteProgress(int secondNow, int millisecondNow) {
|
||||||
|
return millisecondNow / 60d / 1000d + secondNow /60d;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package org.nanoboot.utils.timecalc.swing.progress;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert Vokac
|
||||||
|
* @since 21.02.2024
|
||||||
|
*/
|
||||||
|
public class YearBattery extends Battery {
|
||||||
|
public YearBattery(int x, int i, int i1) {
|
||||||
|
super("Year", x, i, i1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getYearProgress(Integer year, Integer month, Integer day, Integer hour, Integer minute, Integer second, Integer millisecond) {
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.set(Calendar.YEAR, year);
|
||||||
|
cal.set(Calendar.MONTH, month - 1);
|
||||||
|
cal.set(Calendar.DAY_OF_MONTH, day);
|
||||||
|
cal.set(Calendar.HOUR, hour);
|
||||||
|
cal.set(Calendar.MINUTE, minute);
|
||||||
|
cal.set(Calendar.SECOND, second);
|
||||||
|
cal.set(Calendar.MILLISECOND, millisecond);
|
||||||
|
|
||||||
|
double seconds = second + millisecond / 1000d;
|
||||||
|
double minutes = minute + seconds / 60d;
|
||||||
|
double hours = hour + minutes / 60d;
|
||||||
|
double days = cal.get(Calendar.DAY_OF_YEAR) + hours / 24d;
|
||||||
|
// System.out.println("millisecond=" + millisecond);
|
||||||
|
// System.out.println("seconds=" + seconds);
|
||||||
|
// System.out.println("minutes=" + minutes);
|
||||||
|
// System.out.println("hours=" + hours);
|
||||||
|
// System.out.println("days=" + days);
|
||||||
|
// System.out.println("cal.get(Calendar.DAY_OF_YEAR)=" + cal.get(Calendar.DAY_OF_YEAR));
|
||||||
|
|
||||||
|
double totalCountOfDaysInAYear = getTotalCountOfDaysInAYear(year);
|
||||||
|
return days / totalCountOfDaysInAYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double getTotalCountOfDaysInAYear(Integer year) {
|
||||||
|
boolean leapYear = isLeapYear(year);
|
||||||
|
double daysInYear = 365d;
|
||||||
|
if(leapYear) {
|
||||||
|
daysInYear++;
|
||||||
|
}
|
||||||
|
return daysInYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isLeapYear(Integer year) {
|
||||||
|
return year % 4 == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getYearProgress(AnalogClock analogClock) {
|
||||||
|
return getYearProgress(
|
||||||
|
analogClock.yearProperty.getValue(),
|
||||||
|
analogClock.monthProperty.getValue(),
|
||||||
|
analogClock.dayProperty.getValue(),
|
||||||
|
analogClock.hourProperty.getValue(),
|
||||||
|
analogClock.minuteProperty.getValue(),
|
||||||
|
analogClock.secondProperty.getValue(),
|
||||||
|
analogClock.millisecondProperty.getValue()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,10 @@ public class NumberFormats {
|
|||||||
new DecimalFormat("#0.00000");
|
new DecimalFormat("#0.00000");
|
||||||
public static final NumberFormat FORMATTER_THREE_DECIMAL_PLACES =
|
public static final NumberFormat FORMATTER_THREE_DECIMAL_PLACES =
|
||||||
new DecimalFormat("#0.000");
|
new DecimalFormat("#0.000");
|
||||||
|
public static final NumberFormat FORMATTER_SIX_DECIMAL_PLACES =
|
||||||
|
new DecimalFormat("#0.000000");
|
||||||
|
public static final NumberFormat FORMATTER_EIGHT_DECIMAL_PLACES =
|
||||||
|
new DecimalFormat("#0.00000000");
|
||||||
private NumberFormats() {
|
private NumberFormats() {
|
||||||
//Not meant to be instantiated.
|
//Not meant to be instantiated.
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#Wed Feb 28 14:01:26 CET 2024
|
#Thu Feb 29 07:17:51 CET 2024
|
||||||
battery.charging-unicode-character.visible=true
|
battery.charging-unicode-character.visible=true
|
||||||
battery.week.visible=true
|
battery.week.visible=true
|
||||||
smileys.colored=true
|
smileys.colored=true
|
||||||
@ -16,14 +16,14 @@ jokes.visible=true
|
|||||||
visibility.default=STRONGLY_COLORED
|
visibility.default=STRONGLY_COLORED
|
||||||
square.smileys.visible=true
|
square.smileys.visible=true
|
||||||
battery.month.visible=true
|
battery.month.visible=true
|
||||||
battery.day.visible=true
|
|
||||||
battery.waves.visible=true
|
battery.waves.visible=true
|
||||||
clock.hands.minute.visible=true
|
battery.day.visible=true
|
||||||
battery.smileys.visible=true
|
battery.smileys.visible=true
|
||||||
|
clock.hands.minute.visible=true
|
||||||
circle.visible=true
|
circle.visible=true
|
||||||
square.visible=true
|
|
||||||
clock.hands.long.visible=true
|
|
||||||
logs.detailed=false
|
logs.detailed=false
|
||||||
|
clock.hands.long.visible=true
|
||||||
|
square.visible=true
|
||||||
walking-human.visible=true
|
walking-human.visible=true
|
||||||
battery.label.finished-from-total.visible=true
|
battery.label.finished-from-total.visible=true
|
||||||
smileys.visible=true
|
smileys.visible=true
|
||||||
|
@ -27,8 +27,10 @@ square.visible=true
|
|||||||
circle.visible=true
|
circle.visible=true
|
||||||
walking-human.visible=true
|
walking-human.visible=true
|
||||||
battery.visible=true
|
battery.visible=true
|
||||||
|
battery.minute.visible=true
|
||||||
battery.hour.visible=true
|
battery.hour.visible=true
|
||||||
battery.day.visible=true
|
battery.day.visible=true
|
||||||
battery.week.visible=true
|
battery.week.visible=true
|
||||||
battery.month.visible=true
|
battery.month.visible=true
|
||||||
|
battery.year.visible=true
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user