Added several improvements

This commit is contained in:
Robert Vokac 2024-03-27 17:39:55 +01:00
parent b391b2caf8
commit a9ee1ed4c9
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
20 changed files with 593 additions and 533 deletions

View File

@ -70,8 +70,8 @@ public class TimeCalcConfiguration {
public final BooleanProperty clockCentreCircleVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_VISIBLE
.getKey());
public final BooleanProperty clockCentreCircleBlackProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK
public final BooleanProperty clockCentreCircleColoredProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_COLORED
.getKey());
public final BooleanProperty clockProgressVisibleOnlyIfMouseMovingOverProperty
= new BooleanProperty(
@ -291,7 +291,7 @@ public class TimeCalcConfiguration {
clockCircleStrongBorderProperty,
clockCircleBorderColorProperty,
clockCentreCircleVisibleProperty,
clockCentreCircleBlackProperty,
clockCentreCircleColoredProperty,
clockProgressVisibleOnlyIfMouseMovingOverProperty,
clockDateVisibleOnlyIfMouseMovingOverProperty,
clockSmileyVisibleProperty,

View File

@ -40,8 +40,8 @@ public enum TimeCalcProperty {
Color.class),
CLOCK_CENTRE_CIRCLE_VISIBLE("clock.centre-circle.visible",
"Clock : Centre circle"),
CLOCK_CENTRE_CIRCLE_BLACK("clock.centre-circle.black",
"Clock : Centre Circle is black"),
CLOCK_CENTRE_CIRCLE_COLORED("clock.centre-circle.colored",
"Clock : Centre Circle is colored"),
CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER(
"clock.progress.visible-only-if-mouse-moving-over",
"Clock : Progress visible only, if mouse moving over"),

View File

@ -689,7 +689,7 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
timeCalcConfiguration.clockCircleStrongBorderProperty.disable();
timeCalcConfiguration.clockCircleBorderColorProperty.setValue("0,0,255");
timeCalcConfiguration.clockCentreCircleVisibleProperty.enable();
timeCalcConfiguration.clockCentreCircleBlackProperty.disable();
timeCalcConfiguration.clockCentreCircleColoredProperty.disable();
timeCalcConfiguration.clockProgressVisibleOnlyIfMouseMovingOverProperty.disable();
timeCalcConfiguration.clockDateVisibleOnlyIfMouseMovingOverProperty.disable();
}

View File

@ -1,12 +1,11 @@
package org.nanoboot.utils.timecalc.swing.common;
import lombok.Getter;
import org.nanoboot.utils.timecalc.app.GetProperty;
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
import org.nanoboot.utils.timecalc.entity.Progress;
import org.nanoboot.utils.timecalc.entity.Visibility;
import org.nanoboot.utils.timecalc.entity.WidgetType;
import org.nanoboot.utils.timecalc.swing.progress.Battery;
import org.nanoboot.utils.timecalc.swing.progress.battery.Battery;
import org.nanoboot.utils.timecalc.swing.progress.ProgressSmileyIcon;
import org.nanoboot.utils.timecalc.swing.progress.ProgressSwing;
import org.nanoboot.utils.timecalc.utils.common.ProgressSmiley;
@ -31,10 +30,10 @@ import java.util.List;
import java.util.Locale;
import java.util.function.Consumer;
import javax.swing.JMenuItem;
import static org.nanoboot.utils.timecalc.swing.progress.Battery.HIGH_STRONGLY_COLORED;
import static org.nanoboot.utils.timecalc.swing.progress.Battery.HIGH_WEAKLY_COLORED;
import static org.nanoboot.utils.timecalc.swing.progress.Battery.LIGHT_RED;
import static org.nanoboot.utils.timecalc.swing.progress.Battery.ULTRA_LIGHT_RED;
import static org.nanoboot.utils.timecalc.swing.progress.battery.Battery.HIGH_STRONGLY_COLORED;
import static org.nanoboot.utils.timecalc.swing.progress.battery.Battery.HIGH_WEAKLY_COLORED;
import static org.nanoboot.utils.timecalc.swing.progress.battery.Battery.LIGHT_RED;
import static org.nanoboot.utils.timecalc.swing.progress.battery.Battery.ULTRA_LIGHT_RED;
/**
* @author Robert Vokac

View File

@ -3,7 +3,7 @@ package org.nanoboot.utils.timecalc.swing.common;
import org.nanoboot.utils.timecalc.app.TimeCalcException;
import org.nanoboot.utils.timecalc.entity.WidgetType;
import org.nanoboot.utils.timecalc.swing.progress.AnalogClock;
import org.nanoboot.utils.timecalc.swing.progress.Battery;
import org.nanoboot.utils.timecalc.swing.progress.battery.Battery;
import org.nanoboot.utils.timecalc.swing.progress.weather.ProgressWeather;
import javax.swing.JMenu;

View File

@ -6,6 +6,7 @@ import org.nanoboot.utils.timecalc.entity.WidgetType;
import org.nanoboot.utils.timecalc.swing.common.SwingUtils;
import org.nanoboot.utils.timecalc.swing.common.Widget;
import org.nanoboot.utils.timecalc.swing.controls.TMenuItem;
import org.nanoboot.utils.timecalc.swing.progress.battery.Battery;
import org.nanoboot.utils.timecalc.utils.common.DateFormats;
import org.nanoboot.utils.timecalc.utils.common.TTime;
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
@ -34,8 +35,8 @@ import org.nanoboot.utils.timecalc.entity.Progress;
public class AnalogClock extends Widget {
public static final Color COLOR_FOR_MILLISECOND_HAND_STRONGLY_COLORED
= new Color(246,
152, 51);
= new Color(226,
126, 19);
public final BooleanProperty borderVisibleProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_VISIBLE
.getKey());
@ -57,8 +58,8 @@ public class AnalogClock extends Widget {
public final StringProperty centreCircleBorderColorProperty
= new StringProperty(TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR
.getKey());
public final BooleanProperty centreCircleBlackProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK
public final BooleanProperty centreCircleColoredProperty
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_COLORED
.getKey());
public final BooleanProperty progressVisibleOnlyIfMouseMovingOverProperty
= new BooleanProperty(
@ -321,8 +322,7 @@ public class AnalogClock extends Widget {
Visibility visibility
= Visibility.valueOf(visibilityProperty.getValue());
brush.setColor(visibility.isStronglyColored() || mouseOver
? (centreCircleBlackProperty.isEnabled() ? Color.BLACK
: Color.RED)
? (centreCircleColoredProperty.isEnabled() ? Color.RED : Color.BLACK)
: FOREGROUND_COLOR);
brush.fillOval(centerX - 3, centerY - 3, 8, 8);
brush.setColor(currentColor);
@ -422,6 +422,15 @@ public class AnalogClock extends Widget {
if (smileyVisibleProperty.isEnabled()) {
paintSmiley(visibility, brush, ((int) (side * 0.25) + 90),
((int) (side * 0.35)) + 20);
} else {
if(this.smileyIcon != null) {
remove(this.smileyIcon);
this.smileyIcon = null;
}
if(this.smileyIcon2 != null) {
remove(this.smileyIcon2);
this.smileyIcon2 = null;
}
}
if (numbersVisibleProperty.isEnabled()) {

View File

@ -2,6 +2,7 @@ package org.nanoboot.utils.timecalc.swing.progress;
import org.nanoboot.utils.timecalc.entity.Visibility;
import org.nanoboot.utils.timecalc.swing.common.Widget;
import org.nanoboot.utils.timecalc.swing.progress.battery.Battery;
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
import java.awt.Color;

View File

@ -59,6 +59,9 @@ public class ProgressLife extends Widget implements GetProperty {
}).start();
}
public int getTimerDelay() {
return 100;
}
@Override
public void paintWidget(Graphics brush) {

View File

@ -50,6 +50,10 @@ public class ProgressMoney extends Widget implements GetProperty {
}
public int getTimerDelay() {
return 100;
}
@Override
public void paintWidget(Graphics brush) {
double perMonth = this.perMonthProperty.getValue();

View File

@ -1,408 +1,408 @@
package org.nanoboot.utils.timecalc.swing.progress;
import lombok.Getter;
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
import org.nanoboot.utils.timecalc.entity.Visibility;
import org.nanoboot.utils.timecalc.swing.common.Widget;
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
import org.nanoboot.utils.timecalc.utils.common.Utils;
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
public class Battery extends Widget {
public static final Color LOW_WEAKLY_COLORED = new Color(253, 130, 130);
public static final Color MEDIUM_WEAKLY_COLORED = new Color(255, 204, 153);
public static final Color HIGH_WEAKLY_COLORED = new Color(204, 255, 204);
public static final Color HIGHEST_WEAKLY_COLORED = new Color(153, 255, 153);
public static final Color LOW_STRONGLY_COLORED = Color.red;
public static final Color MEDIUM_STRONGLY_COLORED = Color.ORANGE;
public static final Color HIGH_STRONGLY_COLORED = new Color(158, 227, 158);
public static final Color HIGHEST_STRONGLY_COLORED = Color.green;
public static final double CRITICAL_LOW_ENERGY = 0.10;
public static final double LOW_ENERGY = 0.20;
public static final double HIGH_ENERGY = 0.75;
public static final double VERY_HIGH_ENERGY = 0.9;
public static final Color LIGHT_RED = new Color(
229, 168, 168);
public static final Color ULTRA_LIGHT_RED = new Color(
238, 196, 196);
public static final String CHARCHING = "";
public static final String COLON = ":";
@Getter
private final String name;
private final double[] randomDoubles
= new double[]{1d, 1d, 1d, 1d, 1d, 1d, 1};
private final BooleanProperty blinking = new BooleanProperty("blinking");
public static Color getColourForProgress(double donePercent,
Visibility visibility, boolean mouseOver) {
if (visibility.isGray()) {
return Utils.ULTRA_LIGHT_GRAY;
}
boolean stronglyColored = visibility.isStronglyColored() || mouseOver;
Color low = stronglyColored ? LOW_STRONGLY_COLORED : LOW_WEAKLY_COLORED;
Color medium = stronglyColored ? MEDIUM_STRONGLY_COLORED :
MEDIUM_WEAKLY_COLORED;
Color high = stronglyColored ? HIGH_STRONGLY_COLORED : HIGH_WEAKLY_COLORED;
Color highest = stronglyColored ? HIGHEST_STRONGLY_COLORED :
HIGHEST_WEAKLY_COLORED;
Color result = donePercent < LOW_ENERGY ? low
: (donePercent < HIGH_ENERGY
? medium
: (donePercent < VERY_HIGH_ENERGY
? high
: highest));
return result;
// if(donePercent < CRITICAL_LOW_ENERGY) {
// return result;
// }
// if(donePercent > VERY_HIGH_ENERGY) {
// return result;
// }
// double transition = 0d;
// if (donePercent < LOW_ENERGY) {
// transition = (donePercent - CRITICAL_LOW_ENERGY) / (LOW_ENERGY
// - CRITICAL_LOW_ENERGY);
// } else {
// if (donePercent < HIGH_ENERGY) {
// transition =
// (donePercent - LOW_ENERGY) / (HIGH_ENERGY - LOW_ENERGY);
// } else {
// if (donePercent < VERY_HIGH_ENERGY) {
// transition = (donePercent - HIGH_ENERGY) / (VERY_HIGH_ENERGY
// - HIGH_ENERGY);
// }
// }
// }
//
// return getColorBetween(result, result == low ? medium : (result == medium ? high : highest), transition, donePercent);
}
private static Map<String, Color> colorCache = new HashMap<>();
// private static Color getColorBetween(Color color1, Color color2, double transition, double progress) {
// if(color1.equals(color2)) {
// return color1;
// }
// int red1 = color1.getRed();
// int green1 = color1.getGreen();
// int blue1 = color1.getBlue();
// int red2 = color2.getRed();
// int green2 = color2.getGreen();
// int blue2 = color2.getBlue();
// int redDiff = Math.abs(red2-red1);
// int greenDiff = Math.abs(green2-green1);
// int blueDiff = Math.abs(blue2-blue1);
// int red = (int) (Math.min(red1, red2) + ((double)redDiff) * transition);
// int green = (int) (Math.min(green1, green2) + ((double)greenDiff) * transition);
// int blue = (int) (Math.min(blue1, blue2) + ((double)blueDiff) * transition);
// String key = red + COLON + green + COLON + blue;
//
//// try {new Color(red, green, blue);} catch (Exception e) {
//// System.out.println(key);
//// System.out.println("\n\n\nred1=" + red1);
//// System.out.println("green1=" + green1);
//// System.out.println("blue1=" + blue1);
//// System.out.println("red2=" + red2);
//// System.out.println("green2=" + green2);
//// System.out.println("blue2=" + blue2);
//// System.out.println("redDiff=" + redDiff);
//// System.out.println("greenDiff=" + greenDiff);
//// System.out.println("blueDiff=" + blueDiff);
//// System.out.println("red=" + red);
//// System.out.println("green=" + green);
//// System.out.println("blue=" + blue);
//// System.out.println("transition=" + transition);
//// System.out.println("progress=" + progress);
////
//// return Color.LIGHT_GRAY;
//// }
//
// if(!colorCache.containsKey(key)) {
// colorCache.put(key, new Color(red, green, blue));
// }
// return colorCache.get(key);
//
// }
public BooleanProperty wavesVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE
.getKey(), true);
public BooleanProperty circleProgressVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE
.getKey(), true);
public BooleanProperty percentProgressVisibleProperty = new BooleanProperty(
TimeCalcProperty.BATTERY_PERCENT_PROGRESS_VISIBLE
.getKey(), true);
public BooleanProperty chargingCharacterVisibleProperty
= new BooleanProperty(
TimeCalcProperty.BATTERY_CHARGING_CHARACTER_VISIBLE
.getKey(), true);
public BooleanProperty nameVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_NAME_VISIBLE
.getKey(), true);
public BooleanProperty labelVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_LABEL_VISIBLE
.getKey(), true);
public BooleanProperty blinkingIfCriticalLowVisibleProperty
= new BooleanProperty(
TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW
.getKey(), true);
public final BooleanProperty quarterIconVisibleProperty
= new BooleanProperty(
TimeCalcProperty.BATTERY_QUARTER_ICON_VISIBLE
.getKey(), true);
private long tmpNanoTime = 0l;
private int totalHeight = 0;
private int totalWidth;
private String label = null;
protected Battery(String name) {
this.name = name;
setPreferredSize(new Dimension(40, 100));
this.typeProperty.setValue(getClass().getSimpleName().replace("Battery", "").toLowerCase(
Locale.ROOT));
}
protected Battery(String name, int i, int y, int height) {
this(name);
setBounds(i, y, height);
}
@Override
public void paintWidget(Graphics g) {
if (totalHeight == 0) {
this.totalHeight = (int) (this.getHeight() / 10d * 7d);
this.totalWidth = this.getWidth();
}
double donePercent = donePercent();
if (blinkingIfCriticalLowVisibleProperty.isEnabled()) {
if (donePercent > 0 && donePercent <= CRITICAL_LOW_ENERGY
&& (System.nanoTime() - tmpNanoTime) > (1000000000l) / 2l) {
blinking.flip();
tmpNanoTime = System.nanoTime();
}
if (donePercent > CRITICAL_LOW_ENERGY && blinking.isEnabled()) {
blinking.disable();
}
if (donePercent <= 0 && blinking.getValue()) {
blinking.setValue(false);
}
} else {
if (blinking.isEnabled()) {
blinking.disable();
}
}
Graphics2D brush = (Graphics2D) g;
Visibility visibility
= Visibility.valueOf(visibilityProperty.getValue());
brush.setColor(
visibility.isStronglyColored() || mouseOver ? Color.YELLOW
: FOREGROUND_COLOR);
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
if (!visibility.isGray()) {
brush.fillRect(1, 1, totalWidth, totalHeight);
}
brush.setColor(getColourForProgress(donePercent, visibility, mouseOver));
if (blinking.getValue()) {
brush.setColor(BACKGROUND_COLOR);
}
int doneHeight = (int) (totalHeight * donePercent);
int intX = 1;
int todoHeight = totalHeight - doneHeight;
double surfacePower
= 1;//donePercent < 0.5 ? 0.5 : donePercent;// (donePercent * 100 - ((int)(donePercent * 100)));
int waterSurfaceHeight
= (int) (4 * surfacePower);//2 + (int) (Math.random() * 3);
if (waterSurfaceHeight <= 2 || wavesVisibleProperty.isDisabled() || !changedInTheLastXMilliseconds(1000)) {
waterSurfaceHeight = 0;
}
brush.fillRect(intX + 1,
doneHeight < waterSurfaceHeight || donePercent >= 1
? todoHeight : todoHeight + waterSurfaceHeight,
totalWidth - 3,
doneHeight < waterSurfaceHeight || donePercent >= 1
? doneHeight : doneHeight - waterSurfaceHeight + 1);
int pointCount = 8;
if (doneHeight >= waterSurfaceHeight
&& donePercent < 1) {// && todoHeight > waterSurfaceHeight) {
//g2d.fillArc(intX, intY, width_, intHeight - waterSurfaceHeight, 30, 60);
brush.fillPolygon(
new int[]{intX,
(int) (intX + totalWidth / pointCount * 0.5),
intX + totalWidth / pointCount * 3,
intX + totalWidth / pointCount * 4,
intX + totalWidth / pointCount * 5,
intX + totalWidth / pointCount * 6,
intX + totalWidth / pointCount * 7,
intX + totalWidth / pointCount * 8},
new int[]{todoHeight + (waterSurfaceHeight * 1),
todoHeight + (int) (waterSurfaceHeight * getRandom(
0)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
1)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
2)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
3)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
4)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
5)),
todoHeight + (waterSurfaceHeight * 1)},
pointCount);
brush.setColor(
(visibility.isGray() || !visibility.isStronglyColored())
&& !mouseOver ? Utils.ULTRA_LIGHT_GRAY : Color.DARK_GRAY);
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_OFF);
brush.drawPolyline(
new int[]{intX,
(int) (intX + totalWidth / pointCount * 0.5),
intX + totalWidth / pointCount * 3,
intX + totalWidth / pointCount * 4,
intX + totalWidth / pointCount * 5,
intX + totalWidth / pointCount * 6,
intX + totalWidth / pointCount * 7,
intX + totalWidth / pointCount * 8},
new int[]{todoHeight + (waterSurfaceHeight * 1),
todoHeight + (int) (waterSurfaceHeight * getRandom(
0, true)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
1, true)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
2, true)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
3, true)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
4, true)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
5, true)),
todoHeight + (waterSurfaceHeight * 1)},
pointCount);
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
}
brush.setColor(visibility.isStronglyColored() || mouseOver ? Color.BLACK
: Color.LIGHT_GRAY);
if (donePercent < 1 && donePercent > 0) {
{
Font currentFont = brush.getFont();
brush.setFont(BIG_FONT);
if (chargingCharacterVisibleProperty.isEnabled() && changedInTheLastXMilliseconds(1000)) {
paintChargingCharacter(brush);
}
brush.setFont(currentFont);
}
}
if (quarterIconVisibleProperty.isEnabled()) {
paintQuarterIcon(brush, visibility, totalWidth, totalHeight);
}
if (circleProgressVisibleProperty.isEnabled()) {
paintCircleProgress(brush, visibility, totalWidth, totalHeight);
}
if (donePercent > 0) {
Font currentFont = brush.getFont();
brush.setFont(BIG_FONT);
paintSmiley(visibility, brush, ((int) (totalWidth * 0.45)) + 15,
(donePercent < 0.5 ? totalHeight / 4 * 3
: (totalHeight / 4 * 1) + 10) + 8 - 16);
brush.setFont(currentFont);
}
if (percentProgressVisibleProperty.isEnabled()) {
brush.drawString(
(donePercent == 1 ? 100 : (NumberFormats.FORMATTER_THREE_DECIMAL_PLACES
.format(donePercent * 100))) + "%",
((int) (totalWidth * 0.15)),
donePercent > 0.5 ? totalHeight / 4 * 3
: totalHeight / 4 * 1);
}
if (labelVisibleProperty.isEnabled() && label != null && !label
.isEmpty()) {
brush.drawString(
label,
((int) (totalWidth * 0.15)),
(donePercent > 0.5 ? totalHeight / 4 * 3
: totalHeight / 4 * 1) + 20);
}
if (nameVisibleProperty.isEnabled() && name != null && !name
.isEmpty()) {
brush.drawString(
name,
((int) (totalWidth * 0.10)),
(totalHeight / 4 * 3) + 20 + 20);
}
brush.setColor(visibility.isStronglyColored() || mouseOver ? Color.BLACK
: Color.LIGHT_GRAY);
brush.drawRect(1, 1, totalWidth - 2, totalHeight);
}
public void paintChargingCharacter(Graphics2D brush) {
brush.drawString(
CHARCHING, ((int) (totalWidth * 0.45)),
(donePercent() < 0.5 ? totalHeight / 4 * 3
: (totalHeight / 4 * 1) + 10) + 10
);
}
private double getRandom(int index) {
return getRandom(index, false);
}
private double getRandom(int index, boolean keepArray) {
if (!keepArray && Math.random() > 0.96) {
randomDoubles[index] = Math.random();
}
return randomDoubles[index];
}
public String getLabel() {
return this.label;
}
public void setLabel(String label) {
this.label = label;
}
@Override
public void setBounds(int x, int y, int height) {
setBounds(x, y, (int) (40d / 100d * ((double) height)), height);
}
@Override
public int getTimerDelay() {
return 100;
}
}
package org.nanoboot.utils.timecalc.swing.progress.battery;
import lombok.Getter;
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
import org.nanoboot.utils.timecalc.entity.Visibility;
import org.nanoboot.utils.timecalc.swing.common.Widget;
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
import org.nanoboot.utils.timecalc.utils.common.Utils;
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
public class Battery extends Widget {
public static final Color LOW_WEAKLY_COLORED = new Color(253, 130, 130);
public static final Color MEDIUM_WEAKLY_COLORED = new Color(255, 204, 153);
public static final Color HIGH_WEAKLY_COLORED = new Color(204, 255, 204);
public static final Color HIGHEST_WEAKLY_COLORED = new Color(153, 255, 153);
public static final Color LOW_STRONGLY_COLORED = Color.red;
public static final Color MEDIUM_STRONGLY_COLORED = Color.ORANGE;
public static final Color HIGH_STRONGLY_COLORED = new Color(158, 227, 158);
public static final Color HIGHEST_STRONGLY_COLORED = Color.green;
public static final double CRITICAL_LOW_ENERGY = 0.10;
public static final double LOW_ENERGY = 0.20;
public static final double HIGH_ENERGY = 0.75;
public static final double VERY_HIGH_ENERGY = 0.9;
public static final Color LIGHT_RED = new Color(
229, 168, 168);
public static final Color ULTRA_LIGHT_RED = new Color(
238, 196, 196);
public static final String CHARCHING = "";
public static final String COLON = ":";
@Getter
private final String name;
private final double[] randomDoubles
= new double[]{1d, 1d, 1d, 1d, 1d, 1d, 1};
private final BooleanProperty blinking = new BooleanProperty("blinking");
public static Color getColourForProgress(double donePercent,
Visibility visibility, boolean mouseOver) {
if (visibility.isGray()) {
return Utils.ULTRA_LIGHT_GRAY;
}
boolean stronglyColored = visibility.isStronglyColored() || mouseOver;
Color low = stronglyColored ? LOW_STRONGLY_COLORED : LOW_WEAKLY_COLORED;
Color medium = stronglyColored ? MEDIUM_STRONGLY_COLORED :
MEDIUM_WEAKLY_COLORED;
Color high = stronglyColored ? HIGH_STRONGLY_COLORED : HIGH_WEAKLY_COLORED;
Color highest = stronglyColored ? HIGHEST_STRONGLY_COLORED :
HIGHEST_WEAKLY_COLORED;
Color result = donePercent < LOW_ENERGY ? low
: (donePercent < HIGH_ENERGY
? medium
: (donePercent < VERY_HIGH_ENERGY
? high
: highest));
return result;
// if(donePercent < CRITICAL_LOW_ENERGY) {
// return result;
// }
// if(donePercent > VERY_HIGH_ENERGY) {
// return result;
// }
// double transition = 0d;
// if (donePercent < LOW_ENERGY) {
// transition = (donePercent - CRITICAL_LOW_ENERGY) / (LOW_ENERGY
// - CRITICAL_LOW_ENERGY);
// } else {
// if (donePercent < HIGH_ENERGY) {
// transition =
// (donePercent - LOW_ENERGY) / (HIGH_ENERGY - LOW_ENERGY);
// } else {
// if (donePercent < VERY_HIGH_ENERGY) {
// transition = (donePercent - HIGH_ENERGY) / (VERY_HIGH_ENERGY
// - HIGH_ENERGY);
// }
// }
// }
//
// return getColorBetween(result, result == low ? medium : (result == medium ? high : highest), transition, donePercent);
}
private static Map<String, Color> colorCache = new HashMap<>();
// private static Color getColorBetween(Color color1, Color color2, double transition, double progress) {
// if(color1.equals(color2)) {
// return color1;
// }
// int red1 = color1.getRed();
// int green1 = color1.getGreen();
// int blue1 = color1.getBlue();
// int red2 = color2.getRed();
// int green2 = color2.getGreen();
// int blue2 = color2.getBlue();
// int redDiff = Math.abs(red2-red1);
// int greenDiff = Math.abs(green2-green1);
// int blueDiff = Math.abs(blue2-blue1);
// int red = (int) (Math.min(red1, red2) + ((double)redDiff) * transition);
// int green = (int) (Math.min(green1, green2) + ((double)greenDiff) * transition);
// int blue = (int) (Math.min(blue1, blue2) + ((double)blueDiff) * transition);
// String key = red + COLON + green + COLON + blue;
//
//// try {new Color(red, green, blue);} catch (Exception e) {
//// System.out.println(key);
//// System.out.println("\n\n\nred1=" + red1);
//// System.out.println("green1=" + green1);
//// System.out.println("blue1=" + blue1);
//// System.out.println("red2=" + red2);
//// System.out.println("green2=" + green2);
//// System.out.println("blue2=" + blue2);
//// System.out.println("redDiff=" + redDiff);
//// System.out.println("greenDiff=" + greenDiff);
//// System.out.println("blueDiff=" + blueDiff);
//// System.out.println("red=" + red);
//// System.out.println("green=" + green);
//// System.out.println("blue=" + blue);
//// System.out.println("transition=" + transition);
//// System.out.println("progress=" + progress);
////
//// return Color.LIGHT_GRAY;
//// }
//
// if(!colorCache.containsKey(key)) {
// colorCache.put(key, new Color(red, green, blue));
// }
// return colorCache.get(key);
//
// }
public BooleanProperty wavesVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE
.getKey(), true);
public BooleanProperty circleProgressVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE
.getKey(), true);
public BooleanProperty percentProgressVisibleProperty = new BooleanProperty(
TimeCalcProperty.BATTERY_PERCENT_PROGRESS_VISIBLE
.getKey(), true);
public BooleanProperty chargingCharacterVisibleProperty
= new BooleanProperty(
TimeCalcProperty.BATTERY_CHARGING_CHARACTER_VISIBLE
.getKey(), true);
public BooleanProperty nameVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_NAME_VISIBLE
.getKey(), true);
public BooleanProperty labelVisibleProperty
= new BooleanProperty(TimeCalcProperty.BATTERY_LABEL_VISIBLE
.getKey(), true);
public BooleanProperty blinkingIfCriticalLowVisibleProperty
= new BooleanProperty(
TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW
.getKey(), true);
public final BooleanProperty quarterIconVisibleProperty
= new BooleanProperty(
TimeCalcProperty.BATTERY_QUARTER_ICON_VISIBLE
.getKey(), true);
private long tmpNanoTime = 0l;
private int totalHeight = 0;
private int totalWidth;
private String label = null;
protected Battery(String name) {
this.name = name;
setPreferredSize(new Dimension(40, 100));
this.typeProperty.setValue(getClass().getSimpleName().replace("Battery", "").toLowerCase(
Locale.ROOT));
}
protected Battery(String name, int i, int y, int height) {
this(name);
setBounds(i, y, height);
}
@Override
public void paintWidget(Graphics g) {
if (totalHeight == 0) {
this.totalHeight = (int) (this.getHeight() / 10d * 7d);
this.totalWidth = this.getWidth();
}
double donePercent = donePercent();
if (blinkingIfCriticalLowVisibleProperty.isEnabled()) {
if (donePercent > 0 && donePercent <= CRITICAL_LOW_ENERGY
&& (System.nanoTime() - tmpNanoTime) > (1000000000l) / 2l) {
blinking.flip();
tmpNanoTime = System.nanoTime();
}
if (donePercent > CRITICAL_LOW_ENERGY && blinking.isEnabled()) {
blinking.disable();
}
if (donePercent <= 0 && blinking.getValue()) {
blinking.setValue(false);
}
} else {
if (blinking.isEnabled()) {
blinking.disable();
}
}
Graphics2D brush = (Graphics2D) g;
Visibility visibility
= Visibility.valueOf(visibilityProperty.getValue());
brush.setColor(
visibility.isStronglyColored() || mouseOver ? Color.YELLOW
: FOREGROUND_COLOR);
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
if (!visibility.isGray()) {
brush.fillRect(1, 1, totalWidth, totalHeight);
}
brush.setColor(getColourForProgress(donePercent, visibility, mouseOver));
if (blinking.getValue()) {
brush.setColor(BACKGROUND_COLOR);
}
int doneHeight = (int) (totalHeight * donePercent);
int intX = 1;
int todoHeight = totalHeight - doneHeight;
double surfacePower
= 1;//donePercent < 0.5 ? 0.5 : donePercent;// (donePercent * 100 - ((int)(donePercent * 100)));
int waterSurfaceHeight
= (int) (4 * surfacePower);//2 + (int) (Math.random() * 3);
if (waterSurfaceHeight <= 2 || wavesVisibleProperty.isDisabled() || !changedInTheLastXMilliseconds(1000)) {
waterSurfaceHeight = 0;
}
brush.fillRect(intX + 1,
doneHeight < waterSurfaceHeight || donePercent >= 1
? todoHeight : todoHeight + waterSurfaceHeight,
totalWidth - 3,
doneHeight < waterSurfaceHeight || donePercent >= 1
? doneHeight : doneHeight - waterSurfaceHeight + 1);
int pointCount = 8;
if (doneHeight >= waterSurfaceHeight
&& donePercent < 1) {// && todoHeight > waterSurfaceHeight) {
//g2d.fillArc(intX, intY, width_, intHeight - waterSurfaceHeight, 30, 60);
brush.fillPolygon(
new int[]{intX,
(int) (intX + totalWidth / pointCount * 0.5),
intX + totalWidth / pointCount * 3,
intX + totalWidth / pointCount * 4,
intX + totalWidth / pointCount * 5,
intX + totalWidth / pointCount * 6,
intX + totalWidth / pointCount * 7,
intX + totalWidth / pointCount * 8},
new int[]{todoHeight + (waterSurfaceHeight * 1),
todoHeight + (int) (waterSurfaceHeight * getRandom(
0)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
1)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
2)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
3)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
4)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
5)),
todoHeight + (waterSurfaceHeight * 1)},
pointCount);
brush.setColor(
(visibility.isGray() || !visibility.isStronglyColored())
&& !mouseOver ? Utils.ULTRA_LIGHT_GRAY : Color.DARK_GRAY);
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_OFF);
brush.drawPolyline(
new int[]{intX,
(int) (intX + totalWidth / pointCount * 0.5),
intX + totalWidth / pointCount * 3,
intX + totalWidth / pointCount * 4,
intX + totalWidth / pointCount * 5,
intX + totalWidth / pointCount * 6,
intX + totalWidth / pointCount * 7,
intX + totalWidth / pointCount * 8},
new int[]{todoHeight + (waterSurfaceHeight * 1),
todoHeight + (int) (waterSurfaceHeight * getRandom(
0, true)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
1, true)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
2, true)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
3, true)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
4, true)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
5, true)),
todoHeight + (waterSurfaceHeight * 1)},
pointCount);
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
}
brush.setColor(visibility.isStronglyColored() || mouseOver ? Color.BLACK
: Color.LIGHT_GRAY);
if (donePercent < 1 && donePercent > 0) {
{
Font currentFont = brush.getFont();
brush.setFont(BIG_FONT);
if (chargingCharacterVisibleProperty.isEnabled() && changedInTheLastXMilliseconds(1000)) {
paintChargingCharacter(brush);
}
brush.setFont(currentFont);
}
}
if (quarterIconVisibleProperty.isEnabled()) {
paintQuarterIcon(brush, visibility, totalWidth, totalHeight);
}
if (circleProgressVisibleProperty.isEnabled()) {
paintCircleProgress(brush, visibility, totalWidth, totalHeight);
}
if (donePercent > 0) {
Font currentFont = brush.getFont();
brush.setFont(BIG_FONT);
paintSmiley(visibility, brush, ((int) (totalWidth * 0.45)) + 15,
(donePercent < 0.5 ? totalHeight / 4 * 3
: (totalHeight / 4 * 1) + 10) + 8 - 16);
brush.setFont(currentFont);
}
if (percentProgressVisibleProperty.isEnabled()) {
brush.drawString(
(donePercent == 1 ? 100 : (NumberFormats.FORMATTER_THREE_DECIMAL_PLACES
.format(donePercent * 100))) + "%",
((int) (totalWidth * 0.15)),
donePercent > 0.5 ? totalHeight / 4 * 3
: totalHeight / 4 * 1);
}
if (labelVisibleProperty.isEnabled() && label != null && !label
.isEmpty()) {
brush.drawString(
label,
((int) (totalWidth * 0.15)),
(donePercent > 0.5 ? totalHeight / 4 * 3
: totalHeight / 4 * 1) + 20);
}
if (nameVisibleProperty.isEnabled() && name != null && !name
.isEmpty()) {
brush.drawString(
name,
((int) (totalWidth * 0.10)),
(totalHeight / 4 * 3) + 20 + 20);
}
brush.setColor(visibility.isStronglyColored() || mouseOver ? Color.BLACK
: Color.LIGHT_GRAY);
brush.drawRect(1, 1, totalWidth - 2, totalHeight);
}
public void paintChargingCharacter(Graphics2D brush) {
brush.drawString(
CHARCHING, ((int) (totalWidth * 0.45)),
(donePercent() < 0.5 ? totalHeight / 4 * 3
: (totalHeight / 4 * 1) + 10) + 10
);
}
private double getRandom(int index) {
return getRandom(index, false);
}
private double getRandom(int index, boolean keepArray) {
if (!keepArray && Math.random() > 0.96) {
randomDoubles[index] = Math.random();
}
return randomDoubles[index];
}
public String getLabel() {
return this.label;
}
public void setLabel(String label) {
this.label = label;
}
@Override
public void setBounds(int x, int y, int height) {
setBounds(x, y, (int) (40d / 100d * ((double) height)), height);
}
@Override
public int getTimerDelay() {
return 100;
}
}

View File

@ -1,14 +1,14 @@
package org.nanoboot.utils.timecalc.swing.progress;
/**
* @author Robert Vokac
* @since 21.02.2024
*/
public class DayBattery extends Battery {
public static final String DAY = "Day";
public DayBattery(int x, int i, int i1) {
super(DAY, x, i, i1);
}
}
package org.nanoboot.utils.timecalc.swing.progress.battery;
/**
* @author Robert Vokac
* @since 21.02.2024
*/
public class DayBattery extends Battery {
public static final String DAY = "Day";
public DayBattery(int x, int i, int i1) {
super(DAY, x, i, i1);
}
}

View File

@ -1,17 +1,15 @@
package org.nanoboot.utils.timecalc.swing.progress;
import org.nanoboot.utils.timecalc.utils.common.TTime;
/**
* @author Robert Vokac
* @since 21.02.2024
*/
public class HourBattery extends Battery {
public static final String HOUR = "Hour";
public HourBattery(int x, int i, int i1) {
super(HOUR, x, i, i1);
}
}
package org.nanoboot.utils.timecalc.swing.progress.battery;
/**
* @author Robert Vokac
* @since 21.02.2024
*/
public class HourBattery extends Battery {
public static final String HOUR = "Hour";
public HourBattery(int x, int i, int i1) {
super(HOUR, x, i, i1);
}
}

View File

@ -1,4 +1,4 @@
package org.nanoboot.utils.timecalc.swing.progress;
package org.nanoboot.utils.timecalc.swing.progress.battery;
/**
* @author Robert Vokac

View File

@ -1,15 +1,15 @@
package org.nanoboot.utils.timecalc.swing.progress;
/**
* @author Robert Vokac
* @since 21.02.2024
*/
public class MonthBattery extends Battery {
public static final String MONTH = "Month";
public MonthBattery(int x, int i, int i1) {
super(MONTH, x, i, i1);
}
}
package org.nanoboot.utils.timecalc.swing.progress.battery;
/**
* @author Robert Vokac
* @since 21.02.2024
*/
public class MonthBattery extends Battery {
public static final String MONTH = "Month";
public MonthBattery(int x, int i, int i1) {
super(MONTH, x, i, i1);
}
}

View File

@ -1,15 +1,15 @@
package org.nanoboot.utils.timecalc.swing.progress;
/**
* @author Robert Vokac
* @since 21.02.2024
*/
public class WeekBattery extends Battery {
public static final String WEEK = "Week";
public WeekBattery(int x, int i, int i1) {
super(WEEK, x, i, i1);
}
}
package org.nanoboot.utils.timecalc.swing.progress.battery;
/**
* @author Robert Vokac
* @since 21.02.2024
*/
public class WeekBattery extends Battery {
public static final String WEEK = "Week";
public WeekBattery(int x, int i, int i1) {
super(WEEK, x, i, i1);
}
}

View File

@ -1,6 +1,4 @@
package org.nanoboot.utils.timecalc.swing.progress;
import java.util.Calendar;
package org.nanoboot.utils.timecalc.swing.progress.battery;
/**
* @author Robert Vokac

View File

@ -64,6 +64,10 @@ public class ProgressWeather extends Widget implements GetProperty {
private static Map<Integer, List<WeatherForecast>> forecastsForYears = new HashMap<>();
public int getTimerDelay() {
return 1000;
}
@Override
public void paintWidget(Graphics brush) {

View File

@ -67,10 +67,12 @@ public class ConfigWindow extends TWindow {
private final JPanel panelInsideScrollPaneLife;
private final JPanel panelInsideScrollPaneMoney;
private final JPanel panelInsideScrollPaneSmileys;
private final JPanel panelInsideScrollPaneProgress;
private final JPanel panelInsideScrollPaneTest;
private final JPanel panelInsideScrollPaneOther;
private final int[] currentY = new int[]{SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN};
private final int[] currentX = new int[]{SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN};
private final int[] currentY = new int[]{SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN};
private final int[] currentX = new int[]{SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN, SwingUtils.MARGIN};
private final List<JComponent> propertiesList = new ArrayList<>();
private final Map<TimeCalcProperty, JComponent> propertiesMap = new HashMap<>();
private final TButton enableAsMuchAsPossible
@ -110,8 +112,8 @@ public class ConfigWindow extends TWindow {
private final JCheckBox clockCentreCircleVisibleProperty
= new JCheckBox(
TimeCalcProperty.CLOCK_CENTRE_CIRCLE_VISIBLE.getKey());
private final JCheckBox clockCentreCircleBlackProperty
= new JCheckBox(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK.getKey());
private final JCheckBox clockCentreCircleColoredProperty
= new JCheckBox(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_COLORED.getKey());
private final JCheckBox clockProgressVisibleOnlyIfMouseMovingOverProperty
= new JCheckBox(
TimeCalcProperty.CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
@ -299,6 +301,7 @@ public class ConfigWindow extends TWindow {
this.panelInsideScrollPaneLife = new JPanel();
this.panelInsideScrollPaneMoney = new JPanel();
this.panelInsideScrollPaneSmileys = new JPanel();
this.panelInsideScrollPaneProgress = new JPanel();
this.panelInsideScrollPaneTest = new JPanel();
this.panelInsideScrollPaneOther = new JPanel();
@ -308,6 +311,7 @@ public class ConfigWindow extends TWindow {
panelInsideScrollPaneLife,
panelInsideScrollPaneMoney,
panelInsideScrollPaneSmileys,
panelInsideScrollPaneProgress,
panelInsideScrollPaneTest,
panelInsideScrollPaneOther).collect(Collectors.toList());
panelsInsideScrollPane.forEach(p -> {
@ -327,6 +331,7 @@ public class ConfigWindow extends TWindow {
JScrollPane scrollPaneLife = new JScrollPane(panelInsideScrollPaneLife);
JScrollPane scrollPaneMoney = new JScrollPane(panelInsideScrollPaneMoney);
JScrollPane scrollPaneSmileys = new JScrollPane(panelInsideScrollPaneSmileys);
JScrollPane scrollPaneProgress = new JScrollPane(panelInsideScrollPaneProgress);
JScrollPane scrollPaneTest = new JScrollPane(panelInsideScrollPaneTest);
JScrollPane scrollPaneOther = new JScrollPane(panelInsideScrollPaneOther);
@ -336,6 +341,7 @@ public class ConfigWindow extends TWindow {
scrollPaneLife,
scrollPaneMoney,
scrollPaneSmileys,
scrollPaneProgress,
scrollPaneTest,
scrollPaneOther
).collect(Collectors.toList());
@ -345,6 +351,7 @@ public class ConfigWindow extends TWindow {
tp.add("Life", scrollPaneLife);
tp.add("Money", scrollPaneMoney);
tp.add("Smileys", scrollPaneSmileys);
tp.add("Progress", scrollPaneProgress);
tp.add("Test", scrollPaneTest);
tp.add("Other", scrollPaneOther);
scrollPanes.forEach(s
@ -402,7 +409,7 @@ public class ConfigWindow extends TWindow {
.setValue(enable ? "0,0,255" : "0,0,0");
clockCentreCircleVisibleProperty.setSelected(enable);
clockCentreCircleBlackProperty.setSelected(!enable);
clockCentreCircleColoredProperty.setSelected(!enable);
clockProgressVisibleOnlyIfMouseMovingOverProperty
.setSelected(!enable);
clockDateVisibleOnlyIfMouseMovingOverProperty
@ -437,6 +444,12 @@ public class ConfigWindow extends TWindow {
dotVisibleProperty.setSelected(enable);
lifeVisibleProperty.setSelected(enable);
moneyVisibleProperty.setSelected(enable);
if(enable && moneyPerMonthProperty.getText().isEmpty()) {
moneyPerMonthProperty.setText("1000000");
}
if(enable && moneyCurrencyProperty.getText().isEmpty()) {
moneyPerMonthProperty.setText("$TT");
}
weatherVisibleProperty.setSelected(enable);
circleVisibleProperty.setSelected(enable);
swingVisibleProperty.setSelected(enable);
@ -459,10 +472,9 @@ public class ConfigWindow extends TWindow {
// dotHiddenProperty.setSelected(!enable);
if (enable) {
speedProperty.setText("0");
speedFloatingProperty.setSelected(true);
}
if (!enable) {
speedProperty.setText(String.valueOf(Integer.MIN_VALUE));
speedProperty.setText(String.valueOf(Integer.MAX_VALUE));
speedFloatingProperty.setSelected(false);
}
MainWindow.hideShowFormsCheckBox.setSelected(enable);
@ -485,7 +497,7 @@ public class ConfigWindow extends TWindow {
clockCircleStrongBorderProperty,
clockCircleBorderColorProperty,
clockCentreCircleVisibleProperty,
clockCentreCircleBlackProperty,
clockCentreCircleColoredProperty,
clockProgressVisibleOnlyIfMouseMovingOverProperty,
clockDateVisibleOnlyIfMouseMovingOverProperty,
clockSmileyVisibleProperty,
@ -530,12 +542,12 @@ public class ConfigWindow extends TWindow {
squareVisibleProperty,
squareHiddenProperty,
squareTypeProperty,
dotVisibleProperty,
dotHiddenProperty,
dotTypeProperty,
circleVisibleProperty,
circleHiddenProperty,
circleTypeProperty,
dotVisibleProperty,
dotHiddenProperty,
dotTypeProperty,
swingVisibleProperty,
swingHiddenProperty,
swingTypeProperty,
@ -687,7 +699,9 @@ public class ConfigWindow extends TWindow {
String groupName = array[0];
if (groupName.equals("Clock") || groupName.equals("Battery")
|| groupName.equals("Smileys")
|| groupName.equals("Test")) {
|| groupName.equals("Test")
|| groupName.equals("Money")
|| groupName.equals("Life")) {
checkBox.setText(array.length > 1 ? (checkBox.getText()
.substring(groupName.length() + 3)) : "Visible");
@ -867,6 +881,9 @@ public class ConfigWindow extends TWindow {
});
}
if(timeCalcConfiguration.speedProperty.getValue() == Integer.MIN_VALUE) {
timeCalcConfiguration.speedProperty.setValue(Integer.MAX_VALUE);
}
propertiesMap.put(TimeCalcProperty.forKey(
(String) p.getClientProperty(CLIENT_PROPERTY_KEY)), p);
addToNextRow(p);
@ -934,7 +951,7 @@ public class ConfigWindow extends TWindow {
}
private void addToNextRow(JComponent jComponent, boolean nextRow) {
int index = 6;
int index = 7;
String key = (String) jComponent.getClientProperty(CLIENT_PROPERTY_KEY);
if (key == null) {
//nothing to do
@ -959,6 +976,10 @@ public class ConfigWindow extends TWindow {
index = 5;
}
if (key.startsWith("square.")||key.startsWith("circle.")||key.startsWith("dot.")||key.startsWith("swing.")||key.startsWith("walking-human.")) {
index = 6;
}
JPanel panel = null;
switch (index) {
case 0:
@ -979,17 +1000,34 @@ public class ConfigWindow extends TWindow {
case 5:
panel = panelInsideScrollPaneTest;
break;
case 6:
panel = panelInsideScrollPaneProgress;
break;
default:
panel = panelInsideScrollPaneOther;
}
if(index == 6 && !key.startsWith("test.") && !key.startsWith("square.") && key.endsWith(".visible") && !key.endsWith(".quarter-icon.visible")) {
panel.add(Box.createRigidArea(new Dimension(5, 20)));
}
if (jComponent instanceof JTextField) {
JPanel p = new JPanel();
//p.setLayout(null);
JLabel label = new JLabel(TimeCalcProperty.forKey(key).getDescription() + ": ");
p.add(label);
p.add(jComponent);
label.setBounds(10, 0, 200, 25);
if (label.getText().startsWith("Life")) {
label.setText(label.getText().substring("Life".length() + 3));
}
if (label.getText().startsWith("Money")) {
label.setText(label.getText().substring("Money".length() + 3));
}
if (label.getText().startsWith("Test")) {
label.setText(label.getText().substring("Test".length() + 3));
}
jComponent.setBounds(220, 0, 200, 25);
LayoutManager flowLayout = new FlowLayout(FlowLayout.LEFT);
@ -1010,9 +1048,11 @@ public class ConfigWindow extends TWindow {
jComponent.setBounds(currentX[index], currentY[index], 200,
HEIGHT1);
panel.add(Box.createRigidArea(new Dimension(5, 5)));
panel.add(Box.createRigidArea(new Dimension(5, 4)));
if (nextRow) {
nextRow(index);
} else {
currentX[index] = currentX[index] + SwingUtils.MARGIN + jComponent.getWidth();
}

View File

@ -27,11 +27,11 @@ import org.nanoboot.utils.timecalc.swing.controls.TLabel;
import org.nanoboot.utils.timecalc.swing.controls.TTextField;
import org.nanoboot.utils.timecalc.swing.controls.TWindow;
import org.nanoboot.utils.timecalc.swing.progress.AnalogClock;
import org.nanoboot.utils.timecalc.swing.progress.Battery;
import org.nanoboot.utils.timecalc.swing.progress.DayBattery;
import org.nanoboot.utils.timecalc.swing.progress.HourBattery;
import org.nanoboot.utils.timecalc.swing.progress.MinuteBattery;
import org.nanoboot.utils.timecalc.swing.progress.MonthBattery;
import org.nanoboot.utils.timecalc.swing.progress.battery.Battery;
import org.nanoboot.utils.timecalc.swing.progress.battery.DayBattery;
import org.nanoboot.utils.timecalc.swing.progress.battery.HourBattery;
import org.nanoboot.utils.timecalc.swing.progress.battery.MinuteBattery;
import org.nanoboot.utils.timecalc.swing.progress.battery.MonthBattery;
import org.nanoboot.utils.timecalc.swing.progress.ProgressCircle;
import org.nanoboot.utils.timecalc.swing.progress.ProgressLife;
import org.nanoboot.utils.timecalc.swing.progress.ProgressMoney;
@ -40,8 +40,8 @@ import org.nanoboot.utils.timecalc.swing.progress.ProgressSwing;
import org.nanoboot.utils.timecalc.swing.progress.weather.ProgressWeather;
import org.nanoboot.utils.timecalc.swing.progress.Time;
import org.nanoboot.utils.timecalc.swing.progress.WalkingHumanProgress;
import org.nanoboot.utils.timecalc.swing.progress.WeekBattery;
import org.nanoboot.utils.timecalc.swing.progress.YearBattery;
import org.nanoboot.utils.timecalc.swing.progress.battery.WeekBattery;
import org.nanoboot.utils.timecalc.swing.progress.battery.YearBattery;
import org.nanoboot.utils.timecalc.utils.common.Constants;
import org.nanoboot.utils.timecalc.utils.common.DateFormats;
import org.nanoboot.utils.timecalc.utils.common.FileConstants;
@ -682,8 +682,8 @@ public class MainWindow extends TWindow {
.bindTo(timeCalcConfiguration.clockCircleBorderColorProperty);
clock.handsColoredProperty
.bindTo(timeCalcConfiguration.clockHandsColoredProperty);
clock.centreCircleBlackProperty
.bindTo(timeCalcConfiguration.clockCentreCircleBlackProperty);
clock.centreCircleColoredProperty
.bindTo(timeCalcConfiguration.clockCentreCircleColoredProperty);
clock.progressVisibleOnlyIfMouseMovingOverProperty
.bindTo(timeCalcConfiguration.clockProgressVisibleOnlyIfMouseMovingOverProperty);
clock.dateVisibleOnlyIfMouseMovingOverProperty
@ -893,7 +893,11 @@ public class MainWindow extends TWindow {
new Timer(100, e -> {
IntegerProperty speed = timeCalcConfiguration.speedProperty;
if (speed.getValue() == Integer.MIN_VALUE) {
timeCalcConfiguration.speedProperty.setValue(Integer.MAX_VALUE);
}
if (speed.getValue() == Integer.MAX_VALUE) {
//timeCalcConfiguration.testEnabledProperty.setValue(false);
if (timeCalcConfiguration.speedFloatingProperty.isEnabled()) {
speed.setValue(0);
@ -1437,7 +1441,7 @@ public class MainWindow extends TWindow {
public void increaseSpeed() {
IntegerProperty speed = timeCalcConfiguration.speedProperty;
if (speed.getValue() == Integer.MIN_VALUE) {
if (speed.getValue() == Integer.MIN_VALUE || speed.getValue() == Integer.MAX_VALUE) {
speed.setZero();
}
if (speed.getValue() == MAX_SPEED) {
@ -1449,7 +1453,7 @@ public class MainWindow extends TWindow {
public void decreaseSpeed() {
IntegerProperty speed = timeCalcConfiguration.speedProperty;
if (speed.getValue() == Integer.MIN_VALUE) {
if (speed.getValue() == Integer.MIN_VALUE || speed.getValue() == Integer.MAX_VALUE) {
speed.setZero();
}
if (speed.getValue() == MIN_SPEED) {
@ -1466,7 +1470,7 @@ public class MainWindow extends TWindow {
}
public void resetSpeed() {
timeCalcConfiguration.speedProperty.setValue(Integer.MIN_VALUE);
timeCalcConfiguration.speedProperty.setValue(Integer.MAX_VALUE);
}
public void enableFloatingTime() {

View File

@ -3,23 +3,23 @@ visibility.supported.colored=true
#
clock.visible=true
clock.hands.long.visible=true
clock.centre-circle.black=false
clock.centre-circle.colored=true
clock.hands.hour.visible=true
clock.hands.minute.visible=true
clock.hands.second.visible=true
clock.hands.millisecond.visible=false
clock.border.visible=false
clock.hands.millisecond.visible=true
clock.border.visible=true
clock.border.only-hours=false
clock.numbers.visible=true
clock.circle.visible=true
clock.circle.strong-border=false
clock.circle.border-color=0,0,0
clock.circle.border-color=0,0,255
clock.centre-circle.visible=true
clock.hands.colored=true
clock.progress.visible-only-if-mouse-moving-over=true
clock.date.visible-only-if-mouse-moving-over=true
clock.smiley.visible=false
clock.percent-progress.visible=false
clock.progress.visible-only-if-mouse-moving-over=false
clock.date.visible-only-if-mouse-moving-over=false
clock.smiley.visible=true
clock.percent-progress.visible=true
clock.circle-progress.visible=true
clock.hidden=false
#
@ -50,7 +50,7 @@ jokes.visible=true
commands.visible=true
notifications.visible=true
smileys.visible=true
smileys.visible-only-if-mouse-moving-over=true
smileys.visible-only-if-mouse-moving-over=false
smileys.colored=true
square.visible=true
square.type=day
@ -65,15 +65,15 @@ swing.visible=true
swing.type=day
swing.hidden=false
swing.quarter-icon.visible=true
life.visible=false
life.visible=true
life.type=day
life.hidden=false
life.birth-date=
money.visible=false
life.birth-date=2000-01-01
money.visible=true
money.type=day
money.hidden=false
money.per-month=0
money.currency=
money.per-month=1000000
money.currency=$T
weather.visible=true
weather.hidden=false
walking-human.visible=true