mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
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 class TimeCalcConfiguration {
|
||||||
public final BooleanProperty clockHandLongProperty =
|
public final BooleanProperty clockHandLongProperty =
|
||||||
new BooleanProperty("clockHandLongProperty", true);
|
new BooleanProperty("clockHandLongProperty", true);
|
||||||
|
public final BooleanProperty clockHandMinuteEnabledProperty =
|
||||||
|
new BooleanProperty("clockHandMinuteEnabledProperty", true);
|
||||||
public final BooleanProperty clockHandSecondEnabledProperty =
|
public final BooleanProperty clockHandSecondEnabledProperty =
|
||||||
new BooleanProperty("clockHandSecondEnabledProperty", true);
|
new BooleanProperty("clockHandSecondEnabledProperty", true);
|
||||||
public final BooleanProperty clockHandMillisecondEnabledProperty =
|
public final BooleanProperty clockHandMillisecondEnabledProperty =
|
||||||
@ -38,6 +40,8 @@ public class TimeCalcConfiguration {
|
|||||||
public void setFromTimeCalcProperties(
|
public void setFromTimeCalcProperties(
|
||||||
TimeCalcProperties timeCalcProperties) {
|
TimeCalcProperties timeCalcProperties) {
|
||||||
clockHandLongProperty.setValue(timeCalcProperties.areClockHandsLong());
|
clockHandLongProperty.setValue(timeCalcProperties.areClockHandsLong());
|
||||||
|
clockHandMinuteEnabledProperty
|
||||||
|
.setValue(timeCalcProperties.isMinuteEnabled());
|
||||||
clockHandSecondEnabledProperty
|
clockHandSecondEnabledProperty
|
||||||
.setValue(timeCalcProperties.isSecondEnabled());
|
.setValue(timeCalcProperties.isSecondEnabled());
|
||||||
clockHandMillisecondEnabledProperty
|
clockHandMillisecondEnabledProperty
|
||||||
|
@ -374,6 +374,8 @@ public class TimeCalcManager {
|
|||||||
.bindTo(timeCalcConfiguration.clockHandMillisecondEnabledProperty);
|
.bindTo(timeCalcConfiguration.clockHandMillisecondEnabledProperty);
|
||||||
analogClock.secondEnabledProperty
|
analogClock.secondEnabledProperty
|
||||||
.bindTo(timeCalcConfiguration.clockHandSecondEnabledProperty);
|
.bindTo(timeCalcConfiguration.clockHandSecondEnabledProperty);
|
||||||
|
analogClock.minuteEnabledProperty
|
||||||
|
.bindTo(timeCalcConfiguration.clockHandMinuteEnabledProperty);
|
||||||
analogClock.handsLongProperty
|
analogClock.handsLongProperty
|
||||||
.bindTo(timeCalcConfiguration.clockHandLongProperty);
|
.bindTo(timeCalcConfiguration.clockHandLongProperty);
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@ import java.util.Properties;
|
|||||||
*/
|
*/
|
||||||
public class TimeCalcProperties {
|
public class TimeCalcProperties {
|
||||||
private static final String CLOCK_HANDS_LONG = "clock.hands.long";
|
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 =
|
private static final String CLOCK_HANDS_SECOND_ENABLED =
|
||||||
"clock.hands.second.enabled";
|
"clock.hands.second.enabled";
|
||||||
private static final String CLOCK_HANDS_MILLISECOND_ENABLED =
|
private static final String CLOCK_HANDS_MILLISECOND_ENABLED =
|
||||||
@ -45,6 +47,21 @@ public class TimeCalcProperties {
|
|||||||
TimeCalcProperties.CLOCK_HANDS_MILLISECOND_ENABLED,
|
TimeCalcProperties.CLOCK_HANDS_MILLISECOND_ENABLED,
|
||||||
"false");
|
"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() {
|
public static TimeCalcProperties getInstance() {
|
||||||
@ -58,6 +75,9 @@ public class TimeCalcProperties {
|
|||||||
return getBooleanProperty(CLOCK_HANDS_LONG, true);
|
return getBooleanProperty(CLOCK_HANDS_LONG, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMinuteEnabled() {
|
||||||
|
return getBooleanProperty(CLOCK_HANDS_MINUTE_ENABLED, true);
|
||||||
|
}
|
||||||
public boolean isSecondEnabled() {
|
public boolean isSecondEnabled() {
|
||||||
return getBooleanProperty(CLOCK_HANDS_SECOND_ENABLED, true);
|
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");
|
new IntegerProperty("millisecondProperty");
|
||||||
public IntegerProperty dayOfWeekProperty =
|
public IntegerProperty dayOfWeekProperty =
|
||||||
new IntegerProperty("dayOfWeekProperty");
|
new IntegerProperty("dayOfWeekProperty");
|
||||||
|
public BooleanProperty minuteEnabledProperty =
|
||||||
|
new BooleanProperty("minuteEnabledProperty", true);
|
||||||
public BooleanProperty secondEnabledProperty =
|
public BooleanProperty secondEnabledProperty =
|
||||||
new BooleanProperty("secondEnabledProperty", true);
|
new BooleanProperty("secondEnabledProperty", true);
|
||||||
public BooleanProperty millisecondEnabledProperty =
|
public BooleanProperty millisecondEnabledProperty =
|
||||||
@ -163,17 +165,18 @@ public class AnalogClock extends Widget {
|
|||||||
Color.RED, visibility);
|
Color.RED, visibility);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
if (minuteEnabledProperty.isEnabled()) {
|
||||||
double minutes = minute / 60.0 + second / 60.0 / 60.0;
|
double minutes = minute / 60.0 + second / 60.0 / 60.0;
|
||||||
drawHand(g2d, side / 2 - 20, minutes, 2.0f,
|
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);
|
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;
|
double hours = hour / 12.0 + minute / 60.0 / 12 + second / 60 / 60 / 12;
|
||||||
drawHand(g2d, side / 2 - 40,
|
drawHand(g2d, side / 2 - 40,
|
||||||
hours, 4.0f,
|
hours, 4.0f,
|
||||||
|
@ -60,11 +60,14 @@ public class Battery extends Widget {
|
|||||||
this.totalHeight = (int) (this.getHeight() / 10d * 7d);
|
this.totalHeight = (int) (this.getHeight() / 10d * 7d);
|
||||||
this.totalWidth = this.getWidth();
|
this.totalWidth = this.getWidth();
|
||||||
}
|
}
|
||||||
if (donePercent > 0 && donePercent < CRITICAL_LOW_ENERGY
|
if (donePercent > 0 && donePercent <= CRITICAL_LOW_ENERGY
|
||||||
&& (System.nanoTime() - tmpNanoTime) > (1000000000l) / 2l) {
|
&& (System.nanoTime() - tmpNanoTime) > (1000000000l) / 2l) {
|
||||||
blinking.flip();
|
blinking.flip();
|
||||||
tmpNanoTime = System.nanoTime();
|
tmpNanoTime = System.nanoTime();
|
||||||
}
|
}
|
||||||
|
if (donePercent > CRITICAL_LOW_ENERGY && blinking.isEnabled()) {
|
||||||
|
blinking.disable();
|
||||||
|
}
|
||||||
if (donePercent <= 0 && blinking.getValue()) {
|
if (donePercent <= 0 && blinking.getValue()) {
|
||||||
blinking.setValue(false);
|
blinking.setValue(false);
|
||||||
}
|
}
|
||||||
@ -200,7 +203,7 @@ public class Battery extends Widget {
|
|||||||
{
|
{
|
||||||
Color currentColor = g2d.getColor();
|
Color currentColor = g2d.getColor();
|
||||||
g2d.setColor(
|
g2d.setColor(
|
||||||
visibility.isStronglyColored() || mouseOver ? Color.darkGray : Color.lightGray);
|
visibility.isStronglyColored() || mouseOver ? HIGH_HIGHLIGHTED : (visibility.isWeaklyColored() ? HIGH : Color.lightGray));
|
||||||
|
|
||||||
|
|
||||||
double angleDouble = donePercent * 360;
|
double angleDouble = donePercent * 360;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
clock.hands.long=true
|
clock.hands.long=true
|
||||||
|
clock.hands.minute.enabled=false
|
||||||
clock.hands.second.enabled=true
|
clock.hands.second.enabled=true
|
||||||
clock.hands.millisecond.enabled=false
|
clock.hands.millisecond.enabled=false
|
||||||
battery.waves.enabled=true
|
battery.waves.enabled=true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user