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 7ded876..e65e4b3 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 @@ -199,12 +199,6 @@ public class TimeCalcConfiguration { = new StringProperty(TimeCalcProperty.FUEL_TYPE.getKey()); public final BooleanProperty fuelIconVisibleProperty = new BooleanProperty(TimeCalcProperty.FUEL_ICON_VISIBLE.getKey()); - public final BooleanProperty rotationVisibleProperty - = new BooleanProperty(TimeCalcProperty.ROTATION_VISIBLE.getKey()); - public final BooleanProperty rotationHiddenProperty - = new BooleanProperty(TimeCalcProperty.ROTATION_HIDDEN.getKey()); - public final StringProperty rotationTypeProperty - = new StringProperty(TimeCalcProperty.ROTATION_TYPE.getKey()); public final BooleanProperty circleVisibleProperty = new BooleanProperty(TimeCalcProperty.CIRCLE_VISIBLE.getKey()); public final BooleanProperty circleHiddenProperty @@ -365,7 +359,6 @@ public class TimeCalcConfiguration { dotVisibleProperty,dotTypeProperty, fuelVisibleProperty, fuelTypeProperty, fuelHiddenProperty, fuelIconVisibleProperty, - rotationVisibleProperty, rotationTypeProperty, rotationHiddenProperty, swingVisibleProperty, swingTypeProperty, swingQuarterIconVisibleProperty, 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 62541f7..d8437f0 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 @@ -95,9 +95,6 @@ public enum TimeCalcProperty { FUEL_VISIBLE("fuel.visible", "Fuel"), FUEL_TYPE("fuel.type", "Fuel : Type"), FUEL_HIDDEN("fuel.hidden", "Fuel : Hidden"), - ROTATION_VISIBLE("rotation.visible", "Rotation"), - ROTATION_TYPE("rotation.type", "Rotation : Type"), - ROTATION_HIDDEN("rotation.hidden", "Rotation : Hidden"), FUEL_ICON_VISIBLE("fuel.icon.visible", "Fuel : Icon"), CIRCLE_VISIBLE("circle.visible", "Circle"), CIRCLE_TYPE("circle.type", "Circle : Type"), 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 index d234a2b..62ac2fd 100644 --- 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 @@ -64,7 +64,7 @@ public class Progress { } public static double getMinuteProgress(int secondNow, int millisecondNow) { - return millisecondNow / 60d / 1000d + secondNow / 60d; + return ((double)millisecondNow) / 60d / 1000d + secondNow / 60d; } public static double getHourProgress(TTime timeRemains, int secondsRemains, 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 4182638..5282602 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 @@ -65,6 +65,7 @@ public class Widget extends JPanel implements private static final Color VERY_LIGHT_GRAY = new Color(220, 220, 220); private static final Font FONT = new Font("sans", Font.PLAIN, 12); public static final Color WIDGET_BACKGROUND_COLOR = ((Supplier) () ->{int i = 232;return new Color(i,i,i);}).get(); + private static final int WIDGET_TIMER_DELAY_MINIMUM = 25; public final BooleanProperty visibilitySupportedColoredProperty = new BooleanProperty("visibilitySupportedColoredProperty", true); public final BooleanProperty visibleProperty @@ -101,7 +102,7 @@ public class Widget extends JPanel implements private WidgetMenu widgetMenu = null; public Widget() { setBackground(BACKGROUND_COLOR); - new Timer(getTimerDelay(), e -> repaint()).start(); + new Timer(getTimerDelay() > WIDGET_TIMER_DELAY_MINIMUM ? WIDGET_TIMER_DELAY_MINIMUM : getTimerDelay(), e -> repaint()).start(); this.addMouseMotionListener(new MouseMotionListener() { @Override public void mouseDragged(MouseEvent e) { diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressRotation.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressRotation.java deleted file mode 100644 index bad0a6f..0000000 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressRotation.java +++ /dev/null @@ -1,180 +0,0 @@ -package org.nanoboot.utils.timecalc.swing.progress; - -import org.nanoboot.utils.timecalc.app.TimeCalcProperty; -import org.nanoboot.utils.timecalc.entity.Progress; -import org.nanoboot.utils.timecalc.entity.Visibility; -import org.nanoboot.utils.timecalc.entity.WidgetType; -import org.nanoboot.utils.timecalc.swing.common.SwingUtils; -import org.nanoboot.utils.timecalc.swing.common.Widget; -import org.nanoboot.utils.timecalc.swing.controls.TMenuItem; -import org.nanoboot.utils.timecalc.swing.progress.battery.Battery; -import org.nanoboot.utils.timecalc.utils.common.DateFormats; -import org.nanoboot.utils.timecalc.utils.common.NumberFormats; -import org.nanoboot.utils.timecalc.utils.common.TTime; -import org.nanoboot.utils.timecalc.utils.property.BooleanProperty; -import org.nanoboot.utils.timecalc.utils.property.IntegerProperty; -import org.nanoboot.utils.timecalc.utils.property.StringProperty; - -import javax.swing.JFrame; -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.RenderingHints; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Locale; -import java.util.function.Consumer; - -//https://kodejava.org/how-do-i-write-a-simple-analog-clock-using-java-2d/ -public class ProgressRotation extends Widget { - - public static final Color COLOR_FOR_MILLISECOND_HAND_STRONGLY_COLORED - = new Color(226, - 126, 19); - 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 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 centreCircleColoredProperty - = new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_COLORED - .getKey()); - - public BooleanProperty circleProgressVisibleProperty - = new BooleanProperty(TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE - .getKey(), true); - - private Color customCircleColor = null; - - private List menuItems = null; - - public ProgressRotation() { - typeProperty.setValue(WidgetType.DAY.name().toLowerCase(Locale.ROOT)); - - setPreferredSize(new Dimension(100, 100)); - - centreCircleBorderColorProperty.addListener(property - -> customCircleColor = SwingUtils.getColorFromString( - centreCircleBorderColorProperty.getValue())); - } - - public static void main(String[] args) { - JFrame window = new JFrame("Analog Clock"); - window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - ProgressRotation rotation - = new ProgressRotation(); - window.add(rotation); - window.pack(); - rotation.visibilityProperty.setValue(Visibility.GRAY.name()); - window.setVisible(true); - - } - - private double angle = 0d; - @Override - public void paintWidget(Graphics g) { - - Visibility visibility - = Visibility.valueOf(visibilityProperty.getValue()); - Graphics2D brush = (Graphics2D) g; - brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - - this.side = Math.min(getWidth(), getHeight()); - int centerX = getWidth() / 2; - int centerY = getHeight() / 2; - - if (customCircleColor == null) { - customCircleColor = SwingUtils.getColorFromString( - centreCircleBorderColorProperty.getValue()); - } - - // - angle = angle + 0.001d * donePercent() * 50d; - if(angle > 1.0d) { - angle = angle - 1.0d; - } - - drawHand(brush, side / 2 - 10, angle, 1.0f, - COLOR_FOR_MILLISECOND_HAND_STRONGLY_COLORED, visibility); - //brush.drawString(NumberFormats.FORMATTER_FIVE_DECIMAL_PLACES.format(angle), 15, 15); - - - - if (centreCircleVisibleProperty.isEnabled()) { - drawCentreCircle(brush, centerX, centerY); - } - - if (progress == null) { - progress = new Progress(); - } - - if (circleProgressVisibleProperty.isEnabled()) { - paintCircleProgress(brush, visibility, getWidth(), getHeight()); - } - - - } - - private void drawCentreCircle(Graphics2D brush, int centerX, int centerY) { - Color currentColor = brush.getColor(); - Visibility visibility - = Visibility.valueOf(visibilityProperty.getValue()); - brush.setColor(visibility.isStronglyColored() || mouseOver - ? (centreCircleColoredProperty.isEnabled() ? Color.RED : Color.BLACK) - : FOREGROUND_COLOR); - brush.fillOval(centerX - 3, centerY - 3, 8, 8); - brush.setColor(currentColor); - } - - private void drawHand(Graphics2D brush, int length, double value, - float stroke, Color color, Visibility visibility) { - length = length - 4; - double angle = Math.PI * 2 * (value - 0.25); - int endX = (int) (getWidth() / 2 + length * Math.cos(angle)); - int endY = (int) (getHeight() / 2 + length * Math.sin(angle)); - - brush.setColor((visibility.isStronglyColored() || mouseOver) - ? Color.BLACK : FOREGROUND_COLOR); - brush.setStroke(new BasicStroke(stroke)); - brush.drawLine(getWidth() / 2, getHeight() / 2, endX, endY); - } - - public int getTimerDelay() { - return 1; - } - - @Override - public List createAdditionalMenus() { - if (menuItems == null) { - menuItems = new ArrayList<>(); - } - return this.menuItems; - } - - protected Consumer createRefreshConsumer() { - return (o) -> { - }; - } -} diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressWater.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressWater.java index 0d9d2df..d1dfc7e 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressWater.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressWater.java @@ -1,6 +1,5 @@ package org.nanoboot.utils.timecalc.swing.progress; -import org.nanoboot.utils.timecalc.entity.Progress; import org.nanoboot.utils.timecalc.entity.Visibility; import org.nanoboot.utils.timecalc.swing.common.Widget; import org.nanoboot.utils.timecalc.swing.progress.battery.Battery; @@ -37,7 +36,7 @@ public class ProgressWater extends Widget { int tankHeight = (int) (getHeight() * 0.48); - int doneWaterHeight = (int) (tankHeight * (donePercent())); + int doneWaterHeight = (int) (((double)tankHeight) * (donePercent())); int h = getHeight() - 1; int w = getWidth() - 1; diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/battery/Battery.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/battery/Battery.java index 8aed879..60a2ed3 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/battery/Battery.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/battery/Battery.java @@ -184,7 +184,7 @@ public class Battery extends Widget { @Override public void paintWidget(Graphics g) { if (totalHeight == 0) { - this.totalHeight = (int) (this.getHeight() / 10d * 7d); + this.totalHeight = (int) (this.getHeight() / 10d * 8d); this.totalWidth = this.getWidth(); } double donePercent = donePercent(); 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 d633003..36b0424 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 @@ -267,13 +267,6 @@ public class ConfigWindow extends TWindow { private final JCheckBox fuelIconVisibleProperty = new JCheckBox(TimeCalcProperty.FUEL_ICON_VISIBLE.getKey()); // - private final JCheckBox rotationVisibleProperty - = new JCheckBox(TimeCalcProperty.ROTATION_VISIBLE.getKey()); - private final JTextField rotationTypeProperty = - new JTextField(TimeCalcProperty.ROTATION_TYPE.getKey()); - private final JCheckBox rotationHiddenProperty - = new JCheckBox(TimeCalcProperty.ROTATION_HIDDEN.getKey()); - // public final JCheckBox clockHiddenProperty = new JCheckBox(TimeCalcProperty.CLOCK_HIDDEN.getKey()); public final JCheckBox batteryMinuteHiddenProperty @@ -504,8 +497,7 @@ public class ConfigWindow extends TWindow { walkingHumanVisibleProperty.setSelected(enable); fuelVisibleProperty.setSelected(enable); fuelIconVisibleProperty.setSelected(enable); - rotationVisibleProperty.setSelected(enable); - typeVisibleProperty.setSelected(false); +// typeVisibleProperty.setSelected(false); // clockHiddenProperty.setSelected(!enable); // batteryMinuteHiddenProperty.setSelected(!enable); // batteryHourHiddenProperty.setSelected(!enable); @@ -594,7 +586,6 @@ public class ConfigWindow extends TWindow { waterVisibleProperty, waterHiddenProperty, waterTypeProperty,waterColoredProperty, dotVisibleProperty,dotHiddenProperty,dotTypeProperty, fuelVisibleProperty,fuelTypeProperty,fuelHiddenProperty,fuelIconVisibleProperty, - rotationVisibleProperty, rotationTypeProperty, rotationHiddenProperty, swingVisibleProperty,swingHiddenProperty,swingTypeProperty,swingQuarterIconVisibleProperty, walkingHumanVisibleProperty,walkingHumanHiddenProperty,walkingHumanTypeProperty, lifeVisibleProperty,lifeHiddenProperty,lifeTypeProperty,lifeBirthDateProperty, @@ -1018,9 +1009,7 @@ public class ConfigWindow extends TWindow { key.startsWith("swing.") || key.startsWith("walking-human.") || key.startsWith("fuel.") || - key.startsWith("rotation.") || key.startsWith("bar.") || - key.startsWith("color.") || key.startsWith("water.") ) { index = 6; 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 694e7e8..185160d 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 @@ -33,7 +33,6 @@ import org.nanoboot.utils.timecalc.swing.progress.ProgressDot; import org.nanoboot.utils.timecalc.swing.progress.ProgressFuelGauge; import org.nanoboot.utils.timecalc.swing.progress.ProgressLife; import org.nanoboot.utils.timecalc.swing.progress.ProgressMoney; -import org.nanoboot.utils.timecalc.swing.progress.ProgressRotation; import org.nanoboot.utils.timecalc.swing.progress.ProgressSquare; import org.nanoboot.utils.timecalc.swing.progress.ProgressSwing; import org.nanoboot.utils.timecalc.swing.progress.ProgressWater; @@ -139,7 +138,6 @@ public class MainWindow extends TWindow { private final ProgressMoney progressMoney; private final ProgressWeather progressWeather; private final ProgressFuelGauge progressFuelGauge; - private final ProgressRotation progressRotation; private final ProgressBar progressBar; private final ProgressWater progressWater; private final JLabel hourGlassElapsedDayIcon; @@ -502,22 +500,9 @@ public class MainWindow extends TWindow { add(progressFuelGauge); // - this.progressRotation = new ProgressRotation(); - progressRotation.setBounds(progressFuelGauge.getX() + progressFuelGauge.getWidth() + SwingUtils.MARGIN, progressFuelGauge.getY(), - 100, 100); - - progressRotation.visibleProperty - .bindTo(timeCalcConfiguration.rotationVisibleProperty); - progressRotation.typeProperty - .bindTo(timeCalcConfiguration.rotationTypeProperty); - progressRotation.hiddenProperty - .bindTo(timeCalcConfiguration.rotationHiddenProperty); - - add(progressRotation); - // this.progressBar = new ProgressBar(); progressBar.setBounds(progressSwing.getX(), progressSwing.getY() + progressSwing.getHeight() + SwingUtils.MARGIN, - progressRotation.getX() + progressRotation.getWidth() - 2 * SwingUtils.MARGIN, 25); + progressCircle.getX() + progressCircle.getWidth() - 1 * SwingUtils.MARGIN, 25); progressBar.visibleProperty .bindTo(timeCalcConfiguration.barVisibleProperty); @@ -1628,7 +1613,6 @@ public class MainWindow extends TWindow { progressMoney.setProgress(progress); progressDot.setProgress(progress); progressFuelGauge.setProgress(progress); - progressRotation.setProgress(progress); progressBar.setProgress(progress); progressWater.setProgress(progress); dayBattery.setProgress(progress); 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 6d9334f..883bf8d 100644 --- a/modules/time-calc-app/src/main/resources/timecalc-default.conf +++ b/modules/time-calc-app/src/main/resources/timecalc-default.conf @@ -58,8 +58,8 @@ square.hidden=false circle.visible=true circle.type=day circle.hidden=false -circle.inner-circle.visible=true -circle.outer-circle.only-border=false +circle.inner-circle.visible=false +circle.outer-circle.only-border=true bar.visible=true bar.type=day bar.hidden=false @@ -75,9 +75,6 @@ fuel.visible=true fuel.type=day fuel.hidden=false fuel.icon.visible=true -rotation.visible=true -rotation.type=day -rotation.hidden=false swing.visible=true swing.type=day swing.hidden=false