Added improvements

This commit is contained in:
Robert Vokac 2024-03-02 10:32:21 +00:00
parent c244abe78b
commit bed5c39a1a
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
7 changed files with 46 additions and 13 deletions

View File

@ -106,6 +106,10 @@ public class TimeCalcConfiguration {
public final BooleanProperty squareVisibleProperty public final BooleanProperty squareVisibleProperty
= new BooleanProperty(TimeCalcProperty.SQUARE_VISIBLE.getKey()); = new BooleanProperty(TimeCalcProperty.SQUARE_VISIBLE.getKey());
public final BooleanProperty circleVisibleProperty
= new BooleanProperty(TimeCalcProperty.CIRCLE_VISIBLE.getKey());
public final BooleanProperty walkingHumanVisibleProperty
= new BooleanProperty(TimeCalcProperty.WALKING_HUMAN_VISIBLE.getKey());
private final Map<TimeCalcProperty, Property> mapOfProperties = new HashMap<>(); private final Map<TimeCalcProperty, Property> mapOfProperties = new HashMap<>();
private List<Property> allProperties = new ArrayList<>(); private List<Property> allProperties = new ArrayList<>();
@ -142,7 +146,9 @@ public class TimeCalcConfiguration {
smileysVisibleProperty, smileysVisibleProperty,
smileysVisibleOnlyIfMouseMovingOverProperty, smileysVisibleOnlyIfMouseMovingOverProperty,
smileysColoredProperty, smileysColoredProperty,
squareVisibleProperty,}) { squareVisibleProperty,
circleVisibleProperty,
walkingHumanVisibleProperty,}) {
allProperties.add(p); allProperties.add(p);
} }
allProperties.stream().forEach(p -> mapOfProperties.put(TimeCalcProperty.forKey(p.getName()), p)); allProperties.stream().forEach(p -> mapOfProperties.put(TimeCalcProperty.forKey(p.getName()), p));

View File

@ -47,8 +47,10 @@ public enum TimeCalcProperty {
SMILEYS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER("smileys.visible-only-if-mouse-moving-over", "Smileys : Visible only, if mouse moving over"), SMILEYS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER("smileys.visible-only-if-mouse-moving-over", "Smileys : Visible only, if mouse moving over"),
SMILEYS_COLORED("smileys.colored", "Smileys : Colored"), SMILEYS_COLORED("smileys.colored", "Smileys : Colored"),
SQUARE_VISIBLE("square.visible", "Square"); SQUARE_VISIBLE("square.visible", "Square"),
CIRCLE_VISIBLE("circle.visible", "Circle"),
WALKING_HUMAN_VISIBLE("walking-human.visible", "Walking Human");
@Getter @Getter
private final String key; private final String key;

View File

@ -5,6 +5,7 @@ import lombok.Getter;
import java.awt.Component; import java.awt.Component;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.function.Predicate;
/** /**
* @author Robert Vokac * @author Robert Vokac
@ -28,9 +29,17 @@ public class ComponentRegistry<T extends Component> {
add(c); add(c);
} }
} }
public void setVisible(boolean b) { public void setVisible(boolean b) {
setVisible(null, b);
}
public void setVisible(Predicate<Component> predicate, boolean b) {
for (T c : set) { for (T c : set) {
if(predicate != null) {
if(!predicate.test(c)) {
continue;
}
}
c.setVisible(b); c.setVisible(b);
} }
} }

View File

@ -105,9 +105,12 @@ public class ConfigWindow extends TWindow {
private JCheckBox smileysColoredProperty private JCheckBox smileysColoredProperty
= new JCheckBox(TimeCalcProperty.SMILEYS_COLORED.getKey()); = new JCheckBox(TimeCalcProperty.SMILEYS_COLORED.getKey());
private JCheckBox squareVisibleProperty private JCheckBox squareVisibleProperty
= new JCheckBox(TimeCalcProperty.SQUARE_VISIBLE.getKey()); = new JCheckBox(TimeCalcProperty.SQUARE_VISIBLE.getKey());
private JCheckBox circleVisibleProperty
= new JCheckBox(TimeCalcProperty.CIRCLE_VISIBLE.getKey());
private JCheckBox walkingHumanVisibleProperty
= new JCheckBox(TimeCalcProperty.WALKING_HUMAN_VISIBLE.getKey());
public ConfigWindow(TimeCalcConfiguration timeCalcConfiguration) { public ConfigWindow(TimeCalcConfiguration timeCalcConfiguration) {
this.timeCalcConfiguration = timeCalcConfiguration; this.timeCalcConfiguration = timeCalcConfiguration;
@ -157,7 +160,9 @@ public class ConfigWindow extends TWindow {
smileysVisibleProperty.setSelected(enable); smileysVisibleProperty.setSelected(enable);
smileysColoredProperty.setSelected(enable); smileysColoredProperty.setSelected(enable);
smileysVisibleOnlyIfMouseMovingOverProperty.setSelected(!enable); smileysVisibleOnlyIfMouseMovingOverProperty.setSelected(!enable);
squareVisibleProperty.setSelected(true); squareVisibleProperty.setSelected(enable);
circleVisibleProperty.setSelected(enable);
walkingHumanVisibleProperty.setSelected(enable);
}); });
} }
@ -190,7 +195,9 @@ public class ConfigWindow extends TWindow {
smileysVisibleProperty, smileysVisibleProperty,
smileysVisibleOnlyIfMouseMovingOverProperty, smileysVisibleOnlyIfMouseMovingOverProperty,
smileysColoredProperty, smileysColoredProperty,
squareVisibleProperty)); squareVisibleProperty,
circleVisibleProperty,
walkingHumanVisibleProperty));
// //
propertiesList.stream().forEach(p -> { propertiesList.stream().forEach(p -> {
if (p == visibilityDefaultProperty) { if (p == visibilityDefaultProperty) {

View File

@ -38,6 +38,7 @@ import java.time.LocalDate;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.Properties; import java.util.Properties;
import java.util.function.Predicate;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -139,10 +140,13 @@ public class MainWindow extends TWindow {
.setBounds( .setBounds(
progressSquare.getX() + progressSquare.getWidth() + SwingUtils.MARGIN, progressSquare.getY(), 80); progressSquare.getX() + progressSquare.getWidth() + SwingUtils.MARGIN, progressSquare.getY(), 80);
add(progressCircle); add(progressCircle);
progressCircle.visibleProperty.bindTo(timeCalcConfiguration.squareVisibleProperty);
WalkingHumanProgressAsciiArt walkingHumanProgressAsciiArt WalkingHumanProgressAsciiArt walkingHumanProgressAsciiArt
= new WalkingHumanProgressAsciiArt(analogClock.getX(), analogClock.getY() + analogClock.getHeight() + SwingUtils.MARGIN, 420, 180); = new WalkingHumanProgressAsciiArt(analogClock.getX(), analogClock.getY() + analogClock.getHeight() + SwingUtils.MARGIN, 420, 180);
add(walkingHumanProgressAsciiArt); add(walkingHumanProgressAsciiArt);
walkingHumanProgressAsciiArt.visibleProperty.bindTo(timeCalcConfiguration.squareVisibleProperty);
weatherButton weatherButton
.setBounds(SwingUtils.MARGIN, walkingHumanProgressAsciiArt.getY() .setBounds(SwingUtils.MARGIN, walkingHumanProgressAsciiArt.getY()
+ walkingHumanProgressAsciiArt.getHeight() + walkingHumanProgressAsciiArt.getHeight()
@ -384,7 +388,7 @@ public class MainWindow extends TWindow {
break; break;
} }
componentRegistry.setVisible(currentVisibility.isNotNone()); componentRegistry.setVisible(c -> c instanceof Widget ? ((Widget)c).visibleProperty.isEnabled() : true, currentVisibility.isNotNone());
jokeButton.setVisible( jokeButton.setVisible(
TimeCalcProperties.getInstance().getBooleanProperty( TimeCalcProperties.getInstance().getBooleanProperty(

View File

@ -39,6 +39,8 @@ public class WalkingHumanProgressAsciiArt extends JTextPane implements
Visibility.STRONGLY_COLORED.name()); Visibility.STRONGLY_COLORED.name());
public final BooleanProperty visibilitySupportedColoredProperty public final BooleanProperty visibilitySupportedColoredProperty
= new BooleanProperty("visibilitySupportedColoredProperty", true); = new BooleanProperty("visibilitySupportedColoredProperty", true);
public final BooleanProperty visibleProperty
= new BooleanProperty("visibleProperty", true);
public WalkingHumanProgressAsciiArt(int x, int y, int width, int height) { public WalkingHumanProgressAsciiArt(int x, int y, int width, int height) {
setFont(new Font(Font.MONOSPACED, Font.PLAIN, 11)); setFont(new Font(Font.MONOSPACED, Font.PLAIN, 11));
@ -111,7 +113,10 @@ public class WalkingHumanProgressAsciiArt extends JTextPane implements
public void printPercentToAscii(double percent, int hourRemains, public void printPercentToAscii(double percent, int hourRemains,
int minuteRemains, double done, int minuteRemains, double done,
double totalSecondsRemainsDouble, TimeHM endTime) { double totalSecondsRemainsDouble, TimeHM endTime) {
if (visibleProperty.isDisabled()) {
setText("");
return;
}
Visibility visibility Visibility visibility
= Visibility.valueOf(visibilityProperty.getValue()); = Visibility.valueOf(visibilityProperty.getValue());
this.setVisible(visibility != Visibility.NONE); this.setVisible(visibility != Visibility.NONE);

View File

@ -31,7 +31,8 @@ smileys.visible=true
smileys.visible-only-if-mouse-moving-over=true smileys.visible-only-if-mouse-moving-over=true
smileys.colored=true smileys.colored=true
square.visible=true square.visible=true
circle.visible=true
walking-human.visible=true
@ -42,8 +43,7 @@ logs.detailed=false
battery.percent-precision.count-of-decimal-points=5 battery.percent-precision.count-of-decimal-points=5
clock.visible=true clock.visible=true
circle.visible=true
walking-human.visible=true
battery.visible=true battery.visible=true
battery.minute.visible=true battery.minute.visible=true
battery.hour.visible=true battery.hour.visible=true