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 d5315f4..5fab42c 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 @@ -6,6 +6,7 @@ import org.nanoboot.utils.timecalc.utils.property.StringProperty; import javax.swing.JPanel; import javax.swing.Timer; import java.awt.Color; +import java.awt.Font; import java.awt.Graphics; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; @@ -18,6 +19,8 @@ public class Widget extends JPanel { protected static final Color FOREGROUND_COLOR = new Color(220, 220, 220); protected static final Color FOREGROUND_COLOR2 = new Color(210, 210, 210); protected static final Color BACKGROUND_COLOR = new Color(238, 238, 238); + protected static final Font BIG_FONT = new Font("sans", Font.BOLD, 24); + protected static final Font MEDIUM_FONT = new Font("sans", Font.PLAIN, 16); public StringProperty visibilityProperty = new StringProperty("widget.visibilityProperty", Visibility.STRONGLY_COLORED.name()); 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 82f7355..e9f59d0 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 @@ -4,6 +4,7 @@ import lombok.Getter; import org.nanoboot.utils.timecalc.app.TimeCalcProperties; import org.nanoboot.utils.timecalc.entity.Visibility; import org.nanoboot.utils.timecalc.swing.common.Widget; +import org.nanoboot.utils.timecalc.utils.ProgressSmiley; import org.nanoboot.utils.timecalc.utils.common.NumberFormats; import org.nanoboot.utils.timecalc.utils.common.Utils; import org.nanoboot.utils.timecalc.utils.property.BooleanProperty; @@ -28,11 +29,11 @@ public class Battery extends Widget { public static final double LOW_ENERGY = 0.15; public static final double HIGH_ENERGY = 0.75; public static final double VERY_HIGH_ENERGY = 0.9; - private static final Font bigFont = new Font("sans", Font.BOLD, 24); public static final Color LIGHT_RED = new Color( 229, 168, 168); public static final Color ULTRA_LIGHT_RED = new Color( 238, 196, 196); + public static final String CHARCHING = "⚡"; @Getter private final String name; private final double[] randomDoubles = @@ -193,11 +194,26 @@ public class Battery extends Widget { if (donePercent < 1 && donePercent > 0) { { Font currentFont = g2d.getFont(); - g2d.setFont(bigFont); + g2d.setFont(BIG_FONT); g2d.drawString( - "⚡", ((int) (totalWidth * 0.45)), + CHARCHING, ((int) (totalWidth * 0.45)), (donePercent < 0.5 ? totalHeight / 4 * 3 : totalHeight / 4 * 1) + 10 ); + if(mouseOver){ + if(!visibility.isStronglyColored()) { + g2d.setColor(Color.GRAY); + } + if(visibility.isGray()) { + g2d.setColor(Color.LIGHT_GRAY); + } + g2d.setFont(MEDIUM_FONT); + g2d.drawString( + ProgressSmiley.forProgress(donePercent).getCharacter(), + ((int) (totalWidth * 0.45)) + 15, + (donePercent < 0.5 ? totalHeight / 4 * 3 : totalHeight / 4 * 1) + 8 + ); + + } g2d.setFont(currentFont); } { diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressCircle.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressCircle.java index 41b77ab..56c3796 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressCircle.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressCircle.java @@ -2,6 +2,7 @@ package org.nanoboot.utils.timecalc.swing.progress; import org.nanoboot.utils.timecalc.entity.Visibility; import org.nanoboot.utils.timecalc.swing.common.Widget; +import org.nanoboot.utils.timecalc.utils.ProgressSmiley; import org.nanoboot.utils.timecalc.utils.common.NumberFormats; import java.awt.Color; @@ -47,6 +48,20 @@ public class ProgressCircle extends Widget { NumberFormats.FORMATTER_ZERO_DECIMAL_PLACES .format(donePercent * 100) + "%", (int) (side / 8d * 0d), (int) (side / 8d * 7.5d)); + if(mouseOver){ + if(!visibility.isStronglyColored()) { + g2d.setColor(Color.GRAY); + } + if(visibility.isGray()) { + g2d.setColor(Color.LIGHT_GRAY); + } + g2d.setFont(MEDIUM_FONT); + g2d.drawString( + ProgressSmiley.forProgress(donePercent).getCharacter(), + (int) (side / 8d * 0d) + 30, + (int) (side / 8d * 7.5d) + ); + } } } \ No newline at end of file diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressSquare.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressSquare.java index 9c52ea2..9d819b6 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressSquare.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressSquare.java @@ -2,6 +2,7 @@ package org.nanoboot.utils.timecalc.swing.progress; import org.nanoboot.utils.timecalc.entity.Visibility; import org.nanoboot.utils.timecalc.swing.common.Widget; +import org.nanoboot.utils.timecalc.utils.ProgressSmiley; import org.nanoboot.utils.timecalc.utils.common.NumberFormats; import java.awt.Color; @@ -81,6 +82,20 @@ public class ProgressSquare extends Widget { .format(donePercent * 100) + "%", (int) (side / 8d * 3d), (int) (side / 8d * (donePercent > 0.5 ? 3d : 5d))); + if(mouseOver){ + if(!visibility.isStronglyColored()) { + g2d.setColor(Color.GRAY); + } + if(visibility.isGray()) { + g2d.setColor(Color.LIGHT_GRAY); + } + g2d.setFont(MEDIUM_FONT); + g2d.drawString( + ProgressSmiley.forProgress(donePercent).getCharacter(), + (int) (side / 8d * 3d) + 65, + (int) (side / 8d * (donePercent > 0.5 ? 3d : 5d)) + ); + } } diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/ProgressSmiley.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/ProgressSmiley.java new file mode 100644 index 0000000..a52ab49 --- /dev/null +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/ProgressSmiley.java @@ -0,0 +1,64 @@ +package org.nanoboot.utils.timecalc.utils; + +import lombok.Getter; +import org.nanoboot.utils.timecalc.app.TimeCalcException; + +/** + * @author Robert + * @since 26.02.2024 + */ +public enum ProgressSmiley { + + SMILEY_1("😱", "face screaming in fear"), + SMILEY_2("😡", "pouting face"), + SMILEY_3("😠", "angry face"), + SMILEY_4("😭", "loudly crying face"), + SMILEY_5("😢", "crying face"), + SMILEY_6("😞", "disappointed face"), + SMILEY_7("😫", "tired face"), + SMILEY_8("😨", "fearful face"), + SMILEY_9("😲", "astonished face"), + SMILEY_10("😦", "frowning face with open mouth"), + SMILEY_11("😊", "smiling face with smiling eyes"), + SMILEY_12("😃", "smiling face with open mouth"), + SMILEY_13("😁", "grinning face with smiling eyes"), + SMILEY_14("😎", "smiling face with sunglasses"), + SMILEY_15("😍", "smiling face with heart-shaped eyes"), + SMILEY_16("😈", "smiling face with horns"); + + @Getter + private final String character; + @Getter + private final String description; + + ProgressSmiley(String ch, String d) { + this.character = ch; + this.description = d; + } + public int getNumber() { + return Integer.valueOf(this.name().replace("SMILEY_", "")); + } + + public static ProgressSmiley forNumber(int number) { + for (ProgressSmiley s : ProgressSmiley.values()) { + if (s.getNumber() == number) { + return s; + } + } + throw new TimeCalcException( + "There is no smiley with this number: " + number); + } + + public static ProgressSmiley forProgress(double progress) { + progress = progress * 100; + for (int i = 1; i < 16; i++) { + if (progress < 100d / 16d * ((double) i)) { + return forNumber(i); + } + } + if (progress >= 99) { + return SMILEY_16; + } + throw new IllegalStateException(); + } +} diff --git a/timecalc.conf b/timecalc.conf index 669e34a..abf135c 100644 --- a/timecalc.conf +++ b/timecalc.conf @@ -7,4 +7,14 @@ default-visibility=STRONGLY_COLORED visibility.only-grey-or-none.enabled=false jokes.enabled=true commands.enabled=true -toasts.enabled=true \ No newline at end of file +toasts.enabled=true + +#todo +smileys.enabled=true +battery.smileys.enabled=true +progress.square.smileys.enabled=true +progress.circle.smileys.enabled=true +battery.progress-circle.enabled.true +battery.charging-unicode-character.enabled=true +battery.percent-precision.count-of-decimal-points=5 +battery.label.finished-from-total.enabled=true \ No newline at end of file