Added color smileys
57
Readme.md
@ -43,6 +43,63 @@ If file overtime.txt does not exist, then the default overtime is 0:00.
|
||||
### test.txt
|
||||
If file test.txt exists, then user is not asked for start time and overtime. Instead, the values in files starttime.txt and overtime.txt are used.
|
||||
|
||||
## Features
|
||||
|
||||
### 3 Visibility modes
|
||||
|
||||
* STRONGLY_COLORED - many colors
|
||||
* WEAKLY_COLORED - darkened colors
|
||||
* GRAY - gray colors
|
||||
* NONE - widgets are hidden
|
||||
|
||||
### Widgets
|
||||
|
||||
#### Analog Clock
|
||||
|
||||
* hour hand
|
||||
* minute hand (can be disabled in configuration)
|
||||
* second hand (can be disabled in configuration)
|
||||
* millisecond hand (can be disabled in configuration)
|
||||
* shows current year, month, day of month and day of week, if analog clock is hovered by mouse cursor and Visibility is STRONGLY_COLORED
|
||||
* shows yellow highlighted remaining time until end of today working hours, if analog clock is hovered by mouse cursor and Visibility is STRONGLY_COLORED
|
||||
* hands can be long or shorter (can be set in configuration)
|
||||
|
||||
#### Progress Square
|
||||
* Show graphically day progress
|
||||
|
||||
#### Progress Circle
|
||||
|
||||
* Show graphically day progress
|
||||
|
||||
#### Hour Battery
|
||||
|
||||
#### Day Battery
|
||||
|
||||
#### Week Battery
|
||||
|
||||
#### Month Battery
|
||||
|
||||
### Smileys
|
||||
|
||||
Progress in square, circle or batteries is represented also by smileys (only, if the widget is hovered by mouse cursor):
|
||||
|
||||
* ? ... face screaming in fear ... less than 6.25%
|
||||
* ? ... pouting face ... less than 12.5%
|
||||
* ? ... angry face ... less than 18.75%
|
||||
* ? ... loudly crying face ... less than 25%
|
||||
* ? ... crying face ... less than 31.25%
|
||||
* ? ... disappointed face ... less than 37.5%
|
||||
* ? ... tired face ... less than 43.75%
|
||||
* ? ... fearful face ... less than 50%
|
||||
* ? ... astonished face ... less than 56.25%
|
||||
* ? ... frowning face with open mouth ... less than 62.5%
|
||||
* ? ... smiling face with smiling eyes ... less than 68.75%
|
||||
* ? ... smiling face with open mouth ... less than 75%
|
||||
* ? ... grinning face with smiling eyes ... less than 81.25%
|
||||
* ? ... smiling face with sunglasses ... less than 87.5%
|
||||
* ? ... smiling face with heart-shaped eyes ... less than 93.75%
|
||||
* ? ... smiling face with horns ... more or equal to 93.75%
|
||||
|
||||
## Key shortcuts
|
||||
|
||||
## Command button
|
||||
|
@ -32,6 +32,8 @@ public class TimeCalcConfiguration {
|
||||
new BooleanProperty("commandsEnabledProperty", true);
|
||||
public final BooleanProperty toastsEnabledProperty =
|
||||
new BooleanProperty("toastsEnabledProperty", true);
|
||||
public final BooleanProperty smileysColoredProperty =
|
||||
new BooleanProperty("smileysColoredProperty", true);
|
||||
|
||||
public TimeCalcConfiguration() {
|
||||
|
||||
@ -56,6 +58,7 @@ public class TimeCalcConfiguration {
|
||||
commandsEnabledProperty
|
||||
.setValue(timeCalcProperties.areCommandsEnabled());
|
||||
toastsEnabledProperty.setValue(timeCalcProperties.areToastsEnabled());
|
||||
smileysColoredProperty.setValue(timeCalcProperties.areSmileysColored());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.nanoboot.utils.timecalc.swing.common.TimeCalcButton;
|
||||
import org.nanoboot.utils.timecalc.swing.common.TimeCalcWindow;
|
||||
import org.nanoboot.utils.timecalc.swing.common.Toaster;
|
||||
import org.nanoboot.utils.timecalc.swing.common.WeatherWindow;
|
||||
import org.nanoboot.utils.timecalc.swing.common.Widget;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.AnalogClock;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.Battery;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.DayBattery;
|
||||
@ -114,6 +115,7 @@ public class TimeCalcManager {
|
||||
.setBounds(SwingUtils.MARGIN, walkingHumanProgressAsciiArt.getY()
|
||||
+ walkingHumanProgressAsciiArt.getHeight()
|
||||
+ SwingUtils.MARGIN);
|
||||
|
||||
configButton.setBoundsFromTop(walkingHumanProgressAsciiArt);
|
||||
commandButton.setBoundsFromLeft(configButton);
|
||||
|
||||
@ -160,17 +162,17 @@ public class TimeCalcManager {
|
||||
|
||||
Time time = new Time();
|
||||
|
||||
bindToIfPropertyMissing(testProperties, "current.day", calNow, Calendar.DAY_OF_MONTH, analogClock.dayProperty, time.dayProperty);
|
||||
bindToIfPropertyMissing(testProperties, "current.month", calNow, Calendar.MONTH, analogClock.monthProperty, time.monthProperty);
|
||||
bindToIfPropertyMissing(testProperties, "current.year", calNow, Calendar.YEAR, analogClock.yearProperty, time.yearProperty);
|
||||
bindToIfPropertyMissing(testProperties, "current.hour", calNow, Calendar.HOUR, analogClock.hourProperty, time.hourProperty);
|
||||
bindToIfPropertyMissing(testProperties, "current.minute", calNow, Calendar.MINUTE, analogClock.minuteProperty, time.minuteProperty);
|
||||
bindToIfPropertyMissing(testProperties, "current.second", calNow, Calendar.SECOND, analogClock.secondProperty, time.secondProperty);
|
||||
bindToIfPropertyMissing(testProperties, "current.millisecond", calNow, Calendar.MILLISECOND, analogClock.millisecondProperty, time.millisecondProperty);
|
||||
bindToIfPropertyMissing(testProperties, "test.current.day", calNow, Calendar.DAY_OF_MONTH, analogClock.dayProperty, time.dayProperty);
|
||||
bindToIfPropertyMissing(testProperties, "test.current.month", calNow, Calendar.MONTH, analogClock.monthProperty, time.monthProperty);
|
||||
bindToIfPropertyMissing(testProperties, "test.current.year", calNow, Calendar.YEAR, analogClock.yearProperty, time.yearProperty);
|
||||
bindToIfPropertyMissing(testProperties, "test.current.hour", calNow, Calendar.HOUR, analogClock.hourProperty, time.hourProperty);
|
||||
bindToIfPropertyMissing(testProperties, "test.current.minute", calNow, Calendar.MINUTE, analogClock.minuteProperty, time.minuteProperty);
|
||||
bindToIfPropertyMissing(testProperties, "test.current.second", calNow, Calendar.SECOND, analogClock.secondProperty, time.secondProperty);
|
||||
bindToIfPropertyMissing(testProperties, "test.current.millisecond", calNow, Calendar.MILLISECOND, analogClock.millisecondProperty, time.millisecondProperty);
|
||||
|
||||
if (testProperties.containsKey("current.year") || testProperties
|
||||
.containsKey("current.month") || testProperties
|
||||
.containsKey("current.day")) {
|
||||
if (testProperties.containsKey("test.current.year") || testProperties
|
||||
.containsKey("test.current.month") || testProperties
|
||||
.containsKey("test.current.day")) {
|
||||
analogClock.dayOfWeekProperty
|
||||
.setValue(calNow.get(Calendar.DAY_OF_WEEK));
|
||||
} else {
|
||||
@ -259,6 +261,8 @@ public class TimeCalcManager {
|
||||
componentRegistry.getSet().stream().filter(c-> c instanceof Battery).forEach(c ->
|
||||
((Battery)c).wavesProperty.bindTo(timeCalcConfiguration.batteryWavesEnabledProperty));
|
||||
|
||||
componentRegistry.getSet().stream().filter(c-> c instanceof Widget).forEach(c ->
|
||||
((Widget)c).smileysColoredProperty.bindTo(timeCalcConfiguration.smileysColoredProperty));
|
||||
window.setSize(dayBattery.getX() + dayBattery.getWidth() + 3 * SwingUtils.MARGIN,
|
||||
exitButton.getY() + 3 * exitButton.getHeight() + SwingUtils.MARGIN);
|
||||
while (true) {
|
||||
|
@ -26,6 +26,8 @@ public class TimeCalcProperties {
|
||||
private static final String JOKES_ENABLED = "jokes.enabled";
|
||||
private static final String COMMANDS_ENABLED = "commands-enabled";
|
||||
private static final String TOASTS_ENABLED = "toasts.enabled";
|
||||
private static final String SMILEYS_COLORED = "smileys.colored";
|
||||
|
||||
|
||||
private static TimeCalcProperties INSTANCE;
|
||||
private final Properties properties = new Properties();
|
||||
@ -98,6 +100,10 @@ public class TimeCalcProperties {
|
||||
return getBooleanProperty(TOASTS_ENABLED, true);
|
||||
}
|
||||
|
||||
public boolean areSmileysColored() {
|
||||
return getBooleanProperty(SMILEYS_COLORED, true);
|
||||
}
|
||||
|
||||
public Visibility getDefaultVisibility() {
|
||||
if (!properties.containsKey(DEFAULT_VISIBILITY)) {
|
||||
return Visibility.STRONGLY_COLORED;
|
||||
|
@ -2,6 +2,7 @@ package org.nanoboot.utils.timecalc.swing.common;
|
||||
|
||||
import org.nanoboot.utils.timecalc.app.GetProperty;
|
||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
||||
import org.nanoboot.utils.timecalc.utils.property.Property;
|
||||
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
||||
|
||||
@ -23,10 +24,12 @@ public class Widget extends JPanel implements
|
||||
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);
|
||||
protected static final Font MEDIUM_FONT = new Font("sans", Font.BOLD, 16);
|
||||
public StringProperty visibilityProperty =
|
||||
new StringProperty("widget.visibilityProperty",
|
||||
Visibility.STRONGLY_COLORED.name());
|
||||
public final BooleanProperty smileysColoredProperty =
|
||||
new BooleanProperty("smileysColoredProperty", true);
|
||||
protected int side = 0;
|
||||
protected double donePercent = 0;
|
||||
protected boolean mouseOver = false;
|
||||
|
@ -4,11 +4,13 @@ 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.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;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
@ -44,6 +46,7 @@ public class Battery extends Widget {
|
||||
private int totalHeight = 0;
|
||||
private int totalWidth;
|
||||
private String label = null;
|
||||
private JLabel smileyIcon;
|
||||
|
||||
protected Battery(String name) {
|
||||
this.name = name;
|
||||
@ -73,22 +76,22 @@ public class Battery extends Widget {
|
||||
blinking.setValue(false);
|
||||
}
|
||||
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
Graphics2D brush = (Graphics2D) g;
|
||||
|
||||
Visibility visibility =
|
||||
Visibility.valueOf(visibilityProperty.getValue());
|
||||
g2d.setColor(
|
||||
brush.setColor(
|
||||
visibility.isStronglyColored() || mouseOver ? Color.YELLOW :
|
||||
FOREGROUND_COLOR);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
if (!visibility.isGray()) {
|
||||
g2d.fillRect(1, 1, totalWidth, totalHeight);
|
||||
brush.fillRect(1, 1, totalWidth, totalHeight);
|
||||
}
|
||||
|
||||
if (visibility.isStronglyColored() || mouseOver) {
|
||||
g2d.setColor(
|
||||
brush.setColor(
|
||||
donePercent < LOW_ENERGY ? LOW_HIGHLIGHTED :
|
||||
(donePercent < HIGH_ENERGY ?
|
||||
MEDIUM_HIGHLIGHTED :
|
||||
@ -96,16 +99,16 @@ public class Battery extends Widget {
|
||||
HIGH_HIGHLIGHTED :
|
||||
HIGHEST_HIGHLIGHTED)));
|
||||
} else {
|
||||
g2d.setColor(donePercent < LOW_ENERGY ? LOW :
|
||||
brush.setColor(donePercent < LOW_ENERGY ? LOW :
|
||||
(donePercent < HIGH_ENERGY ?
|
||||
MEDIUM :
|
||||
(donePercent < VERY_HIGH_ENERGY ? HIGH : HIGHEST)));
|
||||
}
|
||||
if (visibility.isGray()) {
|
||||
g2d.setColor(Utils.ULTRA_LIGHT_GRAY);
|
||||
brush.setColor(Utils.ULTRA_LIGHT_GRAY);
|
||||
}
|
||||
if (blinking.getValue()) {
|
||||
g2d.setColor(BACKGROUND_COLOR);
|
||||
brush.setColor(BACKGROUND_COLOR);
|
||||
}
|
||||
int doneHeight = (int) (totalHeight * donePercent);
|
||||
int intX = 1;
|
||||
@ -119,7 +122,7 @@ public class Battery extends Widget {
|
||||
waterSurfaceHeight = 0;
|
||||
}
|
||||
|
||||
g2d.fillRect(intX + 1,
|
||||
brush.fillRect(intX + 1,
|
||||
doneHeight < waterSurfaceHeight || donePercent >= 1 ?
|
||||
todoHeight : todoHeight + waterSurfaceHeight,
|
||||
totalWidth - 3,
|
||||
@ -130,7 +133,7 @@ public class Battery extends Widget {
|
||||
&& donePercent < 1) {// && todoHeight > waterSurfaceHeight) {
|
||||
//g2d.fillArc(intX, intY, width_, intHeight - waterSurfaceHeight, 30, 60);
|
||||
|
||||
g2d.fillPolygon(
|
||||
brush.fillPolygon(
|
||||
new int[] {intX,
|
||||
(int) (intX + totalWidth / pointCount * 0.5),
|
||||
intX + totalWidth / pointCount * 3,
|
||||
@ -155,13 +158,13 @@ public class Battery extends Widget {
|
||||
todoHeight + (waterSurfaceHeight * 1)},
|
||||
pointCount);
|
||||
|
||||
g2d.setColor(
|
||||
brush.setColor(
|
||||
(visibility.isGray() || !visibility.isStronglyColored())
|
||||
&& !mouseOver ? Utils.ULTRA_LIGHT_GRAY : Color.DARK_GRAY);
|
||||
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
g2d.drawPolyline(
|
||||
brush.drawPolyline(
|
||||
new int[] {intX,
|
||||
(int) (intX + totalWidth / pointCount * 0.5),
|
||||
intX + totalWidth / pointCount * 3,
|
||||
@ -185,81 +188,110 @@ public class Battery extends Widget {
|
||||
5, true)),
|
||||
todoHeight + (waterSurfaceHeight * 1)},
|
||||
pointCount);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
}
|
||||
g2d.setColor(visibility.isStronglyColored() || mouseOver ? Color.BLACK :
|
||||
brush.setColor(visibility.isStronglyColored() || mouseOver ? Color.BLACK :
|
||||
Color.LIGHT_GRAY);
|
||||
|
||||
if (donePercent < 1 && donePercent > 0) {
|
||||
{
|
||||
Font currentFont = g2d.getFont();
|
||||
g2d.setFont(BIG_FONT);
|
||||
g2d.drawString(
|
||||
Font currentFont = brush.getFont();
|
||||
brush.setFont(BIG_FONT);
|
||||
brush.drawString(
|
||||
CHARCHING, ((int) (totalWidth * 0.45)),
|
||||
(donePercent < 0.5 ? totalHeight / 4 * 3 : totalHeight / 4 * 1) + 10
|
||||
);
|
||||
if(mouseOver){
|
||||
if(mouseOver && smileysColoredProperty.isDisabled()){//no colored
|
||||
//paint smiley
|
||||
if(!visibility.isStronglyColored()) {
|
||||
g2d.setColor(Color.GRAY);
|
||||
brush.setColor(Color.GRAY);
|
||||
}
|
||||
if(visibility.isGray()) {
|
||||
g2d.setColor(Color.LIGHT_GRAY);
|
||||
brush.setColor(Color.LIGHT_GRAY);
|
||||
}
|
||||
g2d.setFont(MEDIUM_FONT);
|
||||
g2d.drawString(
|
||||
if(visibility.isStronglyColored()) {
|
||||
brush.setColor(Color.BLACK);
|
||||
}
|
||||
|
||||
Color currentColor= brush.getColor();
|
||||
brush.setColor(visibility.isStronglyColored() ? Color.WHITE : BACKGROUND_COLOR);
|
||||
brush.fillRect(
|
||||
((int) (totalWidth * 0.45)) + 15,
|
||||
(donePercent < 0.5 ? totalHeight / 4 * 3 : totalHeight / 4 * 1) + 8 - 16,
|
||||
20,
|
||||
20
|
||||
);
|
||||
brush.setColor(currentColor);
|
||||
brush.setColor(Color.BLACK);
|
||||
brush.setFont(MEDIUM_FONT);
|
||||
brush.drawString(
|
||||
ProgressSmiley.forProgress(donePercent).getCharacter(),
|
||||
((int) (totalWidth * 0.45)) + 15,
|
||||
(donePercent < 0.5 ? totalHeight / 4 * 3 : totalHeight / 4 * 1) + 8
|
||||
);
|
||||
|
||||
}
|
||||
g2d.setFont(currentFont);
|
||||
brush.setFont(currentFont);
|
||||
}
|
||||
if(mouseOver && smileysColoredProperty.isEnabled()) {//colored
|
||||
ImageIcon imageIcon = ProgressSmileyIcon.forSmiley(ProgressSmiley.forProgress(donePercent)).getIcon();
|
||||
if(this.smileyIcon != null) {
|
||||
this.remove(smileyIcon);
|
||||
}
|
||||
this.smileyIcon = new JLabel(imageIcon);
|
||||
smileyIcon.setBounds(((int) (totalWidth * 0.45)) + 15,
|
||||
(donePercent < 0.5 ? totalHeight / 4 * 3 : totalHeight / 4 * 1) - 7,15, 15);
|
||||
this.add(smileyIcon);
|
||||
} else {
|
||||
if(this.smileyIcon != null) {
|
||||
this.remove(smileyIcon);
|
||||
}
|
||||
}
|
||||
{
|
||||
Color currentColor = g2d.getColor();
|
||||
g2d.setColor(
|
||||
Color currentColor = brush.getColor();
|
||||
brush.setColor(
|
||||
visibility.isStronglyColored() || mouseOver ? HIGH_HIGHLIGHTED : (visibility.isWeaklyColored() ? HIGH : Color.lightGray));
|
||||
|
||||
|
||||
double angleDouble = donePercent * 360;
|
||||
|
||||
g2d.fillArc(((int) (totalWidth * 0.45)) + 15,
|
||||
brush.fillArc(((int) (totalWidth * 0.45)) + 15,
|
||||
totalHeight / 4 * 3 + 28,
|
||||
15, 15, 90, -(int) angleDouble);
|
||||
g2d.setColor(
|
||||
brush.setColor(
|
||||
visibility.isStronglyColored() || mouseOver ? LIGHT_RED :
|
||||
visibility.isWeaklyColored() ? ULTRA_LIGHT_RED : BACKGROUND_COLOR);
|
||||
g2d.fillArc(((int) (totalWidth * 0.45)) + 15,
|
||||
brush.fillArc(((int) (totalWidth * 0.45)) + 15,
|
||||
totalHeight / 4 * 3 + 28,
|
||||
15, 15, 90, +(int) (360 - angleDouble));
|
||||
|
||||
g2d.setColor(currentColor);
|
||||
brush.setColor(currentColor);
|
||||
}
|
||||
}
|
||||
|
||||
g2d.drawString(
|
||||
brush.drawString(
|
||||
NumberFormats.FORMATTER_THREE_DECIMAL_PLACES
|
||||
.format(donePercent * 100) + "%",
|
||||
((int) (totalWidth * 0.15)),
|
||||
donePercent > 0.5 ? totalHeight / 4 * 3 : totalHeight / 4 * 1);
|
||||
|
||||
if (label != null && !label.isEmpty()) {
|
||||
g2d.drawString(
|
||||
brush.drawString(
|
||||
label,
|
||||
((int) (totalWidth * 0.15)),
|
||||
(donePercent > 0.5 ? totalHeight / 4 * 3 :
|
||||
totalHeight / 4 * 1) + 20);
|
||||
}
|
||||
if (name != null && !name.isEmpty()) {
|
||||
g2d.drawString(
|
||||
brush.drawString(
|
||||
name,
|
||||
((int) (totalWidth * 0.10)),
|
||||
(totalHeight / 4 * 3) + 20 + 20);
|
||||
}
|
||||
g2d.setColor(visibility.isStronglyColored() || mouseOver ? Color.BLACK :
|
||||
brush.setColor(visibility.isStronglyColored() || mouseOver ? Color.BLACK :
|
||||
Color.LIGHT_GRAY);
|
||||
g2d.drawRect(1, 1, totalWidth - 2, totalHeight);
|
||||
brush.drawRect(1, 1, totalWidth - 2, totalHeight);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,11 @@ 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.ProgressSmiley;
|
||||
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
@ -13,6 +15,8 @@ import java.awt.RenderingHints;
|
||||
|
||||
public class ProgressCircle extends Widget {
|
||||
|
||||
private JLabel smileyIcon;
|
||||
|
||||
public ProgressCircle() {
|
||||
setPreferredSize(new Dimension(200, 200));
|
||||
}
|
||||
@ -24,44 +28,70 @@ public class ProgressCircle extends Widget {
|
||||
}
|
||||
Visibility visibility =
|
||||
Visibility.valueOf(visibilityProperty.getValue());
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setColor(
|
||||
Graphics2D brush = (Graphics2D) g;
|
||||
brush.setColor(
|
||||
visibility.isStronglyColored() || mouseOver ? Color.darkGray :
|
||||
FOREGROUND_COLOR);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
double angleDouble = donePercent * 360;
|
||||
double angleDouble2 = (angleDouble - (int) (angleDouble)) * 360;
|
||||
// System.out.println("remainingAngle=" + angleDouble2);
|
||||
|
||||
g2d.fillArc(0, 0, side, side, 90, -(int) angleDouble);
|
||||
brush.fillArc(0, 0, side, side, 90, -(int) angleDouble);
|
||||
int side2 = side / 2;
|
||||
g2d.setColor(visibility.isStronglyColored() || mouseOver ?
|
||||
brush.setColor(visibility.isStronglyColored() || mouseOver ?
|
||||
new Color(105, 175, 236) : FOREGROUND_COLOR2);
|
||||
g2d.fillArc(0 + (side2 / 2), 0 + (side2 / 2), side2, side2, 90,
|
||||
brush.fillArc(0 + (side2 / 2), 0 + (side2 / 2), side2, side2, 90,
|
||||
-(int) angleDouble2);
|
||||
g2d.setColor(visibility.isStronglyColored() || mouseOver ? Color.blue :
|
||||
brush.setColor(visibility.isStronglyColored() || mouseOver ? Color.blue :
|
||||
FOREGROUND_COLOR);
|
||||
|
||||
g2d.drawString(
|
||||
brush.drawString(
|
||||
NumberFormats.FORMATTER_ZERO_DECIMAL_PLACES
|
||||
.format(donePercent * 100) + "%",
|
||||
(int) (side / 8d * 0d), (int) (side / 8d * 7.5d));
|
||||
if(mouseOver){
|
||||
if(mouseOver && smileysColoredProperty.isDisabled()){//no colored
|
||||
if(!visibility.isStronglyColored()) {
|
||||
g2d.setColor(Color.GRAY);
|
||||
brush.setColor(Color.GRAY);
|
||||
}
|
||||
if(visibility.isGray()) {
|
||||
g2d.setColor(Color.LIGHT_GRAY);
|
||||
brush.setColor(Color.LIGHT_GRAY);
|
||||
}
|
||||
g2d.setFont(MEDIUM_FONT);
|
||||
g2d.drawString(
|
||||
if(visibility.isStronglyColored()) {
|
||||
brush.setColor(Color.BLACK);
|
||||
}
|
||||
Color currentColor= brush.getColor();
|
||||
brush.setColor(visibility.isStronglyColored() ? Color.WHITE : BACKGROUND_COLOR);
|
||||
brush.fillRect(
|
||||
(int) (side / 8d * 0d) + 30,
|
||||
(int) (side / 8d * 7.5d - 16d),
|
||||
20,
|
||||
20
|
||||
);
|
||||
brush.setColor(currentColor);
|
||||
brush.setFont(MEDIUM_FONT);
|
||||
brush.drawString(
|
||||
ProgressSmiley.forProgress(donePercent).getCharacter(),
|
||||
(int) (side / 8d * 0d) + 30,
|
||||
(int) (side / 8d * 7.5d)
|
||||
);
|
||||
}
|
||||
if(mouseOver && smileysColoredProperty.isEnabled()) {//colored
|
||||
ImageIcon imageIcon = ProgressSmileyIcon.forSmiley(ProgressSmiley.forProgress(donePercent)).getIcon();
|
||||
if(this.smileyIcon != null) {
|
||||
this.remove(smileyIcon);
|
||||
}
|
||||
this.smileyIcon = new JLabel(imageIcon);
|
||||
smileyIcon.setBounds((int) (side / 8d * 0d) + 30,
|
||||
(int) (side / 8d * 7.5d) - 15,15, 15);
|
||||
this.add(smileyIcon);
|
||||
} else {
|
||||
if(this.smileyIcon != null) {
|
||||
this.remove(smileyIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package org.nanoboot.utils.timecalc.swing.progress;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.nanoboot.utils.timecalc.utils.common.ProgressSmiley;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import java.awt.Image;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Robert
|
||||
* @since 27.02.2024
|
||||
*/
|
||||
public class ProgressSmileyIcon extends javax.swing.ImageIcon{
|
||||
|
||||
private static final Map<ProgressSmiley, ProgressSmileyIcon> cache = new HashMap<>();
|
||||
@Getter
|
||||
private final ProgressSmiley progressSmiley;
|
||||
@Getter
|
||||
private final ImageIcon icon;
|
||||
public static ProgressSmileyIcon forSmiley(ProgressSmiley progressSmiley) {
|
||||
if(!cache.containsKey(progressSmiley)) {
|
||||
cache.put(progressSmiley, new ProgressSmileyIcon(progressSmiley));
|
||||
}
|
||||
return cache.get(progressSmiley);
|
||||
}
|
||||
private ProgressSmileyIcon(ProgressSmiley progressSmiley) {
|
||||
this.progressSmiley = progressSmiley;
|
||||
java.net.URL smileyUrl = getClass().getResource("/smileys/" + progressSmiley.name() + ".png");
|
||||
ImageIcon tmpIcon = new javax.swing.ImageIcon(smileyUrl);
|
||||
this.icon = new ImageIcon(tmpIcon.getImage().getScaledInstance(15,15, Image.SCALE_SMOOTH));
|
||||
}
|
||||
|
||||
}
|
@ -2,9 +2,11 @@ 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.ProgressSmiley;
|
||||
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
@ -14,6 +16,7 @@ import java.awt.RenderingHints;
|
||||
public class ProgressSquare extends Widget {
|
||||
|
||||
private int square;
|
||||
private JLabel smileyIcon;
|
||||
|
||||
public ProgressSquare() {
|
||||
setPreferredSize(new Dimension(400, 400));
|
||||
@ -26,9 +29,9 @@ public class ProgressSquare extends Widget {
|
||||
this.square = side * side;
|
||||
}
|
||||
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setColor(FOREGROUND_COLOR);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
Graphics2D brush = (Graphics2D) g;
|
||||
brush.setColor(FOREGROUND_COLOR);
|
||||
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
int dotNumber = (int) (donePercent * square);
|
||||
@ -42,60 +45,86 @@ public class ProgressSquare extends Widget {
|
||||
Visibility visibility = Visibility.ofProperty(visibilityProperty);
|
||||
if (y > 1) {
|
||||
if (visibility.isStronglyColored() || mouseOver) {
|
||||
g2d.setColor(Color.GRAY);
|
||||
brush.setColor(Color.GRAY);
|
||||
}
|
||||
g2d.fillRect(side - 4, side - 4, 4, 4);
|
||||
g2d.fillRect(1, side - 4, 4, 4);
|
||||
brush.fillRect(side - 4, side - 4, 4, 4);
|
||||
brush.fillRect(1, side - 4, 4, 4);
|
||||
|
||||
g2d.setColor(FOREGROUND_COLOR);
|
||||
g2d.fillRect(1, 1, side, y - 1);
|
||||
brush.setColor(FOREGROUND_COLOR);
|
||||
brush.fillRect(1, 1, side, y - 1);
|
||||
if (x > 1) {
|
||||
if (visibility.isStronglyColored() || mouseOver) {
|
||||
g2d.setColor(Color.GRAY);
|
||||
brush.setColor(Color.GRAY);
|
||||
}
|
||||
g2d.drawRect(1, y, x - 1, 1);
|
||||
brush.drawRect(1, y, x - 1, 1);
|
||||
}
|
||||
if (visibility.isStronglyColored() || mouseOver) {
|
||||
g2d.setColor(Color.GRAY);
|
||||
brush.setColor(Color.GRAY);
|
||||
}
|
||||
g2d.fillRect(side - 4, 1, 4, 4);
|
||||
g2d.fillRect(1, 1, 4, 4);
|
||||
brush.fillRect(side - 4, 1, 4, 4);
|
||||
brush.fillRect(1, 1, 4, 4);
|
||||
|
||||
if (visibility.isStronglyColored() || mouseOver) {
|
||||
g2d.setColor(Color.GRAY);
|
||||
brush.setColor(Color.GRAY);
|
||||
}
|
||||
g2d.drawLine(1, 1, x, y);
|
||||
brush.drawLine(1, 1, x, y);
|
||||
// g2d.drawLine(1+1, 1+1, x+1, y+1);
|
||||
g2d.drawLine(1, 1 + 1, x, y + 1);
|
||||
g2d.drawLine(1, 1 + 1, x, y + 1);
|
||||
brush.drawLine(1, 1 + 1, x, y + 1);
|
||||
brush.drawLine(1, 1 + 1, x, y + 1);
|
||||
if (visibility.isStronglyColored() || mouseOver) {
|
||||
g2d.setColor(Color.BLUE);
|
||||
g2d.drawLine(x - 10, y - 10, x + 10, y + 10);
|
||||
g2d.drawLine(x + 10, y - 10, x - 10, y + 10);
|
||||
brush.setColor(Color.BLUE);
|
||||
brush.drawLine(x - 10, y - 10, x + 10, y + 10);
|
||||
brush.drawLine(x + 10, y - 10, x - 10, y + 10);
|
||||
}
|
||||
g2d.setColor(FOREGROUND_COLOR);
|
||||
brush.setColor(FOREGROUND_COLOR);
|
||||
}
|
||||
g2d.setColor(visibility.isStronglyColored() || mouseOver ? Color.BLACK :
|
||||
brush.setColor(visibility.isStronglyColored() || mouseOver ? Color.BLACK :
|
||||
BACKGROUND_COLOR);
|
||||
|
||||
g2d.drawString(NumberFormats.FORMATTER_FIVE_DECIMAL_PLACES
|
||||
brush.drawString(NumberFormats.FORMATTER_FIVE_DECIMAL_PLACES
|
||||
.format(donePercent * 100) + "%",
|
||||
(int) (side / 8d * 3d),
|
||||
(int) (side / 8d * (donePercent > 0.5 ? 3d : 5d)));
|
||||
if(mouseOver){
|
||||
if(mouseOver && smileysColoredProperty.isDisabled()){//no colored
|
||||
if(!visibility.isStronglyColored()) {
|
||||
g2d.setColor(Color.GRAY);
|
||||
brush.setColor(Color.GRAY);
|
||||
}
|
||||
if(visibility.isGray()) {
|
||||
g2d.setColor(Color.LIGHT_GRAY);
|
||||
brush.setColor(Color.LIGHT_GRAY);
|
||||
}
|
||||
g2d.setFont(MEDIUM_FONT);
|
||||
g2d.drawString(
|
||||
if(visibility.isStronglyColored()) {
|
||||
brush.setColor(Color.BLACK);
|
||||
}
|
||||
Color currentColor= brush.getColor();
|
||||
brush.setColor(visibility.isStronglyColored() ? Color.WHITE : BACKGROUND_COLOR);
|
||||
brush.fillRect(
|
||||
(int) (side / 8d * 3d) + 65,
|
||||
(int) ((side / 8d * (donePercent > 0.5 ? 3d : 5d)) - 16d),
|
||||
20,
|
||||
20
|
||||
);
|
||||
brush.setColor(currentColor);
|
||||
brush.setFont(MEDIUM_FONT);
|
||||
brush.drawString(
|
||||
ProgressSmiley.forProgress(donePercent).getCharacter(),
|
||||
(int) (side / 8d * 3d) + 65,
|
||||
(int) (side / 8d * (donePercent > 0.5 ? 3d : 5d))
|
||||
);
|
||||
}
|
||||
if(mouseOver && smileysColoredProperty.isEnabled()) {//colored
|
||||
ImageIcon imageIcon = ProgressSmileyIcon.forSmiley(ProgressSmiley.forProgress(donePercent)).getIcon();
|
||||
if(this.smileyIcon != null) {
|
||||
this.remove(smileyIcon);
|
||||
}
|
||||
this.smileyIcon = new JLabel(imageIcon);
|
||||
smileyIcon.setBounds((int) (side / 8d * 3d) + 65,
|
||||
(int) (side / 8d * (donePercent > 0.5 ? 3d : 5d)) - 15,15, 15);
|
||||
this.add(smileyIcon);
|
||||
} else {
|
||||
if(this.smileyIcon != null) {
|
||||
this.remove(smileyIcon);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
package org.nanoboot.utils.timecalc.utils;
|
||||
package org.nanoboot.utils.timecalc.utils.common;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.nanoboot.utils.timecalc.app.TimeCalcException;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Robert
|
||||
* @since 26.02.2024
|
@ -4,6 +4,8 @@ import org.nanoboot.utils.timecalc.app.Main;
|
||||
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontFormatException;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
BIN
modules/time-calc-app/src/main/resources/smileys/SMILEY_1.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
modules/time-calc-app/src/main/resources/smileys/SMILEY_10.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
modules/time-calc-app/src/main/resources/smileys/SMILEY_11.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
modules/time-calc-app/src/main/resources/smileys/SMILEY_12.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
modules/time-calc-app/src/main/resources/smileys/SMILEY_13.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
modules/time-calc-app/src/main/resources/smileys/SMILEY_14.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
modules/time-calc-app/src/main/resources/smileys/SMILEY_15.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
modules/time-calc-app/src/main/resources/smileys/SMILEY_16.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
modules/time-calc-app/src/main/resources/smileys/SMILEY_2.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
modules/time-calc-app/src/main/resources/smileys/SMILEY_3.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
modules/time-calc-app/src/main/resources/smileys/SMILEY_4.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
modules/time-calc-app/src/main/resources/smileys/SMILEY_5.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
modules/time-calc-app/src/main/resources/smileys/SMILEY_6.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
modules/time-calc-app/src/main/resources/smileys/SMILEY_7.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
modules/time-calc-app/src/main/resources/smileys/SMILEY_8.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
modules/time-calc-app/src/main/resources/smileys/SMILEY_9.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
@ -8,6 +8,7 @@ visibility.only-grey-or-none.enabled=false
|
||||
jokes.enabled=true
|
||||
commands.enabled=true
|
||||
toasts.enabled=true
|
||||
smileys.colored=false
|
||||
|
||||
#todo
|
||||
smileys.enabled=true
|
||||
@ -24,4 +25,4 @@ widgets.walking-human.enabled=true
|
||||
widgets.battery.hour.enabled=true
|
||||
widgets.battery.day.enabled=true
|
||||
widgets.battery.week.enabled=true
|
||||
widgets.battery.month.enabled=true
|
||||
widgets.battery.month.enabled=true
|
||||
|