mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
patch17
This commit is contained in:
parent
46ae2a8d5b
commit
8e9b90d622
@ -156,20 +156,33 @@ public class TimeCalcConfiguration {
|
|||||||
|
|
||||||
public final BooleanProperty squareVisibleProperty
|
public final BooleanProperty squareVisibleProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.SQUARE_VISIBLE.getKey());
|
= new BooleanProperty(TimeCalcProperty.SQUARE_VISIBLE.getKey());
|
||||||
public final BooleanProperty swingVisibleProperty
|
public final StringProperty squareTypeProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.SWING_VISIBLE.getKey());
|
= new StringProperty(TimeCalcProperty.SQUARE_TYPE.getKey());
|
||||||
public final BooleanProperty swingQuarterIconVisibleProperty
|
|
||||||
= new BooleanProperty(TimeCalcProperty.SWING_QUARTER_ICON_VISIBLE.getKey());
|
|
||||||
public final BooleanProperty circleVisibleProperty
|
public final BooleanProperty circleVisibleProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.CIRCLE_VISIBLE.getKey());
|
= new BooleanProperty(TimeCalcProperty.CIRCLE_VISIBLE.getKey());
|
||||||
|
public final StringProperty circleTypeProperty
|
||||||
|
= new StringProperty(TimeCalcProperty.CIRCLE_TYPE.getKey());
|
||||||
public final BooleanProperty walkingHumanVisibleProperty
|
public final BooleanProperty walkingHumanVisibleProperty
|
||||||
= new BooleanProperty(
|
= new BooleanProperty(
|
||||||
TimeCalcProperty.WALKING_HUMAN_VISIBLE.getKey());
|
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
|
public final StringProperty mainWindowCustomTitleProperty
|
||||||
= new StringProperty(
|
= new StringProperty(
|
||||||
TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE.getKey());
|
TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE.getKey());
|
||||||
public final BooleanProperty testModeProperty
|
|
||||||
= new BooleanProperty("testModeProperty", false);
|
|
||||||
public final StringProperty profileNameProperty
|
public final StringProperty profileNameProperty
|
||||||
= new StringProperty(TimeCalcProperty.PROFILE_NAME.getKey());
|
= new StringProperty(TimeCalcProperty.PROFILE_NAME.getKey());
|
||||||
public final StringProperty activityNeededFlagsProperty
|
public final StringProperty activityNeededFlagsProperty
|
||||||
@ -242,10 +255,17 @@ public class TimeCalcConfiguration {
|
|||||||
smileysVisibleOnlyIfMouseMovingOverProperty,
|
smileysVisibleOnlyIfMouseMovingOverProperty,
|
||||||
smileysColoredProperty,
|
smileysColoredProperty,
|
||||||
squareVisibleProperty,
|
squareVisibleProperty,
|
||||||
|
squareTypeProperty,
|
||||||
circleVisibleProperty,
|
circleVisibleProperty,
|
||||||
|
circleTypeProperty,
|
||||||
swingVisibleProperty,
|
swingVisibleProperty,
|
||||||
|
swingTypeProperty,
|
||||||
swingQuarterIconVisibleProperty,
|
swingQuarterIconVisibleProperty,
|
||||||
walkingHumanVisibleProperty,
|
walkingHumanVisibleProperty,
|
||||||
|
walkingHumanTypeProperty,
|
||||||
|
lifeVisibleProperty,
|
||||||
|
lifeTypeProperty,
|
||||||
|
lifeBirthDateProperty,
|
||||||
mainWindowCustomTitleProperty,
|
mainWindowCustomTitleProperty,
|
||||||
profileNameProperty,
|
profileNameProperty,
|
||||||
activityNeededFlagsProperty,
|
activityNeededFlagsProperty,
|
||||||
|
@ -291,10 +291,6 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Calendar.DAY_OF_MONTH:
|
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) {
|
if (oldMonth != newMonth) {
|
||||||
updateProperty(timeCalcConfiguration.testMonthCustomProperty, increase, decrease, reset, Calendar.MONTH);
|
updateProperty(timeCalcConfiguration.testMonthCustomProperty, increase, decrease, reset, Calendar.MONTH);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
package org.nanoboot.utils.timecalc.app;
|
package org.nanoboot.utils.timecalc.app;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
@ -76,12 +80,18 @@ public enum TimeCalcProperty {
|
|||||||
"Smileys : Visible only, if mouse moving over"),
|
"Smileys : Visible only, if mouse moving over"),
|
||||||
SMILEYS_COLORED("smileys.colored", "Smileys : Colored"),
|
SMILEYS_COLORED("smileys.colored", "Smileys : Colored"),
|
||||||
SQUARE_VISIBLE("square.visible", "Square"),
|
SQUARE_VISIBLE("square.visible", "Square"),
|
||||||
SWING_VISIBLE("swing.visible", "Swing"),
|
SQUARE_TYPE("square.type", "Square : Type"),
|
||||||
SWING_QUARTER_ICON_VISIBLE("swing.quarter-icon.visible", "Swing: Quarter icon"),
|
|
||||||
CIRCLE_VISIBLE("circle.visible", "Circle"),
|
CIRCLE_VISIBLE("circle.visible", "Circle"),
|
||||||
|
CIRCLE_TYPE("circle.type", "Circle : Type"),
|
||||||
WALKING_HUMAN_VISIBLE("walking-human.visible", "Walking Human"),
|
WALKING_HUMAN_VISIBLE("walking-human.visible", "Walking Human"),
|
||||||
MAIN_WINDOW_CUSTOM_TITLE("main-window.custom-title",
|
WALKING_HUMAN_TYPE("walking-human.type", "Walking Human : Type"),
|
||||||
"Main Window : Custom Title"),
|
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"),
|
PROFILE_NAME("profile.name", "Profile : Name"),
|
||||||
TEST_ENABLED("test.enabled", "Test : Enabled", Boolean.class),
|
TEST_ENABLED("test.enabled", "Test : Enabled", Boolean.class),
|
||||||
TEST_CLOCK_CUSTOM_YEAR("test.clock.custom.year", "Test : Clock : Custom : Year", Integer.class),
|
TEST_CLOCK_CUSTOM_YEAR("test.clock.custom.year", "Test : Clock : Custom : Year", Integer.class),
|
||||||
@ -100,6 +110,20 @@ public enum TimeCalcProperty {
|
|||||||
@Getter
|
@Getter
|
||||||
private final Class clazz;
|
private final Class clazz;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static {
|
||||||
|
Set<String> 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) {
|
TimeCalcProperty(String key, String description, Class clazz) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
@ -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()];
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ package org.nanoboot.utils.timecalc.swing.common;
|
|||||||
import org.nanoboot.utils.timecalc.app.GetProperty;
|
import org.nanoboot.utils.timecalc.app.GetProperty;
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
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.Battery;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressSmileyIcon;
|
import org.nanoboot.utils.timecalc.swing.progress.ProgressSmileyIcon;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressSwing;
|
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.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.awt.event.MouseMotionListener;
|
import java.awt.event.MouseMotionListener;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
@ -59,6 +61,8 @@ public class Widget extends JPanel implements
|
|||||||
public StringProperty visibilityProperty
|
public StringProperty visibilityProperty
|
||||||
= new StringProperty("widget.visibilityProperty",
|
= new StringProperty("widget.visibilityProperty",
|
||||||
Visibility.STRONGLY_COLORED.name());
|
Visibility.STRONGLY_COLORED.name());
|
||||||
|
public StringProperty typeProperty
|
||||||
|
= new StringProperty("widget.typeProperty", WidgetType.DAY.name().toLowerCase());
|
||||||
protected int side = 0;
|
protected int side = 0;
|
||||||
protected double donePercent = 0;
|
protected double donePercent = 0;
|
||||||
protected boolean mouseOver = false;
|
protected boolean mouseOver = false;
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,15 @@
|
|||||||
package org.nanoboot.utils.timecalc.swing.windows;
|
package org.nanoboot.utils.timecalc.swing.windows;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcConfiguration;
|
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.app.TimeCalcProperty;
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
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.SwingUtils;
|
||||||
import org.nanoboot.utils.timecalc.swing.controls.MouseClickedListener;
|
import org.nanoboot.utils.timecalc.swing.controls.MouseClickedListener;
|
||||||
import org.nanoboot.utils.timecalc.swing.controls.TButton;
|
import org.nanoboot.utils.timecalc.swing.controls.TButton;
|
||||||
import org.nanoboot.utils.timecalc.swing.controls.TTabbedPane;
|
import org.nanoboot.utils.timecalc.swing.controls.TTabbedPane;
|
||||||
import org.nanoboot.utils.timecalc.swing.controls.TWindow;
|
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.BooleanProperty;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@ -173,14 +175,28 @@ public class ConfigWindow extends TWindow {
|
|||||||
= new JCheckBox(TimeCalcProperty.SMILEYS_COLORED.getKey());
|
= new JCheckBox(TimeCalcProperty.SMILEYS_COLORED.getKey());
|
||||||
private final JCheckBox squareVisibleProperty
|
private final JCheckBox squareVisibleProperty
|
||||||
= new JCheckBox(TimeCalcProperty.SQUARE_VISIBLE.getKey());
|
= new JCheckBox(TimeCalcProperty.SQUARE_VISIBLE.getKey());
|
||||||
|
private final JTextField squareTypeProperty
|
||||||
|
= new JTextField(TimeCalcProperty.SQUARE_TYPE.getKey());
|
||||||
private final JCheckBox circleVisibleProperty
|
private final JCheckBox circleVisibleProperty
|
||||||
= new JCheckBox(TimeCalcProperty.CIRCLE_VISIBLE.getKey());
|
= new JCheckBox(TimeCalcProperty.CIRCLE_VISIBLE.getKey());
|
||||||
|
private final JTextField circleTypeProperty
|
||||||
|
= new JTextField(TimeCalcProperty.CIRCLE_TYPE.getKey());
|
||||||
private final JCheckBox swingVisibleProperty
|
private final JCheckBox swingVisibleProperty
|
||||||
= new JCheckBox(TimeCalcProperty.SWING_VISIBLE.getKey());
|
= new JCheckBox(TimeCalcProperty.SWING_VISIBLE.getKey());
|
||||||
|
private final JTextField swingTypeProperty
|
||||||
|
= new JTextField(TimeCalcProperty.SWING_TYPE.getKey());
|
||||||
private final JCheckBox swingQuarterIconVisibleProperty
|
private final JCheckBox swingQuarterIconVisibleProperty
|
||||||
= new JCheckBox(TimeCalcProperty.SWING_QUARTER_ICON_VISIBLE.getKey());
|
= new JCheckBox(TimeCalcProperty.SWING_QUARTER_ICON_VISIBLE.getKey());
|
||||||
private final JCheckBox walkingHumanVisibleProperty
|
private final JCheckBox walkingHumanVisibleProperty
|
||||||
= new JCheckBox(TimeCalcProperty.WALKING_HUMAN_VISIBLE.getKey());
|
= 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
|
private final JTextField mainWindowCustomTitleProperty
|
||||||
= new JTextField();
|
= new JTextField();
|
||||||
private final JTextField profileNameProperty
|
private final JTextField profileNameProperty
|
||||||
@ -345,6 +361,7 @@ public class ConfigWindow extends TWindow {
|
|||||||
smileysVisibleOnlyIfMouseMovingOverProperty
|
smileysVisibleOnlyIfMouseMovingOverProperty
|
||||||
.setSelected(!enable);
|
.setSelected(!enable);
|
||||||
squareVisibleProperty.setSelected(enable);
|
squareVisibleProperty.setSelected(enable);
|
||||||
|
lifeVisibleProperty.setSelected(enable);
|
||||||
circleVisibleProperty.setSelected(enable);
|
circleVisibleProperty.setSelected(enable);
|
||||||
swingVisibleProperty.setSelected(enable);
|
swingVisibleProperty.setSelected(enable);
|
||||||
swingQuarterIconVisibleProperty.setSelected(enable);
|
swingQuarterIconVisibleProperty.setSelected(enable);
|
||||||
@ -404,10 +421,17 @@ public class ConfigWindow extends TWindow {
|
|||||||
commandsVisibleProperty,
|
commandsVisibleProperty,
|
||||||
notificationsVisibleProperty,
|
notificationsVisibleProperty,
|
||||||
squareVisibleProperty,
|
squareVisibleProperty,
|
||||||
|
squareTypeProperty,
|
||||||
circleVisibleProperty,
|
circleVisibleProperty,
|
||||||
|
circleTypeProperty,
|
||||||
swingVisibleProperty,
|
swingVisibleProperty,
|
||||||
|
swingTypeProperty,
|
||||||
swingQuarterIconVisibleProperty,
|
swingQuarterIconVisibleProperty,
|
||||||
walkingHumanVisibleProperty,
|
walkingHumanVisibleProperty,
|
||||||
|
walkingHumanTypeProperty,
|
||||||
|
lifeVisibleProperty,
|
||||||
|
lifeTypeProperty,
|
||||||
|
lifeBirthDateProperty,
|
||||||
mainWindowCustomTitleProperty,
|
mainWindowCustomTitleProperty,
|
||||||
profileNameProperty,
|
profileNameProperty,
|
||||||
activityNeededFlagsProperty,
|
activityNeededFlagsProperty,
|
||||||
@ -455,38 +479,26 @@ public class ConfigWindow extends TWindow {
|
|||||||
p.putClientProperty(CLIENT_PROPERTY_KEY,
|
p.putClientProperty(CLIENT_PROPERTY_KEY,
|
||||||
TimeCalcProperty.PROFILE_NAME.getKey());
|
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) {
|
if (p == activityNeededFlagsProperty) {
|
||||||
final JLabel jLabel = new JLabel(
|
addLabelToNextRow(TimeCalcProperty.ACTIVITY_NEEDED_FLAGS);
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p == testClockCustomYearProperty) {
|
if (p == testClockCustomYearProperty) {
|
||||||
@ -525,6 +537,8 @@ public class ConfigWindow extends TWindow {
|
|||||||
|
|
||||||
checkBox.setText(timeCalcProperty.getDescription());
|
checkBox.setText(timeCalcProperty.getDescription());
|
||||||
|
|
||||||
|
System.out.println(((JCheckBox) p).getText());
|
||||||
|
System.out.println(timeCalcProperty);
|
||||||
BooleanProperty property
|
BooleanProperty property
|
||||||
= (BooleanProperty) timeCalcConfiguration
|
= (BooleanProperty) timeCalcConfiguration
|
||||||
.getProperty(timeCalcProperty);
|
.getProperty(timeCalcProperty);
|
||||||
@ -632,9 +646,54 @@ public class ConfigWindow extends TWindow {
|
|||||||
String timeCalcPropertyKey
|
String timeCalcPropertyKey
|
||||||
= (String) textField.getClientProperty(
|
= (String) textField.getClientProperty(
|
||||||
CLIENT_PROPERTY_KEY);
|
CLIENT_PROPERTY_KEY);
|
||||||
|
if(timeCalcPropertyKey == null) {
|
||||||
|
timeCalcPropertyKey = textField.getText();
|
||||||
|
textField.putClientProperty(CLIENT_PROPERTY_KEY, timeCalcPropertyKey);
|
||||||
|
}
|
||||||
TimeCalcProperty timeCalcProperty
|
TimeCalcProperty timeCalcProperty
|
||||||
= TimeCalcProperty.forKey(timeCalcPropertyKey);
|
= TimeCalcProperty.forKey(timeCalcPropertyKey);
|
||||||
boolean isInteger = Integer.class == timeCalcProperty.getClazz();
|
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
|
timeCalcConfiguration
|
||||||
.getProperty(timeCalcProperty).addListener(e -> {
|
.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) {
|
private void addToNextRow(JComponent jComponent) {
|
||||||
int index = 4;
|
int index = 4;
|
||||||
String key = (String) jComponent.getClientProperty(CLIENT_PROPERTY_KEY);
|
String key = (String) jComponent.getClientProperty(CLIENT_PROPERTY_KEY);
|
||||||
|
@ -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.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.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;
|
||||||
@ -96,6 +97,7 @@ public class MainWindow extends TWindow {
|
|||||||
private final TTextField elapsedTextField;
|
private final TTextField elapsedTextField;
|
||||||
private final TTextField remainingTextField;
|
private final TTextField remainingTextField;
|
||||||
private final TButton saveButton;
|
private final TButton saveButton;
|
||||||
|
private final ProgressLife progressLife;
|
||||||
private HelpWindow helpWindow = null;
|
private HelpWindow helpWindow = null;
|
||||||
private ConfigWindow configWindow = null;
|
private ConfigWindow configWindow = null;
|
||||||
private ActivitiesWindow activitiesWindow = 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);
|
// placeHolderWidget.setBounds(progressSquare.getX() + progressSquare.getWidth() + SwingUtils.MARGIN, SwingUtils.MARGIN, 50, 50);
|
||||||
|
|
||||||
ProgressSwing progressSwing = new ProgressSwing();
|
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);
|
200, 100);
|
||||||
add(progressSwing);
|
add(progressSwing);
|
||||||
progressSwing.visibleProperty
|
progressSwing.visibleProperty
|
||||||
.bindTo(timeCalcConfiguration.swingVisibleProperty);
|
.bindTo(timeCalcConfiguration.swingVisibleProperty);
|
||||||
progressSwing.quarterIconVisibleProperty.bindTo(timeCalcConfiguration.swingQuarterIconVisibleProperty);
|
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);
|
TLabel arrivalTextFieldLabel = new TLabel("Arrival:", 70);
|
||||||
arrivalTextFieldLabel.setBoundsFromTop(progressSwing, 3);
|
arrivalTextFieldLabel.setBoundsFromTop(progressSwing, 3);
|
||||||
|
|
||||||
@ -956,15 +977,12 @@ public class MainWindow extends TWindow {
|
|||||||
progressSquare.setDonePercent(done);
|
progressSquare.setDonePercent(done);
|
||||||
progressCircle.setDonePercent(done);
|
progressCircle.setDonePercent(done);
|
||||||
progressSwing.setDonePercent(done);
|
progressSwing.setDonePercent(done);
|
||||||
|
progressLife.setDonePercent(done);
|
||||||
dayBattery.setDonePercent(done);
|
dayBattery.setDonePercent(done);
|
||||||
try {
|
try {
|
||||||
WeekStatistics weekStatisticsTmp = new WeekStatistics(clock, time);
|
WeekStatistics weekStatisticsTmp = new WeekStatistics(clock, time);
|
||||||
weekStatistics = weekStatisticsTmp;
|
weekStatistics = weekStatisticsTmp;
|
||||||
} catch (DateTimeException e) {
|
} 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();
|
e.printStackTrace();
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
@ -11,8 +11,8 @@ import java.util.Locale;
|
|||||||
*/
|
*/
|
||||||
public class DateFormats {
|
public class DateFormats {
|
||||||
|
|
||||||
public final static DateTimeFormatter DATE_TIME_FORMATTER_HHmmssSSS
|
public final static DateFormat DATE_TIME_FORMATTER_HHmmssSSS
|
||||||
= DateTimeFormatter.ofPattern("HH:mm:ss:SSS");
|
= new SimpleDateFormat("HH:mm:ss:SSS", Locale.ENGLISH);
|
||||||
public static DateFormat DATE_TIME_FORMATTER_LONG
|
public static DateFormat DATE_TIME_FORMATTER_LONG
|
||||||
= new SimpleDateFormat("yyyy-MM-dd : EEEE", Locale.ENGLISH);
|
= new SimpleDateFormat("yyyy-MM-dd : EEEE", Locale.ENGLISH);
|
||||||
|
|
||||||
|
@ -45,10 +45,17 @@ smileys.visible=true
|
|||||||
smileys.visible-only-if-mouse-moving-over=true
|
smileys.visible-only-if-mouse-moving-over=true
|
||||||
smileys.colored=true
|
smileys.colored=true
|
||||||
square.visible=true
|
square.visible=true
|
||||||
|
square.type=day
|
||||||
circle.visible=true
|
circle.visible=true
|
||||||
|
circle.type=day
|
||||||
swing.visible=true
|
swing.visible=true
|
||||||
|
swing.type=day
|
||||||
swing.quarter-icon.visible=true
|
swing.quarter-icon.visible=true
|
||||||
|
life.visible=true
|
||||||
|
life.type=day
|
||||||
|
life.birth-date=
|
||||||
walking-human.visible=true
|
walking-human.visible=true
|
||||||
|
walking-human.type=day
|
||||||
main-window.custom-title=---
|
main-window.custom-title=---
|
||||||
profile.name=
|
profile.name=
|
||||||
test.enabled=false
|
test.enabled=false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user