mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
Added clock border
This commit is contained in:
parent
7f10583aaf
commit
41d71021bc
@ -33,6 +33,9 @@ public class TimeCalcConfiguration {
|
|||||||
public final BooleanProperty clockHandsMillisecondVisibleProperty =
|
public final BooleanProperty clockHandsMillisecondVisibleProperty =
|
||||||
new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_MILLISECOND_VISIBLE
|
new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_MILLISECOND_VISIBLE
|
||||||
.getKey());
|
.getKey());
|
||||||
|
public final BooleanProperty clockBorderVisibleProperty =
|
||||||
|
new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_VISIBLE
|
||||||
|
.getKey());
|
||||||
//
|
//
|
||||||
public final BooleanProperty batteryWavesVisibleProperty =
|
public final BooleanProperty batteryWavesVisibleProperty =
|
||||||
new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE
|
new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE
|
||||||
@ -64,6 +67,7 @@ public class TimeCalcConfiguration {
|
|||||||
clockHandsMinuteVisibleProperty,
|
clockHandsMinuteVisibleProperty,
|
||||||
clockHandsSecondVisibleProperty,
|
clockHandsSecondVisibleProperty,
|
||||||
clockHandsMillisecondVisibleProperty,
|
clockHandsMillisecondVisibleProperty,
|
||||||
|
clockBorderVisibleProperty,
|
||||||
batteryWavesVisibleProperty,
|
batteryWavesVisibleProperty,
|
||||||
jokesVisibleProperty,
|
jokesVisibleProperty,
|
||||||
commandsVisibleProperty,
|
commandsVisibleProperty,
|
||||||
|
@ -129,6 +129,11 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
window.openConfigWindow();
|
window.openConfigWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (e.getKeyCode() == KeyEvent.VK_P) {
|
||||||
|
window.openHelpWindow();
|
||||||
|
}
|
||||||
|
|
||||||
window.repaint();
|
window.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ public enum TimeCalcProperty {
|
|||||||
CLOCK_HANDS_MINUTE_VISIBLE("clock.hands.minute.visible", "Clock : Minute hand"),
|
CLOCK_HANDS_MINUTE_VISIBLE("clock.hands.minute.visible", "Clock : Minute hand"),
|
||||||
CLOCK_HANDS_SECOND_VISIBLE("clock.hands.second.visible", "Clock : Second hand"),
|
CLOCK_HANDS_SECOND_VISIBLE("clock.hands.second.visible", "Clock : Second hand"),
|
||||||
CLOCK_HANDS_MILLISECOND_VISIBLE("clock.hands.millisecond.visible", "Clock : Millisecond 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"),
|
BATTERY_WAVES_VISIBLE("battery.waves.visible", "Battery : Waves"),
|
||||||
JOKES_VISIBLE("jokes.visible", "Jokes"),
|
JOKES_VISIBLE("jokes.visible", "Jokes"),
|
||||||
@ -31,6 +32,8 @@ public enum TimeCalcProperty {
|
|||||||
SQUARE_VISIBLE("square.visible", "Square");
|
SQUARE_VISIBLE("square.visible", "Square");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final String key;
|
private final String key;
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -45,6 +45,8 @@ public class ConfigWindow extends TWindow {
|
|||||||
new JCheckBox("clock.hands.second.visible");
|
new JCheckBox("clock.hands.second.visible");
|
||||||
private JCheckBox clockHandsMillisecondVisibleProperty =
|
private JCheckBox clockHandsMillisecondVisibleProperty =
|
||||||
new JCheckBox("clock.hands.millisecond.visible");
|
new JCheckBox("clock.hands.millisecond.visible");
|
||||||
|
private JCheckBox clockBorderVisibleProperty =
|
||||||
|
new JCheckBox("clock.border.visible");
|
||||||
private JCheckBox batteryWavesVisibleProperty =
|
private JCheckBox batteryWavesVisibleProperty =
|
||||||
new JCheckBox("battery.waves.visible");
|
new JCheckBox("battery.waves.visible");
|
||||||
|
|
||||||
@ -67,10 +69,11 @@ public class ConfigWindow extends TWindow {
|
|||||||
|
|
||||||
propertiesList.addAll(Arrays.asList(visibilityDefaultProperty,
|
propertiesList.addAll(Arrays.asList(visibilityDefaultProperty,
|
||||||
visibilitySupportedColoredProperty,
|
visibilitySupportedColoredProperty,
|
||||||
clockHandsLongVisibleProperty,
|
|
||||||
clockHandsMinuteVisibleProperty,
|
clockHandsMinuteVisibleProperty,
|
||||||
clockHandsSecondVisibleProperty,
|
clockHandsSecondVisibleProperty,
|
||||||
clockHandsMillisecondVisibleProperty,
|
clockHandsMillisecondVisibleProperty,
|
||||||
|
clockHandsLongVisibleProperty,
|
||||||
|
clockBorderVisibleProperty,
|
||||||
batteryWavesVisibleProperty,
|
batteryWavesVisibleProperty,
|
||||||
jokesVisibleProperty,
|
jokesVisibleProperty,
|
||||||
commandsVisibleProperty,
|
commandsVisibleProperty,
|
||||||
|
@ -253,6 +253,7 @@ public class MainWindow extends TWindow {
|
|||||||
.bindTo(timeCalcConfiguration.clockHandsMinuteVisibleProperty);
|
.bindTo(timeCalcConfiguration.clockHandsMinuteVisibleProperty);
|
||||||
analogClock.handsLongProperty
|
analogClock.handsLongProperty
|
||||||
.bindTo(timeCalcConfiguration.clockHandsLongVisibleProperty);
|
.bindTo(timeCalcConfiguration.clockHandsLongVisibleProperty);
|
||||||
|
analogClock.borderVisibleProperty.bindTo(timeCalcConfiguration.clockBorderVisibleProperty);
|
||||||
|
|
||||||
MinuteBattery minuteBattery = new MinuteBattery(progressCircle.getBounds().x,
|
MinuteBattery minuteBattery = new MinuteBattery(progressCircle.getBounds().x,
|
||||||
progressCircle.getY() + SwingUtils.MARGIN + progressCircle.getHeight(),140);
|
progressCircle.getY() + SwingUtils.MARGIN + progressCircle.getHeight(),140);
|
||||||
@ -485,6 +486,7 @@ public class MainWindow extends TWindow {
|
|||||||
activitiesButton.doClick();
|
activitiesButton.doClick();
|
||||||
}
|
}
|
||||||
public void doExit() {
|
public void doExit() {
|
||||||
|
timeCalcConfiguration.saveToTimeCalcProperties();
|
||||||
exitButton.doClick();
|
exitButton.doClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,10 +495,15 @@ public class MainWindow extends TWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void doRestart() {
|
public void doRestart() {
|
||||||
|
timeCalcConfiguration.saveToTimeCalcProperties();
|
||||||
restartButton.doClick();
|
restartButton.doClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doCommand() {
|
public void doCommand() {
|
||||||
commandButton.doClick();
|
commandButton.doClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void openHelpWindow() {
|
||||||
|
helpButton.doClick();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.nanoboot.utils.timecalc.swing.progress;
|
package org.nanoboot.utils.timecalc.swing.progress;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcProperties;
|
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.entity.Visibility;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.Widget;
|
import org.nanoboot.utils.timecalc.swing.common.Widget;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.DateFormats;
|
import org.nanoboot.utils.timecalc.utils.common.DateFormats;
|
||||||
@ -53,6 +54,9 @@ public class AnalogClock extends Widget {
|
|||||||
new BooleanProperty("millisecondEnabledProperty", false);
|
new BooleanProperty("millisecondEnabledProperty", false);
|
||||||
public BooleanProperty handsLongProperty =
|
public BooleanProperty handsLongProperty =
|
||||||
new BooleanProperty("handsLongProperty", true);
|
new BooleanProperty("handsLongProperty", true);
|
||||||
|
public final BooleanProperty borderVisibleProperty =
|
||||||
|
new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_VISIBLE
|
||||||
|
.getKey());
|
||||||
private TimeHM startTime;
|
private TimeHM startTime;
|
||||||
private final TimeHM endTime;
|
private final TimeHM endTime;
|
||||||
private int startAngle;
|
private int startAngle;
|
||||||
@ -189,43 +193,64 @@ public class AnalogClock extends Widget {
|
|||||||
hours + (hours > 0.5 ? (-1) : 1) * 0.5, 4.0f,
|
hours + (hours > 0.5 ? (-1) : 1) * 0.5, 4.0f,
|
||||||
Color.BLACK, visibility);
|
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);
|
drawCentre(g2d, centerX, centerY);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawCentre(Graphics2D g2d, int centerX, int centerY) {
|
private void drawCentre(Graphics2D brush, int centerX, int centerY) {
|
||||||
Color currentColor = g2d.getColor();
|
Color currentColor = brush.getColor();
|
||||||
Visibility visibility =
|
Visibility visibility =
|
||||||
Visibility.valueOf(visibilityProperty.getValue());
|
Visibility.valueOf(visibilityProperty.getValue());
|
||||||
g2d.setColor(visibility.isStronglyColored() || mouseOver ? Color.RED :
|
brush.setColor(visibility.isStronglyColored() || mouseOver ? Color.RED :
|
||||||
FOREGROUND_COLOR);
|
FOREGROUND_COLOR);
|
||||||
g2d.fillOval(centerX - 3, centerY - 3, 8, 8);
|
brush.fillOval(centerX - 3, centerY - 3, 8, 8);
|
||||||
g2d.setColor(currentColor);
|
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) {
|
float stroke, Color color, Visibility visibility) {
|
||||||
length = length - 4;
|
length = length - 4;
|
||||||
double angle = Math.PI * 2 * (value - 0.25);
|
double angle = Math.PI * 2 * (value - 0.25);
|
||||||
int endX = (int) (getWidth() / 2 + length * Math.cos(angle));
|
int endX = (int) (getWidth() / 2 + length * Math.cos(angle));
|
||||||
int endY = (int) (getHeight() / 2 + length * Math.sin(angle));
|
int endY = (int) (getHeight() / 2 + length * Math.sin(angle));
|
||||||
|
|
||||||
g2d.setColor((visibility.isStronglyColored() || mouseOver) ? color :
|
brush.setColor((visibility.isStronglyColored() || mouseOver) ? color :
|
||||||
FOREGROUND_COLOR);
|
FOREGROUND_COLOR);
|
||||||
g2d.setStroke(new BasicStroke(stroke));
|
brush.setStroke(new BasicStroke(stroke));
|
||||||
g2d.drawLine(getWidth() / 2, getHeight() / 2, endX, endY);
|
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) {
|
int radius, Visibility visibility) {
|
||||||
g2d.setStroke(new BasicStroke(2.0f));
|
brush.setStroke(new BasicStroke(2.0f));
|
||||||
g2d.setColor(visibility.isStronglyColored() || mouseOver ? Color.BLACK :
|
brush.setColor(visibility.isStronglyColored() || mouseOver ? Color.BLACK :
|
||||||
FOREGROUND_COLOR);
|
FOREGROUND_COLOR);
|
||||||
// System.out.println("centerX=" + centerX);
|
// System.out.println("centerX=" + centerX);
|
||||||
// System.out.println("centerY=" + centerY);
|
// System.out.println("centerY=" + centerY);
|
||||||
// System.out.println("radius=" + radius);
|
// System.out.println("radius=" + radius);
|
||||||
g2d.drawOval(1, 1, centerX * 2 - 4, centerY * 2 - 4);
|
brush.drawOval(1, 1, centerX * 2 - 3, centerY * 2 - 3);
|
||||||
g2d.drawOval(2, 2, centerX * 2 - 4, centerY * 2 - 4);
|
brush.drawOval(2, 2, centerX * 2 - 3, centerY * 2 - 3);
|
||||||
|
|
||||||
// g2d.drawOval(3, 3, centerX * 2 - 6, centerY * 2 - 6);
|
// g2d.drawOval(3, 3, centerX * 2 - 6, centerY * 2 - 6);
|
||||||
// g2d.drawOval(4, 4, centerX * 2 - 8, centerY * 2 - 8);
|
// 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.MONTH, monthProperty.getValue() - 1);
|
||||||
cal.set(Calendar.DAY_OF_MONTH, dayProperty.getValue());
|
cal.set(Calendar.DAY_OF_MONTH, dayProperty.getValue());
|
||||||
Date date = cal.getTime();
|
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.25)),
|
||||||
((int) (side * 0.35)));
|
((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.25) + 30),
|
||||||
((int) (side * 0.35)) + 60);
|
((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 dx = centerX + (int) ((radius + 20) * Math.cos(angle)) - 4;
|
||||||
int dy = centerY + (int) ((radius + 20) * Math.sin(angle)) + 4;
|
int dy = centerY + (int) ((radius + 20) * Math.sin(angle)) + 4;
|
||||||
|
|
||||||
g2d.setFont(new Font("sans", Font.BOLD, 16));
|
brush.setFont(new Font("sans", Font.BOLD, 16));
|
||||||
g2d.drawString(Integer.toString(i), dx, dy);
|
brush.drawString(Integer.toString(i), dx + (i == 12 ? -3 : 0), dy + (i == 12 ? +3 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ clock.hands.long.visible=true
|
|||||||
clock.hands.minute.visible=true
|
clock.hands.minute.visible=true
|
||||||
clock.hands.second.visible=true
|
clock.hands.second.visible=true
|
||||||
clock.hands.millisecond.visible=false
|
clock.hands.millisecond.visible=false
|
||||||
|
clock.border.visible=true
|
||||||
#
|
#
|
||||||
battery.waves.visible=true
|
battery.waves.visible=true
|
||||||
#
|
#
|
||||||
@ -12,22 +13,4 @@ jokes.visible=true
|
|||||||
commands.visible=true
|
commands.visible=true
|
||||||
notifications.visible=true
|
notifications.visible=true
|
||||||
smileys.colored=true
|
smileys.colored=true
|
||||||
square.visible=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
|
|
@ -15,14 +15,19 @@ smileys.colored=false
|
|||||||
|
|
||||||
#todo
|
#todo
|
||||||
logs.detailed=false
|
logs.detailed=false
|
||||||
smileys.visible=true
|
|
||||||
battery.smileys.visible=true
|
battery.smileys.visible=true
|
||||||
square.smileys.visible=true
|
square.smileys.visible=true
|
||||||
circle.smileys.visible=true
|
circle.smileys.visible=true
|
||||||
battery.charging-unicode-character.visible=true
|
battery.charging-unicode-character.visible=true
|
||||||
battery.percent-precision.count-of-decimal-points=5
|
battery.percent-precision.count-of-decimal-points=5
|
||||||
battery.label.finished-from-total.visible=true
|
battery.percent-progress.visible
|
||||||
widgets.clock.visible=true
|
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
|
square.visible=true
|
||||||
circle.visible=true
|
circle.visible=true
|
||||||
walking-human.visible=true
|
walking-human.visible=true
|
||||||
@ -33,4 +38,7 @@ battery.day.visible=true
|
|||||||
battery.week.visible=true
|
battery.week.visible=true
|
||||||
battery.month.visible=true
|
battery.month.visible=true
|
||||||
battery.year.visible=true
|
battery.year.visible=true
|
||||||
|
battery.blinking-if-critical-low=true
|
||||||
|
smileys.visible=true
|
||||||
|
smileys.visible-only-if-mouse-moving-over=true
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user