diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcConfiguration.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcConfiguration.java index b88265e..25ab5d9 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcConfiguration.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcConfiguration.java @@ -156,20 +156,33 @@ public class TimeCalcConfiguration { public final BooleanProperty squareVisibleProperty = new BooleanProperty(TimeCalcProperty.SQUARE_VISIBLE.getKey()); - public final BooleanProperty swingVisibleProperty - = new BooleanProperty(TimeCalcProperty.SWING_VISIBLE.getKey()); - public final BooleanProperty swingQuarterIconVisibleProperty - = new BooleanProperty(TimeCalcProperty.SWING_QUARTER_ICON_VISIBLE.getKey()); + public final StringProperty squareTypeProperty + = new StringProperty(TimeCalcProperty.SQUARE_TYPE.getKey()); public final BooleanProperty circleVisibleProperty = new BooleanProperty(TimeCalcProperty.CIRCLE_VISIBLE.getKey()); + public final StringProperty circleTypeProperty + = new StringProperty(TimeCalcProperty.CIRCLE_TYPE.getKey()); public final BooleanProperty walkingHumanVisibleProperty = new BooleanProperty( TimeCalcProperty.WALKING_HUMAN_VISIBLE.getKey()); + public final StringProperty walkingHumanTypeProperty + = new StringProperty(TimeCalcProperty.WALKING_HUMAN_TYPE.getKey()); + public final BooleanProperty swingVisibleProperty + = new BooleanProperty(TimeCalcProperty.SWING_VISIBLE.getKey()); + public final StringProperty swingTypeProperty + = new StringProperty(TimeCalcProperty.SWING_TYPE.getKey()); + public final BooleanProperty swingQuarterIconVisibleProperty + = new BooleanProperty(TimeCalcProperty.SWING_QUARTER_ICON_VISIBLE.getKey()); + + public final BooleanProperty lifeVisibleProperty + = new BooleanProperty(TimeCalcProperty.LIFE_VISIBLE.getKey()); + public final StringProperty lifeTypeProperty + = new StringProperty(TimeCalcProperty.LIFE_TYPE.getKey()); + public final StringProperty lifeBirthDateProperty + = new StringProperty(TimeCalcProperty.LIFE_BIRTH_DATE.getKey()); public final StringProperty mainWindowCustomTitleProperty = new StringProperty( TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE.getKey()); - public final BooleanProperty testModeProperty - = new BooleanProperty("testModeProperty", false); public final StringProperty profileNameProperty = new StringProperty(TimeCalcProperty.PROFILE_NAME.getKey()); public final StringProperty activityNeededFlagsProperty @@ -242,10 +255,17 @@ public class TimeCalcConfiguration { smileysVisibleOnlyIfMouseMovingOverProperty, smileysColoredProperty, squareVisibleProperty, + squareTypeProperty, circleVisibleProperty, + circleTypeProperty, swingVisibleProperty, + swingTypeProperty, swingQuarterIconVisibleProperty, walkingHumanVisibleProperty, + walkingHumanTypeProperty, + lifeVisibleProperty, + lifeTypeProperty, + lifeBirthDateProperty, mainWindowCustomTitleProperty, profileNameProperty, activityNeededFlagsProperty, diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java index 08d78a2..e4cbe0b 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java @@ -291,10 +291,6 @@ public class TimeCalcKeyAdapter extends KeyAdapter { } break; case Calendar.DAY_OF_MONTH: - System.out.println("oldMonth=" + oldMonth); - System.out.println("newMonth=" + newMonth); - System.out.println("oldDay=" + oldDay); - System.out.println("newDay=" + newDay); if (oldMonth != newMonth) { updateProperty(timeCalcConfiguration.testMonthCustomProperty, increase, decrease, reset, Calendar.MONTH); } diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcProperty.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcProperty.java index 39bae21..836cab4 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcProperty.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcProperty.java @@ -1,10 +1,14 @@ package org.nanoboot.utils.timecalc.app; import lombok.Getter; +import org.nanoboot.utils.timecalc.utils.common.Utils; +import javax.swing.JOptionPane; import java.awt.Color; import java.util.Arrays; +import java.util.HashSet; import java.util.Optional; +import java.util.Set; /** * @author Robert Vokac @@ -76,12 +80,18 @@ public enum TimeCalcProperty { "Smileys : Visible only, if mouse moving over"), SMILEYS_COLORED("smileys.colored", "Smileys : Colored"), SQUARE_VISIBLE("square.visible", "Square"), - SWING_VISIBLE("swing.visible", "Swing"), - SWING_QUARTER_ICON_VISIBLE("swing.quarter-icon.visible", "Swing: Quarter icon"), + SQUARE_TYPE("square.type", "Square : Type"), CIRCLE_VISIBLE("circle.visible", "Circle"), + CIRCLE_TYPE("circle.type", "Circle : Type"), WALKING_HUMAN_VISIBLE("walking-human.visible", "Walking Human"), - MAIN_WINDOW_CUSTOM_TITLE("main-window.custom-title", - "Main Window : Custom Title"), + WALKING_HUMAN_TYPE("walking-human.type", "Walking Human : Type"), + SWING_VISIBLE("swing.visible", "Swing"), + SWING_TYPE("swing.type", "Swing : Type"), + SWING_QUARTER_ICON_VISIBLE("swing.quarter-icon.visible", "Swing: Quarter icon"), + LIFE_VISIBLE("life.visible", "Life"), + LIFE_TYPE("life.type", "Life : Type"), + LIFE_BIRTH_DATE("life.birth-date", "Life : Birth date"), + MAIN_WINDOW_CUSTOM_TITLE("main-window.custom-title","Main Window : Custom Title"), PROFILE_NAME("profile.name", "Profile : Name"), TEST_ENABLED("test.enabled", "Test : Enabled", Boolean.class), TEST_CLOCK_CUSTOM_YEAR("test.clock.custom.year", "Test : Clock : Custom : Year", Integer.class), @@ -100,6 +110,20 @@ public enum TimeCalcProperty { @Getter private final Class clazz; + + + static { + Set uniqueKeys = new HashSet<>(); + for(TimeCalcProperty tcp:TimeCalcProperty.values()) { + if(uniqueKeys.contains(tcp.getKey())) { + String msg = "Fatal exception: TimeCalcProperty key must be unique: " + tcp.getKey(); + JOptionPane.showMessageDialog(null, msg); + throw new TimeCalcException(msg); + } else { + uniqueKeys.add(tcp.getKey()); + } + } + } TimeCalcProperty(String key, String description, Class clazz) { this.key = key; this.description = description; diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/entity/Progress.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/entity/Progress.java new file mode 100644 index 0000000..bb1d179 --- /dev/null +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/entity/Progress.java @@ -0,0 +1,17 @@ +package org.nanoboot.utils.timecalc.entity; + +import org.nanoboot.utils.timecalc.app.TimeCalcException; + +/** + * @author pc00289 + * @since 21.03.2024 + */ +public class Progress { + private final double[] array = new double[6]; + public void set(WidgetType type, double value) { + array[WidgetType.DAY.getIndex()] = value; + } + public double get(WidgetType type) { + return array[WidgetType.DAY.getIndex()]; + } +} diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/entity/WidgetType.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/entity/WidgetType.java new file mode 100644 index 0000000..c84dfd7 --- /dev/null +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/entity/WidgetType.java @@ -0,0 +1,21 @@ +package org.nanoboot.utils.timecalc.entity; + +import org.nanoboot.utils.timecalc.app.TimeCalcException; + +/** + * @author pc00289 + * @since 21.03.2024 + */ +public enum WidgetType { + MINUTE, HOUR, DAY, WEEK, MONTH, YEAR; + public int getIndex() { + int i = 0; + for(WidgetType wt:WidgetType.values()) { + if(wt == this) { + return i; + } + i++; + } + throw new TimeCalcException("This widget type is not supported: " + this); + } +} diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/Widget.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/Widget.java index 10442b4..0b6323f 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/Widget.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/Widget.java @@ -3,6 +3,7 @@ package org.nanoboot.utils.timecalc.swing.common; import org.nanoboot.utils.timecalc.app.GetProperty; import org.nanoboot.utils.timecalc.app.TimeCalcProperty; import org.nanoboot.utils.timecalc.entity.Visibility; +import org.nanoboot.utils.timecalc.entity.WidgetType; import org.nanoboot.utils.timecalc.swing.progress.Battery; import org.nanoboot.utils.timecalc.swing.progress.ProgressSmileyIcon; import org.nanoboot.utils.timecalc.swing.progress.ProgressSwing; @@ -23,6 +24,7 @@ import java.awt.Graphics2D; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; +import java.util.Locale; /** * @author Robert Vokac @@ -59,6 +61,8 @@ public class Widget extends JPanel implements public StringProperty visibilityProperty = new StringProperty("widget.visibilityProperty", Visibility.STRONGLY_COLORED.name()); + public StringProperty typeProperty + = new StringProperty("widget.typeProperty", WidgetType.DAY.name().toLowerCase()); protected int side = 0; protected double donePercent = 0; protected boolean mouseOver = false; diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressLife.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressLife.java new file mode 100644 index 0000000..bab21d5 --- /dev/null +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressLife.java @@ -0,0 +1,113 @@ +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.swing.common.SwingUtils; +import org.nanoboot.utils.timecalc.swing.common.Toaster; +import org.nanoboot.utils.timecalc.swing.common.Widget; +import org.nanoboot.utils.timecalc.swing.windows.MainWindow; +import org.nanoboot.utils.timecalc.utils.common.Constants; +import org.nanoboot.utils.timecalc.utils.common.DateFormats; +import org.nanoboot.utils.timecalc.utils.common.NumberFormats; +import org.nanoboot.utils.timecalc.utils.common.Utils; +import org.nanoboot.utils.timecalc.utils.property.Property; +import org.nanoboot.utils.timecalc.utils.property.StringProperty; + +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; +import javax.swing.Timer; +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.time.format.DateTimeFormatter; +import java.util.Calendar; +import java.util.Date; +import java.util.HashSet; +import java.util.Locale; +import java.util.Set; + +/** + * @author Robert Vokac + * @since 21.02.2024 + */ +public class ProgressLife extends Widget implements GetProperty { + + private final Time time; + public StringProperty birthDateProperty + = new StringProperty("life.birthDateProperty"); + + public ProgressLife(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) { + if (birthDateProperty.getValue().isEmpty()) { + //nothing to do + return; + } else { + Calendar birthDateCal = Calendar.getInstance(); + String[] array = birthDateProperty.getValue().split("-"); + birthDateCal.set(Calendar.YEAR, Integer.valueOf(array[0])); + birthDateCal.set(Calendar.MONTH, Integer.valueOf(array[1]) - 1); + birthDateCal.set(Calendar.DAY_OF_MONTH, Integer.valueOf(array[2])); + Date birthDate = birthDateCal.getTime(); + Date now = time.asCalendar().getTime(); + long diff = now.getTime() - birthDate.getTime(); + Date result = new Date( + (long) (birthDate.getTime() + diff * donePercent)); + + String date = + DateFormats.DATE_TIME_FORMATTER_YYYYMMDD.format(result); + String time = + DateFormats.DATE_TIME_FORMATTER_HHmmssSSS.format(result); + + Visibility visibility + = Visibility.valueOf(visibilityProperty.getValue()); + + brush.setColor(visibility.isStronglyColored() ? Color.BLUE + : visibility.isWeaklyColored() ? Color.GRAY + : Color.LIGHT_GRAY); + // if(mouseOver) { + // brush.drawRect(1,1,getWidth() - 2, getHeight() - 2); + // } + brush.setFont(SwingUtils.MEDIUM_MONOSPACE_FONT); + + brush.drawString(date, SwingUtils.MARGIN, 3 * SwingUtils.MARGIN); + brush.drawString(time, SwingUtils.MARGIN, (int) (SwingUtils.MARGIN + + (getHeight() - SwingUtils.MARGIN) + * 0.6d)); + + } + } + + @Override + public Property getVisibilityProperty() { + return visibilityProperty; + } + + @Override + public Property getVisibilitySupportedColoredProperty() { + return visibilitySupportedColoredProperty; + } +} diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/ConfigWindow.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/ConfigWindow.java index 8828740..6abd9b7 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/ConfigWindow.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/ConfigWindow.java @@ -1,14 +1,15 @@ package org.nanoboot.utils.timecalc.swing.windows; import org.nanoboot.utils.timecalc.app.TimeCalcConfiguration; +import org.nanoboot.utils.timecalc.app.TimeCalcException; import org.nanoboot.utils.timecalc.app.TimeCalcProperty; 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.controls.MouseClickedListener; import org.nanoboot.utils.timecalc.swing.controls.TButton; import org.nanoboot.utils.timecalc.swing.controls.TTabbedPane; import org.nanoboot.utils.timecalc.swing.controls.TWindow; -import org.nanoboot.utils.timecalc.utils.common.TTime; import org.nanoboot.utils.timecalc.utils.property.BooleanProperty; import org.nanoboot.utils.timecalc.utils.property.StringProperty; @@ -36,6 +37,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -173,14 +175,28 @@ public class ConfigWindow extends TWindow { = new JCheckBox(TimeCalcProperty.SMILEYS_COLORED.getKey()); private final JCheckBox squareVisibleProperty = new JCheckBox(TimeCalcProperty.SQUARE_VISIBLE.getKey()); + private final JTextField squareTypeProperty + = new JTextField(TimeCalcProperty.SQUARE_TYPE.getKey()); private final JCheckBox circleVisibleProperty = new JCheckBox(TimeCalcProperty.CIRCLE_VISIBLE.getKey()); + private final JTextField circleTypeProperty + = new JTextField(TimeCalcProperty.CIRCLE_TYPE.getKey()); private final JCheckBox swingVisibleProperty = new JCheckBox(TimeCalcProperty.SWING_VISIBLE.getKey()); + private final JTextField swingTypeProperty + = new JTextField(TimeCalcProperty.SWING_TYPE.getKey()); private final JCheckBox swingQuarterIconVisibleProperty = new JCheckBox(TimeCalcProperty.SWING_QUARTER_ICON_VISIBLE.getKey()); private final JCheckBox walkingHumanVisibleProperty = new JCheckBox(TimeCalcProperty.WALKING_HUMAN_VISIBLE.getKey()); + private final JTextField walkingHumanTypeProperty + = new JTextField(TimeCalcProperty.WALKING_HUMAN_TYPE.getKey()); + public final JCheckBox lifeVisibleProperty + = new JCheckBox(TimeCalcProperty.LIFE_VISIBLE.getKey()); + public final JTextField lifeTypeProperty + = new JTextField(TimeCalcProperty.LIFE_TYPE.getKey()); + public final JTextField lifeBirthDateProperty + = new JTextField(TimeCalcProperty.LIFE_BIRTH_DATE.getKey()); private final JTextField mainWindowCustomTitleProperty = new JTextField(); private final JTextField profileNameProperty @@ -345,6 +361,7 @@ public class ConfigWindow extends TWindow { smileysVisibleOnlyIfMouseMovingOverProperty .setSelected(!enable); squareVisibleProperty.setSelected(enable); + lifeVisibleProperty.setSelected(enable); circleVisibleProperty.setSelected(enable); swingVisibleProperty.setSelected(enable); swingQuarterIconVisibleProperty.setSelected(enable); @@ -404,10 +421,17 @@ public class ConfigWindow extends TWindow { commandsVisibleProperty, notificationsVisibleProperty, squareVisibleProperty, + squareTypeProperty, circleVisibleProperty, + circleTypeProperty, swingVisibleProperty, + swingTypeProperty, swingQuarterIconVisibleProperty, walkingHumanVisibleProperty, + walkingHumanTypeProperty, + lifeVisibleProperty, + lifeTypeProperty, + lifeBirthDateProperty, mainWindowCustomTitleProperty, profileNameProperty, activityNeededFlagsProperty, @@ -455,38 +479,26 @@ public class ConfigWindow extends TWindow { p.putClientProperty(CLIENT_PROPERTY_KEY, TimeCalcProperty.PROFILE_NAME.getKey()); } + if (p == squareTypeProperty) { + addLabelToNextRow(TimeCalcProperty.SQUARE_TYPE); + } + if (p == circleTypeProperty) { + addLabelToNextRow(TimeCalcProperty.CIRCLE_TYPE); + } + if (p == walkingHumanTypeProperty) { + addLabelToNextRow(TimeCalcProperty.WALKING_HUMAN_TYPE); + } + if (p == swingTypeProperty) { + addLabelToNextRow(TimeCalcProperty.SWING_TYPE); + } + if (p == lifeTypeProperty) { + addLabelToNextRow(TimeCalcProperty.LIFE_TYPE); + } + if (p == lifeBirthDateProperty) { + addLabelToNextRow(TimeCalcProperty.LIFE_BIRTH_DATE); + } if (p == activityNeededFlagsProperty) { - final JLabel jLabel = new JLabel( - TimeCalcProperty.ACTIVITY_NEEDED_FLAGS.getDescription()); - jLabel.putClientProperty(CLIENT_PROPERTY_KEY, - TimeCalcProperty.ACTIVITY_NEEDED_FLAGS.getKey()); - addToNextRow(jLabel); - p.putClientProperty(CLIENT_PROPERTY_KEY, - TimeCalcProperty.ACTIVITY_NEEDED_FLAGS.getKey()); - activityNeededFlagsProperty.setEditable(false); - activityNeededFlagsProperty.setBackground(Color.WHITE); - activityNeededFlagsProperty.putClientProperty( - EDITABLE_ONLY_IN_DIALOG, ""); - activityNeededFlagsProperty - .addMouseListener((MouseClickedListener) f -> { - - String result = - (String) JOptionPane.showInputDialog( - null, - "Select new value", - "New value", - JOptionPane.PLAIN_MESSAGE, - null, - null, - activityNeededFlagsProperty - .getText() - ); - if (result != null) { - activityNeededFlagsProperty.setText(result); - timeCalcConfiguration.activityNeededFlagsProperty.setValue(result); - } - }); - + addLabelToNextRow(TimeCalcProperty.ACTIVITY_NEEDED_FLAGS); } if (p == testClockCustomYearProperty) { @@ -525,6 +537,8 @@ public class ConfigWindow extends TWindow { checkBox.setText(timeCalcProperty.getDescription()); + System.out.println(((JCheckBox) p).getText()); + System.out.println(timeCalcProperty); BooleanProperty property = (BooleanProperty) timeCalcConfiguration .getProperty(timeCalcProperty); @@ -632,9 +646,54 @@ public class ConfigWindow extends TWindow { String timeCalcPropertyKey = (String) textField.getClientProperty( CLIENT_PROPERTY_KEY); + if(timeCalcPropertyKey == null) { + timeCalcPropertyKey = textField.getText(); + textField.putClientProperty(CLIENT_PROPERTY_KEY, timeCalcPropertyKey); + } TimeCalcProperty timeCalcProperty = TimeCalcProperty.forKey(timeCalcPropertyKey); boolean isInteger = Integer.class == timeCalcProperty.getClazz(); + + + + + { + textField.setEditable(false); + textField.setBackground(Color.WHITE); + textField.putClientProperty( + EDITABLE_ONLY_IN_DIALOG, ""); + textField + .addMouseListener((MouseClickedListener) f -> { + + String result = + (String) JOptionPane.showInputDialog( + null, + "Select new value", + "New value", + JOptionPane.PLAIN_MESSAGE, + null, + null, + textField + .getText() + ); + if (result != null) { + if(timeCalcProperty.name().contains("TYPE")) { + try { + WidgetType widgetType = + WidgetType.valueOf(result.toUpperCase( + Locale.ROOT)); + } catch (Exception e) { + throw new TimeCalcException("Invalid format. Only these values are allowed: " + Arrays + .stream(WidgetType.values()).map(WidgetType::name).map(String::toLowerCase).collect( + Collectors.joining(", "))); + } + } + textField.setText(result); + timeCalcConfiguration.getProperty(timeCalcProperty).setValue(timeCalcProperty.getClazz() == Integer.class ? Integer.valueOf(result) : result); + } + }); + + } timeCalcConfiguration .getProperty(timeCalcProperty).addListener(e -> { @@ -730,6 +789,13 @@ public class ConfigWindow extends TWindow { }); } + private void addLabelToNextRow(TimeCalcProperty timeCalcProperty) { + final JLabel jLabel = new JLabel( + timeCalcProperty.getDescription()); + jLabel.putClientProperty(CLIENT_PROPERTY_KEY,timeCalcProperty.getKey()); + addToNextRow(jLabel); + } + private void addToNextRow(JComponent jComponent) { int index = 4; String key = (String) jComponent.getClientProperty(CLIENT_PROPERTY_KEY); diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/MainWindow.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/MainWindow.java index 6a0b329..8c285ba 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/MainWindow.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/MainWindow.java @@ -31,6 +31,7 @@ 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.ProgressLife; import org.nanoboot.utils.timecalc.swing.progress.ProgressSquare; import org.nanoboot.utils.timecalc.swing.progress.ProgressSwing; import org.nanoboot.utils.timecalc.swing.progress.Time; @@ -96,6 +97,7 @@ public class MainWindow extends TWindow { private final TTextField elapsedTextField; private final TTextField remainingTextField; private final TButton saveButton; + private final ProgressLife progressLife; private HelpWindow helpWindow = null; private ConfigWindow configWindow = null; private ActivitiesWindow activitiesWindow = null; @@ -305,13 +307,32 @@ public class MainWindow extends TWindow { // placeHolderWidget.setBounds(progressSquare.getX() + progressSquare.getWidth() + SwingUtils.MARGIN, SwingUtils.MARGIN, 50, 50); ProgressSwing progressSwing = new ProgressSwing(); - progressSwing.setBounds(clock.getX(), clock.getY() + clock.getHeight() + SwingUtils.MARGIN, + progressSwing.setBounds(clock.getX(), walkingHumanProgress.getY() + walkingHumanProgress.getHeight() + SwingUtils.MARGIN, 200, 100); add(progressSwing); progressSwing.visibleProperty .bindTo(timeCalcConfiguration.swingVisibleProperty); progressSwing.quarterIconVisibleProperty.bindTo(timeCalcConfiguration.swingQuarterIconVisibleProperty); + this.progressLife = new ProgressLife(time); + progressLife.setBounds(progressSwing.getX() + progressSwing.getWidth() + SwingUtils.MARGIN, progressSwing.getY(), + 100, 100); + + { + progressSquare.typeProperty + .bindTo(timeCalcConfiguration.squareTypeProperty); + progressCircle.typeProperty + .bindTo(timeCalcConfiguration.circleTypeProperty); + walkingHumanProgress.typeProperty + .bindTo(timeCalcConfiguration.walkingHumanTypeProperty); + progressSwing.typeProperty + .bindTo(timeCalcConfiguration.swingTypeProperty); + progressLife.typeProperty + .bindTo(timeCalcConfiguration.squareTypeProperty); + progressLife.birthDateProperty + .bindTo(timeCalcConfiguration.lifeBirthDateProperty); + } + add(progressLife); TLabel arrivalTextFieldLabel = new TLabel("Arrival:", 70); arrivalTextFieldLabel.setBoundsFromTop(progressSwing, 3); @@ -956,15 +977,12 @@ public class MainWindow extends TWindow { progressSquare.setDonePercent(done); progressCircle.setDonePercent(done); progressSwing.setDonePercent(done); + progressLife.setDonePercent(done); dayBattery.setDonePercent(done); try { WeekStatistics weekStatisticsTmp = new WeekStatistics(clock, time); weekStatistics = weekStatisticsTmp; } catch (DateTimeException e) { - System.out.println("time.monthProperty=" + time.monthProperty); - System.out.println("time.dayProperty=" + time.dayProperty); - System.out.println("time.monthCustomProperty=" + time.monthCustomProperty); - System.out.println("time.dayCustomProperty=" + time.dayCustomProperty); e.printStackTrace(); try { Thread.sleep(1000); diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/DateFormats.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/DateFormats.java index d10ff94..c17010d 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/DateFormats.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/DateFormats.java @@ -11,8 +11,8 @@ import java.util.Locale; */ public class DateFormats { - public final static DateTimeFormatter DATE_TIME_FORMATTER_HHmmssSSS - = DateTimeFormatter.ofPattern("HH:mm:ss:SSS"); + public final static DateFormat DATE_TIME_FORMATTER_HHmmssSSS + = new SimpleDateFormat("HH:mm:ss:SSS", Locale.ENGLISH); public static DateFormat DATE_TIME_FORMATTER_LONG = new SimpleDateFormat("yyyy-MM-dd : EEEE", Locale.ENGLISH); diff --git a/modules/time-calc-app/src/main/resources/timecalc-default.conf b/modules/time-calc-app/src/main/resources/timecalc-default.conf index aaba1c6..2dbbad3 100644 --- a/modules/time-calc-app/src/main/resources/timecalc-default.conf +++ b/modules/time-calc-app/src/main/resources/timecalc-default.conf @@ -45,10 +45,17 @@ smileys.visible=true smileys.visible-only-if-mouse-moving-over=true smileys.colored=true square.visible=true +square.type=day circle.visible=true +circle.type=day swing.visible=true +swing.type=day swing.quarter-icon.visible=true +life.visible=true +life.type=day +life.birth-date= walking-human.visible=true +walking-human.type=day main-window.custom-title=--- profile.name= test.enabled=false