mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
patch22
This commit is contained in:
parent
bf2e692b10
commit
e0f62c66bb
@ -180,6 +180,14 @@ public class TimeCalcConfiguration {
|
|||||||
= new StringProperty(TimeCalcProperty.LIFE_TYPE.getKey());
|
= new StringProperty(TimeCalcProperty.LIFE_TYPE.getKey());
|
||||||
public final StringProperty lifeBirthDateProperty
|
public final StringProperty lifeBirthDateProperty
|
||||||
= new StringProperty(TimeCalcProperty.LIFE_BIRTH_DATE.getKey());
|
= new StringProperty(TimeCalcProperty.LIFE_BIRTH_DATE.getKey());
|
||||||
|
public final BooleanProperty moneyVisibleProperty
|
||||||
|
= new BooleanProperty(TimeCalcProperty.MONEY_VISIBLE.getKey());
|
||||||
|
public final StringProperty moneyTypeProperty
|
||||||
|
= new StringProperty(TimeCalcProperty.MONEY_TYPE.getKey());
|
||||||
|
public final IntegerProperty moneyPerMonthProperty
|
||||||
|
= new IntegerProperty(TimeCalcProperty.MONEY_PER_MONTH.getKey());
|
||||||
|
public final StringProperty moneyCurrencyProperty
|
||||||
|
= new StringProperty(TimeCalcProperty.MONEY_CURRENCY.getKey());
|
||||||
public final StringProperty mainWindowCustomTitleProperty
|
public final StringProperty mainWindowCustomTitleProperty
|
||||||
= new StringProperty(
|
= new StringProperty(
|
||||||
TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE.getKey());
|
TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE.getKey());
|
||||||
@ -266,6 +274,10 @@ public class TimeCalcConfiguration {
|
|||||||
lifeVisibleProperty,
|
lifeVisibleProperty,
|
||||||
lifeTypeProperty,
|
lifeTypeProperty,
|
||||||
lifeBirthDateProperty,
|
lifeBirthDateProperty,
|
||||||
|
moneyVisibleProperty,
|
||||||
|
moneyTypeProperty,
|
||||||
|
moneyPerMonthProperty,
|
||||||
|
moneyCurrencyProperty,
|
||||||
mainWindowCustomTitleProperty,
|
mainWindowCustomTitleProperty,
|
||||||
profileNameProperty,
|
profileNameProperty,
|
||||||
activityNeededFlagsProperty,
|
activityNeededFlagsProperty,
|
||||||
|
@ -91,6 +91,10 @@ public enum TimeCalcProperty {
|
|||||||
LIFE_VISIBLE("life.visible", "Life"),
|
LIFE_VISIBLE("life.visible", "Life"),
|
||||||
LIFE_TYPE("life.type", "Life : Type"),
|
LIFE_TYPE("life.type", "Life : Type"),
|
||||||
LIFE_BIRTH_DATE("life.birth-date", "Life : Birth date"),
|
LIFE_BIRTH_DATE("life.birth-date", "Life : Birth date"),
|
||||||
|
MONEY_VISIBLE("money.visible", "Money"),
|
||||||
|
MONEY_TYPE("money.type", "Money : Type"),
|
||||||
|
MONEY_PER_MONTH("money.per-month", "Money : Per month", Integer.class),
|
||||||
|
MONEY_CURRENCY("money.currency", "Money : Currency", String.class),
|
||||||
MAIN_WINDOW_CUSTOM_TITLE("main-window.custom-title","Main Window : Custom Title"),
|
MAIN_WINDOW_CUSTOM_TITLE("main-window.custom-title","Main Window : Custom Title"),
|
||||||
PROFILE_NAME("profile.name", "Profile : Name"),
|
PROFILE_NAME("profile.name", "Profile : Name"),
|
||||||
TEST_ENABLED("test.enabled", "Test : Enabled", Boolean.class),
|
TEST_ENABLED("test.enabled", "Test : Enabled", Boolean.class),
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
package org.nanoboot.utils.timecalc.entity;
|
package org.nanoboot.utils.timecalc.entity;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcException;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.progress.AnalogClock;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.common.TTime;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author pc00289
|
* @author pc00289
|
||||||
@ -8,10 +13,120 @@ import org.nanoboot.utils.timecalc.app.TimeCalcException;
|
|||||||
*/
|
*/
|
||||||
public class Progress {
|
public class Progress {
|
||||||
private final double[] array = new double[6];
|
private final double[] array = new double[6];
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private int workDaysInMonth;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private boolean weekend;
|
||||||
|
|
||||||
public void set(WidgetType type, double value) {
|
public void set(WidgetType type, double value) {
|
||||||
array[type.getIndex()] = value > 1 ? 1 : (value < 0 ? 0 : value);
|
array[type.getIndex()] = value > 1 ? 1 : (value < 0 ? 0 : value);
|
||||||
}
|
}
|
||||||
public double get(WidgetType type) {
|
public double get(WidgetType type) {
|
||||||
return array[type.getIndex()];
|
return array[type.getIndex()];
|
||||||
}
|
}
|
||||||
|
public static double getMinuteProgress(int secondNow, int millisecondNow) {
|
||||||
|
return millisecondNow / 60d / 1000d + secondNow / 60d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getHourProgress(TTime timeRemains, int secondsRemains,
|
||||||
|
int millisecondsRemains) {
|
||||||
|
if (secondsRemains < 0 || millisecondsRemains < 0
|
||||||
|
|| timeRemains.getHour() < 0 || timeRemains.getMinute() < 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
double minutesRemainsD = timeRemains.getMinute();
|
||||||
|
double secondsRemainsD = secondsRemains;
|
||||||
|
double millisecondsRemainsD = millisecondsRemains;
|
||||||
|
minutesRemainsD = minutesRemainsD + secondsRemainsD / 60d;
|
||||||
|
minutesRemainsD
|
||||||
|
= minutesRemainsD + millisecondsRemainsD / 1000d / 60d;
|
||||||
|
if (secondsRemainsD > 0) {
|
||||||
|
minutesRemainsD = minutesRemainsD - 1d;
|
||||||
|
}
|
||||||
|
if (millisecondsRemainsD > 0) {
|
||||||
|
minutesRemainsD = minutesRemainsD - 1d / 1000d;
|
||||||
|
}
|
||||||
|
double hourProgress = 1 - ((minutesRemainsD % 60d) / 60d);
|
||||||
|
return hourProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getWeekProgress(int weekDayWhenMondayIsOne,
|
||||||
|
double done) {
|
||||||
|
if (done > 1) {
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
return weekDayWhenMondayIsOne == 0
|
||||||
|
|| weekDayWhenMondayIsOne == 6
|
||||||
|
? 100 : ((weekDayWhenMondayIsOne - 1) * 0.20 + done * 0.20);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getMonthProgress(int weekDayWhenMondayIsOne,
|
||||||
|
int workDaysDone, int workDaysTotal, double done) {
|
||||||
|
|
||||||
|
if (done > 1) {
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
double result = weekDayWhenMondayIsOne == 6
|
||||||
|
|| weekDayWhenMondayIsOne == 7
|
||||||
|
? (double) workDaysDone / workDaysTotal
|
||||||
|
: (workDaysDone + done) / workDaysTotal;
|
||||||
|
// System.out.println("result=" + result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
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,7 +16,6 @@ import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
|||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JMenu;
|
import javax.swing.JMenu;
|
||||||
import javax.swing.JMenuItem;
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
import java.awt.BasicStroke;
|
import java.awt.BasicStroke;
|
||||||
@ -28,7 +27,6 @@ import java.awt.event.MouseAdapter;
|
|||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.awt.event.MouseMotionListener;
|
import java.awt.event.MouseMotionListener;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -71,7 +69,7 @@ public class Widget extends JPanel implements
|
|||||||
public StringProperty typeProperty
|
public StringProperty typeProperty
|
||||||
= new StringProperty("widget.typeProperty", WidgetType.DAY.name().toLowerCase());
|
= new StringProperty("widget.typeProperty", WidgetType.DAY.name().toLowerCase());
|
||||||
protected int side = 0;
|
protected int side = 0;
|
||||||
private Progress progress = null;
|
protected Progress progress = null;
|
||||||
protected boolean mouseOver = false;
|
protected boolean mouseOver = false;
|
||||||
private boolean mouseOverCloseButton = false;
|
private boolean mouseOverCloseButton = false;
|
||||||
protected JLabel smileyIcon;
|
protected JLabel smileyIcon;
|
||||||
@ -244,6 +242,9 @@ public class Widget extends JPanel implements
|
|||||||
|
|
||||||
paintCloseIcon(brush, getWidth(), mouseOver, mouseOverCloseButton);
|
paintCloseIcon(brush, getWidth(), mouseOver, mouseOverCloseButton);
|
||||||
|
|
||||||
|
if (mouseOver) {
|
||||||
|
brush.drawRect(1, 1, getWidth() - 2, getHeight() - 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void paintCloseIcon(Graphics brush, int width,
|
private static void paintCloseIcon(Graphics brush, int width,
|
||||||
|
@ -2,6 +2,7 @@ package org.nanoboot.utils.timecalc.swing.common;
|
|||||||
|
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcException;
|
import org.nanoboot.utils.timecalc.app.TimeCalcException;
|
||||||
import org.nanoboot.utils.timecalc.entity.WidgetType;
|
import org.nanoboot.utils.timecalc.entity.WidgetType;
|
||||||
|
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 javax.swing.JMenu;
|
import javax.swing.JMenu;
|
||||||
@ -54,7 +55,7 @@ public class WidgetMenu extends JPopupMenu {
|
|||||||
|
|
||||||
BiConsumer<JMenuItem, WidgetType> typeActionCreator = (m,w) -> {
|
BiConsumer<JMenuItem, WidgetType> typeActionCreator = (m,w) -> {
|
||||||
m.addActionListener(e -> {
|
m.addActionListener(e -> {
|
||||||
if(widget instanceof Battery && !widget.typeProperty.getValue().equals(w.name().toLowerCase(Locale.ROOT))) {
|
if(((widget instanceof Battery) || (widget instanceof AnalogClock)) && !widget.typeProperty.getValue().equals(w.name().toLowerCase(Locale.ROOT))) {
|
||||||
//nothing to do
|
//nothing to do
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -14,25 +14,4 @@ public class HourBattery extends Battery {
|
|||||||
super(HOUR, x, i, i1);
|
super(HOUR, x, i, i1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getHourProgress(TTime timeRemains, int secondsRemains,
|
|
||||||
int millisecondsRemains) {
|
|
||||||
if (secondsRemains < 0 || millisecondsRemains < 0
|
|
||||||
|| timeRemains.getHour() < 0 || timeRemains.getMinute() < 0) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
double minutesRemainsD = timeRemains.getMinute();
|
|
||||||
double secondsRemainsD = secondsRemains;
|
|
||||||
double millisecondsRemainsD = millisecondsRemains;
|
|
||||||
minutesRemainsD = minutesRemainsD + secondsRemainsD / 60d;
|
|
||||||
minutesRemainsD
|
|
||||||
= minutesRemainsD + millisecondsRemainsD / 1000d / 60d;
|
|
||||||
if (secondsRemainsD > 0) {
|
|
||||||
minutesRemainsD = minutesRemainsD - 1d;
|
|
||||||
}
|
|
||||||
if (millisecondsRemainsD > 0) {
|
|
||||||
minutesRemainsD = minutesRemainsD - 1d / 1000d;
|
|
||||||
}
|
|
||||||
double hourProgress = 1 - ((minutesRemainsD % 60d) / 60d);
|
|
||||||
return hourProgress;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,4 @@ public class MinuteBattery extends Battery {
|
|||||||
super(MINUTE, x, i, i1);
|
super(MINUTE, x, i, i1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getMinuteProgress(int secondNow, int millisecondNow) {
|
|
||||||
return millisecondNow / 60d / 1000d + secondNow / 60d;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -12,17 +12,4 @@ public class MonthBattery extends Battery {
|
|||||||
super(MONTH, x, i, i1);
|
super(MONTH, x, i, i1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getMonthProgress(int weekDayWhenMondayIsOne,
|
|
||||||
int workDaysDone, int workDaysTotal, double done) {
|
|
||||||
|
|
||||||
if (done > 1) {
|
|
||||||
done = 1;
|
|
||||||
}
|
|
||||||
double result = weekDayWhenMondayIsOne == 6
|
|
||||||
|| weekDayWhenMondayIsOne == 7
|
|
||||||
? (double) workDaysDone / workDaysTotal
|
|
||||||
: (workDaysDone + done) / workDaysTotal;
|
|
||||||
// System.out.println("result=" + result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -93,13 +93,10 @@ public class ProgressLife extends Widget implements GetProperty {
|
|||||||
// }
|
// }
|
||||||
brush.setFont(SwingUtils.MEDIUM_MONOSPACE_FONT);
|
brush.setFont(SwingUtils.MEDIUM_MONOSPACE_FONT);
|
||||||
|
|
||||||
brush.drawString(date, SwingUtils.MARGIN, 3 * SwingUtils.MARGIN);
|
brush.drawString(date, SwingUtils.MARGIN, SwingUtils.MARGIN);
|
||||||
brush.drawString(time, SwingUtils.MARGIN, (int) (SwingUtils.MARGIN
|
brush.drawString(time, SwingUtils.MARGIN,
|
||||||
+ (getHeight() - SwingUtils.MARGIN)
|
(int) (2.5 * SwingUtils.MARGIN) + 5);
|
||||||
* 0.6d));
|
brush.drawString(typeProperty.getValue(), SwingUtils.MARGIN, 4 * SwingUtils.MARGIN + 5);
|
||||||
brush.drawString(typeProperty.getValue(), SwingUtils.MARGIN, (int) (SwingUtils.MARGIN
|
|
||||||
+ (getHeight() - SwingUtils.MARGIN)
|
|
||||||
* 0.6d) + 20);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,99 @@
|
|||||||
|
package org.nanoboot.utils.timecalc.swing.progress;
|
||||||
|
|
||||||
|
import org.nanoboot.utils.timecalc.app.GetProperty;
|
||||||
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
|
import org.nanoboot.utils.timecalc.entity.WidgetType;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.common.SwingUtils;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.common.Widget;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.windows.MainWindow;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.common.DateFormats;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.property.IntegerProperty;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.property.Property;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
||||||
|
|
||||||
|
import javax.swing.Timer;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert Vokac
|
||||||
|
* @since 21.02.2024
|
||||||
|
*/
|
||||||
|
public class ProgressMoney extends Widget implements GetProperty {
|
||||||
|
|
||||||
|
private final Time time;
|
||||||
|
public IntegerProperty perMonthProperty
|
||||||
|
= new IntegerProperty("money.perMonthProperty");
|
||||||
|
public StringProperty currencyProperty
|
||||||
|
= new StringProperty("money.currencyProperty");
|
||||||
|
|
||||||
|
public ProgressMoney(Time time) {
|
||||||
|
this.time = time;
|
||||||
|
setFont(new Font(Font.MONOSPACED, Font.PLAIN, 11));
|
||||||
|
|
||||||
|
setFocusable(false);
|
||||||
|
setForeground(Color.GRAY);
|
||||||
|
setBackground(MainWindow.BACKGROUND_COLOR);
|
||||||
|
|
||||||
|
new Timer(100, e -> {
|
||||||
|
Visibility visibility
|
||||||
|
= Visibility.valueOf(visibilityProperty.getValue());
|
||||||
|
setForeground(
|
||||||
|
visibility.isStronglyColored()
|
||||||
|
|| mouseOver
|
||||||
|
? Color.BLACK : Color.LIGHT_GRAY);
|
||||||
|
}).start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paintWidget(Graphics brush) {
|
||||||
|
double perMonth = this.perMonthProperty.getValue();
|
||||||
|
if (perMonth == 0) {
|
||||||
|
//nothing to do
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
double workDaysInMonth = progress.getWorkDaysInMonth();
|
||||||
|
boolean isWeekend = progress.isWeekend();
|
||||||
|
double perDay = perMonth / workDaysInMonth;
|
||||||
|
double value = 0;
|
||||||
|
switch(WidgetType.valueOf(this.typeProperty.getValue().toUpperCase(
|
||||||
|
Locale.ROOT))) {
|
||||||
|
case MINUTE: value = perDay / 8d / 60d * progress.get(WidgetType.MINUTE);break;
|
||||||
|
case HOUR: value = perDay / 8d * progress.get(WidgetType.HOUR);break;
|
||||||
|
case DAY: value = perDay * progress.get(WidgetType.DAY);break;
|
||||||
|
case WEEK: value = perDay * 5d * progress.get(WidgetType.WEEK);break;
|
||||||
|
case MONTH: value = perMonth * progress.get(WidgetType.MONTH);break;
|
||||||
|
case YEAR: value = perMonth * 12 * progress.get(WidgetType.YEAR);break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Visibility visibility
|
||||||
|
= Visibility.valueOf(visibilityProperty.getValue());
|
||||||
|
|
||||||
|
brush.setColor(visibility.isStronglyColored() ? Color.BLUE
|
||||||
|
: visibility.isWeaklyColored() ? Color.GRAY
|
||||||
|
: Color.LIGHT_GRAY);
|
||||||
|
brush.setFont(SwingUtils.MEDIUM_MONOSPACE_FONT);
|
||||||
|
|
||||||
|
String valueFinal = NumberFormats.FORMATTER_FIVE_DECIMAL_PLACES.format(value) + " " + this.currencyProperty.getValue();
|
||||||
|
brush.drawString(valueFinal, SwingUtils.MARGIN, SwingUtils.MARGIN + 10);
|
||||||
|
brush.drawString(typeProperty.getValue(), SwingUtils.MARGIN, SwingUtils.MARGIN + 25);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Property getVisibilityProperty() {
|
||||||
|
return visibilityProperty;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Property getVisibilitySupportedColoredProperty() {
|
||||||
|
return visibilitySupportedColoredProperty;
|
||||||
|
}
|
||||||
|
}
|
@ -12,13 +12,4 @@ public class WeekBattery extends Battery {
|
|||||||
super(WEEK, x, i, i1);
|
super(WEEK, x, i, i1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getWeekProgress(int weekDayWhenMondayIsOne,
|
|
||||||
double done) {
|
|
||||||
if (done > 1) {
|
|
||||||
done = 1;
|
|
||||||
}
|
|
||||||
return weekDayWhenMondayIsOne == 0
|
|
||||||
|| weekDayWhenMondayIsOne == 6
|
|
||||||
? 100 : ((weekDayWhenMondayIsOne - 1) * 0.20 + done * 0.20);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -14,55 +14,4 @@ public class YearBattery extends Battery {
|
|||||||
super(YEAR, x, i, 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()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -195,6 +195,14 @@ public class ConfigWindow extends TWindow {
|
|||||||
= new JCheckBox(TimeCalcProperty.LIFE_VISIBLE.getKey());
|
= new JCheckBox(TimeCalcProperty.LIFE_VISIBLE.getKey());
|
||||||
public final JTextField lifeTypeProperty
|
public final JTextField lifeTypeProperty
|
||||||
= new JTextField(TimeCalcProperty.LIFE_TYPE.getKey());
|
= new JTextField(TimeCalcProperty.LIFE_TYPE.getKey());
|
||||||
|
public final JCheckBox moneyVisibleProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.MONEY_VISIBLE.getKey());
|
||||||
|
public final JTextField moneyTypeProperty
|
||||||
|
= new JTextField(TimeCalcProperty.MONEY_TYPE.getKey());
|
||||||
|
public final JTextField moneyPerMonthProperty
|
||||||
|
= new JTextField(TimeCalcProperty.MONEY_PER_MONTH.getKey());
|
||||||
|
public final JTextField moneyCurrencyProperty
|
||||||
|
= new JTextField(TimeCalcProperty.MONEY_CURRENCY.getKey());
|
||||||
public final JTextField lifeBirthDateProperty
|
public final JTextField lifeBirthDateProperty
|
||||||
= new JTextField(TimeCalcProperty.LIFE_BIRTH_DATE.getKey());
|
= new JTextField(TimeCalcProperty.LIFE_BIRTH_DATE.getKey());
|
||||||
private final JTextField mainWindowCustomTitleProperty
|
private final JTextField mainWindowCustomTitleProperty
|
||||||
@ -362,6 +370,7 @@ public class ConfigWindow extends TWindow {
|
|||||||
.setSelected(!enable);
|
.setSelected(!enable);
|
||||||
squareVisibleProperty.setSelected(enable);
|
squareVisibleProperty.setSelected(enable);
|
||||||
lifeVisibleProperty.setSelected(enable);
|
lifeVisibleProperty.setSelected(enable);
|
||||||
|
moneyVisibleProperty.setSelected(enable);
|
||||||
circleVisibleProperty.setSelected(enable);
|
circleVisibleProperty.setSelected(enable);
|
||||||
swingVisibleProperty.setSelected(enable);
|
swingVisibleProperty.setSelected(enable);
|
||||||
swingQuarterIconVisibleProperty.setSelected(enable);
|
swingQuarterIconVisibleProperty.setSelected(enable);
|
||||||
@ -432,6 +441,10 @@ public class ConfigWindow extends TWindow {
|
|||||||
lifeVisibleProperty,
|
lifeVisibleProperty,
|
||||||
lifeTypeProperty,
|
lifeTypeProperty,
|
||||||
lifeBirthDateProperty,
|
lifeBirthDateProperty,
|
||||||
|
moneyVisibleProperty,
|
||||||
|
moneyTypeProperty,
|
||||||
|
moneyPerMonthProperty,
|
||||||
|
moneyCurrencyProperty,
|
||||||
mainWindowCustomTitleProperty,
|
mainWindowCustomTitleProperty,
|
||||||
profileNameProperty,
|
profileNameProperty,
|
||||||
activityNeededFlagsProperty,
|
activityNeededFlagsProperty,
|
||||||
@ -500,6 +513,15 @@ public class ConfigWindow extends TWindow {
|
|||||||
if (p == activityNeededFlagsProperty) {
|
if (p == activityNeededFlagsProperty) {
|
||||||
addLabelToNextRow(TimeCalcProperty.ACTIVITY_NEEDED_FLAGS);
|
addLabelToNextRow(TimeCalcProperty.ACTIVITY_NEEDED_FLAGS);
|
||||||
}
|
}
|
||||||
|
if (p == moneyTypeProperty) {
|
||||||
|
addLabelToNextRow(TimeCalcProperty.MONEY_TYPE);
|
||||||
|
}
|
||||||
|
if (p == moneyPerMonthProperty) {
|
||||||
|
addLabelToNextRow(TimeCalcProperty.MONEY_PER_MONTH);
|
||||||
|
}
|
||||||
|
if (p == moneyCurrencyProperty) {
|
||||||
|
addLabelToNextRow(TimeCalcProperty.MONEY_CURRENCY);
|
||||||
|
}
|
||||||
|
|
||||||
if (p == testClockCustomYearProperty) {
|
if (p == testClockCustomYearProperty) {
|
||||||
JLabel label = new JLabel("Test");
|
JLabel label = new JLabel("Test");
|
||||||
|
@ -34,6 +34,7 @@ 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.ProgressLife;
|
import org.nanoboot.utils.timecalc.swing.progress.ProgressLife;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.progress.ProgressMoney;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressSquare;
|
import org.nanoboot.utils.timecalc.swing.progress.ProgressSquare;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressSwing;
|
import org.nanoboot.utils.timecalc.swing.progress.ProgressSwing;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.Time;
|
import org.nanoboot.utils.timecalc.swing.progress.Time;
|
||||||
@ -100,6 +101,7 @@ public class MainWindow extends TWindow {
|
|||||||
private final TTextField remainingTextField;
|
private final TTextField remainingTextField;
|
||||||
private final TButton saveButton;
|
private final TButton saveButton;
|
||||||
private final ProgressLife progressLife;
|
private final ProgressLife progressLife;
|
||||||
|
private final ProgressMoney progressMoney;
|
||||||
private HelpWindow helpWindow = null;
|
private HelpWindow helpWindow = null;
|
||||||
private ConfigWindow configWindow = null;
|
private ConfigWindow configWindow = null;
|
||||||
private ActivitiesWindow activitiesWindow = null;
|
private ActivitiesWindow activitiesWindow = null;
|
||||||
@ -318,7 +320,7 @@ public class MainWindow extends TWindow {
|
|||||||
|
|
||||||
this.progressLife = new ProgressLife(time);
|
this.progressLife = new ProgressLife(time);
|
||||||
progressLife.setBounds(progressSwing.getX() + progressSwing.getWidth() + SwingUtils.MARGIN, progressSwing.getY(),
|
progressLife.setBounds(progressSwing.getX() + progressSwing.getWidth() + SwingUtils.MARGIN, progressSwing.getY(),
|
||||||
100, 100);
|
100, 50);
|
||||||
|
|
||||||
{
|
{
|
||||||
progressSquare.typeProperty
|
progressSquare.typeProperty
|
||||||
@ -337,6 +339,24 @@ public class MainWindow extends TWindow {
|
|||||||
.bindTo(timeCalcConfiguration.lifeVisibleProperty);
|
.bindTo(timeCalcConfiguration.lifeVisibleProperty);
|
||||||
}
|
}
|
||||||
add(progressLife);
|
add(progressLife);
|
||||||
|
|
||||||
|
|
||||||
|
this.progressMoney
|
||||||
|
= new ProgressMoney(time);
|
||||||
|
progressMoney.setBounds(progressLife.getX(), progressSwing.getY() + progressLife.getHeight() + SwingUtils.MARGIN,
|
||||||
|
100, 50);
|
||||||
|
|
||||||
|
progressMoney.visibleProperty
|
||||||
|
.bindTo(timeCalcConfiguration.moneyVisibleProperty);
|
||||||
|
progressMoney.typeProperty
|
||||||
|
.bindTo(timeCalcConfiguration.moneyTypeProperty);
|
||||||
|
progressMoney.perMonthProperty
|
||||||
|
.bindTo(timeCalcConfiguration.moneyPerMonthProperty);
|
||||||
|
progressMoney.currencyProperty
|
||||||
|
.bindTo(timeCalcConfiguration.moneyCurrencyProperty);
|
||||||
|
|
||||||
|
add(progressMoney);
|
||||||
|
|
||||||
TLabel arrivalTextFieldLabel = new TLabel("Arrival:", 70);
|
TLabel arrivalTextFieldLabel = new TLabel("Arrival:", 70);
|
||||||
arrivalTextFieldLabel.setBoundsFromTop(progressSwing, 3);
|
arrivalTextFieldLabel.setBoundsFromTop(progressSwing, 3);
|
||||||
|
|
||||||
@ -981,38 +1001,40 @@ public class MainWindow extends TWindow {
|
|||||||
Progress progress = new Progress();
|
Progress progress = new Progress();
|
||||||
progress.set(WidgetType.DAY, done);
|
progress.set(WidgetType.DAY, done);
|
||||||
|
|
||||||
|
try {
|
||||||
|
WeekStatistics weekStatisticsTmp = new WeekStatistics(clock, time);
|
||||||
|
weekStatistics = weekStatisticsTmp;
|
||||||
|
} catch (DateTimeException e) {
|
||||||
|
e.printStackTrace();
|
||||||
try {
|
try {
|
||||||
WeekStatistics weekStatisticsTmp = new WeekStatistics(clock, time);
|
Thread.sleep(1000);
|
||||||
weekStatistics = weekStatisticsTmp;
|
} catch (InterruptedException interruptedException) {
|
||||||
} catch (DateTimeException e) {
|
interruptedException.printStackTrace();
|
||||||
e.printStackTrace();
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (InterruptedException interruptedException) {
|
|
||||||
interruptedException.printStackTrace();
|
|
||||||
}
|
|
||||||
// return false;
|
|
||||||
}
|
}
|
||||||
final boolean nowIsWeekend = weekStatistics.isNowIsWeekend();
|
// return false;
|
||||||
final int workDaysDone = weekStatistics.getWorkDaysDone();
|
}
|
||||||
final int workDaysTotal = weekStatistics.getWorkDaysTotal();
|
final boolean nowIsWeekend = weekStatistics.isNowIsWeekend();
|
||||||
|
final int workDaysDone = weekStatistics.getWorkDaysDone();
|
||||||
|
final int workDaysTotal = weekStatistics.getWorkDaysTotal();
|
||||||
|
|
||||||
int weekDayWhenMondayIsOne = clock.dayOfWeekProperty.getValue();
|
progress.setWorkDaysInMonth(workDaysTotal);
|
||||||
double weekProgress = WeekBattery.getWeekProgress(weekDayWhenMondayIsOne, done);
|
progress.setWeekend(nowIsWeekend);
|
||||||
|
int weekDayWhenMondayIsOne = clock.dayOfWeekProperty.getValue();
|
||||||
|
double weekProgress = Progress.getWeekProgress(weekDayWhenMondayIsOne, done);
|
||||||
weekBattery.setProgress(progress);
|
weekBattery.setProgress(progress);
|
||||||
weekBattery.setLabel(
|
weekBattery.setLabel(
|
||||||
nowIsWeekend ? "5/5" : (weekDayWhenMondayIsOne + "/5"));
|
nowIsWeekend ? "5/5" : (weekDayWhenMondayIsOne + "/5"));
|
||||||
|
|
||||||
double monthProgress = MonthBattery
|
double monthProgress = Progress
|
||||||
.getMonthProgress(weekDayWhenMondayIsOne, workDaysDone,
|
.getMonthProgress(weekDayWhenMondayIsOne, workDaysDone,
|
||||||
workDaysTotal, done);
|
workDaysTotal, done);
|
||||||
progress.set(WidgetType.MONTH, monthProgress);
|
progress.set(WidgetType.MONTH, monthProgress);
|
||||||
double hourProgress =
|
double hourProgress =
|
||||||
HourBattery.getHourProgress(timeRemains, secondsRemains,
|
Progress.getHourProgress(timeRemains, secondsRemains,
|
||||||
millisecondsRemains);
|
millisecondsRemains);
|
||||||
double minuteProgress =
|
double minuteProgress =
|
||||||
MinuteBattery.getMinuteProgress(secondNow, millisecondNow);
|
Progress.getMinuteProgress(secondNow, millisecondNow);
|
||||||
double yearProgress = YearBattery.getYearProgress(clock);
|
double yearProgress = Progress.getYearProgress(clock);
|
||||||
progress.set(WidgetType.HOUR, hourProgress);
|
progress.set(WidgetType.HOUR, hourProgress);
|
||||||
progress.set(WidgetType.WEEK, weekProgress);
|
progress.set(WidgetType.WEEK, weekProgress);
|
||||||
progress.set(WidgetType.MINUTE, minuteProgress);
|
progress.set(WidgetType.MINUTE, minuteProgress);
|
||||||
@ -1021,6 +1043,7 @@ public class MainWindow extends TWindow {
|
|||||||
progressCircle.setProgress(progress);
|
progressCircle.setProgress(progress);
|
||||||
progressSwing.setProgress(progress);
|
progressSwing.setProgress(progress);
|
||||||
progressLife.setProgress(progress);
|
progressLife.setProgress(progress);
|
||||||
|
progressMoney.setProgress(progress);
|
||||||
dayBattery.setProgress(progress);
|
dayBattery.setProgress(progress);
|
||||||
|
|
||||||
monthBattery.setProgress(progress);
|
monthBattery.setProgress(progress);
|
||||||
|
@ -51,9 +51,13 @@ circle.type=day
|
|||||||
swing.visible=true
|
swing.visible=true
|
||||||
swing.type=day
|
swing.type=day
|
||||||
swing.quarter-icon.visible=true
|
swing.quarter-icon.visible=true
|
||||||
life.visible=true
|
life.visible=false
|
||||||
life.type=day
|
life.type=day
|
||||||
life.birth-date=
|
life.birth-date=
|
||||||
|
money.visible=false
|
||||||
|
money.type=day
|
||||||
|
money.per-month=0
|
||||||
|
money.currency=
|
||||||
walking-human.visible=true
|
walking-human.visible=true
|
||||||
walking-human.type=day
|
walking-human.type=day
|
||||||
main-window.custom-title=---
|
main-window.custom-title=---
|
||||||
@ -67,8 +71,7 @@ test.clock.custom.hour=2147483647
|
|||||||
test.clock.custom.minute=2147483647
|
test.clock.custom.minute=2147483647
|
||||||
test.clock.custom.second=2147483647
|
test.clock.custom.second=2147483647
|
||||||
test.clock.custom.millisecond=2147483647
|
test.clock.custom.millisecond=2147483647
|
||||||
|
activity.needed-flags=
|
||||||
#TODO:
|
#TODO:
|
||||||
logs.detailed=false
|
logs.detailed=false
|
||||||
battery.percent-precision.count-of-decimal-points=5
|
|
||||||
main-window.custom-title=---
|
|
||||||
activity.needed-flags=
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user