mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
ConfigWindow I
This commit is contained in:
parent
58f1238123
commit
ad8b49ee2d
@ -3,6 +3,7 @@ package org.nanoboot.utils.timecalc.app;
|
|||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.AboutButton;
|
import org.nanoboot.utils.timecalc.swing.common.AboutButton;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.ComponentRegistry;
|
import org.nanoboot.utils.timecalc.swing.common.ComponentRegistry;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.common.ConfigWindow;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.SwingUtils;
|
import org.nanoboot.utils.timecalc.swing.common.SwingUtils;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.TimeCalcButton;
|
import org.nanoboot.utils.timecalc.swing.common.TimeCalcButton;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.TimeCalcWindow;
|
import org.nanoboot.utils.timecalc.swing.common.TimeCalcWindow;
|
||||||
@ -46,6 +47,7 @@ import java.util.logging.Logger;
|
|||||||
public class TimeCalcManager {
|
public class TimeCalcManager {
|
||||||
public static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
public static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
||||||
public static final Color FOREGROUND_COLOR = new Color(210, 210, 210);
|
public static final Color FOREGROUND_COLOR = new Color(210, 210, 210);
|
||||||
|
private ConfigWindow configWindow = null;
|
||||||
|
|
||||||
private boolean stopBeforeEnd = false;
|
private boolean stopBeforeEnd = false;
|
||||||
private final TimeCalcConfiguration timeCalcConfiguration =
|
private final TimeCalcConfiguration timeCalcConfiguration =
|
||||||
@ -146,6 +148,12 @@ public class TimeCalcManager {
|
|||||||
stopBeforeEnd = true;
|
stopBeforeEnd = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
configButton.addActionListener(e -> {
|
||||||
|
if(configWindow == null) {
|
||||||
|
this.configWindow = new ConfigWindow(timeCalcConfiguration);
|
||||||
|
}
|
||||||
|
configWindow.setVisible(true);
|
||||||
|
});
|
||||||
Calendar calNow = Calendar.getInstance();
|
Calendar calNow = Calendar.getInstance();
|
||||||
calNow.setTime(new Date());
|
calNow.setTime(new Date());
|
||||||
|
|
||||||
@ -266,14 +274,17 @@ public class TimeCalcManager {
|
|||||||
window.setSize(dayBattery.getX() + dayBattery.getWidth() + 3 * SwingUtils.MARGIN,
|
window.setSize(dayBattery.getX() + dayBattery.getWidth() + 3 * SwingUtils.MARGIN,
|
||||||
exitButton.getY() + 3 * exitButton.getHeight() + SwingUtils.MARGIN);
|
exitButton.getY() + 3 * exitButton.getHeight() + SwingUtils.MARGIN);
|
||||||
while (true) {
|
while (true) {
|
||||||
|
//System.out.println("timeCalcConfiguration.handsLongProperty=" + timeCalcConfiguration.clockHandLongProperty.isEnabled());
|
||||||
Visibility currentVisibility = Visibility
|
Visibility currentVisibility = Visibility
|
||||||
.valueOf(timeCalcApp.visibilityProperty.getValue());
|
.valueOf(timeCalcApp.visibilityProperty.getValue());
|
||||||
if(timeCalcConfiguration.visibilityOnlyGreyOrNoneEnabledProperty.isEnabled() && currentVisibility.isColored() ){
|
if(timeCalcConfiguration.visibilityOnlyGreyOrNoneEnabledProperty.isEnabled() && currentVisibility.isColored() ){
|
||||||
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
|
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
|
||||||
}
|
}
|
||||||
if (stopBeforeEnd) {
|
if (stopBeforeEnd) {
|
||||||
|
if(configWindow != null) {configWindow.setVisible(false);configWindow.dispose();}
|
||||||
window.setVisible(false);
|
window.setVisible(false);
|
||||||
window.dispose();
|
window.dispose();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,6 +391,7 @@ public class TimeCalcManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(configWindow != null) {configWindow.setVisible(false);configWindow.dispose();}
|
||||||
window.setVisible(false);
|
window.setVisible(false);
|
||||||
window.dispose();
|
window.dispose();
|
||||||
}
|
}
|
||||||
|
@ -42,28 +42,7 @@ public class TimeCalcProperties {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println(e);
|
System.err.println(e);
|
||||||
}
|
}
|
||||||
if (!isSecondEnabled() && isMillisecondEnabled()) {
|
|
||||||
System.out.println(
|
|
||||||
"Sorry, seconds are disabled, millisecond must be disabled too.");
|
|
||||||
this.properties.setProperty(
|
|
||||||
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() {
|
public static TimeCalcProperties getInstance() {
|
||||||
|
@ -1,32 +1,71 @@
|
|||||||
package org.nanoboot.utils.timecalc.swing.common;
|
package org.nanoboot.utils.timecalc.swing.common;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
import org.nanoboot.utils.timecalc.app.TimeCalcConfiguration;
|
||||||
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
|
|
||||||
import javax.swing.JEditorPane;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JLabel;
|
||||||
import javax.xml.transform.OutputKeys;
|
import javax.swing.JTextField;
|
||||||
import javax.xml.transform.Source;
|
import java.awt.FlowLayout;
|
||||||
import javax.xml.transform.Transformer;
|
import java.awt.LayoutManager;
|
||||||
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
|
* @author Robert Vokac
|
||||||
* @since 16.02.2024
|
* @since 16.02.2024
|
||||||
*/
|
*/
|
||||||
public class ConfigWindow extends JFrame {
|
public class ConfigWindow extends JFrame {
|
||||||
public ConfigWindow() {
|
private final TimeCalcConfiguration timeCalcConfiguration;
|
||||||
this.setSize(800, 600);
|
private JCheckBox clockHandLongProperty = new JCheckBox("Visibility : Clock : Hands are long", true);
|
||||||
|
private JCheckBox clockHandMinuteEnabledProperty = new JCheckBox("Visibility : Clock : Minute hand", true);
|
||||||
|
private JCheckBox clockHandSecondEnabledProperty = new JCheckBox("Visibility : Clock : Second hand", true);
|
||||||
|
private JCheckBox clockHandMillisecondEnabledProperty = new JCheckBox("Visibility : Clock : Millisecond hand", false);
|
||||||
|
private JCheckBox batteryWavesEnabledProperty = new JCheckBox("Visibility : Battery : Waves", true);
|
||||||
|
public final JTextField defaultVisibilityProperty = new JTextField(Visibility.STRONGLY_COLORED.name());
|
||||||
|
|
||||||
}
|
private JCheckBox visibilityOnlyGreyOrNoneEnabledProperty = new JCheckBox("Visibility : Only GREY or NONE",
|
||||||
|
false);
|
||||||
|
private JCheckBox jokesEnabledProperty = new JCheckBox("Visibility : Jokes", true);
|
||||||
|
private JCheckBox commandsEnabledProperty = new JCheckBox("Visibility : Commands", true);
|
||||||
|
private JCheckBox toastsEnabledProperty = new JCheckBox("Visibility : Toasts", true);
|
||||||
|
private JCheckBox smileysColoredProperty = new JCheckBox("Visibility : Smileys", true);
|
||||||
|
|
||||||
|
|
||||||
|
public ConfigWindow(TimeCalcConfiguration timeCalcConfiguration) {
|
||||||
|
this.timeCalcConfiguration = timeCalcConfiguration;
|
||||||
|
setTitle("Configuration");
|
||||||
|
this.setSize(800, 600);
|
||||||
|
LayoutManager flowLayout = new FlowLayout(FlowLayout.LEFT);
|
||||||
|
setLayout(flowLayout);
|
||||||
|
|
||||||
|
add(clockHandLongProperty);
|
||||||
|
add(clockHandMinuteEnabledProperty);
|
||||||
|
add(clockHandSecondEnabledProperty);
|
||||||
|
add(clockHandMillisecondEnabledProperty);
|
||||||
|
add(batteryWavesEnabledProperty);
|
||||||
|
add(new JLabel("Visibility : Default"));
|
||||||
|
add(defaultVisibilityProperty);
|
||||||
|
|
||||||
|
clockHandLongProperty.addActionListener(e -> {
|
||||||
|
timeCalcConfiguration.clockHandLongProperty.setValue(clockHandLongProperty.isSelected());
|
||||||
|
});
|
||||||
|
clockHandMinuteEnabledProperty.addActionListener(e -> {
|
||||||
|
timeCalcConfiguration.clockHandMinuteEnabledProperty.setValue(clockHandMinuteEnabledProperty.isSelected());
|
||||||
|
});
|
||||||
|
clockHandSecondEnabledProperty.addActionListener(e -> {
|
||||||
|
timeCalcConfiguration.clockHandSecondEnabledProperty.setValue(clockHandSecondEnabledProperty.isSelected());
|
||||||
|
});
|
||||||
|
clockHandMillisecondEnabledProperty.addActionListener(e -> {
|
||||||
|
timeCalcConfiguration.clockHandMillisecondEnabledProperty.setValue(clockHandMillisecondEnabledProperty.isSelected());
|
||||||
|
});
|
||||||
|
batteryWavesEnabledProperty.addActionListener(e -> {
|
||||||
|
timeCalcConfiguration.batteryWavesEnabledProperty.setValue(batteryWavesEnabledProperty.isSelected());
|
||||||
|
});
|
||||||
|
|
||||||
|
defaultVisibilityProperty.addActionListener(e -> {
|
||||||
|
timeCalcConfiguration.defaultVisibilityProperty.setValue(defaultVisibilityProperty.getText());
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
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.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;
|
||||||
@ -107,6 +108,7 @@ public class AnalogClock extends Widget {
|
|||||||
@Override
|
@Override
|
||||||
public void paintWidget(Graphics g) {
|
public void paintWidget(Graphics g) {
|
||||||
|
|
||||||
|
//System.out.println("clock.handsLongProperty=" + handsLongProperty.isEnabled());
|
||||||
Visibility visibility =
|
Visibility visibility =
|
||||||
Visibility.valueOf(visibilityProperty.getValue());
|
Visibility.valueOf(visibilityProperty.getValue());
|
||||||
Graphics2D g2d = (Graphics2D) g;
|
Graphics2D g2d = (Graphics2D) g;
|
||||||
@ -142,7 +144,7 @@ public class AnalogClock extends Widget {
|
|||||||
drawClockFace(g2d, centerX, centerY, side / 2 - 40, visibility);
|
drawClockFace(g2d, centerX, centerY, side / 2 - 40, visibility);
|
||||||
|
|
||||||
//
|
//
|
||||||
if (millisecondEnabledProperty.isEnabled()) {
|
if (millisecondEnabledProperty.isEnabled() && secondEnabledProperty.isEnabled() && minuteEnabledProperty.isEnabled()) {
|
||||||
drawHand(g2d, side / 2 - 10, millisecond / 1000.0, 1.0f,
|
drawHand(g2d, side / 2 - 10, millisecond / 1000.0, 1.0f,
|
||||||
COLOR_FOR_MILLISECOND_HAND_STRONGLY_COLORED, visibility);
|
COLOR_FOR_MILLISECOND_HAND_STRONGLY_COLORED, visibility);
|
||||||
|
|
||||||
@ -155,7 +157,7 @@ public class AnalogClock extends Widget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (secondEnabledProperty.isEnabled()) {
|
if (secondEnabledProperty.isEnabled() && minuteEnabledProperty.isEnabled()) {
|
||||||
drawHand(g2d, side / 2 - 10, second / 60.0, 0.5f, Color.RED,
|
drawHand(g2d, side / 2 - 10, second / 60.0, 0.5f, Color.RED,
|
||||||
visibility);
|
visibility);
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ clock.hands.second.enabled=true
|
|||||||
clock.hands.millisecond.enabled=false
|
clock.hands.millisecond.enabled=false
|
||||||
battery.waves.enabled=true
|
battery.waves.enabled=true
|
||||||
default-visibility=STRONGLY_COLORED
|
default-visibility=STRONGLY_COLORED
|
||||||
visibility.only-grey-or-none.enabled=false
|
visibility.only-grey-or-none.enabled=true
|
||||||
jokes.enabled=true
|
jokes.enabled=true
|
||||||
commands.enabled=true
|
commands.enabled=true
|
||||||
toasts.enabled=true
|
toasts.enabled=true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user