Added clock border

This commit is contained in:
Robert Vokac 2024-02-25 08:18:52 +00:00
parent 7f10583aaf
commit 41d71021bc
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
8 changed files with 79 additions and 41 deletions

View File

@ -33,6 +33,9 @@ public class TimeCalcConfiguration {
public final BooleanProperty clockHandsMillisecondVisibleProperty =
new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_MILLISECOND_VISIBLE
.getKey());
public final BooleanProperty clockBorderVisibleProperty =
new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_VISIBLE
.getKey());
//
public final BooleanProperty batteryWavesVisibleProperty =
new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE
@ -64,6 +67,7 @@ public class TimeCalcConfiguration {
clockHandsMinuteVisibleProperty,
clockHandsSecondVisibleProperty,
clockHandsMillisecondVisibleProperty,
clockBorderVisibleProperty,
batteryWavesVisibleProperty,
jokesVisibleProperty,
commandsVisibleProperty,

View File

@ -129,6 +129,11 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
window.openConfigWindow();
}
if (e.getKeyCode() == KeyEvent.VK_P) {
window.openHelpWindow();
}
window.repaint();
}

View File

@ -22,6 +22,7 @@ public enum TimeCalcProperty {
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"),
//
BATTERY_WAVES_VISIBLE("battery.waves.visible", "Battery : Waves"),
JOKES_VISIBLE("jokes.visible", "Jokes"),
@ -31,6 +32,8 @@ public enum TimeCalcProperty {
SQUARE_VISIBLE("square.visible", "Square");
@Getter
private final String key;
@Getter

View File

@ -45,6 +45,8 @@ public class ConfigWindow extends TWindow {
new JCheckBox("clock.hands.second.visible");
private JCheckBox clockHandsMillisecondVisibleProperty =
new JCheckBox("clock.hands.millisecond.visible");
private JCheckBox clockBorderVisibleProperty =
new JCheckBox("clock.border.visible");
private JCheckBox batteryWavesVisibleProperty =
new JCheckBox("battery.waves.visible");
@ -67,10 +69,11 @@ public class ConfigWindow extends TWindow {
propertiesList.addAll(Arrays.asList(visibilityDefaultProperty,
visibilitySupportedColoredProperty,
clockHandsLongVisibleProperty,
clockHandsMinuteVisibleProperty,
clockHandsSecondVisibleProperty,
clockHandsMillisecondVisibleProperty,
clockHandsLongVisibleProperty,
clockBorderVisibleProperty,
batteryWavesVisibleProperty,
jokesVisibleProperty,
commandsVisibleProperty,

View File

@ -253,6 +253,7 @@ public class MainWindow extends TWindow {
.bindTo(timeCalcConfiguration.clockHandsMinuteVisibleProperty);
analogClock.handsLongProperty
.bindTo(timeCalcConfiguration.clockHandsLongVisibleProperty);
analogClock.borderVisibleProperty.bindTo(timeCalcConfiguration.clockBorderVisibleProperty);
MinuteBattery minuteBattery = new MinuteBattery(progressCircle.getBounds().x,
progressCircle.getY() + SwingUtils.MARGIN + progressCircle.getHeight(),140);
@ -485,6 +486,7 @@ public class MainWindow extends TWindow {
activitiesButton.doClick();
}
public void doExit() {
timeCalcConfiguration.saveToTimeCalcProperties();
exitButton.doClick();
}
@ -493,10 +495,15 @@ public class MainWindow extends TWindow {
}
public void doRestart() {
timeCalcConfiguration.saveToTimeCalcProperties();
restartButton.doClick();
}
public void doCommand() {
commandButton.doClick();
}
public void openHelpWindow() {
helpButton.doClick();
}
}

View File

@ -1,6 +1,7 @@
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.Widget;
import org.nanoboot.utils.timecalc.utils.common.DateFormats;
@ -53,6 +54,9 @@ public class AnalogClock extends Widget {
new BooleanProperty("millisecondEnabledProperty", false);
public BooleanProperty handsLongProperty =
new BooleanProperty("handsLongProperty", true);
public final BooleanProperty borderVisibleProperty =
new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_VISIBLE
.getKey());
private TimeHM startTime;
private final TimeHM endTime;
private int startAngle;
@ -189,43 +193,64 @@ public class AnalogClock extends Widget {
hours + (hours > 0.5 ? (-1) : 1) * 0.5, 4.0f,
Color.BLACK, visibility);
}
if(borderVisibleProperty.isEnabled()) {
for (int minuteI = 0; minuteI < 60; minuteI++) {
drawBorder(g2d, minuteI, minuteI % 5 == 0 ? 2f : 1f,
Color.BLACK, visibility);
}
}
drawCentre(g2d, centerX, centerY);
}
private void drawCentre(Graphics2D g2d, int centerX, int centerY) {
Color currentColor = g2d.getColor();
private void drawCentre(Graphics2D brush, int centerX, int centerY) {
Color currentColor = brush.getColor();
Visibility visibility =
Visibility.valueOf(visibilityProperty.getValue());
g2d.setColor(visibility.isStronglyColored() || mouseOver ? Color.RED :
brush.setColor(visibility.isStronglyColored() || mouseOver ? Color.RED :
FOREGROUND_COLOR);
g2d.fillOval(centerX - 3, centerY - 3, 8, 8);
g2d.setColor(currentColor);
brush.fillOval(centerX - 3, centerY - 3, 8, 8);
brush.setColor(currentColor);
}
private void drawHand(Graphics2D g2d, int length, double value,
private void drawBorder(Graphics2D brush, int forMinute,
float stroke, Color color, Visibility visibility) {
double value = ((double)forMinute) / 60d;
int length = side / 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));
brush.setColor((visibility.isStronglyColored() || mouseOver) ? color :
FOREGROUND_COLOR);
brush.setStroke(new BasicStroke(stroke));
brush.drawLine(startX, startY, endX, endY);
}
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));
g2d.setColor((visibility.isStronglyColored() || mouseOver) ? color :
brush.setColor((visibility.isStronglyColored() || mouseOver) ? color :
FOREGROUND_COLOR);
g2d.setStroke(new BasicStroke(stroke));
g2d.drawLine(getWidth() / 2, getHeight() / 2, endX, endY);
brush.setStroke(new BasicStroke(stroke));
brush.drawLine(getWidth() / 2, getHeight() / 2, endX, endY);
}
private void drawClockFace(Graphics2D g2d, int centerX, int centerY,
private void drawClockFace(Graphics2D brush, int centerX, int centerY,
int radius, Visibility visibility) {
g2d.setStroke(new BasicStroke(2.0f));
g2d.setColor(visibility.isStronglyColored() || mouseOver ? Color.BLACK :
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);
g2d.drawOval(1, 1, centerX * 2 - 4, centerY * 2 - 4);
g2d.drawOval(2, 2, centerX * 2 - 4, centerY * 2 - 4);
brush.drawOval(1, 1, centerX * 2 - 3, centerY * 2 - 3);
brush.drawOval(2, 2, centerX * 2 - 3, centerY * 2 - 3);
// g2d.drawOval(3, 3, centerX * 2 - 6, centerY * 2 - 6);
// g2d.drawOval(4, 4, centerX * 2 - 8, centerY * 2 - 8);
@ -236,10 +261,10 @@ public class AnalogClock extends Widget {
cal.set(Calendar.MONTH, monthProperty.getValue() - 1);
cal.set(Calendar.DAY_OF_MONTH, dayProperty.getValue());
Date date = cal.getTime();
g2d.drawString(DateFormats.DATE_TIME_FORMATTER_LONG.format(date),
brush.drawString(DateFormats.DATE_TIME_FORMATTER_LONG.format(date),
((int) (side * 0.25)),
((int) (side * 0.35)));
g2d.drawString(DateFormats.DATE_TIME_FORMATTER_TIME.format(date),
brush.drawString(DateFormats.DATE_TIME_FORMATTER_TIME.format(date),
((int) (side * 0.25) + 30),
((int) (side * 0.35)) + 60);
}
@ -248,8 +273,8 @@ public class AnalogClock extends Widget {
int dx = centerX + (int) ((radius + 20) * Math.cos(angle)) - 4;
int dy = centerY + (int) ((radius + 20) * Math.sin(angle)) + 4;
g2d.setFont(new Font("sans", Font.BOLD, 16));
g2d.drawString(Integer.toString(i), dx, dy);
brush.setFont(new Font("sans", Font.BOLD, 16));
brush.drawString(Integer.toString(i), dx + (i == 12 ? -3 : 0), dy + (i == 12 ? +3 : 0));
}
}

View File

@ -5,6 +5,7 @@ clock.hands.long.visible=true
clock.hands.minute.visible=true
clock.hands.second.visible=true
clock.hands.millisecond.visible=false
clock.border.visible=true
#
battery.waves.visible=true
#
@ -12,22 +13,4 @@ jokes.visible=true
commands.visible=true
notifications.visible=true
smileys.colored=true
square.visible=true
#todo
logs.detailed=false
smileys.visible=true
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.label.finished-from-total.visible=true
widgets.clock.visible=true
circle.visible=true
walking-human.visible=true
battery.visible=true
battery.hour.visible=true
battery.day.visible=true
battery.week.visible=true
battery.month.visible=true
square.visible=true

View File

@ -15,14 +15,19 @@ smileys.colored=false
#todo
logs.detailed=false
smileys.visible=true
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.label.finished-from-total.visible=true
widgets.clock.visible=true
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
@ -33,4 +38,7 @@ 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