Added new improvements
This commit is contained in:
parent
902c022dee
commit
f624f828c9
@ -11,6 +11,8 @@ import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
||||
public class TimeCalcConfiguration {
|
||||
public final BooleanProperty clockHandLongProperty =
|
||||
new BooleanProperty("clockHandLongProperty", true);
|
||||
public final BooleanProperty clockHandMinuteEnabledProperty =
|
||||
new BooleanProperty("clockHandMinuteEnabledProperty", true);
|
||||
public final BooleanProperty clockHandSecondEnabledProperty =
|
||||
new BooleanProperty("clockHandSecondEnabledProperty", true);
|
||||
public final BooleanProperty clockHandMillisecondEnabledProperty =
|
||||
@ -38,6 +40,8 @@ public class TimeCalcConfiguration {
|
||||
public void setFromTimeCalcProperties(
|
||||
TimeCalcProperties timeCalcProperties) {
|
||||
clockHandLongProperty.setValue(timeCalcProperties.areClockHandsLong());
|
||||
clockHandMinuteEnabledProperty
|
||||
.setValue(timeCalcProperties.isMinuteEnabled());
|
||||
clockHandSecondEnabledProperty
|
||||
.setValue(timeCalcProperties.isSecondEnabled());
|
||||
clockHandMillisecondEnabledProperty
|
||||
|
@ -374,6 +374,8 @@ public class TimeCalcManager {
|
||||
.bindTo(timeCalcConfiguration.clockHandMillisecondEnabledProperty);
|
||||
analogClock.secondEnabledProperty
|
||||
.bindTo(timeCalcConfiguration.clockHandSecondEnabledProperty);
|
||||
analogClock.minuteEnabledProperty
|
||||
.bindTo(timeCalcConfiguration.clockHandMinuteEnabledProperty);
|
||||
analogClock.handsLongProperty
|
||||
.bindTo(timeCalcConfiguration.clockHandLongProperty);
|
||||
|
||||
|
@ -13,6 +13,8 @@ import java.util.Properties;
|
||||
*/
|
||||
public class TimeCalcProperties {
|
||||
private static final String CLOCK_HANDS_LONG = "clock.hands.long";
|
||||
private static final String CLOCK_HANDS_MINUTE_ENABLED =
|
||||
"clock.hands.minute.enabled";
|
||||
private static final String CLOCK_HANDS_SECOND_ENABLED =
|
||||
"clock.hands.second.enabled";
|
||||
private static final String CLOCK_HANDS_MILLISECOND_ENABLED =
|
||||
@ -45,6 +47,21 @@ public class TimeCalcProperties {
|
||||
TimeCalcProperties.CLOCK_HANDS_MILLISECOND_ENABLED,
|
||||
"false");
|
||||
}
|
||||
if (!isMinuteEnabled() && isSecondEnabled()) {
|
||||
System.out.println(
|
||||
"Sorry, minutes are disabled, second must be disabled too.");
|
||||
this.properties.setProperty(
|
||||
TimeCalcProperties.CLOCK_HANDS_SECOND_ENABLED,
|
||||
"false");
|
||||
}
|
||||
|
||||
if (!isMinuteEnabled() && isMillisecondEnabled()) {
|
||||
System.out.println(
|
||||
"Sorry, minutes are disabled, millisecond must be disabled too.");
|
||||
this.properties.setProperty(
|
||||
TimeCalcProperties.CLOCK_HANDS_MILLISECOND_ENABLED,
|
||||
"false");
|
||||
}
|
||||
}
|
||||
|
||||
public static TimeCalcProperties getInstance() {
|
||||
@ -58,6 +75,9 @@ public class TimeCalcProperties {
|
||||
return getBooleanProperty(CLOCK_HANDS_LONG, true);
|
||||
}
|
||||
|
||||
public boolean isMinuteEnabled() {
|
||||
return getBooleanProperty(CLOCK_HANDS_MINUTE_ENABLED, true);
|
||||
}
|
||||
public boolean isSecondEnabled() {
|
||||
return getBooleanProperty(CLOCK_HANDS_SECOND_ENABLED, true);
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package org.nanoboot.utils.timecalc.swing.common;
|
||||
|
||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
||||
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* @author Robert Vokac
|
||||
* @since 16.02.2024
|
||||
*/
|
||||
public class ConfigWindow extends JFrame {
|
||||
public ConfigWindow() {
|
||||
this.setSize(800, 600);
|
||||
|
||||
}
|
||||
}
|
@ -44,6 +44,8 @@ public class AnalogClock extends Widget {
|
||||
new IntegerProperty("millisecondProperty");
|
||||
public IntegerProperty dayOfWeekProperty =
|
||||
new IntegerProperty("dayOfWeekProperty");
|
||||
public BooleanProperty minuteEnabledProperty =
|
||||
new BooleanProperty("minuteEnabledProperty", true);
|
||||
public BooleanProperty secondEnabledProperty =
|
||||
new BooleanProperty("secondEnabledProperty", true);
|
||||
public BooleanProperty millisecondEnabledProperty =
|
||||
@ -163,17 +165,18 @@ public class AnalogClock extends Widget {
|
||||
Color.RED, visibility);
|
||||
}
|
||||
}
|
||||
//
|
||||
double minutes = minute / 60.0 + second / 60.0 / 60.0;
|
||||
drawHand(g2d, side / 2 - 20, minutes, 2.0f,
|
||||
Color.BLUE, visibility);
|
||||
if (handsLongProperty.isEnabled()) {
|
||||
drawHand(g2d, (side / 2 - 20) / 4,
|
||||
minutes + minutes > 0.5 ? minutes - 0.5 :
|
||||
minutes + (minutes > 0.5 ? (-1) : 1) * 0.5, 2.0f,
|
||||
if (minuteEnabledProperty.isEnabled()) {
|
||||
double minutes = minute / 60.0 + second / 60.0 / 60.0;
|
||||
drawHand(g2d, side / 2 - 20, minutes, 2.0f,
|
||||
Color.BLUE, visibility);
|
||||
if (handsLongProperty.isEnabled()) {
|
||||
drawHand(g2d, (side / 2 - 20) / 4,
|
||||
minutes + minutes > 0.5 ? minutes - 0.5 :
|
||||
minutes + (minutes > 0.5 ? (-1) : 1) * 0.5,
|
||||
2.0f,
|
||||
Color.BLUE, visibility);
|
||||
}
|
||||
}
|
||||
//
|
||||
double hours = hour / 12.0 + minute / 60.0 / 12 + second / 60 / 60 / 12;
|
||||
drawHand(g2d, side / 2 - 40,
|
||||
hours, 4.0f,
|
||||
|
@ -60,11 +60,14 @@ public class Battery extends Widget {
|
||||
this.totalHeight = (int) (this.getHeight() / 10d * 7d);
|
||||
this.totalWidth = this.getWidth();
|
||||
}
|
||||
if (donePercent > 0 && donePercent < CRITICAL_LOW_ENERGY
|
||||
if (donePercent > 0 && donePercent <= CRITICAL_LOW_ENERGY
|
||||
&& (System.nanoTime() - tmpNanoTime) > (1000000000l) / 2l) {
|
||||
blinking.flip();
|
||||
tmpNanoTime = System.nanoTime();
|
||||
}
|
||||
if (donePercent > CRITICAL_LOW_ENERGY && blinking.isEnabled()) {
|
||||
blinking.disable();
|
||||
}
|
||||
if (donePercent <= 0 && blinking.getValue()) {
|
||||
blinking.setValue(false);
|
||||
}
|
||||
@ -200,7 +203,7 @@ public class Battery extends Widget {
|
||||
{
|
||||
Color currentColor = g2d.getColor();
|
||||
g2d.setColor(
|
||||
visibility.isStronglyColored() || mouseOver ? Color.darkGray : Color.lightGray);
|
||||
visibility.isStronglyColored() || mouseOver ? HIGH_HIGHLIGHTED : (visibility.isWeaklyColored() ? HIGH : Color.lightGray));
|
||||
|
||||
|
||||
double angleDouble = donePercent * 360;
|
||||
|
@ -1,4 +1,5 @@
|
||||
clock.hands.long=true
|
||||
clock.hands.minute.enabled=false
|
||||
clock.hands.second.enabled=true
|
||||
clock.hands.millisecond.enabled=false
|
||||
battery.waves.enabled=true
|
||||
|
Loading…
x
Reference in New Issue
Block a user