This commit is contained in:
Robert Vokac 2024-03-23 08:20:01 +01:00
parent 98c01e571d
commit bde480f222
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
6 changed files with 85 additions and 2 deletions

View File

@ -132,7 +132,10 @@ public class TimeCalcConfiguration {
= new BooleanProperty(
TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW
.getKey());
public final BooleanProperty batteryQuarterIconVisibleProperty
= new BooleanProperty(
TimeCalcProperty.BATTERY_QUARTER_ICON_VISIBLE
.getKey());
public final BooleanProperty jokesVisibleProperty
= new BooleanProperty(TimeCalcProperty.JOKES_VISIBLE
.getKey());
@ -227,6 +230,7 @@ public class TimeCalcConfiguration {
batteryMonthVisibleProperty,
batteryYearVisibleProperty,
batteryBlinkingIfCriticalLowVisibleProperty,
batteryQuarterIconVisibleProperty,
jokesVisibleProperty,
commandsVisibleProperty,
notificationsVisibleProperty,

View File

@ -66,6 +66,7 @@ public enum TimeCalcProperty {
BATTERY_YEAR_VISIBLE("battery.year.visible", "Battery : Year"),
BATTERY_BLINKING_IF_CRITICAL_LOW("battery.blinking-if-critical-low",
"Battery : Blinking, if critical low"),
BATTERY_QUARTER_ICON_VISIBLE("battery.quarter-icon.visible", "Battery : Quarter icon"),
JOKES_VISIBLE("jokes.visible", "Jokes"),
COMMANDS_VISIBLE("commands.visible", "Commands"),
NOTIFICATIONS_VISIBLE("notifications.visible", "Notifications"),

View File

@ -159,6 +159,10 @@ public class Battery extends Widget {
= new BooleanProperty(
TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW
.getKey(), true);
public final BooleanProperty quarterIconVisibleProperty
= new BooleanProperty(
TimeCalcProperty.BATTERY_QUARTER_ICON_VISIBLE
.getKey(), true);
private long tmpNanoTime = 0l;
private int totalHeight = 0;
private int totalWidth;
@ -311,6 +315,11 @@ public class Battery extends Widget {
}
}
if (quarterIconVisibleProperty.isEnabled()) {
paintQuarterIcon(brush, visibility);
}
if (circleProgressVisibleProperty.isEnabled()) {
paintCircleProgress(brush, visibility);
}
@ -355,6 +364,68 @@ public class Battery extends Widget {
}
private static final Color PURPLE_STRONGLY_COLORED = new Color(153,51,255);
private static final Color PURPLE_WEAKLY_COLORED = new Color(204,153,255);
private void paintQuarterIcon(Graphics2D brush,
Visibility visibility) {
Color currentColor = brush.getColor();
//Color currentBackgroundColor = brush.getBackground();
Font currentFont = brush.getFont();
brush.setFont(BIG_FONT);
int q = donePercent < 0.25 ? 0 : (donePercent < 0.5 ? 1 :
(donePercent < 0.75 ? 2 : (donePercent < 1.0 ? 3 : 4)));
Color color;
Color backgroundColor;
switch (visibility) {
case STRONGLY_COLORED:
backgroundColor = Color.WHITE;
break;
case WEAKLY_COLORED:
backgroundColor = Color.LIGHT_GRAY;
break;
default:
backgroundColor = Color.LIGHT_GRAY;
}
switch (q) {
case 0:
color = Battery.getColourForProgress(0.05, visibility,
mouseOver);
break;
case 1:
color = Battery.getColourForProgress(0.25, visibility,
mouseOver);
break;
case 2:
color = Battery.getColourForProgress(0.85, visibility,
mouseOver);
break;
case 3:
color = Battery.getColourForProgress(0.95, visibility,
mouseOver);
break;
case 4:
color = visibility.isStronglyColored() ? PURPLE_STRONGLY_COLORED : (visibility.isWeaklyColored() ? PURPLE_WEAKLY_COLORED : Color.GRAY);
break;
default:
color = Color.LIGHT_GRAY;
}
brush.setColor(backgroundColor);
brush.fillRect( ((int) (totalWidth * 0.08)),
(donePercent < 0.5 ? totalHeight / 4 * 3
: (totalHeight / 4 * 1) + 10) + -8, 20, 20);
brush.setColor(color);
brush.drawString(
String.valueOf(q), ((int) (totalWidth * 0.13)),
(donePercent < 0.5 ? totalHeight / 4 * 3
: (totalHeight / 4 * 1) + 10) + 10
);
brush.setColor(currentColor);
//brush.setBackground(currentBackgroundColor);
brush.setFont(currentFont);
}
public void paintChargingCharacter(Graphics2D brush) {
brush.drawString(
CHARCHING, ((int) (totalWidth * 0.45)),

View File

@ -154,6 +154,9 @@ public class ConfigWindow extends TWindow {
private final JCheckBox batteryBlinkingIfCriticalLowVisibleProperty
= new JCheckBox(
TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW.getKey());
private final JCheckBox batteryQuarterIconVisibleProperty
= new JCheckBox(
TimeCalcProperty.BATTERY_QUARTER_ICON_VISIBLE.getKey());
private final JCheckBox jokesVisibleProperty
= new JCheckBox(TimeCalcProperty.JOKES_VISIBLE.getKey());
private final JCheckBox commandsVisibleProperty
@ -328,6 +331,7 @@ public class ConfigWindow extends TWindow {
batteryMonthVisibleProperty.setSelected(enable);
batteryYearVisibleProperty.setSelected(enable);
batteryBlinkingIfCriticalLowVisibleProperty.setSelected(enable);
batteryQuarterIconVisibleProperty.setSelected(enable);
//
jokesVisibleProperty.setSelected(true);
commandsVisibleProperty.setSelected(enable);
@ -377,6 +381,7 @@ public class ConfigWindow extends TWindow {
batteryMonthVisibleProperty,
batteryYearVisibleProperty,
batteryBlinkingIfCriticalLowVisibleProperty,
batteryQuarterIconVisibleProperty,
//
smileysVisibleProperty,
smileysVisibleOnlyIfMouseMovingOverProperty,

View File

@ -580,7 +580,8 @@ public class MainWindow extends TWindow {
battery.labelVisibleProperty
.bindTo(timeCalcConfiguration.batteryLabelVisibleProperty);
battery.blinkingIfCriticalLowVisibleProperty
.bindTo(timeCalcConfiguration.batteryBlinkingIfCriticalLowVisibleProperty);
.bindTo(timeCalcConfiguration.batteryQuarterIconVisibleProperty);
battery.quarterIconVisibleProperty.bindTo(timeCalcConfiguration.batteryQuarterIconVisibleProperty);
switch (battery.getName()) {
case MinuteBattery.MINUTE:
battery.visibleProperty

View File

@ -36,6 +36,7 @@ battery.week.visible=true
battery.month.visible=true
battery.year.visible=true
battery.blinking-if-critical-low=true
battery.quarter-icon.visible=true
#
jokes.visible=true
commands.visible=true