Added improvements

This commit is contained in:
Robert Vokac 2024-03-02 11:01:34 +00:00
parent 6b0cc58ff1
commit c89d5e6022
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
8 changed files with 140 additions and 51 deletions

View File

@ -31,6 +31,8 @@ public class TimeCalcConfiguration {
public final BooleanProperty clockHandsColoredProperty public final BooleanProperty clockHandsColoredProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_COLORED = new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_COLORED
.getKey()); .getKey());
public final BooleanProperty clockHandsHourVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_HOUR_VISIBLE.getKey());
public final BooleanProperty clockHandsMinuteVisibleProperty public final BooleanProperty clockHandsMinuteVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_MINUTE_VISIBLE = new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_MINUTE_VISIBLE
.getKey()); .getKey());
@ -149,6 +151,7 @@ public class TimeCalcConfiguration {
clockVisibleProperty, clockVisibleProperty,
clockHandsLongVisibleProperty, clockHandsLongVisibleProperty,
clockHandsColoredProperty, clockHandsColoredProperty,
clockHandsHourVisibleProperty,
clockHandsMinuteVisibleProperty, clockHandsMinuteVisibleProperty,
clockHandsSecondVisibleProperty, clockHandsSecondVisibleProperty,
clockHandsMillisecondVisibleProperty, clockHandsMillisecondVisibleProperty,

View File

@ -14,9 +14,10 @@ public enum TimeCalcProperty {
VISIBILITY_DEFAULT("visibility.default", "Default Visibility"), VISIBILITY_DEFAULT("visibility.default", "Default Visibility"),
VISIBILITY_SUPPORTED_COLORED("visibility.supported.colored", "Visibility : Supported : Colored"), VISIBILITY_SUPPORTED_COLORED("visibility.supported.colored", "Visibility : Supported : Colored"),
// //
CLOCK_VISIBLE("clock.hands.long.visible", "Clock"), CLOCK_VISIBLE("clock.visible", "Clock"),
CLOCK_HANDS_LONG_VISIBLE("clock.hands.long.visible", "Clock : Hands are long"), CLOCK_HANDS_LONG_VISIBLE("clock.hands.long.visible", "Clock : Long Hands"),
CLOCK_HANDS_COLORED("clock.hands.colored", "Clock : Hands are colored"), CLOCK_HANDS_COLORED("clock.hands.colored", "Clock : Colored Hands"),
CLOCK_HANDS_HOUR_VISIBLE("clock.hands.hour.visible", "Clock : Hour hand"),
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"),

View File

@ -13,6 +13,7 @@ import javax.swing.JComponent;
import javax.swing.JLabel; import javax.swing.JLabel;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
@ -23,6 +24,12 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;
/** /**
* @author Robert Vokac * @author Robert Vokac
@ -44,10 +51,14 @@ public class ConfigWindow extends TWindow {
private JCheckBox visibilitySupportedColoredProperty private JCheckBox visibilitySupportedColoredProperty
= new JCheckBox(TimeCalcProperty.VISIBILITY_SUPPORTED_COLORED.getKey()); = new JCheckBox(TimeCalcProperty.VISIBILITY_SUPPORTED_COLORED.getKey());
private JCheckBox clockVisibleProperty
= new JCheckBox(TimeCalcProperty.CLOCK_VISIBLE.getKey());
private JCheckBox clockHandsLongVisibleProperty private JCheckBox clockHandsLongVisibleProperty
= new JCheckBox(TimeCalcProperty.CLOCK_HANDS_LONG_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.CLOCK_HANDS_LONG_VISIBLE.getKey());
private JCheckBox clockHandsColoredProperty private JCheckBox clockHandsColoredProperty
= new JCheckBox(TimeCalcProperty.CLOCK_HANDS_COLORED.getKey()); = new JCheckBox(TimeCalcProperty.CLOCK_HANDS_COLORED.getKey());
private JCheckBox clockHandsHourVisibleProperty
= new JCheckBox(TimeCalcProperty.CLOCK_HANDS_HOUR_VISIBLE.getKey());
private JCheckBox clockHandsMinuteVisibleProperty private JCheckBox clockHandsMinuteVisibleProperty
= new JCheckBox(TimeCalcProperty.CLOCK_HANDS_MINUTE_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.CLOCK_HANDS_MINUTE_VISIBLE.getKey());
private JCheckBox clockHandsSecondVisibleProperty private JCheckBox clockHandsSecondVisibleProperty
@ -120,26 +131,53 @@ public class ConfigWindow extends TWindow {
= new JCheckBox(TimeCalcProperty.CIRCLE_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.CIRCLE_VISIBLE.getKey());
private JCheckBox walkingHumanVisibleProperty private JCheckBox walkingHumanVisibleProperty
= new JCheckBox(TimeCalcProperty.WALKING_HUMAN_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.WALKING_HUMAN_VISIBLE.getKey());
private final JPanel panelInsideScrollPane;
public ConfigWindow(TimeCalcConfiguration timeCalcConfiguration) { public ConfigWindow(TimeCalcConfiguration timeCalcConfiguration) {
this.timeCalcConfiguration = timeCalcConfiguration; this.timeCalcConfiguration = timeCalcConfiguration;
setTitle("Configuration"); setTitle("Configuration");
this.setSize(800, 1000); this.setSize(800, 800);
setLayout(null);
add(enableAsMuchAsPossible); JPanel mainPanel = new JPanel();
enableAsMuchAsPossible.setBounds(SwingUtils.MARGIN, currentY, 250, mainPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, getHeight() - 6 * SwingUtils.MARGIN));
this.panelInsideScrollPane = new JPanel();
final BoxLayout boxLayout = new BoxLayout(panelInsideScrollPane, BoxLayout.Y_AXIS);
panelInsideScrollPane.setAlignmentX(LEFT_ALIGNMENT);
mainPanel.setAlignmentX(LEFT_ALIGNMENT);
panelInsideScrollPane.setLayout(boxLayout);
panelInsideScrollPane.setMinimumSize(new Dimension(Integer.MAX_VALUE, 400));
JScrollPane scrollPane = new JScrollPane(panelInsideScrollPane);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.setPreferredSize(new Dimension(getWidth() - 50, getHeight() - 100));
scrollPane.setWheelScrollingEnabled(true);
scrollPane.setBorder(null);
// mainPanel.setBackground(Color.red);
// scrollPane.setBackground(Color.green);
// panelInsideScrollPane.setBackground(Color.blue);
add(mainPanel);
//mainPanel.setLayout(null);
mainPanel.add(enableAsMuchAsPossible);
enableAsMuchAsPossible.setBounds(SwingUtils.MARGIN, SwingUtils.MARGIN, 250,
HEIGHT1); HEIGHT1);
add(disableAsMuchAsPossible);
disableAsMuchAsPossible.setBounds(enableAsMuchAsPossible.getX() + enableAsMuchAsPossible.getWidth() + SwingUtils.MARGIN, currentY, 250, mainPanel.add(disableAsMuchAsPossible);
disableAsMuchAsPossible.setBounds(enableAsMuchAsPossible.getX() + enableAsMuchAsPossible.getWidth() + SwingUtils.MARGIN, SwingUtils.MARGIN, 250,
HEIGHT1); HEIGHT1);
nextRow(); scrollPane.setBounds(enableAsMuchAsPossible.getX(), enableAsMuchAsPossible.getY() + enableAsMuchAsPossible.getHeight() + SwingUtils.MARGIN, Integer.MAX_VALUE, Integer.MAX_VALUE);
mainPanel.add(scrollPane);
for(boolean enable:new boolean[]{true, false}) { for(boolean enable:new boolean[]{true, false}) {
TButton button = enable ? enableAsMuchAsPossible : disableAsMuchAsPossible; TButton button = enable ? enableAsMuchAsPossible : disableAsMuchAsPossible;
button.addActionListener(e -> { button.addActionListener(e -> {
visibilityDefaultProperty.setSelectedItem(Visibility.STRONGLY_COLORED.name()); visibilityDefaultProperty.setSelectedItem(Visibility.STRONGLY_COLORED.name());
clockHandsMinuteVisibleProperty.setSelected(true); clockVisibleProperty.setSelected(true);
clockHandsHourVisibleProperty.setSelected(enable);
clockHandsMinuteVisibleProperty.setSelected(enable);
clockHandsSecondVisibleProperty.setSelected(enable); clockHandsSecondVisibleProperty.setSelected(enable);
clockHandsMillisecondVisibleProperty.setSelected(enable); clockHandsMillisecondVisibleProperty.setSelected(enable);
clockHandsLongVisibleProperty.setSelected(enable); clockHandsLongVisibleProperty.setSelected(enable);
@ -156,15 +194,14 @@ public class ConfigWindow extends TWindow {
clockCentreCircleVisibleProperty.setSelected(enable); clockCentreCircleVisibleProperty.setSelected(enable);
clockCentreCircleBlackProperty.setSelected(!enable); clockCentreCircleBlackProperty.setSelected(!enable);
clockProgressVisibleOnlyIfMouseMovingOverProperty.setSelected(!enable); clockProgressVisibleOnlyIfMouseMovingOverProperty.setSelected(!enable);
clockDateVisibleOnlyIfMouseMovingOverProperty.setSelected(!enable); clockDateVisibleOnlyIfMouseMovingOverProperty.setSelected(false);
batteryVisibleProperty.setSelected(true);
batteryWavesVisibleProperty.setSelected(enable); batteryWavesVisibleProperty.setSelected(enable);
batteryCircleProgressVisibleProperty.setSelected(enable); batteryCircleProgressVisibleProperty.setSelected(enable);
batteryPercentProgressProperty.setSelected(enable); batteryPercentProgressProperty.setSelected(enable);
batteryChargingCharacterVisibleProperty.setSelected(enable); batteryChargingCharacterVisibleProperty.setSelected(enable);
batteryNameVisibleProperty.setSelected(enable); batteryNameVisibleProperty.setSelected(enable);
batteryLabelVisibleProperty.setSelected(enable); batteryLabelVisibleProperty.setSelected(enable);
//
batteryVisibleProperty.setSelected(true);
batteryMinuteVisibleProperty.setSelected(enable); batteryMinuteVisibleProperty.setSelected(enable);
batteryHourVisibleProperty.setSelected(enable); batteryHourVisibleProperty.setSelected(enable);
batteryDayVisibleProperty.setSelected(true); batteryDayVisibleProperty.setSelected(true);
@ -187,6 +224,8 @@ public class ConfigWindow extends TWindow {
propertiesList.addAll(Arrays.asList(visibilityDefaultProperty, propertiesList.addAll(Arrays.asList(visibilityDefaultProperty,
visibilitySupportedColoredProperty, visibilitySupportedColoredProperty,
clockVisibleProperty,
clockHandsHourVisibleProperty,
clockHandsMinuteVisibleProperty, clockHandsMinuteVisibleProperty,
clockHandsSecondVisibleProperty, clockHandsSecondVisibleProperty,
clockHandsMillisecondVisibleProperty, clockHandsMillisecondVisibleProperty,
@ -202,14 +241,13 @@ public class ConfigWindow extends TWindow {
clockCentreCircleBlackProperty, clockCentreCircleBlackProperty,
clockProgressVisibleOnlyIfMouseMovingOverProperty, clockProgressVisibleOnlyIfMouseMovingOverProperty,
clockDateVisibleOnlyIfMouseMovingOverProperty, clockDateVisibleOnlyIfMouseMovingOverProperty,
batteryVisibleProperty,
batteryWavesVisibleProperty, batteryWavesVisibleProperty,
batteryCircleProgressVisibleProperty, batteryCircleProgressVisibleProperty,
batteryPercentProgressProperty, batteryPercentProgressProperty,
batteryChargingCharacterVisibleProperty, batteryChargingCharacterVisibleProperty,
batteryNameVisibleProperty, batteryNameVisibleProperty,
batteryLabelVisibleProperty, batteryLabelVisibleProperty,
//
batteryVisibleProperty,
batteryMinuteVisibleProperty, batteryMinuteVisibleProperty,
batteryHourVisibleProperty, batteryHourVisibleProperty,
batteryDayVisibleProperty, batteryDayVisibleProperty,
@ -218,24 +256,25 @@ public class ConfigWindow extends TWindow {
batteryYearVisibleProperty, batteryYearVisibleProperty,
batteryBlinkingIfCriticalLowVisibleProperty, batteryBlinkingIfCriticalLowVisibleProperty,
// //
jokesVisibleProperty,
commandsVisibleProperty,
notificationsVisibleProperty,
smileysVisibleProperty, smileysVisibleProperty,
smileysVisibleOnlyIfMouseMovingOverProperty, smileysVisibleOnlyIfMouseMovingOverProperty,
smileysColoredProperty, smileysColoredProperty,
jokesVisibleProperty,
commandsVisibleProperty,
notificationsVisibleProperty,
squareVisibleProperty, squareVisibleProperty,
circleVisibleProperty, circleVisibleProperty,
walkingHumanVisibleProperty)); walkingHumanVisibleProperty));
// //
propertiesList.stream().forEach(p -> { propertiesList.stream().forEach(p -> {
p.setAlignmentX(LEFT_ALIGNMENT);
if (p == visibilityDefaultProperty) { if (p == visibilityDefaultProperty) {
p.putClientProperty(CLIENT_PROPERTY_KEY, TimeCalcProperty.VISIBILITY_DEFAULT.getKey()); p.putClientProperty(CLIENT_PROPERTY_KEY, TimeCalcProperty.VISIBILITY_DEFAULT.getKey());
addToNextRow(new JLabel(TimeCalcProperty.VISIBILITY_DEFAULT.getDescription())); addToNextRow(new JLabel(TimeCalcProperty.VISIBILITY_DEFAULT.getDescription()));
} }
if (p == clockCircleBorderColorProperty) { if (p == clockCircleBorderColorProperty) {
p.putClientProperty(CLIENT_PROPERTY_KEY, TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR.getKey()); p.putClientProperty(CLIENT_PROPERTY_KEY, TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR.getKey());
addToNextRow(new JLabel(TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR.getDescription())); addToNextRow(new JLabel(TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR.getDescription().replace("Clock : ", "")));
} }
if (p instanceof JComboBox) { if (p instanceof JComboBox) {
JComboBox jComboBox = ((JComboBox) p); JComboBox jComboBox = ((JComboBox) p);
@ -271,12 +310,33 @@ public class ConfigWindow extends TWindow {
property property
.setValue(checkBox.isSelected()); .setValue(checkBox.isSelected());
}); });
String[] array = checkBox.getText().split(" : ");
String groupName = array[0];
if(groupName.equals("Clock") ||groupName.equals("Battery") ||groupName.equals("Smileys")) {
checkBox.setText(array.length > 1 ? (checkBox.getText().substring(groupName.length() + 3)) : "Visible");
if(array.length == 1) {
panelInsideScrollPane.add(new JSeparator(SwingConstants.VERTICAL));
JLabel label = new JLabel(groupName);
label.setFont(BIG_FONT);
panelInsideScrollPane.add(label);
}
}
if(
timeCalcProperty == TimeCalcProperty.VISIBILITY_DEFAULT
||
timeCalcProperty == TimeCalcProperty.JOKES_VISIBLE
) {
JLabel label = new JLabel("Misc");
label.setFont(BIG_FONT);
panelInsideScrollPane.add(label);
}
} }
if (p instanceof JColorChooser) { if (p instanceof JColorChooser) {
JColorChooser jColorChooser = ((JColorChooser) p); JColorChooser colorChooser = ((JColorChooser) p);
//jColorChooser.setMaximumSize(new Dimension(150, 25)); //jColorChooser.setMaximumSize(new Dimension(150, 25));
String timeCalcPropertyKey = (String) jColorChooser.getClientProperty( String timeCalcPropertyKey = (String) colorChooser.getClientProperty(
CLIENT_PROPERTY_KEY); CLIENT_PROPERTY_KEY);
TimeCalcProperty timeCalcProperty TimeCalcProperty timeCalcProperty
= TimeCalcProperty.forKey(timeCalcPropertyKey); = TimeCalcProperty.forKey(timeCalcPropertyKey);
@ -287,15 +347,16 @@ public class ConfigWindow extends TWindow {
int green = Integer.valueOf(currentColorAsStringArray[1]); int green = Integer.valueOf(currentColorAsStringArray[1]);
int blue = Integer.valueOf(currentColorAsStringArray[2]); int blue = Integer.valueOf(currentColorAsStringArray[2]);
Color color = new Color(red, green, blue); Color color = new Color(red, green, blue);
jColorChooser.setColor(color); colorChooser.setColor(color);
jColorChooser.addMouseListener(new MouseListener() { colorChooser.setMaximumSize(new Dimension(200, HEIGHT1));
colorChooser.addMouseListener(new MouseListener() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
Color selectedColor = jColorChooser.getSelectionModel() Color selectedColor = colorChooser.getSelectionModel()
.getSelectedColor(); .getSelectedColor();
selectedColor = JColorChooser.showDialog(null, "Choose a color", color); selectedColor = JColorChooser.showDialog(null, "Choose a color", color);
if (selectedColor != null) { if (selectedColor != null) {
jColorChooser.setColor(selectedColor); colorChooser.setColor(selectedColor);
((StringProperty) timeCalcConfiguration ((StringProperty) timeCalcConfiguration
.getProperty(timeCalcProperty)) .getProperty(timeCalcProperty))
.setValue( .setValue(
@ -380,15 +441,18 @@ public class ConfigWindow extends TWindow {
} }
}); });
} }
private static final Font BIG_FONT = new Font("sans", Font.BOLD, 24);
private static final String FIVE_SPACES = " ";
private void addToNextRow(JComponent jComponent) { private void addToNextRow(JComponent jComponent) {
add(jComponent); panelInsideScrollPane.add(jComponent);
jComponent.setBounds(SwingUtils.MARGIN, currentY, WIDTH1, jComponent.setBounds(SwingUtils.MARGIN, currentY, 200,
HEIGHT1); HEIGHT1);
panelInsideScrollPane.add(Box.createRigidArea(new Dimension(5, 10)));
nextRow(); nextRow();
} }
private void nextRow() { private void nextRow() {
currentY = (int) (currentY + 2.5d * SwingUtils.MARGIN); currentY = (int) (currentY + 3.0d * SwingUtils.MARGIN);
} }
} }

View File

@ -182,10 +182,15 @@ public class MainWindow extends TWindow {
Jokes.showRandom(); Jokes.showRandom();
} }
}); });
exitButton.addActionListener(e -> System.exit(0)); exitButton.addActionListener(e
-> {
timeCalcConfiguration.saveToTimeCalcProperties();
System.exit(0);
});
focusButton.addActionListener(e -> requestFocus(true)); focusButton.addActionListener(e -> requestFocus(true));
restartButton.addActionListener(e -> { restartButton.addActionListener(e -> {
setVisible(false); setVisible(false);
timeCalcConfiguration.saveToTimeCalcProperties();
stopBeforeEnd = true; stopBeforeEnd = true;
}); });
workDaysButton.addActionListener(e -> { workDaysButton.addActionListener(e -> {
@ -206,6 +211,8 @@ public class MainWindow extends TWindow {
this.configWindow = new ConfigWindow(timeCalcConfiguration); this.configWindow = new ConfigWindow(timeCalcConfiguration);
} }
configWindow.setVisible(true); configWindow.setVisible(true);
configWindow.setLocationRelativeTo(this);
configWindow.setLocation(100, 100);
}); });
helpButton.addActionListener(e -> { helpButton.addActionListener(e -> {
@ -253,6 +260,8 @@ public class MainWindow extends TWindow {
.bindTo(timeCalcConfiguration.clockHandsSecondVisibleProperty); .bindTo(timeCalcConfiguration.clockHandsSecondVisibleProperty);
analogClock.minuteEnabledProperty analogClock.minuteEnabledProperty
.bindTo(timeCalcConfiguration.clockHandsMinuteVisibleProperty); .bindTo(timeCalcConfiguration.clockHandsMinuteVisibleProperty);
analogClock.hourEnabledProperty
.bindTo(timeCalcConfiguration.clockHandsHourVisibleProperty);
analogClock.handsLongProperty analogClock.handsLongProperty
.bindTo(timeCalcConfiguration.clockHandsLongVisibleProperty); .bindTo(timeCalcConfiguration.clockHandsLongVisibleProperty);
analogClock.borderVisibleProperty.bindTo(timeCalcConfiguration.clockBorderVisibleProperty); analogClock.borderVisibleProperty.bindTo(timeCalcConfiguration.clockBorderVisibleProperty);
@ -266,6 +275,7 @@ public class MainWindow extends TWindow {
analogClock.centreCircleBlackProperty.bindTo(timeCalcConfiguration.clockCentreCircleBlackProperty); analogClock.centreCircleBlackProperty.bindTo(timeCalcConfiguration.clockCentreCircleBlackProperty);
analogClock.progressVisibleOnlyIfMouseMovingOverProperty.bindTo(timeCalcConfiguration.clockProgressVisibleOnlyIfMouseMovingOverProperty); analogClock.progressVisibleOnlyIfMouseMovingOverProperty.bindTo(timeCalcConfiguration.clockProgressVisibleOnlyIfMouseMovingOverProperty);
analogClock.dateVisibleOnlyIfMouseMovingOverProperty.bindTo(timeCalcConfiguration.clockDateVisibleOnlyIfMouseMovingOverProperty); analogClock.dateVisibleOnlyIfMouseMovingOverProperty.bindTo(timeCalcConfiguration.clockDateVisibleOnlyIfMouseMovingOverProperty);
analogClock.visibleProperty.bindTo(timeCalcConfiguration.clockVisibleProperty);
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);
@ -326,7 +336,12 @@ public class MainWindow extends TWindow {
ComponentRegistry<TButton> buttonRegistry = new ComponentRegistry(); ComponentRegistry<TButton> buttonRegistry = new ComponentRegistry();
componentRegistry.getSet().stream().filter(c -> c instanceof TButton).forEach(c componentRegistry.getSet().stream().filter(c -> c instanceof TButton).forEach(c
-> buttonRegistry.add((TButton) c)); -> {
buttonRegistry.add((TButton) c);
});
// commandButton.visibleProperty.bindTo(timeCalcConfiguration.commandsVisibleProperty);
// jokeButton.visibleProperty.bindTo(timeCalcConfiguration.jokesVisibleProperty);
componentRegistry.getSet().stream().filter(c componentRegistry.getSet().stream().filter(c
-> GetProperty.class.isAssignableFrom(c.getClass())).forEach(c -> GetProperty.class.isAssignableFrom(c.getClass())).forEach(c
-> { -> {
@ -366,6 +381,7 @@ public class MainWindow extends TWindow {
); );
setSize(dayBattery.getX() + dayBattery.getWidth() + 3 * SwingUtils.MARGIN, setSize(dayBattery.getX() + dayBattery.getWidth() + 3 * SwingUtils.MARGIN,
focusButton.getY() + focusButton.getHeight() + SwingUtils.MARGIN + focusButton.getHeight() + 2 * SwingUtils.MARGIN); focusButton.getY() + focusButton.getHeight() + SwingUtils.MARGIN + focusButton.getHeight() + 2 * SwingUtils.MARGIN);
while (true) { while (true) {
//System.out.println("timeCalcConfiguration.handsLongProperty=" + timeCalcConfiguration.clockHandLongProperty.isEnabled()); //System.out.println("timeCalcConfiguration.handsLongProperty=" + timeCalcConfiguration.clockHandLongProperty.isEnabled());
Visibility currentVisibility = Visibility Visibility currentVisibility = Visibility
@ -398,7 +414,9 @@ public class MainWindow extends TWindow {
break; break;
} }
componentRegistry.setVisible(c -> c instanceof Widget ? ((Widget)c).visibleProperty.isEnabled() : true, currentVisibility.isNotNone()); componentRegistry.setVisible(c -> (c instanceof Widget ? ((Widget)c).visibleProperty.isEnabled()
: true) /*|| (c instanceof TButton ? ((Widget)c).visibleProperty.isEnabled()
: true)*/, currentVisibility.isNotNone());
jokeButton.setVisible( jokeButton.setVisible(
TimeCalcProperties.getInstance().getBooleanProperty( TimeCalcProperties.getInstance().getBooleanProperty(
@ -547,7 +565,6 @@ public class MainWindow extends TWindow {
} }
public void doExit() { public void doExit() {
timeCalcConfiguration.saveToTimeCalcProperties();
exitButton.doClick(); exitButton.doClick();
} }
@ -556,7 +573,6 @@ public class MainWindow extends TWindow {
} }
public void doRestart() { public void doRestart() {
timeCalcConfiguration.saveToTimeCalcProperties();
restartButton.doClick(); restartButton.doClick();
} }

View File

@ -28,12 +28,15 @@ public class TButton extends JButton implements GetProperty {
private Color originalBackground; private Color originalBackground;
private Color originalForeground; private Color originalForeground;
public final BooleanProperty visibleProperty
= new BooleanProperty("visibleProperty", true);
public TButton(String label) { public TButton(String label) {
super(label); super(label);
new Timer(100, e -> { new Timer(100, e -> {
Visibility visibility Visibility visibility
= Visibility.valueOf(visibilityProperty.getValue()); = Visibility.valueOf(visibilityProperty.getValue());
setVisible(visibility.isNotNone()); setVisible(visibility.isNotNone() && visibleProperty.isEnabled());
if (!visibility.isStronglyColored() || visibility.isGray()) { if (!visibility.isStronglyColored() || visibility.isGray()) {
setBackground(MainWindow.BACKGROUND_COLOR); setBackground(MainWindow.BACKGROUND_COLOR);
setForeground(MainWindow.FOREGROUND_COLOR); setForeground(MainWindow.FOREGROUND_COLOR);

View File

@ -47,6 +47,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 hourEnabledProperty
= new BooleanProperty("hourEnabledProperty", true);
public BooleanProperty minuteEnabledProperty public BooleanProperty minuteEnabledProperty
= new BooleanProperty("minuteEnabledProperty", true); = new BooleanProperty("minuteEnabledProperty", true);
public BooleanProperty secondEnabledProperty public BooleanProperty secondEnabledProperty
@ -179,7 +181,7 @@ public class AnalogClock extends Widget {
} }
// //
if (millisecondEnabledProperty.isEnabled() && secondEnabledProperty.isEnabled() && minuteEnabledProperty.isEnabled()) { if (millisecondEnabledProperty.isEnabled() && secondEnabledProperty.isEnabled() && minuteEnabledProperty.isEnabled() && hourEnabledProperty.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);
@ -192,7 +194,7 @@ public class AnalogClock extends Widget {
} }
} }
if (secondEnabledProperty.isEnabled() && minuteEnabledProperty.isEnabled()) { if (secondEnabledProperty.isEnabled() && minuteEnabledProperty.isEnabled() && hourEnabledProperty.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);
@ -202,7 +204,7 @@ public class AnalogClock extends Widget {
Color.RED, visibility); Color.RED, visibility);
} }
} }
if (minuteEnabledProperty.isEnabled()) { if (minuteEnabledProperty.isEnabled() && hourEnabledProperty.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); Color.BLUE, visibility);
@ -214,15 +216,17 @@ public class AnalogClock extends Widget {
Color.BLUE, visibility); Color.BLUE, visibility);
} }
} }
double hours = hour / 12.0 + minute / 60.0 / 12 + second / 60 / 60 / 12; if (hourEnabledProperty.isEnabled()) {
drawHand(g2d, side / 2 - 40, double hours = hour / 12.0 + minute / 60.0 / 12 + second / 60 / 60 / 12;
hours, 4.0f, drawHand(g2d, side / 2 - 40,
Color.BLACK, visibility); hours, 4.0f,
if (handsLongProperty.isEnabled()) {
drawHand(g2d, (side / 2 - 40) / 4,
hours + hours > 0.5 ? hours - 0.5
: hours + (hours > 0.5 ? (-1) : 1) * 0.5, 4.0f,
Color.BLACK, visibility); Color.BLACK, visibility);
if (handsLongProperty.isEnabled()) {
drawHand(g2d, (side / 2 - 40) / 4,
hours + hours > 0.5 ? hours - 0.5
: hours + (hours > 0.5 ? (-1) : 1) * 0.5, 4.0f,
Color.BLACK, visibility);
}
} }
if (borderVisibleProperty.isEnabled()) { if (borderVisibleProperty.isEnabled()) {
for (int minuteI = 0; minuteI < 60; minuteI++) { for (int minuteI = 0; minuteI < 60; minuteI++) {

View File

@ -2,11 +2,8 @@ package org.nanoboot.utils.timecalc.swing.progress;
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.ProgressSmiley;
import org.nanoboot.utils.timecalc.utils.common.NumberFormats; import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;

View File

@ -4,6 +4,7 @@ visibility.supported.colored=true
clock.visible=true clock.visible=true
clock.hands.long.visible=true clock.hands.long.visible=true
clock.centre-circle.black=false clock.centre-circle.black=false
clock.hands.hour.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