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
= 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 List<Property> allProperties = new ArrayList<>();
@ -142,7 +146,9 @@ public class TimeCalcConfiguration {
smileysVisibleProperty,
smileysVisibleOnlyIfMouseMovingOverProperty,
smileysColoredProperty,
squareVisibleProperty,}) {
squareVisibleProperty,
circleVisibleProperty,
walkingHumanVisibleProperty,}) {
allProperties.add(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_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
private final String key;

View File

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

View File

@ -105,9 +105,12 @@ public class ConfigWindow extends TWindow {
private JCheckBox smileysColoredProperty
= new JCheckBox(TimeCalcProperty.SMILEYS_COLORED.getKey());
private JCheckBox squareVisibleProperty
= 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) {
this.timeCalcConfiguration = timeCalcConfiguration;
@ -157,7 +160,9 @@ public class ConfigWindow extends TWindow {
smileysVisibleProperty.setSelected(enable);
smileysColoredProperty.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,
smileysVisibleOnlyIfMouseMovingOverProperty,
smileysColoredProperty,
squareVisibleProperty));
squareVisibleProperty,
circleVisibleProperty,
walkingHumanVisibleProperty));
//
propertiesList.stream().forEach(p -> {
if (p == visibilityDefaultProperty) {

View File

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

View File

@ -39,6 +39,8 @@ public class WalkingHumanProgressAsciiArt extends JTextPane implements
Visibility.STRONGLY_COLORED.name());
public final BooleanProperty visibilitySupportedColoredProperty
= new BooleanProperty("visibilitySupportedColoredProperty", true);
public final BooleanProperty visibleProperty
= new BooleanProperty("visibleProperty", true);
public WalkingHumanProgressAsciiArt(int x, int y, int width, int height) {
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,
int minuteRemains, double done,
double totalSecondsRemainsDouble, TimeHM endTime) {
if (visibleProperty.isDisabled()) {
setText("");
return;
}
Visibility visibility
= Visibility.valueOf(visibilityProperty.getValue());
this.setVisible(visibility != Visibility.NONE);

View File

@ -31,7 +31,8 @@ smileys.visible=true
smileys.visible-only-if-mouse-moving-over=true
smileys.colored=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
clock.visible=true
circle.visible=true
walking-human.visible=true
battery.visible=true
battery.minute.visible=true
battery.hour.visible=true