Added minute and year batteries
This commit is contained in:
parent
42f19ad7ba
commit
a12df0214a
@ -1,8 +1,7 @@
|
||||
package org.nanoboot.utils.timecalc.app;
|
||||
|
||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||
import org.nanoboot.utils.timecalc.swing.common.TimeCalcButton;
|
||||
import org.nanoboot.utils.timecalc.swing.common.TimeCalcWindow;
|
||||
import org.nanoboot.utils.timecalc.swing.common.MainWindow;
|
||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||
|
||||
import java.awt.event.KeyAdapter;
|
||||
@ -15,18 +14,15 @@ import java.awt.event.KeyEvent;
|
||||
public class TimeCalcKeyAdapter extends KeyAdapter {
|
||||
private final TimeCalcConfiguration timeCalcConfiguration;
|
||||
private final TimeCalcApp timeCalcApp;
|
||||
private final TimeCalcButton commandButton;
|
||||
private final TimeCalcWindow window;
|
||||
private final MainWindow window;
|
||||
|
||||
public TimeCalcKeyAdapter(
|
||||
TimeCalcConfiguration timeCalcConfiguration,
|
||||
TimeCalcApp timeCalcApp,
|
||||
TimeCalcButton commandButton,
|
||||
TimeCalcWindow window
|
||||
MainWindow window
|
||||
) {
|
||||
this.timeCalcConfiguration = timeCalcConfiguration;
|
||||
this.timeCalcApp = timeCalcApp;
|
||||
this.commandButton = commandButton;
|
||||
this.window = window;
|
||||
}
|
||||
|
||||
@ -110,12 +106,28 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
||||
Visibility.STRONGLY_COLORED.name());
|
||||
}
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_F2) {
|
||||
window.doCommand();
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_R) {
|
||||
commandButton.doClick();
|
||||
window.doRestart();
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_T) {
|
||||
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();
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import javax.swing.JOptionPane;
|
||||
* @author Robert Vokac
|
||||
* @since 21.02.2024
|
||||
*/
|
||||
public class AboutButton extends TimeCalcButton {
|
||||
public class AboutButton extends TButton {
|
||||
public AboutButton() {
|
||||
super("About");
|
||||
addActionListener(e -> {
|
||||
|
@ -1,12 +1,10 @@
|
||||
package org.nanoboot.utils.timecalc.swing.common;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
/**
|
||||
* @author Robert Vokac
|
||||
* @since 16.02.2024
|
||||
*/
|
||||
public class ActivitiesWindow extends TimeCalcWindow {
|
||||
public class ActivitiesWindow extends TWindow {
|
||||
|
||||
public ActivitiesWindow() {
|
||||
setSize(800, 600);
|
||||
|
@ -18,14 +18,13 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Robert Vokac
|
||||
* @since 16.02.2024
|
||||
*/
|
||||
public class ConfigWindow extends TimeCalcWindow {
|
||||
public class ConfigWindow extends TWindow {
|
||||
public static final int WIDTH1 = 600;
|
||||
public static final int HEIGHT1 = 30;
|
||||
public static final String CLIENT_PROPERTY_KEY = TimeCalcProperty.class.getName();
|
||||
|
@ -4,7 +4,7 @@ package org.nanoboot.utils.timecalc.swing.common;
|
||||
* @author Robert Vokac
|
||||
* @since 16.02.2024
|
||||
*/
|
||||
public class HelpWindow extends TimeCalcWindow {
|
||||
public class HelpWindow extends TWindow {
|
||||
|
||||
public HelpWindow() {
|
||||
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.DayBattery;
|
||||
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.ProgressCircle;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressSquare;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.Time;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.WalkingHumanProgressAsciiArt;
|
||||
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.Jokes;
|
||||
import org.nanoboot.utils.timecalc.utils.common.TimeHM;
|
||||
@ -43,14 +45,25 @@ import java.util.logging.Logger;
|
||||
* @author Robert Vokac
|
||||
* @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 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 WorkDaysWindow workDaysWindow = null;
|
||||
private ConfigWindow configWindow = null;
|
||||
private ActivitiesWindow activitiesWindow = null;
|
||||
private WorkDaysWindow workDaysWindow = null;
|
||||
|
||||
private boolean stopBeforeEnd = false;
|
||||
private final TimeCalcConfiguration timeCalcConfiguration =
|
||||
@ -86,18 +99,18 @@ public class MainWindow extends TimeCalcWindow{
|
||||
int totalSeconds = totalMinutes * TimeHM.SECONDS_PER_MINUTE;
|
||||
int totalMilliseconds = totalSeconds * TimeHM.MILLISECONDS_PER_SECOND;
|
||||
|
||||
TimeCalcButton configButton = new TimeCalcButton("Config");
|
||||
TimeCalcButton workDaysButton = new TimeCalcButton("Work Days");
|
||||
TimeCalcButton activitiesButton = new TimeCalcButton("Activities"
|
||||
+ "");
|
||||
TimeCalcButton restartButton = new TimeCalcButton("Restart");
|
||||
TimeCalcButton exitButton = new TimeCalcButton("Exit");
|
||||
TimeCalcButton focusButton = new TimeCalcButton("Focus");
|
||||
TimeCalcButton helpButton = new TimeCalcButton("Help");
|
||||
TimeCalcButton weatherButton = new TimeCalcButton("Weather");
|
||||
TimeCalcButton commandButton = new TimeCalcButton("Command");
|
||||
TimeCalcButton jokeButton = new TimeCalcButton("Joke");
|
||||
AboutButton aboutButton = new AboutButton();
|
||||
this.configButton = new TButton("Config");
|
||||
this.workDaysButton = new TButton("Work Days");
|
||||
this.activitiesButton = new TButton("Activities"
|
||||
+ "");
|
||||
this.restartButton = new TButton("Restart");
|
||||
this.exitButton = new TButton("Exit");
|
||||
this.focusButton = new TButton("Focus");
|
||||
this.helpButton = new TButton("Help");
|
||||
this.weatherButton = new TButton("Weather");
|
||||
this.commandButton = new TButton("Command");
|
||||
this.jokeButton = new TButton("Joke");
|
||||
this.aboutButton = new AboutButton();
|
||||
|
||||
//window.add(weatherButton);
|
||||
addAll(configButton, workDaysButton, activitiesButton, restartButton,
|
||||
@ -108,7 +121,7 @@ public class MainWindow extends TimeCalcWindow{
|
||||
if(!timeCalcConfiguration.visibilitySupportedColoredProperty.isEnabled()) {
|
||||
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
|
||||
}
|
||||
TimeCalcKeyAdapter timeCalcKeyAdapter = new TimeCalcKeyAdapter(timeCalcConfiguration, timeCalcApp, commandButton, this);
|
||||
TimeCalcKeyAdapter timeCalcKeyAdapter = new TimeCalcKeyAdapter(timeCalcConfiguration, timeCalcApp, this);
|
||||
addKeyListener(timeCalcKeyAdapter);
|
||||
|
||||
AnalogClock analogClock = new AnalogClock(startTime, endTime);
|
||||
@ -240,8 +253,11 @@ public class MainWindow extends TimeCalcWindow{
|
||||
analogClock.handsLongProperty
|
||||
.bindTo(timeCalcConfiguration.clockHandsLongVisibleProperty);
|
||||
|
||||
Battery hourBattery = new HourBattery(progressCircle.getBounds().x,
|
||||
progressCircle.getY() + SwingUtils.MARGIN + progressCircle.getHeight(),
|
||||
MinuteBattery minuteBattery = new MinuteBattery(progressCircle.getBounds().x,
|
||||
progressCircle.getY() + SwingUtils.MARGIN + progressCircle.getHeight(),140);
|
||||
add(minuteBattery);
|
||||
Battery hourBattery = new HourBattery(minuteBattery.getBounds().x + minuteBattery.getWidth() + SwingUtils.MARGIN,
|
||||
minuteBattery.getY(),
|
||||
140);
|
||||
add(hourBattery);
|
||||
|
||||
@ -251,7 +267,7 @@ public class MainWindow extends TimeCalcWindow{
|
||||
add(dayBattery);
|
||||
|
||||
Battery weekBattery = new WeekBattery(
|
||||
hourBattery.getBounds().x,
|
||||
minuteBattery.getBounds().x,
|
||||
dayBattery.getY() + dayBattery.getHeight() + SwingUtils.MARGIN, 140);
|
||||
add(weekBattery);
|
||||
|
||||
@ -283,16 +299,20 @@ public class MainWindow extends TimeCalcWindow{
|
||||
workDaysTotal = workDaysDone + (nowIsWeekend ? 0 : 1) + workDaysTodo;
|
||||
|
||||
Battery monthBattery = new MonthBattery(
|
||||
dayBattery.getBounds().x,
|
||||
weekBattery.getBounds().x + weekBattery.getWidth() + SwingUtils.MARGIN,
|
||||
weekBattery.getY(), 140);
|
||||
add(monthBattery);
|
||||
Battery yearBattery = new YearBattery(
|
||||
monthBattery.getBounds().x + monthBattery.getWidth() + SwingUtils.MARGIN,
|
||||
monthBattery.getY(), 140);
|
||||
add(yearBattery);
|
||||
|
||||
ComponentRegistry<Component> componentRegistry = new ComponentRegistry();
|
||||
componentRegistry.addAll(this.getContentPane().getComponents());
|
||||
|
||||
ComponentRegistry<TimeCalcButton> buttonRegistry = new ComponentRegistry();
|
||||
componentRegistry.getSet().stream().filter(c-> c instanceof TimeCalcButton).forEach(c->
|
||||
buttonRegistry.add((TimeCalcButton)c));
|
||||
ComponentRegistry<TButton> buttonRegistry = new ComponentRegistry();
|
||||
componentRegistry.getSet().stream().filter(c-> c instanceof TButton).forEach(c->
|
||||
buttonRegistry.add((TButton)c));
|
||||
componentRegistry.getSet().stream().filter(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(helpWindow != null) {helpWindow.setVisible(false);helpWindow.dispose();}
|
||||
|
||||
timeCalcConfiguration.saveToTimeCalcProperties();
|
||||
//timeCalcConfiguration.saveToTimeCalcProperties();
|
||||
setVisible(false);
|
||||
dispose();
|
||||
|
||||
@ -382,12 +402,16 @@ public class MainWindow extends TimeCalcWindow{
|
||||
hourBattery.setDonePercent(
|
||||
HourBattery.getHourProgress(timeRemains, secondsRemains,
|
||||
millisecondsRemains));
|
||||
|
||||
if (!nowIsWeekend) {
|
||||
hourBattery.setLabel(
|
||||
hourDone + "/" + (
|
||||
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 =
|
||||
(timeRemains.getHour() * 60 * 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();
|
||||
}
|
||||
}
|
||||
|
@ -1,82 +1,82 @@
|
||||
package org.nanoboot.utils.timecalc.swing.common;
|
||||
|
||||
import org.nanoboot.utils.timecalc.app.GetProperty;
|
||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
||||
import org.nanoboot.utils.timecalc.utils.property.Property;
|
||||
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.Timer;
|
||||
import java.awt.Color;
|
||||
|
||||
/**
|
||||
* @author Robert Vokac
|
||||
* @since 21.02.2024
|
||||
*/
|
||||
public class TimeCalcButton extends JButton implements GetProperty {
|
||||
private static final int BUTTON_WIDTH = 100;
|
||||
private static final int BUTTON_HEIGHT = 30;
|
||||
public StringProperty visibilityProperty =
|
||||
new StringProperty("visibilityProperty",
|
||||
Visibility.STRONGLY_COLORED.name());
|
||||
|
||||
public final BooleanProperty visibilitySupportedColoredProperty =
|
||||
new BooleanProperty("visibilitySupportedColoredProperty", true);
|
||||
private Color originalBackground;
|
||||
private Color originalForeground;
|
||||
|
||||
public TimeCalcButton(String label) {
|
||||
super(label);
|
||||
new Timer(100, e -> {
|
||||
Visibility visibility =
|
||||
Visibility.valueOf(visibilityProperty.getValue());
|
||||
setVisible(visibility.isNotNone());
|
||||
if (!visibility.isStronglyColored() || visibility.isGray()) {
|
||||
setBackground(MainWindow.BACKGROUND_COLOR);
|
||||
setForeground(MainWindow.FOREGROUND_COLOR);
|
||||
} else {
|
||||
setOriginalBackground();
|
||||
setOriginalForeground();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void setBounds(int x, int y) {
|
||||
setBounds(x, y, BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
this.originalBackground = getBackground();
|
||||
this.originalForeground = getForeground();
|
||||
}
|
||||
|
||||
public void setOriginalBackground() {
|
||||
this.setBackground(originalBackground);
|
||||
}
|
||||
|
||||
public void setOriginalForeground() {
|
||||
this.setForeground(originalForeground);
|
||||
}
|
||||
|
||||
public void setBoundsFromLeft(JComponent jComponent) {
|
||||
setBounds(jComponent.getX() + jComponent.getWidth() + SwingUtils.MARGIN, jComponent.getY());
|
||||
}
|
||||
|
||||
public void setBoundsFromTop(JComponent jComponent) {
|
||||
setBoundsFromTop(jComponent, 1);
|
||||
}
|
||||
public void setBoundsFromTop(JComponent jComponent, int marginCount) {
|
||||
setBounds(SwingUtils.MARGIN, jComponent.getY()
|
||||
+ jComponent.getHeight()
|
||||
+ marginCount * SwingUtils.MARGIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getVisibilityProperty() {
|
||||
return visibilityProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getVisibilitySupportedColoredProperty() {
|
||||
return visibilitySupportedColoredProperty;
|
||||
}
|
||||
}
|
||||
package org.nanoboot.utils.timecalc.swing.common;
|
||||
|
||||
import org.nanoboot.utils.timecalc.app.GetProperty;
|
||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
||||
import org.nanoboot.utils.timecalc.utils.property.Property;
|
||||
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.Timer;
|
||||
import java.awt.Color;
|
||||
|
||||
/**
|
||||
* @author Robert Vokac
|
||||
* @since 21.02.2024
|
||||
*/
|
||||
public class TButton extends JButton implements GetProperty {
|
||||
private static final int BUTTON_WIDTH = 100;
|
||||
private static final int BUTTON_HEIGHT = 30;
|
||||
public StringProperty visibilityProperty =
|
||||
new StringProperty("visibilityProperty",
|
||||
Visibility.STRONGLY_COLORED.name());
|
||||
|
||||
public final BooleanProperty visibilitySupportedColoredProperty =
|
||||
new BooleanProperty("visibilitySupportedColoredProperty", true);
|
||||
private Color originalBackground;
|
||||
private Color originalForeground;
|
||||
|
||||
public TButton(String label) {
|
||||
super(label);
|
||||
new Timer(100, e -> {
|
||||
Visibility visibility =
|
||||
Visibility.valueOf(visibilityProperty.getValue());
|
||||
setVisible(visibility.isNotNone());
|
||||
if (!visibility.isStronglyColored() || visibility.isGray()) {
|
||||
setBackground(MainWindow.BACKGROUND_COLOR);
|
||||
setForeground(MainWindow.FOREGROUND_COLOR);
|
||||
} else {
|
||||
setOriginalBackground();
|
||||
setOriginalForeground();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void setBounds(int x, int y) {
|
||||
setBounds(x, y, BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
this.originalBackground = getBackground();
|
||||
this.originalForeground = getForeground();
|
||||
}
|
||||
|
||||
public void setOriginalBackground() {
|
||||
this.setBackground(originalBackground);
|
||||
}
|
||||
|
||||
public void setOriginalForeground() {
|
||||
this.setForeground(originalForeground);
|
||||
}
|
||||
|
||||
public void setBoundsFromLeft(JComponent jComponent) {
|
||||
setBounds(jComponent.getX() + jComponent.getWidth() + SwingUtils.MARGIN, jComponent.getY());
|
||||
}
|
||||
|
||||
public void setBoundsFromTop(JComponent jComponent) {
|
||||
setBoundsFromTop(jComponent, 1);
|
||||
}
|
||||
public void setBoundsFromTop(JComponent jComponent, int marginCount) {
|
||||
setBounds(SwingUtils.MARGIN, jComponent.getY()
|
||||
+ jComponent.getHeight()
|
||||
+ marginCount * SwingUtils.MARGIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getVisibilityProperty() {
|
||||
return visibilityProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getVisibilitySupportedColoredProperty() {
|
||||
return visibilitySupportedColoredProperty;
|
||||
}
|
||||
}
|
@ -1,23 +1,23 @@
|
||||
package org.nanoboot.utils.timecalc.swing.common;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import java.awt.Component;
|
||||
import java.awt.HeadlessException;
|
||||
|
||||
/**
|
||||
* @author Robert Vokac
|
||||
* @since 21.02.2024
|
||||
*/
|
||||
public class TimeCalcWindow extends JFrame {
|
||||
public TimeCalcWindow() throws HeadlessException {
|
||||
|
||||
}
|
||||
|
||||
public Component[] addAll(Component... comp) {
|
||||
for (Component c : comp) {
|
||||
add(c);
|
||||
}
|
||||
return comp;
|
||||
}
|
||||
|
||||
}
|
||||
package org.nanoboot.utils.timecalc.swing.common;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import java.awt.Component;
|
||||
import java.awt.HeadlessException;
|
||||
|
||||
/**
|
||||
* @author Robert Vokac
|
||||
* @since 21.02.2024
|
||||
*/
|
||||
public class TWindow extends JFrame {
|
||||
public TWindow() throws HeadlessException {
|
||||
|
||||
}
|
||||
|
||||
public Component[] addAll(Component... comp) {
|
||||
for (Component c : comp) {
|
||||
add(c);
|
||||
}
|
||||
return comp;
|
||||
}
|
||||
|
||||
}
|
@ -1,25 +1,10 @@
|
||||
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
|
||||
* @since 16.02.2024
|
||||
*/
|
||||
public class WorkDaysWindow extends TimeCalcWindow {
|
||||
public class WorkDaysWindow extends TWindow {
|
||||
public WorkDaysWindow() {
|
||||
setSize(800, 600);
|
||||
setTitle("Work Days");
|
||||
|
@ -229,7 +229,6 @@ public class Battery extends Widget {
|
||||
brush.setColor(currentColor);
|
||||
}
|
||||
}
|
||||
|
||||
brush.drawString(
|
||||
NumberFormats.FORMATTER_THREE_DECIMAL_PLACES
|
||||
.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");
|
||||
public static final NumberFormat FORMATTER_THREE_DECIMAL_PLACES =
|
||||
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() {
|
||||
//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.week.visible=true
|
||||
smileys.colored=true
|
||||
@ -16,14 +16,14 @@ jokes.visible=true
|
||||
visibility.default=STRONGLY_COLORED
|
||||
square.smileys.visible=true
|
||||
battery.month.visible=true
|
||||
battery.day.visible=true
|
||||
battery.waves.visible=true
|
||||
clock.hands.minute.visible=true
|
||||
battery.day.visible=true
|
||||
battery.smileys.visible=true
|
||||
clock.hands.minute.visible=true
|
||||
circle.visible=true
|
||||
square.visible=true
|
||||
clock.hands.long.visible=true
|
||||
logs.detailed=false
|
||||
clock.hands.long.visible=true
|
||||
square.visible=true
|
||||
walking-human.visible=true
|
||||
battery.label.finished-from-total.visible=true
|
||||
smileys.visible=true
|
||||
|
@ -27,8 +27,10 @@ square.visible=true
|
||||
circle.visible=true
|
||||
walking-human.visible=true
|
||||
battery.visible=true
|
||||
battery.minute.visible=true
|
||||
battery.hour.visible=true
|
||||
battery.day.visible=true
|
||||
battery.week.visible=true
|
||||
battery.month.visible=true
|
||||
battery.year.visible=true
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user