mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
patch23
This commit is contained in:
parent
e0f62c66bb
commit
f28ca92503
@ -77,9 +77,11 @@ public class Progress {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getYearProgress(Integer year, Integer month,
|
public static double getYearProgress(double monthProgress, Integer year, Integer month,
|
||||||
Integer day, Integer hour, Integer minute, Integer second,
|
Integer day, Integer hour, Integer minute, Integer second,
|
||||||
Integer millisecond) {
|
Integer millisecond) {
|
||||||
|
double totalCountOfDaysInAYear = getTotalCountOfDaysInAYear(year);
|
||||||
|
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.set(Calendar.YEAR, year);
|
cal.set(Calendar.YEAR, year);
|
||||||
cal.set(Calendar.MONTH, month - 1);
|
cal.set(Calendar.MONTH, month - 1);
|
||||||
@ -88,22 +90,46 @@ public class Progress {
|
|||||||
cal.set(Calendar.MINUTE, minute);
|
cal.set(Calendar.MINUTE, minute);
|
||||||
cal.set(Calendar.SECOND, second);
|
cal.set(Calendar.SECOND, second);
|
||||||
cal.set(Calendar.MILLISECOND, millisecond);
|
cal.set(Calendar.MILLISECOND, millisecond);
|
||||||
|
int daysInMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||||
double seconds = second + millisecond / 1000d;
|
if(month == 1) {
|
||||||
double minutes = minute + seconds / 60d;
|
return (daysInMonth * monthProgress + totalCountOfDaysInAYear - daysInMonth) / totalCountOfDaysInAYear;
|
||||||
double hours = hour + minutes / 60d;
|
} else {
|
||||||
double days = cal.get(Calendar.DAY_OF_YEAR) + hours / 24d;
|
cal.set(Calendar.MONTH, month - 2);
|
||||||
// System.out.println("millisecond=" + millisecond);
|
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||||||
// System.out.println("seconds=" + seconds);
|
int totalDaysUntilLastDayOfLastMonth = cal.get(Calendar.DAY_OF_YEAR);
|
||||||
// System.out.println("minutes=" + minutes);
|
cal.set(Calendar.MONTH, month - 1);
|
||||||
// System.out.println("hours=" + hours);
|
cal.set(Calendar.DAY_OF_MONTH, day);
|
||||||
// System.out.println("days=" + days);
|
return (totalDaysUntilLastDayOfLastMonth + (daysInMonth * monthProgress) + (totalCountOfDaysInAYear - totalDaysUntilLastDayOfLastMonth - daysInMonth))/totalCountOfDaysInAYear;
|
||||||
// System.out.println("cal.get(Calendar.DAY_OF_YEAR)=" + cal.get(Calendar.DAY_OF_YEAR));
|
}
|
||||||
|
|
||||||
double totalCountOfDaysInAYear = getTotalCountOfDaysInAYear(year);
|
|
||||||
return days / totalCountOfDaysInAYear;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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) {
|
private static double getTotalCountOfDaysInAYear(Integer year) {
|
||||||
boolean leapYear = isLeapYear(year);
|
boolean leapYear = isLeapYear(year);
|
||||||
double daysInYear = 365d;
|
double daysInYear = 365d;
|
||||||
@ -117,8 +143,8 @@ public class Progress {
|
|||||||
return year % 4 == 0;
|
return year % 4 == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getYearProgress(AnalogClock analogClock) {
|
public static double getYearProgress(AnalogClock analogClock, double monthProgress) {
|
||||||
return getYearProgress(
|
return getYearProgress(monthProgress,
|
||||||
analogClock.yearProperty.getValue(),
|
analogClock.yearProperty.getValue(),
|
||||||
analogClock.monthProperty.getValue(),
|
analogClock.monthProperty.getValue(),
|
||||||
analogClock.dayProperty.getValue(),
|
analogClock.dayProperty.getValue(),
|
||||||
|
@ -243,7 +243,12 @@ public class Widget extends JPanel implements
|
|||||||
paintCloseIcon(brush, getWidth(), mouseOver, mouseOverCloseButton);
|
paintCloseIcon(brush, getWidth(), mouseOver, mouseOverCloseButton);
|
||||||
|
|
||||||
if (mouseOver) {
|
if (mouseOver) {
|
||||||
|
Color currentColor = brush.getColor();
|
||||||
|
if(visibility.isStronglyColored()) {
|
||||||
|
brush.setColor(Color.BLUE);
|
||||||
|
}
|
||||||
brush.drawRect(1, 1, getWidth() - 2, getHeight() - 2);
|
brush.drawRect(1, 1, getWidth() - 2, getHeight() - 2);
|
||||||
|
brush.setColor(currentColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ public class ProgressLife extends Widget implements GetProperty {
|
|||||||
// }
|
// }
|
||||||
brush.setFont(SwingUtils.MEDIUM_MONOSPACE_FONT);
|
brush.setFont(SwingUtils.MEDIUM_MONOSPACE_FONT);
|
||||||
|
|
||||||
brush.drawString(date, SwingUtils.MARGIN, SwingUtils.MARGIN);
|
brush.drawString(date, SwingUtils.MARGIN, SwingUtils.MARGIN + 5);
|
||||||
brush.drawString(time, SwingUtils.MARGIN,
|
brush.drawString(time, SwingUtils.MARGIN,
|
||||||
(int) (2.5 * SwingUtils.MARGIN) + 5);
|
(int) (2.5 * SwingUtils.MARGIN) + 5);
|
||||||
brush.drawString(typeProperty.getValue(), SwingUtils.MARGIN, 4 * SwingUtils.MARGIN + 5);
|
brush.drawString(typeProperty.getValue(), SwingUtils.MARGIN, 4 * SwingUtils.MARGIN + 5);
|
||||||
|
@ -64,9 +64,9 @@ public class ProgressMoney extends Widget implements GetProperty {
|
|||||||
double value = 0;
|
double value = 0;
|
||||||
switch(WidgetType.valueOf(this.typeProperty.getValue().toUpperCase(
|
switch(WidgetType.valueOf(this.typeProperty.getValue().toUpperCase(
|
||||||
Locale.ROOT))) {
|
Locale.ROOT))) {
|
||||||
case MINUTE: value = perDay / 8d / 60d * progress.get(WidgetType.MINUTE);break;
|
case MINUTE: value = isWeekend ? 0d : perDay / 8d / 60d * progress.get(WidgetType.MINUTE);break;
|
||||||
case HOUR: value = perDay / 8d * progress.get(WidgetType.HOUR);break;
|
case HOUR: value = isWeekend ? 0d : perDay / 8d * progress.get(WidgetType.HOUR);break;
|
||||||
case DAY: value = perDay * progress.get(WidgetType.DAY);break;
|
case DAY: value = isWeekend ? 0d : perDay * progress.get(WidgetType.DAY);break;
|
||||||
case WEEK: value = perDay * 5d * progress.get(WidgetType.WEEK);break;
|
case WEEK: value = perDay * 5d * progress.get(WidgetType.WEEK);break;
|
||||||
case MONTH: value = perMonth * progress.get(WidgetType.MONTH);break;
|
case MONTH: value = perMonth * progress.get(WidgetType.MONTH);break;
|
||||||
case YEAR: value = perMonth * 12 * progress.get(WidgetType.YEAR);break;
|
case YEAR: value = perMonth * 12 * progress.get(WidgetType.YEAR);break;
|
||||||
|
@ -1034,7 +1034,7 @@ public class MainWindow extends TWindow {
|
|||||||
millisecondsRemains);
|
millisecondsRemains);
|
||||||
double minuteProgress =
|
double minuteProgress =
|
||||||
Progress.getMinuteProgress(secondNow, millisecondNow);
|
Progress.getMinuteProgress(secondNow, millisecondNow);
|
||||||
double yearProgress = Progress.getYearProgress(clock);
|
double yearProgress = Progress.getYearProgress(clock, monthProgress);
|
||||||
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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user