diff --git a/Readme.md b/Readme.md index 1b7452e..f35ad6b 100644 --- a/Readme.md +++ b/Readme.md @@ -116,3 +116,17 @@ Progress in square, circle or batteries is represented also by smileys (only, if * Sonarqube * Add SQLite support and store times of arrivals and departures and time of activities +## For Developers + +### How to add new property + +**Change these places:** + +* timecalc-default.conf +* timecalc-template.conf +* TimeCalcProperty +* TimeCalcConfiguration +* ConfigWindow +* Widget class +* MainWindow - bind + diff --git a/modules/time-calc-app/pom.xml b/modules/time-calc-app/pom.xml index e72285b..6cf5a98 100644 --- a/modules/time-calc-app/pom.xml +++ b/modules/time-calc-app/pom.xml @@ -49,7 +49,6 @@ - \ No newline at end of file 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 6f9cf9c..8e9b352 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 @@ -24,6 +24,9 @@ public class TimeCalcConfiguration { public final BooleanProperty clockHandsLongVisibleProperty = new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_LONG_VISIBLE .getKey()); + public final BooleanProperty clockHandsBlackProperty = + new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_BLACK + .getKey()); public final BooleanProperty clockHandsMinuteVisibleProperty = new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_MINUTE_VISIBLE .getKey()); @@ -36,6 +39,28 @@ public class TimeCalcConfiguration { public final BooleanProperty clockBorderVisibleProperty = new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_VISIBLE .getKey()); + public final BooleanProperty clockBorderOnlyHoursProperty = + new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_ONLY_HOURS + .getKey()); + + public final BooleanProperty clockNumbersVisibleProperty = + new BooleanProperty(TimeCalcProperty.CLOCK_NUMBERS_VISIBLE + .getKey()); + public final BooleanProperty clockCircleVisibleProperty = + new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_VISIBLE + .getKey()); + public final BooleanProperty clockCircleStrongBorderProperty = + new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_STRONG_BORDER + .getKey()); + public final StringProperty clockCircleBorderColorProperty = + new StringProperty(TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR + .getKey()); + public final BooleanProperty clockCentreCircleVisibleProperty = + new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_VISIBLE + .getKey()); + public final BooleanProperty clockCentreCircleBlackProperty = + new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK + .getKey()); // public final BooleanProperty batteryWavesVisibleProperty = new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE @@ -64,10 +89,18 @@ public class TimeCalcConfiguration { visibilityDefaultProperty, visibilitySupportedColoredProperty, clockHandsLongVisibleProperty, + clockHandsBlackProperty, clockHandsMinuteVisibleProperty, clockHandsSecondVisibleProperty, clockHandsMillisecondVisibleProperty, clockBorderVisibleProperty, + clockBorderOnlyHoursProperty, + clockNumbersVisibleProperty, + clockCircleVisibleProperty, + clockCircleStrongBorderProperty, + clockCircleBorderColorProperty, + clockCentreCircleVisibleProperty, + clockCentreCircleBlackProperty, batteryWavesVisibleProperty, jokesVisibleProperty, commandsVisibleProperty, 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 d7bba79..3332bfd 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 @@ -3,6 +3,7 @@ package org.nanoboot.utils.timecalc.app; import lombok.Getter; import org.nanoboot.utils.timecalc.entity.Visibility; +import java.awt.Color; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -19,10 +20,19 @@ public enum TimeCalcProperty { VISIBILITY_SUPPORTED_COLORED("visibility.supported.colored", "Visibility : Supported : Colored"), // CLOCK_HANDS_LONG_VISIBLE("clock.hands.long.visible", "Clock : Hands are long"), + CLOCK_HANDS_BLACK("clock.hands.black", "Clock : Hands are black"), CLOCK_HANDS_MINUTE_VISIBLE("clock.hands.minute.visible", "Clock : Minute hand"), CLOCK_HANDS_SECOND_VISIBLE("clock.hands.second.visible", "Clock : Second hand"), CLOCK_HANDS_MILLISECOND_VISIBLE("clock.hands.millisecond.visible", "Clock : Millisecond hand"), CLOCK_BORDER_VISIBLE("clock.border.visible", "Clock : Border"), + CLOCK_BORDER_ONLY_HOURS("clock.border.only-hours", "Clock : Border : Only hours"), + CLOCK_NUMBERS_VISIBLE("clock.numbers.visible", "Clock : Numbers"), + CLOCK_CIRCLE_VISIBLE("clock.circle.visible", "Clock : Circle"), + CLOCK_CIRCLE_STRONG_BORDER("clock.circle.strong-border", "Clock : Circle : Strong border"), + CLOCK_CIRCLE_BORDER_COLOR("clock.circle.border-color", "Clock : Circle : Border color", + Color.class), + CLOCK_CENTRE_CIRCLE_VISIBLE("clock.centre-circle.visible", "Clock : Centre circle"), + CLOCK_CENTRE_CIRCLE_BLACK("clock.centre-circle.black", "Clock : Centre Circle is black"), // BATTERY_WAVES_VISIBLE("battery.waves.visible", "Battery : Waves"), JOKES_VISIBLE("jokes.visible", "Jokes"), @@ -31,9 +41,6 @@ public enum TimeCalcProperty { SMILEYS_COLORED("smileys.colored", "Smileys : Colored"), SQUARE_VISIBLE("square.visible", "Square"); - - - @Getter private final String key; @Getter diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/ConfigWindow.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/ConfigWindow.java index 6a94429..f135aa2 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/ConfigWindow.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/ConfigWindow.java @@ -7,10 +7,14 @@ import org.nanoboot.utils.timecalc.utils.property.BooleanProperty; import org.nanoboot.utils.timecalc.utils.property.StringProperty; import javax.swing.JCheckBox; +import javax.swing.JColorChooser; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JLabel; +import java.awt.Color; import java.awt.Dimension; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.ArrayList; @@ -36,30 +40,49 @@ public class ConfigWindow extends TWindow { Collectors.toList()).toArray()); private JCheckBox visibilitySupportedColoredProperty = - new JCheckBox("visibility.supported.colored"); + new JCheckBox(TimeCalcProperty.VISIBILITY_SUPPORTED_COLORED.getKey()); private JCheckBox clockHandsLongVisibleProperty = - new JCheckBox("clock.hands.long.visible"); + new JCheckBox(TimeCalcProperty.CLOCK_HANDS_LONG_VISIBLE.getKey()); + private JCheckBox clockHandsBlackProperty = + new JCheckBox(TimeCalcProperty.CLOCK_HANDS_BLACK.getKey()); private JCheckBox clockHandsMinuteVisibleProperty = - new JCheckBox("clock.hands.minute.visible"); + new JCheckBox(TimeCalcProperty.CLOCK_HANDS_MINUTE_VISIBLE.getKey()); private JCheckBox clockHandsSecondVisibleProperty = - new JCheckBox("clock.hands.second.visible"); + new JCheckBox(TimeCalcProperty.CLOCK_HANDS_SECOND_VISIBLE.getKey()); private JCheckBox clockHandsMillisecondVisibleProperty = - new JCheckBox("clock.hands.millisecond.visible"); + new JCheckBox(TimeCalcProperty.CLOCK_HANDS_MILLISECOND_VISIBLE.getKey()); private JCheckBox clockBorderVisibleProperty = - new JCheckBox("clock.border.visible"); + new JCheckBox(TimeCalcProperty.CLOCK_BORDER_VISIBLE.getKey()); + private JCheckBox clockBorderOnlyHoursProperty = + new JCheckBox(TimeCalcProperty.CLOCK_BORDER_ONLY_HOURS.getKey()); + + private JCheckBox clockNumbersVisibleProperty = + new JCheckBox(TimeCalcProperty.CLOCK_NUMBERS_VISIBLE.getKey()); + private JCheckBox clockCircleVisibleProperty = + new JCheckBox(TimeCalcProperty.CLOCK_CIRCLE_VISIBLE.getKey()); + private JCheckBox clockCircleStrongBorderProperty = + new JCheckBox(TimeCalcProperty.CLOCK_CIRCLE_STRONG_BORDER.getKey()); + private JColorChooser clockCircleBorderColorProperty = + new JColorChooser(Color.BLACK); + private JCheckBox clockCentreCircleVisibleProperty = + new JCheckBox(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_VISIBLE.getKey()); + private JCheckBox clockCentreCircleBlackProperty = + new JCheckBox(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK.getKey()); + + // private JCheckBox batteryWavesVisibleProperty = - new JCheckBox("battery.waves.visible"); + new JCheckBox(TimeCalcProperty.BATTERY_WAVES_VISIBLE.getKey()); private JCheckBox jokesVisibleProperty = - new JCheckBox("jokes.visible"); + new JCheckBox(TimeCalcProperty.JOKES_VISIBLE.getKey()); private JCheckBox commandsVisibleProperty = - new JCheckBox("commands.visible"); + new JCheckBox(TimeCalcProperty.COMMANDS_VISIBLE.getKey()); private JCheckBox notificationsVisibleProperty = - new JCheckBox("notifications.visible"); + new JCheckBox(TimeCalcProperty.NOTIFICATIONS_VISIBLE.getKey()); private JCheckBox smileysColoredProperty = - new JCheckBox("smileys.colored"); + new JCheckBox(TimeCalcProperty.SMILEYS_COLORED.getKey()); private JCheckBox squareVisibleProperty = - new JCheckBox("square.visible"); + new JCheckBox(TimeCalcProperty.SQUARE_VISIBLE.getKey()); public ConfigWindow(TimeCalcConfiguration timeCalcConfiguration) { this.timeCalcConfiguration = timeCalcConfiguration; @@ -73,7 +96,15 @@ public class ConfigWindow extends TWindow { clockHandsSecondVisibleProperty, clockHandsMillisecondVisibleProperty, clockHandsLongVisibleProperty, + clockHandsBlackProperty, clockBorderVisibleProperty, + clockBorderOnlyHoursProperty, + clockNumbersVisibleProperty, + clockCircleVisibleProperty, + clockCircleStrongBorderProperty, + clockCircleBorderColorProperty, + clockCentreCircleVisibleProperty, + clockCentreCircleBlackProperty, batteryWavesVisibleProperty, jokesVisibleProperty, commandsVisibleProperty, @@ -86,6 +117,10 @@ public class ConfigWindow extends TWindow { p.putClientProperty(CLIENT_PROPERTY_KEY, TimeCalcProperty.VISIBILITY_DEFAULT.getKey()); addToNextRow(new JLabel(TimeCalcProperty.VISIBILITY_DEFAULT.getDescription())); } + if(p == clockCircleBorderColorProperty) { + p.putClientProperty(CLIENT_PROPERTY_KEY, TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR.getKey()); + addToNextRow(new JLabel(TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR.getDescription())); + } if(p instanceof JComboBox) { JComboBox jComboBox = ((JComboBox)p); jComboBox.setMaximumSize(new Dimension(150, 25)); @@ -94,6 +129,7 @@ public class ConfigWindow extends TWindow { CLIENT_PROPERTY_KEY); TimeCalcProperty timeCalcProperty = TimeCalcProperty.forKey(timeCalcPropertyKey); + jComboBox.setSelectedItem(timeCalcConfiguration.getProperty(timeCalcProperty)); jComboBox.addActionListener(e -> { ((StringProperty) timeCalcConfiguration.getProperty(timeCalcProperty)) .setValue( @@ -119,6 +155,61 @@ public class ConfigWindow extends TWindow { .setValue(checkBox.isSelected()); }); } + if(p instanceof JColorChooser) { + JColorChooser jColorChooser = ((JColorChooser)p); + //jColorChooser.setMaximumSize(new Dimension(150, 25)); + + String timeCalcPropertyKey = (String) jColorChooser.getClientProperty( + CLIENT_PROPERTY_KEY); + TimeCalcProperty timeCalcProperty = + TimeCalcProperty.forKey(timeCalcPropertyKey); + + String currentColor = ((StringProperty) timeCalcConfiguration.getProperty(timeCalcProperty)).getValue(); + String[] currentColorAsStringArray = currentColor.split(","); + int red = Integer.valueOf(currentColorAsStringArray[0]); + int green = Integer.valueOf(currentColorAsStringArray[1]); + int blue = Integer.valueOf(currentColorAsStringArray[2]); + Color color = new Color (red, green, blue); + jColorChooser.setColor(color); + jColorChooser.addMouseListener(new MouseListener() { + @Override + public void mouseClicked(MouseEvent e) { + Color selectedColor = jColorChooser.getSelectionModel() + .getSelectedColor(); + selectedColor = JColorChooser.showDialog(null, "Choose a color", color); + if(selectedColor != null) { + jColorChooser.setColor(selectedColor); + ((StringProperty) timeCalcConfiguration + .getProperty(timeCalcProperty)) + .setValue( + selectedColor.getRed() + "," + + selectedColor.getGreen() + "," + + selectedColor.getBlue()); + } + } + + @Override + public void mousePressed(MouseEvent e) { + + } + + @Override + public void mouseReleased(MouseEvent e) { + + } + + @Override + public void mouseEntered(MouseEvent e) { + + } + + @Override + public void mouseExited(MouseEvent e) { + + } + }); + + } propertiesMap.put(TimeCalcProperty.forKey( (String) p.getClientProperty(CLIENT_PROPERTY_KEY)),p); addToNextRow(p); @@ -182,6 +273,6 @@ public class ConfigWindow extends TWindow { } private void nextRow() { - currentY = currentY + 3 * SwingUtils.MARGIN; + currentY = (int) (currentY + 2.5d * SwingUtils.MARGIN); } } diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/MainWindow.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/MainWindow.java index 7e6ce53..832ff8c 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/MainWindow.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/MainWindow.java @@ -254,6 +254,14 @@ public class MainWindow extends TWindow { analogClock.handsLongProperty .bindTo(timeCalcConfiguration.clockHandsLongVisibleProperty); analogClock.borderVisibleProperty.bindTo(timeCalcConfiguration.clockBorderVisibleProperty); + analogClock.borderOnlyHoursProperty.bindTo(timeCalcConfiguration.clockBorderOnlyHoursProperty); + analogClock.numbersVisibleProperty.bindTo(timeCalcConfiguration.clockNumbersVisibleProperty); + analogClock.circleVisibleProperty.bindTo(timeCalcConfiguration.clockCircleVisibleProperty); + analogClock.circleStrongBorderProperty.bindTo(timeCalcConfiguration.clockCircleStrongBorderProperty); + analogClock.centreCircleVisibleProperty.bindTo(timeCalcConfiguration.clockCentreCircleVisibleProperty); + analogClock.centreCircleBorderColorProperty.bindTo(timeCalcConfiguration.clockCircleBorderColorProperty); + analogClock.handsBlackProperty.bindTo(timeCalcConfiguration.clockHandsBlackProperty); + analogClock.centreCircleBlackProperty.bindTo(timeCalcConfiguration.clockCentreCircleBlackProperty); MinuteBattery minuteBattery = new MinuteBattery(progressCircle.getBounds().x, progressCircle.getY() + SwingUtils.MARGIN + progressCircle.getHeight(),140); diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/SwingUtils.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/SwingUtils.java index c3a9493..6700be7 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/SwingUtils.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/SwingUtils.java @@ -1,5 +1,7 @@ package org.nanoboot.utils.timecalc.swing.common; +import org.nanoboot.utils.timecalc.utils.property.StringProperty; + import java.awt.Color; /** @@ -13,4 +15,15 @@ public class SwingUtils { public static final int MARGIN = 10; public static final Color CLOSE_BUTTON_BACKGROUND_COLOR = new Color(127,127,127); + public static final Color getColorFromString(String s) { + if(s.isEmpty()) { + System.out.println("error: empty string for color"); + return Color.ORANGE; + } + String[] colorAsStringArray = s.split(","); + int red = Integer.valueOf(colorAsStringArray[0]); + int green = Integer.valueOf(colorAsStringArray[1]); + int blue = Integer.valueOf(colorAsStringArray[2]); + return new Color(red, green, blue); + } } diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/AnalogClock.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/AnalogClock.java index b6cef96..0a298d0 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/AnalogClock.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/AnalogClock.java @@ -1,13 +1,16 @@ package org.nanoboot.utils.timecalc.swing.progress; -import org.nanoboot.utils.timecalc.app.TimeCalcProperties; import org.nanoboot.utils.timecalc.app.TimeCalcProperty; import org.nanoboot.utils.timecalc.entity.Visibility; +import org.nanoboot.utils.timecalc.swing.common.SwingUtils; import org.nanoboot.utils.timecalc.swing.common.Widget; import org.nanoboot.utils.timecalc.utils.common.DateFormats; import org.nanoboot.utils.timecalc.utils.common.TimeHM; import org.nanoboot.utils.timecalc.utils.property.BooleanProperty; import org.nanoboot.utils.timecalc.utils.property.IntegerProperty; +import org.nanoboot.utils.timecalc.utils.property.InvalidationListener; +import org.nanoboot.utils.timecalc.utils.property.Property; +import org.nanoboot.utils.timecalc.utils.property.StringProperty; import javax.swing.JFrame; import java.awt.BasicStroke; @@ -54,13 +57,38 @@ public class AnalogClock extends Widget { new BooleanProperty("millisecondEnabledProperty", false); public BooleanProperty handsLongProperty = new BooleanProperty("handsLongProperty", true); + public BooleanProperty handsBlackProperty = + new BooleanProperty("handsBlackProperty", false); public final BooleanProperty borderVisibleProperty = new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_VISIBLE .getKey()); + public final BooleanProperty borderOnlyHoursProperty = + new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_ONLY_HOURS + .getKey()); + public final BooleanProperty numbersVisibleProperty = + new BooleanProperty(TimeCalcProperty.CLOCK_NUMBERS_VISIBLE + .getKey()); + public final BooleanProperty circleVisibleProperty = + new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_VISIBLE + .getKey()); + public final BooleanProperty circleStrongBorderProperty = + new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_STRONG_BORDER + .getKey()); + + public final BooleanProperty centreCircleVisibleProperty = + new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_VISIBLE + .getKey()); + public final StringProperty centreCircleBorderColorProperty = + new StringProperty(TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR + .getKey()); + public final BooleanProperty centreCircleBlackProperty = + new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK + .getKey()); private TimeHM startTime; private final TimeHM endTime; private int startAngle; private final int endAngle; + private Color customCircleColor = null; public AnalogClock(TimeHM startTimeIn, TimeHM endTimeIn) { @@ -79,6 +107,8 @@ public class AnalogClock extends Widget { setPreferredSize(new Dimension(200, 200)); + centreCircleBorderColorProperty.addListener(property -> + customCircleColor = SwingUtils.getColorFromString(centreCircleBorderColorProperty.getValue())); } public static void main(String[] args) { @@ -128,6 +158,9 @@ public class AnalogClock extends Widget { int minute = minuteProperty.getValue(); int hour = hourProperty.getValue(); + if(customCircleColor == null) { + customCircleColor = SwingUtils.getColorFromString(centreCircleBorderColorProperty.getValue()); + } if (mouseOver && visibility.isStronglyColored()) { this.startTime = new TimeHM(hour, minute); this.startAngle = @@ -144,9 +177,6 @@ public class AnalogClock extends Widget { g2d.setColor(currentColor); } - // Draw clock numbers and circle - drawClockFace(g2d, centerX, centerY, side / 2 - 40, visibility); - // if (millisecondEnabledProperty.isEnabled() && secondEnabledProperty.isEnabled() && minuteEnabledProperty.isEnabled()) { drawHand(g2d, side / 2 - 10, millisecond / 1000.0, 1.0f, @@ -195,19 +225,26 @@ public class AnalogClock extends Widget { } if(borderVisibleProperty.isEnabled()) { for (int minuteI = 0; minuteI < 60; minuteI++) { - drawBorder(g2d, minuteI, minuteI % 5 == 0 ? 2f : 1f, + if(borderOnlyHoursProperty.isEnabled() && minuteI %5 != 0) { + continue; + } + drawBorder(g2d, minuteI, minuteI % 5 == 0 ? (numbersVisibleProperty.isEnabled() ? 2f : 4f) : 1f, Color.BLACK, visibility); } } - drawCentre(g2d, centerX, centerY); + if(centreCircleVisibleProperty.isEnabled()) { + drawCentreCircle(g2d, centerX, centerY); + } + + drawClockFace(g2d, centerX, centerY, side / 2 - 40, visibility); } - private void drawCentre(Graphics2D brush, int centerX, int centerY) { + private void drawCentreCircle(Graphics2D brush, int centerX, int centerY) { Color currentColor = brush.getColor(); Visibility visibility = Visibility.valueOf(visibilityProperty.getValue()); - brush.setColor(visibility.isStronglyColored() || mouseOver ? Color.RED : + brush.setColor(visibility.isStronglyColored() || mouseOver ? (centreCircleBlackProperty.isEnabled() ? Color.BLACK : Color.RED) : FOREGROUND_COLOR); brush.fillOval(centerX - 3, centerY - 3, 8, 8); brush.setColor(currentColor); @@ -216,12 +253,13 @@ public class AnalogClock extends Widget { private void drawBorder(Graphics2D brush, int forMinute, float stroke, Color color, Visibility visibility) { double value = ((double)forMinute) / 60d; - int length = side / 18; + boolean hourAngle = forMinute % 5 == 0; + int length = side / (numbersVisibleProperty.isEnabled() ? 18 : (hourAngle ? 12 : 18)); double angle = Math.PI * 2 * (value - 0.25); int startX = (int) (getWidth() / 2 + (side/2 - length) * Math.cos(angle)); int startY = (int) (getHeight() / 2 + (side/2 - length) * Math.sin(angle)); - int endX = (int) (getWidth() / 2 + (side/2 - length * 0.50d) * Math.cos(angle)); - int endY = (int) (getHeight() / 2 + (side/2 - length * 0.50d) * Math.sin(angle)); + int endX = (int) (getWidth() / 2 + (side/2 - length * 0.50d * (hourAngle ? 0.25 : 1)) * Math.cos(angle)); + int endY = (int) (getHeight() / 2 + (side/2 - length * 0.50d * (hourAngle ? 0.25 : 1)) * Math.sin(angle)); brush.setColor((visibility.isStronglyColored() || mouseOver) ? color : FOREGROUND_COLOR); @@ -235,7 +273,7 @@ public class AnalogClock extends Widget { int endX = (int) (getWidth() / 2 + length * Math.cos(angle)); int endY = (int) (getHeight() / 2 + length * Math.sin(angle)); - brush.setColor((visibility.isStronglyColored() || mouseOver) ? color : + brush.setColor((visibility.isStronglyColored() || mouseOver) ? (handsBlackProperty.isEnabled() ? Color.BLACK : color) : FOREGROUND_COLOR); brush.setStroke(new BasicStroke(stroke)); brush.drawLine(getWidth() / 2, getHeight() / 2, endX, endY); @@ -246,16 +284,23 @@ public class AnalogClock extends Widget { brush.setStroke(new BasicStroke(2.0f)); brush.setColor(visibility.isStronglyColored() || mouseOver ? Color.BLACK : FOREGROUND_COLOR); - // System.out.println("centerX=" + centerX); - // System.out.println("centerY=" + centerY); - // System.out.println("radius=" + radius); - brush.drawOval(1, 1, centerX * 2 - 3, centerY * 2 - 3); - brush.drawOval(2, 2, centerX * 2 - 3, centerY * 2 - 3); + if(circleVisibleProperty.isEnabled()) { + Color currentColor = brush.getColor(); + if(visibility.isStronglyColored() || mouseOver) { + brush.setColor(customCircleColor); + } + brush.drawOval(1, 1, centerX * 2 - 3, centerY * 2 - 3); + brush.drawOval(2, 2, centerX * 2 - 3, centerY * 2 - 3); + if(circleStrongBorderProperty.isEnabled()) { + brush.drawOval(3, 3, centerX * 2 - 6, centerY * 2 - 6); + brush.drawOval(4, 4, centerX * 2 - 8, centerY * 2 - 8); + brush.drawOval(5, 5, centerX * 2 - 10, centerY * 2 - 10); + brush.drawOval(6, 6, centerX * 2 - 12, centerY * 2 - 12); + } + brush.setColor(currentColor); + } - // g2d.drawOval(3, 3, centerX * 2 - 6, centerY * 2 - 6); - // g2d.drawOval(4, 4, centerX * 2 - 8, centerY * 2 - 8); if (this.mouseOver) { - Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, yearProperty.getValue()); cal.set(Calendar.MONTH, monthProperty.getValue() - 1); @@ -268,15 +313,17 @@ public class AnalogClock extends Widget { ((int) (side * 0.25) + 30), ((int) (side * 0.35)) + 60); } - for (int i = 1; i <= 12; i++) { - double angle = Math.PI * 2 * (i / 12.0 - 0.25); - int dx = centerX + (int) ((radius + 20) * Math.cos(angle)) - 4; - int dy = centerY + (int) ((radius + 20) * Math.sin(angle)) + 4; + if(numbersVisibleProperty.isEnabled()) { + for (int i = 1; i <= 12; i++) { + double angle = Math.PI * 2 * (i / 12.0 - 0.25); + int dx = centerX + (int) ((radius + 20) * Math.cos(angle)) - 4; + int dy = centerY + (int) ((radius + 20) * Math.sin(angle)) + 4; - brush.setFont(new Font("sans", Font.BOLD, 16)); - brush.drawString(Integer.toString(i), dx + (i == 12 ? -3 : 0), dy + (i == 12 ? +3 : 0)); + brush.setFont(new Font("sans", Font.BOLD, 16)); + brush.drawString(Integer.toString(i), dx + (i == 12 ? -3 : 0), + dy + (i == 12 ? +3 : 0)); + } } - } public int getTimerDelay() { diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/Battery.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/Battery.java index fc01773..4f98231 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/Battery.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/Battery.java @@ -115,8 +115,7 @@ public class Battery extends Widget { 1;//donePercent < 0.5 ? 0.5 : donePercent;// (donePercent * 100 - ((int)(donePercent * 100))); int waterSurfaceHeight = (int) (4 * surfacePower);//2 + (int) (Math.random() * 3); - if (waterSurfaceHeight <= 2 || !TimeCalcProperties.getInstance() - .getBooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE) || wavesProperty.isDisabled()) { + if (waterSurfaceHeight <= 2 || wavesProperty.isDisabled()) { waterSurfaceHeight = 0; } diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/property/Property.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/property/Property.java index 757be87..1ed1dad 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/property/Property.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/property/Property.java @@ -50,6 +50,7 @@ public class Property { } public void bindTo(Property anotherProperty) { + fireValueChangedEvent(value); this.boundToProperty = anotherProperty; this.boundChangeListener = (Property p, T oldValue, T newValue) -> { @@ -59,6 +60,7 @@ public class Property { }; this.boundToProperty .addListener(boundChangeListener); + } public T getValue() { 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 9ce1990..2004910 100644 --- a/modules/time-calc-app/src/main/resources/timecalc-default.conf +++ b/modules/time-calc-app/src/main/resources/timecalc-default.conf @@ -2,10 +2,19 @@ visibility.default=STRONGLY_COLORED visibility.supported.colored=true # clock.hands.long.visible=true +clock.centre-circle.black=false clock.hands.minute.visible=true clock.hands.second.visible=true clock.hands.millisecond.visible=false -clock.border.visible=true +clock.border.visible=false +clock.border.only-hours=false +clock.numbers.visible=true +clock.circle.visible=true +clock.circle.strong-border=false +clock.circle.border-color=0,0,0 +clock.centre-circle.visible=true +clock.hands.black=false + # battery.waves.visible=true # @@ -13,4 +22,35 @@ jokes.visible=true commands.visible=true notifications.visible=true smileys.colored=true -square.visible=true \ No newline at end of file +square.visible=true + + + + +#TODO: +logs.detailed=false + +battery.smileys.visible=true +square.smileys.visible=true +circle.smileys.visible=true +battery.charging-unicode-character.visible=true +battery.percent-precision.count-of-decimal-points=5 +battery.percent-progress.visible +battery.label.visible=true +battery.circle-progress.visible=true +clock.visible=true +clock.date.visible-if-mouse-moving-over=true + +circle.visible=true +walking-human.visible=true +battery.visible=true +battery.minute.visible=true +battery.hour.visible=true +battery.day.visible=true +battery.week.visible=true +battery.month.visible=true +battery.year.visible=true +battery.blinking-if-critical-low=true +smileys.visible=true +smileys.visible-only-if-mouse-moving-over=true + diff --git a/pom.xml b/pom.xml index cc9f596..2bc9140 100644 --- a/pom.xml +++ b/pom.xml @@ -114,6 +114,7 @@ + diff --git a/timecalc.template.conf b/timecalc.template.conf deleted file mode 100644 index 83238da..0000000 --- a/timecalc.template.conf +++ /dev/null @@ -1,44 +0,0 @@ -visibility.default=STRONGLY_COLORED -visibility.supported.colored=false -# -clock.hands.long.visible=true -clock.hands.minute.visible=true -clock.hands.second.visible=true -clock.hands.millisecond.visible=false -# -battery.waves.visible=true -# -jokes.visible=true -commands.visible=true -notifications.visible=true -smileys.colored=false - -#todo -logs.detailed=false - -battery.smileys.visible=true -square.smileys.visible=true -circle.smileys.visible=true -battery.charging-unicode-character.visible=true -battery.percent-precision.count-of-decimal-points=5 -battery.percent-progress.visible -battery.label.visible=true -battery.circle-progress.visible=true -clock.visible=true -clock.date.visible-if-mouse-moving-over=true -clock.centre-circle.visible=true -clock.border.visible=true -square.visible=true -circle.visible=true -walking-human.visible=true -battery.visible=true -battery.minute.visible=true -battery.hour.visible=true -battery.day.visible=true -battery.week.visible=true -battery.month.visible=true -battery.year.visible=true -battery.blinking-if-critical-low=true -smileys.visible=true -smileys.visible-only-if-mouse-moving-over=true -