mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-28 00:25:22 +01:00
Formatted code
This commit is contained in:
parent
5a9e7fbf86
commit
5c67a2da5b
modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc
@ -2,7 +2,6 @@ package org.nanoboot.utils.timecalc.app;
|
|||||||
|
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.Toaster;
|
import org.nanoboot.utils.timecalc.swing.common.Toaster;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
@ -20,7 +19,8 @@ public class CommandActionListener
|
|||||||
private final TimeCalcApp timeCalcApp;
|
private final TimeCalcApp timeCalcApp;
|
||||||
private final TimeCalcConfiguration timeCalcConfiguration;
|
private final TimeCalcConfiguration timeCalcConfiguration;
|
||||||
|
|
||||||
public CommandActionListener(TimeCalcApp timeCalcApp, TimeCalcConfiguration timeCalcConfiguration) {
|
public CommandActionListener(TimeCalcApp timeCalcApp,
|
||||||
|
TimeCalcConfiguration timeCalcConfiguration) {
|
||||||
this.timeCalcApp = timeCalcApp;
|
this.timeCalcApp = timeCalcApp;
|
||||||
this.timeCalcConfiguration = timeCalcConfiguration;
|
this.timeCalcConfiguration = timeCalcConfiguration;
|
||||||
}
|
}
|
||||||
@ -75,7 +75,8 @@ public class CommandActionListener
|
|||||||
t.showToaster(commands.substring(6));
|
t.showToaster(commands.substring(6));
|
||||||
break;
|
break;
|
||||||
case "toasts":
|
case "toasts":
|
||||||
timeCalcConfiguration.notificationsVisibleProperty.setValue(commandsAsArray[1].equals("1"));
|
timeCalcConfiguration.notificationsVisibleProperty
|
||||||
|
.setValue(commandsAsArray[1].equals("1"));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
JOptionPane.showMessageDialog(null,
|
JOptionPane.showMessageDialog(null,
|
||||||
|
@ -16,7 +16,8 @@ import java.util.Properties;
|
|||||||
*/
|
*/
|
||||||
public class TimeCalcConfiguration {
|
public class TimeCalcConfiguration {
|
||||||
|
|
||||||
public final StringProperty visibilityDefaultProperty = new StringProperty(TimeCalcProperty.VISIBILITY_DEFAULT
|
public final StringProperty visibilityDefaultProperty =
|
||||||
|
new StringProperty(TimeCalcProperty.VISIBILITY_DEFAULT
|
||||||
.getKey());
|
.getKey());
|
||||||
public final BooleanProperty visibilitySupportedColoredProperty
|
public final BooleanProperty visibilitySupportedColoredProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.VISIBILITY_SUPPORTED_COLORED
|
= new BooleanProperty(TimeCalcProperty.VISIBILITY_SUPPORTED_COLORED
|
||||||
@ -32,7 +33,8 @@ public class TimeCalcConfiguration {
|
|||||||
= new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_COLORED
|
= new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_COLORED
|
||||||
.getKey());
|
.getKey());
|
||||||
public final BooleanProperty clockHandsHourVisibleProperty
|
public final BooleanProperty clockHandsHourVisibleProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_HOUR_VISIBLE.getKey());
|
= 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());
|
||||||
@ -40,7 +42,8 @@ public class TimeCalcConfiguration {
|
|||||||
= new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_SECOND_VISIBLE
|
= new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_SECOND_VISIBLE
|
||||||
.getKey());
|
.getKey());
|
||||||
public final BooleanProperty clockHandsMillisecondVisibleProperty
|
public final BooleanProperty clockHandsMillisecondVisibleProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_MILLISECOND_VISIBLE
|
=
|
||||||
|
new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_MILLISECOND_VISIBLE
|
||||||
.getKey());
|
.getKey());
|
||||||
public final BooleanProperty clockBorderVisibleProperty
|
public final BooleanProperty clockBorderVisibleProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_VISIBLE
|
= new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_VISIBLE
|
||||||
@ -67,24 +70,30 @@ public class TimeCalcConfiguration {
|
|||||||
public final BooleanProperty clockCentreCircleBlackProperty
|
public final BooleanProperty clockCentreCircleBlackProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK
|
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK
|
||||||
.getKey());
|
.getKey());
|
||||||
public final BooleanProperty clockProgressVisibleOnlyIfMouseMovingOverProperty
|
public final BooleanProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
|
clockProgressVisibleOnlyIfMouseMovingOverProperty
|
||||||
|
= new BooleanProperty(
|
||||||
|
TimeCalcProperty.CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
|
||||||
.getKey());
|
.getKey());
|
||||||
public final BooleanProperty clockDateVisibleOnlyIfMouseMovingOverProperty
|
public final BooleanProperty clockDateVisibleOnlyIfMouseMovingOverProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
|
= new BooleanProperty(
|
||||||
|
TimeCalcProperty.CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
|
||||||
.getKey());
|
.getKey());
|
||||||
//
|
//
|
||||||
public final BooleanProperty batteryWavesVisibleProperty
|
public final BooleanProperty batteryWavesVisibleProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE
|
= new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE
|
||||||
.getKey());
|
.getKey());
|
||||||
public final BooleanProperty batteryCircleProgressProperty
|
public final BooleanProperty batteryCircleProgressProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE
|
=
|
||||||
|
new BooleanProperty(TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE
|
||||||
.getKey());
|
.getKey());
|
||||||
public final BooleanProperty batteryPercentProgressProperty
|
public final BooleanProperty batteryPercentProgressProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.BATTERY_PERCENT_PROGRESS_VISIBLE
|
= new BooleanProperty(
|
||||||
|
TimeCalcProperty.BATTERY_PERCENT_PROGRESS_VISIBLE
|
||||||
.getKey());
|
.getKey());
|
||||||
public final BooleanProperty batteryChargingCharacterVisibleProperty
|
public final BooleanProperty batteryChargingCharacterVisibleProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.BATTERY_CHARGING_CHARACTER_VISIBLE
|
= new BooleanProperty(
|
||||||
|
TimeCalcProperty.BATTERY_CHARGING_CHARACTER_VISIBLE
|
||||||
.getKey());
|
.getKey());
|
||||||
public final BooleanProperty batteryNameVisibleProperty
|
public final BooleanProperty batteryNameVisibleProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.BATTERY_NAME_VISIBLE
|
= new BooleanProperty(TimeCalcProperty.BATTERY_NAME_VISIBLE
|
||||||
@ -114,7 +123,8 @@ public class TimeCalcConfiguration {
|
|||||||
= new BooleanProperty(TimeCalcProperty.BATTERY_YEAR_VISIBLE
|
= new BooleanProperty(TimeCalcProperty.BATTERY_YEAR_VISIBLE
|
||||||
.getKey());
|
.getKey());
|
||||||
public final BooleanProperty batteryBlinkingIfCriticalLowVisibleProperty
|
public final BooleanProperty batteryBlinkingIfCriticalLowVisibleProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW
|
= new BooleanProperty(
|
||||||
|
TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW
|
||||||
.getKey());
|
.getKey());
|
||||||
|
|
||||||
public final BooleanProperty jokesVisibleProperty
|
public final BooleanProperty jokesVisibleProperty
|
||||||
@ -129,7 +139,9 @@ public class TimeCalcConfiguration {
|
|||||||
public final BooleanProperty smileysVisibleProperty
|
public final BooleanProperty smileysVisibleProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.SMILEYS_VISIBLE.getKey());
|
= new BooleanProperty(TimeCalcProperty.SMILEYS_VISIBLE.getKey());
|
||||||
public final BooleanProperty smileysVisibleOnlyIfMouseMovingOverProperty
|
public final BooleanProperty smileysVisibleOnlyIfMouseMovingOverProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.SMILEYS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER.getKey());
|
= new BooleanProperty(
|
||||||
|
TimeCalcProperty.SMILEYS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
|
||||||
|
.getKey());
|
||||||
public final BooleanProperty smileysColoredProperty
|
public final BooleanProperty smileysColoredProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.SMILEYS_COLORED.getKey());
|
= new BooleanProperty(TimeCalcProperty.SMILEYS_COLORED.getKey());
|
||||||
|
|
||||||
@ -138,14 +150,17 @@ public class TimeCalcConfiguration {
|
|||||||
public final BooleanProperty circleVisibleProperty
|
public final BooleanProperty circleVisibleProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.CIRCLE_VISIBLE.getKey());
|
= new BooleanProperty(TimeCalcProperty.CIRCLE_VISIBLE.getKey());
|
||||||
public final BooleanProperty walkingHumanVisibleProperty
|
public final BooleanProperty walkingHumanVisibleProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.WALKING_HUMAN_VISIBLE.getKey());
|
= new BooleanProperty(
|
||||||
|
TimeCalcProperty.WALKING_HUMAN_VISIBLE.getKey());
|
||||||
public final StringProperty mainWindowCustomTitleProperty
|
public final StringProperty mainWindowCustomTitleProperty
|
||||||
= new StringProperty(TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE.getKey());
|
= new StringProperty(
|
||||||
|
TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE.getKey());
|
||||||
public final StringProperty profileNameProperty
|
public final StringProperty profileNameProperty
|
||||||
= new StringProperty(TimeCalcProperty.PROFILE_NAME.getKey());
|
= new StringProperty(TimeCalcProperty.PROFILE_NAME.getKey());
|
||||||
|
|
||||||
private final Map<TimeCalcProperty, Property> mapOfProperties = new HashMap<>();
|
private final Map<TimeCalcProperty, Property> mapOfProperties =
|
||||||
private List<Property> allProperties = new ArrayList<>();
|
new HashMap<>();
|
||||||
|
private final List<Property> allProperties = new ArrayList<>();
|
||||||
private TimeCalcProperties timeCalcProperties;
|
private TimeCalcProperties timeCalcProperties;
|
||||||
|
|
||||||
public TimeCalcConfiguration() {
|
public TimeCalcConfiguration() {
|
||||||
@ -197,21 +212,29 @@ public class TimeCalcConfiguration {
|
|||||||
}) {
|
}) {
|
||||||
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));
|
||||||
batteryVisibleProperty.addListener(e -> {
|
batteryVisibleProperty.addListener(e -> {
|
||||||
|
|
||||||
batteryMinuteVisibleProperty.setValue(batteryVisibleProperty.getValue());
|
batteryMinuteVisibleProperty
|
||||||
batteryHourVisibleProperty.setValue(batteryVisibleProperty.getValue());
|
.setValue(batteryVisibleProperty.getValue());
|
||||||
batteryDayVisibleProperty.setValue(batteryVisibleProperty.getValue());
|
batteryHourVisibleProperty
|
||||||
batteryWeekVisibleProperty.setValue(batteryVisibleProperty.getValue());
|
.setValue(batteryVisibleProperty.getValue());
|
||||||
batteryMonthVisibleProperty.setValue(batteryVisibleProperty.getValue());
|
batteryDayVisibleProperty
|
||||||
batteryYearVisibleProperty.setValue(batteryVisibleProperty.getValue());
|
.setValue(batteryVisibleProperty.getValue());
|
||||||
|
batteryWeekVisibleProperty
|
||||||
|
.setValue(batteryVisibleProperty.getValue());
|
||||||
|
batteryMonthVisibleProperty
|
||||||
|
.setValue(batteryVisibleProperty.getValue());
|
||||||
|
batteryYearVisibleProperty
|
||||||
|
.setValue(batteryVisibleProperty.getValue());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Property getProperty(TimeCalcProperty timeCalcProperty) {
|
public Property getProperty(TimeCalcProperty timeCalcProperty) {
|
||||||
if (!mapOfProperties.containsKey(timeCalcProperty)) {
|
if (!mapOfProperties.containsKey(timeCalcProperty)) {
|
||||||
throw new TimeCalcException("There is no property for : " + timeCalcProperty);
|
throw new TimeCalcException(
|
||||||
|
"There is no property for : " + timeCalcProperty);
|
||||||
}
|
}
|
||||||
return mapOfProperties.get(timeCalcProperty);
|
return mapOfProperties.get(timeCalcProperty);
|
||||||
}
|
}
|
||||||
@ -219,11 +242,14 @@ public class TimeCalcConfiguration {
|
|||||||
public void saveToTimeCalcProperties() {
|
public void saveToTimeCalcProperties() {
|
||||||
System.out.println("Going to save properties.");
|
System.out.println("Going to save properties.");
|
||||||
if (timeCalcProperties == null) {
|
if (timeCalcProperties == null) {
|
||||||
throw new TimeCalcException("Cannot save properties, because timeCalcProperties is null.");
|
throw new TimeCalcException(
|
||||||
|
"Cannot save properties, because timeCalcProperties is null.");
|
||||||
}
|
}
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
this.allProperties.stream().forEach(p -> properties.put(p.getName(), p.getValue()));
|
this.allProperties.stream()
|
||||||
this.timeCalcProperties.save(properties, this.profileNameProperty.getValue());
|
.forEach(p -> properties.put(p.getName(), p.getValue()));
|
||||||
|
this.timeCalcProperties
|
||||||
|
.save(properties, this.profileNameProperty.getValue());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,19 +258,27 @@ public class TimeCalcConfiguration {
|
|||||||
this.timeCalcProperties = timeCalcProperties;
|
this.timeCalcProperties = timeCalcProperties;
|
||||||
for (Property p : allProperties) {
|
for (Property p : allProperties) {
|
||||||
if (p instanceof BooleanProperty) {
|
if (p instanceof BooleanProperty) {
|
||||||
((BooleanProperty) p).setValue(timeCalcProperties.getBooleanProperty(TimeCalcProperty.forKey(p.getName())));
|
p.setValue(timeCalcProperties
|
||||||
|
.getBooleanProperty(
|
||||||
|
TimeCalcProperty.forKey(p.getName())));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p.getName().equals(TimeCalcProperty.VISIBILITY_DEFAULT.name())) {
|
if (p.getName()
|
||||||
visibilityDefaultProperty.setValue(timeCalcProperties.getStringProperty(TimeCalcProperty.VISIBILITY_DEFAULT));
|
.equals(TimeCalcProperty.VISIBILITY_DEFAULT.name())) {
|
||||||
|
visibilityDefaultProperty.setValue(timeCalcProperties
|
||||||
|
.getStringProperty(
|
||||||
|
TimeCalcProperty.VISIBILITY_DEFAULT));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (p instanceof StringProperty) {
|
if (p instanceof StringProperty) {
|
||||||
((StringProperty) p).setValue(timeCalcProperties.getStringProperty(TimeCalcProperty.forKey(p.getName())));
|
p.setValue(timeCalcProperties
|
||||||
|
.getStringProperty(
|
||||||
|
TimeCalcProperty.forKey(p.getName())));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
throw new TimeCalcException("Unsupported Property class: " + p.getClass().getName());
|
throw new TimeCalcException(
|
||||||
|
"Unsupported Property class: " + p.getClass().getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
// for(Property p:allProperties) {
|
// for(Property p:allProperties) {
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package org.nanoboot.utils.timecalc.app;
|
package org.nanoboot.utils.timecalc.app;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
* @since 21.02.2024
|
* @since 21.02.2024
|
||||||
|
@ -52,9 +52,10 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
keyCode == KeyEvent.VK_8 ||
|
keyCode == KeyEvent.VK_8 ||
|
||||||
keyCode == KeyEvent.VK_9;
|
keyCode == KeyEvent.VK_9;
|
||||||
|
|
||||||
|
if (numberKeyWasPressed && !FileConstants.TIME_CALC_PROFILES_TXT_FILE
|
||||||
if(numberKeyWasPressed && !FileConstants.TIME_CALC_PROFILES_TXT_FILE.exists()) {
|
.exists()) {
|
||||||
Utils.showNotification("Warning: There is no profile assigned to Key with number, you pressed.");
|
Utils.showNotification(
|
||||||
|
"Warning: There is no profile assigned to Key with number, you pressed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
@ -209,57 +210,95 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
|
|
||||||
if (FileConstants.TIME_CALC_PROFILES_TXT_FILE.exists()) {
|
if (FileConstants.TIME_CALC_PROFILES_TXT_FILE.exists()) {
|
||||||
try {
|
try {
|
||||||
Utils.showNotification(Utils.readTextFromFile(FileConstants.TIME_CALC_PROFILES_TXT_FILE), 15000, 200);
|
Utils.showNotification(Utils.readTextFromFile(
|
||||||
|
FileConstants.TIME_CALC_PROFILES_TXT_FILE),
|
||||||
|
15000, 200);
|
||||||
} catch (IOException ioException) {
|
} catch (IOException ioException) {
|
||||||
ioException.printStackTrace();
|
ioException.printStackTrace();
|
||||||
Utils.showNotification("Error: " + ioException.getMessage());
|
Utils.showNotification(
|
||||||
|
"Error: " + ioException.getMessage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Utils.showNotification("Warning: There are no numbers assigned to profiles. Update file: " + FileConstants.TIME_CALC_PROFILES_TXT_FILE.getAbsolutePath() + ".");
|
Utils.showNotification(
|
||||||
|
"Warning: There are no numbers assigned to profiles. Update file: "
|
||||||
|
+ FileConstants.TIME_CALC_PROFILES_TXT_FILE
|
||||||
|
.getAbsolutePath() + ".");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_Q: {
|
case KeyEvent.VK_Q: {
|
||||||
timeCalcConfiguration.squareVisibleProperty.flip();break;
|
timeCalcConfiguration.squareVisibleProperty.flip();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_L: {
|
case KeyEvent.VK_L: {
|
||||||
timeCalcConfiguration.circleVisibleProperty.flip();break;
|
timeCalcConfiguration.circleVisibleProperty.flip();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_Y: {
|
case KeyEvent.VK_Y: {
|
||||||
timeCalcConfiguration.smileysVisibleOnlyIfMouseMovingOverProperty.flip();break;
|
timeCalcConfiguration.smileysVisibleOnlyIfMouseMovingOverProperty
|
||||||
|
.flip();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case KeyEvent.VK_M: {
|
case KeyEvent.VK_M: {
|
||||||
timeCalcConfiguration.walkingHumanVisibleProperty.flip();break;
|
timeCalcConfiguration.walkingHumanVisibleProperty.flip();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default: Utils.showNotification("Unsupported key was pressed. There is no key shortcut for this key.");
|
default:
|
||||||
|
Utils.showNotification(
|
||||||
|
"Unsupported key was pressed. There is no key shortcut for this key.");
|
||||||
|
|
||||||
}
|
}
|
||||||
if (numberKeyWasPressed && FileConstants.TIME_CALC_PROFILES_TXT_FILE.exists()) {
|
if (numberKeyWasPressed && FileConstants.TIME_CALC_PROFILES_TXT_FILE
|
||||||
|
.exists()) {
|
||||||
|
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
try {
|
try {
|
||||||
properties.load(new FileInputStream(FileConstants.TIME_CALC_PROFILES_TXT_FILE));
|
properties.load(new FileInputStream(
|
||||||
|
FileConstants.TIME_CALC_PROFILES_TXT_FILE));
|
||||||
} catch (IOException ioException) {
|
} catch (IOException ioException) {
|
||||||
ioException.printStackTrace();
|
ioException.printStackTrace();
|
||||||
}
|
}
|
||||||
int profileNumber = 0;
|
int profileNumber = 0;
|
||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
case KeyEvent.VK_0: profileNumber = 0;break;
|
case KeyEvent.VK_0:
|
||||||
case KeyEvent.VK_1: profileNumber = 1;break;
|
profileNumber = 0;
|
||||||
case KeyEvent.VK_2: profileNumber = 2;break;
|
break;
|
||||||
case KeyEvent.VK_3: profileNumber = 3;break;
|
case KeyEvent.VK_1:
|
||||||
case KeyEvent.VK_4: profileNumber = 4;break;
|
profileNumber = 1;
|
||||||
case KeyEvent.VK_5: profileNumber = 5;break;
|
break;
|
||||||
case KeyEvent.VK_6: profileNumber = 6;break;
|
case KeyEvent.VK_2:
|
||||||
case KeyEvent.VK_7: profileNumber = 7;break;
|
profileNumber = 2;
|
||||||
case KeyEvent.VK_8: profileNumber = 8;break;
|
break;
|
||||||
case KeyEvent.VK_9: profileNumber = 9;break;
|
case KeyEvent.VK_3:
|
||||||
|
profileNumber = 3;
|
||||||
|
break;
|
||||||
|
case KeyEvent.VK_4:
|
||||||
|
profileNumber = 4;
|
||||||
|
break;
|
||||||
|
case KeyEvent.VK_5:
|
||||||
|
profileNumber = 5;
|
||||||
|
break;
|
||||||
|
case KeyEvent.VK_6:
|
||||||
|
profileNumber = 6;
|
||||||
|
break;
|
||||||
|
case KeyEvent.VK_7:
|
||||||
|
profileNumber = 7;
|
||||||
|
break;
|
||||||
|
case KeyEvent.VK_8:
|
||||||
|
profileNumber = 8;
|
||||||
|
break;
|
||||||
|
case KeyEvent.VK_9:
|
||||||
|
profileNumber = 9;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
String key = String.valueOf(profileNumber);
|
String key = String.valueOf(profileNumber);
|
||||||
if (properties.containsKey(key)) {
|
if (properties.containsKey(key)) {
|
||||||
String profileName = (String) properties.get(key);
|
String profileName = (String) properties.get(key);
|
||||||
if(profileName.equals( timeCalcConfiguration.profileNameProperty)) {
|
if (profileName
|
||||||
Utils.showNotification("Profile \"" + profileName + "\" is already active. Nothing to do", 5000);
|
.equals(timeCalcConfiguration.profileNameProperty)) {
|
||||||
|
Utils.showNotification("Profile \"" + profileName
|
||||||
|
+ "\" is already active. Nothing to do",
|
||||||
|
5000);
|
||||||
} else {
|
} else {
|
||||||
Utils.showNotification("Info: Changing profile to: " + ((
|
Utils.showNotification("Info: Changing profile to: " + ((
|
||||||
profileName.isEmpty() ? "{Default profile}" :
|
profileName.isEmpty() ? "{Default profile}" :
|
||||||
@ -270,11 +309,12 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Utils.showNotification("Warning: There is no profile assigned to Key " + profileNumber, 5000);
|
Utils.showNotification(
|
||||||
|
"Warning: There is no profile assigned to Key "
|
||||||
|
+ profileNumber, 5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
window.repaint();
|
window.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ import java.util.Properties;
|
|||||||
*/
|
*/
|
||||||
public class TimeCalcProperties {
|
public class TimeCalcProperties {
|
||||||
|
|
||||||
|
|
||||||
private static TimeCalcProperties INSTANCE;
|
private static TimeCalcProperties INSTANCE;
|
||||||
|
|
||||||
private final Properties properties = new Properties();
|
private final Properties properties = new Properties();
|
||||||
@ -29,8 +28,11 @@ public class TimeCalcProperties {
|
|||||||
System.out.println("Loading configuration - start");
|
System.out.println("Loading configuration - start");
|
||||||
String profileName = "";
|
String profileName = "";
|
||||||
try {
|
try {
|
||||||
profileName = FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE.exists() ? Utils.readTextFromFile(
|
profileName =
|
||||||
FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE) : "";
|
FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE.exists() ?
|
||||||
|
Utils.readTextFromFile(
|
||||||
|
FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE) :
|
||||||
|
"";
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new TimeCalcException(e);
|
throw new TimeCalcException(e);
|
||||||
@ -55,7 +57,8 @@ public class TimeCalcProperties {
|
|||||||
.filter(l -> l.contains("="))
|
.filter(l -> l.contains("="))
|
||||||
.forEach(l -> {
|
.forEach(l -> {
|
||||||
String[] array = l.split("=");
|
String[] array = l.split("=");
|
||||||
defaultProperties.put(array[0], array.length > 1 ? array[1] : "");
|
defaultProperties.put(array[0],
|
||||||
|
array.length > 1 ? array[1] : "");
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -81,8 +84,11 @@ public class TimeCalcProperties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getDefaultStringValue(TimeCalcProperty timeCalcProperty) {
|
private String getDefaultStringValue(TimeCalcProperty timeCalcProperty) {
|
||||||
if (!defaultProperties.containsKey((String) timeCalcProperty.getKey())) {
|
if (!defaultProperties
|
||||||
throw new TimeCalcException("timecalc-default.conf is missing key: \"" + timeCalcProperty.getKey() + "\"");
|
.containsKey(timeCalcProperty.getKey())) {
|
||||||
|
throw new TimeCalcException(
|
||||||
|
"timecalc-default.conf is missing key: \""
|
||||||
|
+ timeCalcProperty.getKey() + "\"");
|
||||||
}
|
}
|
||||||
return defaultProperties.get(timeCalcProperty.getKey());
|
return defaultProperties.get(timeCalcProperty.getKey());
|
||||||
}
|
}
|
||||||
@ -97,7 +103,8 @@ public class TimeCalcProperties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getStringProperty(TimeCalcProperty timeCalcProperty) {
|
public String getStringProperty(TimeCalcProperty timeCalcProperty) {
|
||||||
return getStringProperty(timeCalcProperty, getDefaultStringValue(timeCalcProperty));
|
return getStringProperty(timeCalcProperty,
|
||||||
|
getDefaultStringValue(timeCalcProperty));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getStringProperty(TimeCalcProperty timeCalcProperty,
|
private String getStringProperty(TimeCalcProperty timeCalcProperty,
|
||||||
@ -110,7 +117,8 @@ public class TimeCalcProperties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getVisibilityProperty(TimeCalcProperty timeCalcProperty) {
|
private String getVisibilityProperty(TimeCalcProperty timeCalcProperty) {
|
||||||
return getStringProperty(timeCalcProperty, Visibility.STRONGLY_COLORED.name());
|
return getStringProperty(timeCalcProperty,
|
||||||
|
Visibility.STRONGLY_COLORED.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBooleanProperty(TimeCalcProperty timeCalcProperty,
|
private void setBooleanProperty(TimeCalcProperty timeCalcProperty,
|
||||||
@ -153,19 +161,22 @@ public class TimeCalcProperties {
|
|||||||
"Saving to " + file + " failed: " + e.getMessage());
|
"Saving to " + file + " failed: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.writeTextToFile(FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE, profileName);
|
Utils.writeTextToFile(FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE,
|
||||||
|
profileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getFile(String profileName) {
|
private File getFile(String profileName) {
|
||||||
return profileName == null || profileName.isEmpty() ?
|
return profileName == null || profileName.isEmpty() ?
|
||||||
FileConstants.FILE_WITHOUT_ANY_PROFILE :
|
FileConstants.FILE_WITHOUT_ANY_PROFILE :
|
||||||
new File(FileConstants.FILE_WITHOUT_ANY_PROFILE.getParentFile(), "timecalc." + profileName + ".conf");
|
new File(FileConstants.FILE_WITHOUT_ANY_PROFILE.getParentFile(),
|
||||||
|
"timecalc." + profileName + ".conf");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadProfile(String profileName) {
|
public void loadProfile(String profileName) {
|
||||||
File file = getFile(profileName);
|
File file = getFile(profileName);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
Utils.showNotification("There is no profile with name: " + profileName);
|
Utils.showNotification(
|
||||||
|
"There is no profile with name: " + profileName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -12,33 +12,49 @@ import java.util.Optional;
|
|||||||
*/
|
*/
|
||||||
public enum TimeCalcProperty {
|
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.visible", "Clock"),
|
CLOCK_VISIBLE("clock.visible", "Clock"),
|
||||||
CLOCK_HANDS_LONG_VISIBLE("clock.hands.long.visible", "Clock : Long Hands"),
|
CLOCK_HANDS_LONG_VISIBLE("clock.hands.long.visible", "Clock : Long Hands"),
|
||||||
CLOCK_HANDS_COLORED("clock.hands.colored", "Clock : Colored Hands"),
|
CLOCK_HANDS_COLORED("clock.hands.colored", "Clock : Colored Hands"),
|
||||||
CLOCK_HANDS_HOUR_VISIBLE("clock.hands.hour.visible", "Clock : Hour hand"),
|
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_HANDS_SECOND_VISIBLE("clock.hands.second.visible", "Clock : Second hand"),
|
"Clock : Minute hand"),
|
||||||
CLOCK_HANDS_MILLISECOND_VISIBLE("clock.hands.millisecond.visible", "Clock : Millisecond hand"),
|
CLOCK_HANDS_SECOND_VISIBLE("clock.hands.second.visible",
|
||||||
|
"Clock : Second hand"),
|
||||||
|
CLOCK_HANDS_MILLISECOND_VISIBLE("clock.hands.millisecond.visible",
|
||||||
|
"Clock : Millisecond hand"),
|
||||||
CLOCK_BORDER_VISIBLE("clock.border.visible", "Clock : Border"),
|
CLOCK_BORDER_VISIBLE("clock.border.visible", "Clock : Border"),
|
||||||
CLOCK_BORDER_ONLY_HOURS("clock.border.only-hours", "Clock : Border : Only hours"),
|
CLOCK_BORDER_ONLY_HOURS("clock.border.only-hours",
|
||||||
|
"Clock : Border : Only hours"),
|
||||||
CLOCK_NUMBERS_VISIBLE("clock.numbers.visible", "Clock : Numbers"),
|
CLOCK_NUMBERS_VISIBLE("clock.numbers.visible", "Clock : Numbers"),
|
||||||
CLOCK_CIRCLE_VISIBLE("clock.circle.visible", "Clock : Circle"),
|
CLOCK_CIRCLE_VISIBLE("clock.circle.visible", "Clock : Circle"),
|
||||||
CLOCK_CIRCLE_STRONG_BORDER("clock.circle.strong-border", "Clock : Circle : Strong border"),
|
CLOCK_CIRCLE_STRONG_BORDER("clock.circle.strong-border",
|
||||||
CLOCK_CIRCLE_BORDER_COLOR("clock.circle.border-color", "Clock : Circle : Border color",
|
"Clock : Circle : Strong border"),
|
||||||
|
CLOCK_CIRCLE_BORDER_COLOR("clock.circle.border-color",
|
||||||
|
"Clock : Circle : Border color",
|
||||||
Color.class),
|
Color.class),
|
||||||
CLOCK_CENTRE_CIRCLE_VISIBLE("clock.centre-circle.visible", "Clock : Centre circle"),
|
CLOCK_CENTRE_CIRCLE_VISIBLE("clock.centre-circle.visible",
|
||||||
CLOCK_CENTRE_CIRCLE_BLACK("clock.centre-circle.black", "Clock : Centre Circle is black"),
|
"Clock : Centre circle"),
|
||||||
CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER("clock.progress.visible-only-if-mouse-moving-over", "Clock : Progress visible only, if mouse moving over"),
|
CLOCK_CENTRE_CIRCLE_BLACK("clock.centre-circle.black",
|
||||||
CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER("clock.date.visible-only-if-mouse-moving-over", "Clock : Date visible only, if mouse moving over"),
|
"Clock : Centre Circle is black"),
|
||||||
|
CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER(
|
||||||
|
"clock.progress.visible-only-if-mouse-moving-over",
|
||||||
|
"Clock : Progress visible only, if mouse moving over"),
|
||||||
|
CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER(
|
||||||
|
"clock.date.visible-only-if-mouse-moving-over",
|
||||||
|
"Clock : Date visible only, if mouse moving over"),
|
||||||
|
|
||||||
//
|
//
|
||||||
BATTERY_WAVES_VISIBLE("battery.waves.visible", "Battery : Waves"),
|
BATTERY_WAVES_VISIBLE("battery.waves.visible", "Battery : Waves"),
|
||||||
BATTERY_CIRCLE_PROGRESS_VISIBLE("battery.circle-progress.visible", "Battery : Circle Progress"),
|
BATTERY_CIRCLE_PROGRESS_VISIBLE("battery.circle-progress.visible",
|
||||||
BATTERY_PERCENT_PROGRESS_VISIBLE("battery.percent-progress.visible", "Battery : Percent Progress"),
|
"Battery : Circle Progress"),
|
||||||
|
BATTERY_PERCENT_PROGRESS_VISIBLE("battery.percent-progress.visible",
|
||||||
|
"Battery : Percent Progress"),
|
||||||
|
|
||||||
BATTERY_CHARGING_CHARACTER_VISIBLE("battery.charging-character.visible", "Battery : Charging Character"),
|
BATTERY_CHARGING_CHARACTER_VISIBLE("battery.charging-character.visible",
|
||||||
|
"Battery : Charging Character"),
|
||||||
BATTERY_NAME_VISIBLE("battery.name.visible", "Battery : Name"),
|
BATTERY_NAME_VISIBLE("battery.name.visible", "Battery : Name"),
|
||||||
BATTERY_LABEL_VISIBLE("battery.label.visible", "Battery : Label"),
|
BATTERY_LABEL_VISIBLE("battery.label.visible", "Battery : Label"),
|
||||||
|
|
||||||
@ -49,20 +65,23 @@ public enum TimeCalcProperty {
|
|||||||
BATTERY_WEEK_VISIBLE("battery.week.visible", "Battery : Week"),
|
BATTERY_WEEK_VISIBLE("battery.week.visible", "Battery : Week"),
|
||||||
BATTERY_MONTH_VISIBLE("battery.month.visible", "Battery : Month"),
|
BATTERY_MONTH_VISIBLE("battery.month.visible", "Battery : Month"),
|
||||||
BATTERY_YEAR_VISIBLE("battery.year.visible", "Battery : Year"),
|
BATTERY_YEAR_VISIBLE("battery.year.visible", "Battery : Year"),
|
||||||
BATTERY_BLINKING_IF_CRITICAL_LOW("battery.blinking-if-critical-low", "Battery : Blinking, if critical low"),
|
BATTERY_BLINKING_IF_CRITICAL_LOW("battery.blinking-if-critical-low",
|
||||||
|
"Battery : Blinking, if critical low"),
|
||||||
|
|
||||||
JOKES_VISIBLE("jokes.visible", "Jokes"),
|
JOKES_VISIBLE("jokes.visible", "Jokes"),
|
||||||
COMMANDS_VISIBLE("commands.visible", "Commands"),
|
COMMANDS_VISIBLE("commands.visible", "Commands"),
|
||||||
NOTIFICATIONS_VISIBLE("notifications.visible", "Notifications"),
|
NOTIFICATIONS_VISIBLE("notifications.visible", "Notifications"),
|
||||||
SMILEYS_VISIBLE("smileys.visible", "Smileys"),
|
SMILEYS_VISIBLE("smileys.visible", "Smileys"),
|
||||||
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"),
|
CIRCLE_VISIBLE("circle.visible", "Circle"),
|
||||||
WALKING_HUMAN_VISIBLE("walking-human.visible", "Walking Human"),
|
WALKING_HUMAN_VISIBLE("walking-human.visible", "Walking Human"),
|
||||||
MAIN_WINDOW_CUSTOM_TITLE("main-window.custom-title", "Main Window : Custom Title"),
|
MAIN_WINDOW_CUSTOM_TITLE("main-window.custom-title",
|
||||||
|
"Main Window : Custom Title"),
|
||||||
PROFILE_NAME("profile.name", "Profile : Name");
|
PROFILE_NAME("profile.name", "Profile : Name");
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ -72,18 +91,6 @@ public enum TimeCalcProperty {
|
|||||||
@Getter
|
@Getter
|
||||||
private final Class clazz;
|
private final Class clazz;
|
||||||
|
|
||||||
public static TimeCalcProperty forKey(String key) {
|
|
||||||
Optional<TimeCalcProperty> timeCalcPropertyOptional = Arrays.stream(values()).filter(t -> t.getKey().equals(key)).findFirst();
|
|
||||||
if (timeCalcPropertyOptional.isPresent()) {
|
|
||||||
return timeCalcPropertyOptional.get();
|
|
||||||
} else {
|
|
||||||
TimeCalcException e
|
|
||||||
= new TimeCalcException("There is no key: " + key);
|
|
||||||
e.printStackTrace();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TimeCalcProperty(String key, String description, Class clazz) {
|
TimeCalcProperty(String key, String description, Class clazz) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
@ -94,4 +101,18 @@ public enum TimeCalcProperty {
|
|||||||
this(key, description, Boolean.class);
|
this(key, description, Boolean.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TimeCalcProperty forKey(String key) {
|
||||||
|
Optional<TimeCalcProperty> timeCalcPropertyOptional =
|
||||||
|
Arrays.stream(values()).filter(t -> t.getKey().equals(key))
|
||||||
|
.findFirst();
|
||||||
|
if (timeCalcPropertyOptional.isPresent()) {
|
||||||
|
return timeCalcPropertyOptional.get();
|
||||||
|
} else {
|
||||||
|
TimeCalcException e
|
||||||
|
= new TimeCalcException("There is no key: " + key);
|
||||||
|
e.printStackTrace();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,10 @@ public class Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String createBugzillaComment() {
|
public String createBugzillaComment() {
|
||||||
return ticket + SUBJECT_FIELD_SEPARATOR + year + "-" + month + "-" + day + SUBJECT_FIELD_SEPARATOR + ((spentHours + spentMinutes / 60d) + "h") + SUBJECT_FIELD_SEPARATOR + comment;
|
return ticket + SUBJECT_FIELD_SEPARATOR + year + "-" + month + "-" + day
|
||||||
|
+ SUBJECT_FIELD_SEPARATOR + ((spentHours + spentMinutes / 60d)
|
||||||
|
+ "h") + SUBJECT_FIELD_SEPARATOR
|
||||||
|
+ comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
1
modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/ComponentRegistry.java
1
modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/ComponentRegistry.java
@ -29,6 +29,7 @@ public class ComponentRegistry<T extends Component> {
|
|||||||
add(c);
|
add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVisible(boolean b) {
|
public void setVisible(boolean b) {
|
||||||
setVisible(null, b);
|
setVisible(null, b);
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,20 @@ import org.nanoboot.utils.timecalc.entity.Visibility;
|
|||||||
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
import org.nanoboot.utils.timecalc.utils.property.StringProperty;
|
||||||
|
|
||||||
|
import javax.swing.Box;
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JColorChooser;
|
import javax.swing.JColorChooser;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JSeparator;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.event.DocumentEvent;
|
||||||
|
import javax.swing.event.DocumentListener;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
@ -24,15 +33,6 @@ 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.JTextField;
|
|
||||||
import javax.swing.SwingConstants;
|
|
||||||
import javax.swing.event.DocumentEvent;
|
|
||||||
import javax.swing.event.DocumentListener;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
@ -42,123 +42,150 @@ public class ConfigWindow extends TWindow {
|
|||||||
|
|
||||||
public static final int WIDTH1 = 600;
|
public static final int WIDTH1 = 600;
|
||||||
public static final int HEIGHT1 = 30;
|
public static final int HEIGHT1 = 30;
|
||||||
public static final String CLIENT_PROPERTY_KEY = TimeCalcProperty.class.getName();
|
public static final String CLIENT_PROPERTY_KEY =
|
||||||
|
TimeCalcProperty.class.getName();
|
||||||
public static final String THREE_DASHES = "---";
|
public static final String THREE_DASHES = "---";
|
||||||
private final TimeCalcConfiguration timeCalcConfiguration;
|
private static final Font BIG_FONT = new Font("sans", Font.BOLD, 24);
|
||||||
private int currentY = SwingUtils.MARGIN;
|
private static final String FIVE_SPACES = " ";
|
||||||
private List<JComponent> propertiesList = new ArrayList<>();
|
public final JComboBox visibilityDefaultProperty = new JComboBox(
|
||||||
private Map<TimeCalcProperty, JComponent> propertiesMap = new HashMap<>();
|
Arrays.stream(Visibility.values()).map(v -> v.name()).collect(
|
||||||
private TButton enableAsMuchAsPossible = new TButton("Enable as much as possible");
|
|
||||||
private TButton disableAsMuchAsPossible = new TButton("Disable as much as possible");
|
|
||||||
public final JComboBox visibilityDefaultProperty = new JComboBox(Arrays.stream(Visibility.values()).map(v -> v.name()).collect(
|
|
||||||
Collectors.toList()).toArray());
|
Collectors.toList()).toArray());
|
||||||
|
private final TimeCalcConfiguration timeCalcConfiguration;
|
||||||
private JCheckBox visibilitySupportedColoredProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.VISIBILITY_SUPPORTED_COLORED.getKey());
|
|
||||||
private JCheckBox clockVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.CLOCK_VISIBLE.getKey());
|
|
||||||
private JCheckBox clockHandsLongVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.CLOCK_HANDS_LONG_VISIBLE.getKey());
|
|
||||||
private JCheckBox clockHandsColoredProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.CLOCK_HANDS_COLORED.getKey());
|
|
||||||
private JCheckBox clockHandsHourVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.CLOCK_HANDS_HOUR_VISIBLE.getKey());
|
|
||||||
private JCheckBox clockHandsMinuteVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.CLOCK_HANDS_MINUTE_VISIBLE.getKey());
|
|
||||||
private JCheckBox clockHandsSecondVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.CLOCK_HANDS_SECOND_VISIBLE.getKey());
|
|
||||||
private JCheckBox clockHandsMillisecondVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.CLOCK_HANDS_MILLISECOND_VISIBLE.getKey());
|
|
||||||
private JCheckBox clockBorderVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.CLOCK_BORDER_VISIBLE.getKey());
|
|
||||||
private JCheckBox clockBorderOnlyHoursProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.CLOCK_BORDER_ONLY_HOURS.getKey());
|
|
||||||
|
|
||||||
private JCheckBox clockNumbersVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.CLOCK_NUMBERS_VISIBLE.getKey());
|
|
||||||
private JCheckBox clockCircleVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.CLOCK_CIRCLE_VISIBLE.getKey());
|
|
||||||
private JCheckBox clockCircleStrongBorderProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.CLOCK_CIRCLE_STRONG_BORDER.getKey());
|
|
||||||
private JColorChooser clockCircleBorderColorProperty
|
|
||||||
= new JColorChooser(Color.BLACK);
|
|
||||||
private JCheckBox clockCentreCircleVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_VISIBLE.getKey());
|
|
||||||
private JCheckBox clockCentreCircleBlackProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK.getKey());
|
|
||||||
private JCheckBox clockProgressVisibleOnlyIfMouseMovingOverProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER.getKey());
|
|
||||||
private JCheckBox clockDateVisibleOnlyIfMouseMovingOverProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER.getKey());
|
|
||||||
|
|
||||||
//
|
|
||||||
private JCheckBox batteryWavesVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.BATTERY_WAVES_VISIBLE.getKey());
|
|
||||||
private JCheckBox batteryCircleProgressVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE.getKey());
|
|
||||||
private JCheckBox batteryPercentProgressProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.BATTERY_PERCENT_PROGRESS_VISIBLE.getKey());
|
|
||||||
|
|
||||||
private JCheckBox batteryChargingCharacterVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.BATTERY_CHARGING_CHARACTER_VISIBLE.getKey());
|
|
||||||
private JCheckBox batteryNameVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.BATTERY_NAME_VISIBLE.getKey());
|
|
||||||
private JCheckBox batteryLabelVisibleProperty = new JCheckBox(TimeCalcProperty.BATTERY_LABEL_VISIBLE.getKey());
|
|
||||||
|
|
||||||
|
|
||||||
private JCheckBox batteryVisibleProperty = new JCheckBox(TimeCalcProperty.BATTERY_VISIBLE.getKey());
|
|
||||||
private JCheckBox batteryMinuteVisibleProperty = new JCheckBox(TimeCalcProperty.BATTERY_MINUTE_VISIBLE.getKey());
|
|
||||||
private JCheckBox batteryHourVisibleProperty = new JCheckBox(TimeCalcProperty.BATTERY_HOUR_VISIBLE.getKey());
|
|
||||||
private JCheckBox batteryDayVisibleProperty = new JCheckBox(TimeCalcProperty.BATTERY_DAY_VISIBLE.getKey());
|
|
||||||
private JCheckBox batteryWeekVisibleProperty = new JCheckBox(TimeCalcProperty.BATTERY_WEEK_VISIBLE.getKey());
|
|
||||||
private JCheckBox batteryMonthVisibleProperty = new JCheckBox(TimeCalcProperty.BATTERY_MONTH_VISIBLE.getKey());
|
|
||||||
private JCheckBox batteryYearVisibleProperty = new JCheckBox(TimeCalcProperty.BATTERY_YEAR_VISIBLE.getKey());
|
|
||||||
private JCheckBox batteryBlinkingIfCriticalLowVisibleProperty = new JCheckBox(TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW.getKey());
|
|
||||||
|
|
||||||
private JCheckBox jokesVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.JOKES_VISIBLE.getKey());
|
|
||||||
private JCheckBox commandsVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.COMMANDS_VISIBLE.getKey());
|
|
||||||
private JCheckBox notificationsVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.NOTIFICATIONS_VISIBLE.getKey());
|
|
||||||
|
|
||||||
private JCheckBox smileysVisibleOnlyIfMouseMovingOverProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.SMILEYS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER.getKey());
|
|
||||||
private JCheckBox smileysVisibleProperty
|
|
||||||
= new JCheckBox(TimeCalcProperty.SMILEYS_VISIBLE.getKey());
|
|
||||||
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());
|
|
||||||
private JTextField mainWindowCustomTitleProperty
|
|
||||||
= new JTextField();
|
|
||||||
private JTextField profileNameProperty
|
|
||||||
= new JTextField();
|
|
||||||
private final JPanel panelInsideScrollPane;
|
private final JPanel panelInsideScrollPane;
|
||||||
|
private int currentY = SwingUtils.MARGIN;
|
||||||
|
private final List<JComponent> propertiesList = new ArrayList<>();
|
||||||
|
private final Map<TimeCalcProperty, JComponent> propertiesMap = new HashMap<>();
|
||||||
|
private final TButton enableAsMuchAsPossible =
|
||||||
|
new TButton("Enable as much as possible");
|
||||||
|
private final TButton disableAsMuchAsPossible =
|
||||||
|
new TButton("Disable as much as possible");
|
||||||
|
private final JCheckBox visibilitySupportedColoredProperty
|
||||||
|
= new JCheckBox(
|
||||||
|
TimeCalcProperty.VISIBILITY_SUPPORTED_COLORED.getKey());
|
||||||
|
private final JCheckBox clockVisibleProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.CLOCK_VISIBLE.getKey());
|
||||||
|
private final JCheckBox clockHandsLongVisibleProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.CLOCK_HANDS_LONG_VISIBLE.getKey());
|
||||||
|
private final JCheckBox clockHandsColoredProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.CLOCK_HANDS_COLORED.getKey());
|
||||||
|
private final JCheckBox clockHandsHourVisibleProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.CLOCK_HANDS_HOUR_VISIBLE.getKey());
|
||||||
|
private final JCheckBox clockHandsMinuteVisibleProperty
|
||||||
|
=
|
||||||
|
new JCheckBox(TimeCalcProperty.CLOCK_HANDS_MINUTE_VISIBLE.getKey());
|
||||||
|
private final JCheckBox clockHandsSecondVisibleProperty
|
||||||
|
=
|
||||||
|
new JCheckBox(TimeCalcProperty.CLOCK_HANDS_SECOND_VISIBLE.getKey());
|
||||||
|
private final JCheckBox clockHandsMillisecondVisibleProperty
|
||||||
|
= new JCheckBox(
|
||||||
|
TimeCalcProperty.CLOCK_HANDS_MILLISECOND_VISIBLE.getKey());
|
||||||
|
private final JCheckBox clockBorderVisibleProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.CLOCK_BORDER_VISIBLE.getKey());
|
||||||
|
private final JCheckBox clockBorderOnlyHoursProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.CLOCK_BORDER_ONLY_HOURS.getKey());
|
||||||
|
private final JCheckBox clockNumbersVisibleProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.CLOCK_NUMBERS_VISIBLE.getKey());
|
||||||
|
private final JCheckBox clockCircleVisibleProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.CLOCK_CIRCLE_VISIBLE.getKey());
|
||||||
|
private final JCheckBox clockCircleStrongBorderProperty
|
||||||
|
=
|
||||||
|
new JCheckBox(TimeCalcProperty.CLOCK_CIRCLE_STRONG_BORDER.getKey());
|
||||||
|
private final JColorChooser clockCircleBorderColorProperty
|
||||||
|
= new JColorChooser(Color.BLACK);
|
||||||
|
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 clockProgressVisibleOnlyIfMouseMovingOverProperty
|
||||||
|
= new JCheckBox(
|
||||||
|
TimeCalcProperty.CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
|
||||||
|
.getKey());
|
||||||
|
private final JCheckBox clockDateVisibleOnlyIfMouseMovingOverProperty
|
||||||
|
= new JCheckBox(
|
||||||
|
TimeCalcProperty.CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
|
||||||
|
.getKey());
|
||||||
|
//
|
||||||
|
private final JCheckBox batteryWavesVisibleProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.BATTERY_WAVES_VISIBLE.getKey());
|
||||||
|
private final JCheckBox batteryCircleProgressVisibleProperty
|
||||||
|
= new JCheckBox(
|
||||||
|
TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE.getKey());
|
||||||
|
private final JCheckBox batteryPercentProgressProperty
|
||||||
|
= new JCheckBox(
|
||||||
|
TimeCalcProperty.BATTERY_PERCENT_PROGRESS_VISIBLE.getKey());
|
||||||
|
private final JCheckBox batteryChargingCharacterVisibleProperty
|
||||||
|
= new JCheckBox(
|
||||||
|
TimeCalcProperty.BATTERY_CHARGING_CHARACTER_VISIBLE.getKey());
|
||||||
|
private final JCheckBox batteryNameVisibleProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.BATTERY_NAME_VISIBLE.getKey());
|
||||||
|
private final JCheckBox batteryLabelVisibleProperty =
|
||||||
|
new JCheckBox(TimeCalcProperty.BATTERY_LABEL_VISIBLE.getKey());
|
||||||
|
private final JCheckBox batteryVisibleProperty =
|
||||||
|
new JCheckBox(TimeCalcProperty.BATTERY_VISIBLE.getKey());
|
||||||
|
private final JCheckBox batteryMinuteVisibleProperty =
|
||||||
|
new JCheckBox(TimeCalcProperty.BATTERY_MINUTE_VISIBLE.getKey());
|
||||||
|
private final JCheckBox batteryHourVisibleProperty =
|
||||||
|
new JCheckBox(TimeCalcProperty.BATTERY_HOUR_VISIBLE.getKey());
|
||||||
|
private final JCheckBox batteryDayVisibleProperty =
|
||||||
|
new JCheckBox(TimeCalcProperty.BATTERY_DAY_VISIBLE.getKey());
|
||||||
|
private final JCheckBox batteryWeekVisibleProperty =
|
||||||
|
new JCheckBox(TimeCalcProperty.BATTERY_WEEK_VISIBLE.getKey());
|
||||||
|
private final JCheckBox batteryMonthVisibleProperty =
|
||||||
|
new JCheckBox(TimeCalcProperty.BATTERY_MONTH_VISIBLE.getKey());
|
||||||
|
private final JCheckBox batteryYearVisibleProperty =
|
||||||
|
new JCheckBox(TimeCalcProperty.BATTERY_YEAR_VISIBLE.getKey());
|
||||||
|
private final JCheckBox batteryBlinkingIfCriticalLowVisibleProperty =
|
||||||
|
new JCheckBox(
|
||||||
|
TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW.getKey());
|
||||||
|
private final JCheckBox jokesVisibleProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.JOKES_VISIBLE.getKey());
|
||||||
|
private final JCheckBox commandsVisibleProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.COMMANDS_VISIBLE.getKey());
|
||||||
|
private final JCheckBox notificationsVisibleProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.NOTIFICATIONS_VISIBLE.getKey());
|
||||||
|
private final JCheckBox smileysVisibleOnlyIfMouseMovingOverProperty
|
||||||
|
= new JCheckBox(
|
||||||
|
TimeCalcProperty.SMILEYS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
|
||||||
|
.getKey());
|
||||||
|
private final JCheckBox smileysVisibleProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.SMILEYS_VISIBLE.getKey());
|
||||||
|
private final JCheckBox smileysColoredProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.SMILEYS_COLORED.getKey());
|
||||||
|
private final JCheckBox squareVisibleProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.SQUARE_VISIBLE.getKey());
|
||||||
|
private final JCheckBox circleVisibleProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.CIRCLE_VISIBLE.getKey());
|
||||||
|
private final JCheckBox walkingHumanVisibleProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.WALKING_HUMAN_VISIBLE.getKey());
|
||||||
|
private final JTextField mainWindowCustomTitleProperty
|
||||||
|
= new JTextField();
|
||||||
|
private final JTextField profileNameProperty
|
||||||
|
= new JTextField();
|
||||||
public ConfigWindow(TimeCalcConfiguration timeCalcConfiguration) {
|
public ConfigWindow(TimeCalcConfiguration timeCalcConfiguration) {
|
||||||
this.timeCalcConfiguration = timeCalcConfiguration;
|
this.timeCalcConfiguration = timeCalcConfiguration;
|
||||||
setTitle("Configuration");
|
setTitle("Configuration");
|
||||||
this.setSize(800, 800);
|
this.setSize(800, 800);
|
||||||
|
|
||||||
JPanel mainPanel = new JPanel();
|
JPanel mainPanel = new JPanel();
|
||||||
mainPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, getHeight() - 6 * SwingUtils.MARGIN));
|
mainPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE,
|
||||||
|
getHeight() - 6 * SwingUtils.MARGIN));
|
||||||
this.panelInsideScrollPane = new JPanel();
|
this.panelInsideScrollPane = new JPanel();
|
||||||
final BoxLayout boxLayout = new BoxLayout(panelInsideScrollPane, BoxLayout.Y_AXIS);
|
final BoxLayout boxLayout =
|
||||||
|
new BoxLayout(panelInsideScrollPane, BoxLayout.Y_AXIS);
|
||||||
panelInsideScrollPane.setAlignmentX(LEFT_ALIGNMENT);
|
panelInsideScrollPane.setAlignmentX(LEFT_ALIGNMENT);
|
||||||
mainPanel.setAlignmentX(LEFT_ALIGNMENT);
|
mainPanel.setAlignmentX(LEFT_ALIGNMENT);
|
||||||
|
|
||||||
panelInsideScrollPane.setLayout(boxLayout);
|
panelInsideScrollPane.setLayout(boxLayout);
|
||||||
panelInsideScrollPane.setMinimumSize(new Dimension(Integer.MAX_VALUE, 400));
|
panelInsideScrollPane
|
||||||
|
.setMinimumSize(new Dimension(Integer.MAX_VALUE, 400));
|
||||||
|
|
||||||
JScrollPane scrollPane = new JScrollPane(panelInsideScrollPane);
|
JScrollPane scrollPane = new JScrollPane(panelInsideScrollPane);
|
||||||
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
scrollPane.setVerticalScrollBarPolicy(
|
||||||
scrollPane.setPreferredSize(new Dimension(getWidth() - 50, getHeight() - 100));
|
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
||||||
|
scrollPane.setPreferredSize(
|
||||||
|
new Dimension(getWidth() - 50, getHeight() - 100));
|
||||||
scrollPane.setWheelScrollingEnabled(true);
|
scrollPane.setWheelScrollingEnabled(true);
|
||||||
scrollPane.setBorder(null);
|
scrollPane.setBorder(null);
|
||||||
// mainPanel.setBackground(Color.red);
|
// mainPanel.setBackground(Color.red);
|
||||||
@ -168,21 +195,29 @@ public class ConfigWindow extends TWindow {
|
|||||||
add(mainPanel);
|
add(mainPanel);
|
||||||
//mainPanel.setLayout(null);
|
//mainPanel.setLayout(null);
|
||||||
mainPanel.add(enableAsMuchAsPossible);
|
mainPanel.add(enableAsMuchAsPossible);
|
||||||
enableAsMuchAsPossible.setBounds(SwingUtils.MARGIN, SwingUtils.MARGIN, 250,
|
enableAsMuchAsPossible
|
||||||
|
.setBounds(SwingUtils.MARGIN, SwingUtils.MARGIN, 250,
|
||||||
HEIGHT1);
|
HEIGHT1);
|
||||||
|
|
||||||
mainPanel.add(disableAsMuchAsPossible);
|
mainPanel.add(disableAsMuchAsPossible);
|
||||||
disableAsMuchAsPossible.setBounds(enableAsMuchAsPossible.getX() + enableAsMuchAsPossible.getWidth() + SwingUtils.MARGIN, SwingUtils.MARGIN, 250,
|
disableAsMuchAsPossible.setBounds(
|
||||||
|
enableAsMuchAsPossible.getX() + enableAsMuchAsPossible
|
||||||
|
.getWidth() + SwingUtils.MARGIN, SwingUtils.MARGIN, 250,
|
||||||
HEIGHT1);
|
HEIGHT1);
|
||||||
scrollPane.setBounds(enableAsMuchAsPossible.getX(), enableAsMuchAsPossible.getY() + enableAsMuchAsPossible.getHeight() + SwingUtils.MARGIN, Integer.MAX_VALUE, Integer.MAX_VALUE);
|
scrollPane.setBounds(enableAsMuchAsPossible.getX(),
|
||||||
|
enableAsMuchAsPossible.getY() + enableAsMuchAsPossible
|
||||||
|
.getHeight() + SwingUtils.MARGIN, Integer.MAX_VALUE,
|
||||||
|
Integer.MAX_VALUE);
|
||||||
|
|
||||||
mainPanel.add(scrollPane);
|
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());
|
||||||
clockVisibleProperty.setSelected(true);
|
clockVisibleProperty.setSelected(true);
|
||||||
clockHandsHourVisibleProperty.setSelected(enable);
|
clockHandsHourVisibleProperty.setSelected(enable);
|
||||||
clockHandsMinuteVisibleProperty.setSelected(enable);
|
clockHandsMinuteVisibleProperty.setSelected(enable);
|
||||||
@ -196,13 +231,17 @@ public class ConfigWindow extends TWindow {
|
|||||||
clockCircleVisibleProperty.setSelected(enable);
|
clockCircleVisibleProperty.setSelected(enable);
|
||||||
clockCircleStrongBorderProperty.setSelected(!enable);
|
clockCircleStrongBorderProperty.setSelected(!enable);
|
||||||
|
|
||||||
clockCircleBorderColorProperty.setColor(enable ? Color.BLUE : Color.BLACK);
|
clockCircleBorderColorProperty
|
||||||
timeCalcConfiguration.clockCircleBorderColorProperty.setValue(enable ? "0,0,255" : "0,0,0");
|
.setColor(enable ? Color.BLUE : Color.BLACK);
|
||||||
|
timeCalcConfiguration.clockCircleBorderColorProperty
|
||||||
|
.setValue(enable ? "0,0,255" : "0,0,0");
|
||||||
|
|
||||||
clockCentreCircleVisibleProperty.setSelected(enable);
|
clockCentreCircleVisibleProperty.setSelected(enable);
|
||||||
clockCentreCircleBlackProperty.setSelected(!enable);
|
clockCentreCircleBlackProperty.setSelected(!enable);
|
||||||
clockProgressVisibleOnlyIfMouseMovingOverProperty.setSelected(!enable);
|
clockProgressVisibleOnlyIfMouseMovingOverProperty
|
||||||
clockDateVisibleOnlyIfMouseMovingOverProperty.setSelected(false);
|
.setSelected(!enable);
|
||||||
|
clockDateVisibleOnlyIfMouseMovingOverProperty
|
||||||
|
.setSelected(false);
|
||||||
batteryVisibleProperty.setSelected(true);
|
batteryVisibleProperty.setSelected(true);
|
||||||
batteryWavesVisibleProperty.setSelected(enable);
|
batteryWavesVisibleProperty.setSelected(enable);
|
||||||
batteryCircleProgressVisibleProperty.setSelected(enable);
|
batteryCircleProgressVisibleProperty.setSelected(enable);
|
||||||
@ -223,7 +262,8 @@ public class ConfigWindow extends TWindow {
|
|||||||
notificationsVisibleProperty.setSelected(enable);
|
notificationsVisibleProperty.setSelected(enable);
|
||||||
smileysVisibleProperty.setSelected(enable);
|
smileysVisibleProperty.setSelected(enable);
|
||||||
smileysColoredProperty.setSelected(enable);
|
smileysColoredProperty.setSelected(enable);
|
||||||
smileysVisibleOnlyIfMouseMovingOverProperty.setSelected(!enable);
|
smileysVisibleOnlyIfMouseMovingOverProperty
|
||||||
|
.setSelected(!enable);
|
||||||
squareVisibleProperty.setSelected(enable);
|
squareVisibleProperty.setSelected(enable);
|
||||||
circleVisibleProperty.setSelected(enable);
|
circleVisibleProperty.setSelected(enable);
|
||||||
walkingHumanVisibleProperty.setSelected(enable);
|
walkingHumanVisibleProperty.setSelected(enable);
|
||||||
@ -280,32 +320,46 @@ public class ConfigWindow extends TWindow {
|
|||||||
propertiesList.stream().forEach(p -> {
|
propertiesList.stream().forEach(p -> {
|
||||||
p.setAlignmentX(LEFT_ALIGNMENT);
|
p.setAlignmentX(LEFT_ALIGNMENT);
|
||||||
if (p == visibilityDefaultProperty) {
|
if (p == visibilityDefaultProperty) {
|
||||||
p.putClientProperty(CLIENT_PROPERTY_KEY, TimeCalcProperty.VISIBILITY_DEFAULT.getKey());
|
p.putClientProperty(CLIENT_PROPERTY_KEY,
|
||||||
addToNextRow(new JLabel(TimeCalcProperty.VISIBILITY_DEFAULT.getDescription()));
|
TimeCalcProperty.VISIBILITY_DEFAULT.getKey());
|
||||||
|
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,
|
||||||
addToNextRow(new JLabel(TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR.getDescription().replace("Clock : ", "")));
|
TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR.getKey());
|
||||||
|
addToNextRow(new JLabel(
|
||||||
|
TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR
|
||||||
|
.getDescription().replace("Clock : ", "")));
|
||||||
}
|
}
|
||||||
if (p == mainWindowCustomTitleProperty) {
|
if (p == mainWindowCustomTitleProperty) {
|
||||||
addToNextRow(new JLabel(TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE.getDescription()));
|
addToNextRow(new JLabel(
|
||||||
p.putClientProperty(CLIENT_PROPERTY_KEY, TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE.getKey());
|
TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE
|
||||||
|
.getDescription()));
|
||||||
|
p.putClientProperty(CLIENT_PROPERTY_KEY,
|
||||||
|
TimeCalcProperty.MAIN_WINDOW_CUSTOM_TITLE.getKey());
|
||||||
}
|
}
|
||||||
if (p == profileNameProperty) {
|
if (p == profileNameProperty) {
|
||||||
addToNextRow(new JLabel(TimeCalcProperty.PROFILE_NAME.getDescription()));
|
addToNextRow(new JLabel(
|
||||||
p.putClientProperty(CLIENT_PROPERTY_KEY, TimeCalcProperty.PROFILE_NAME.getKey());
|
TimeCalcProperty.PROFILE_NAME.getDescription()));
|
||||||
|
p.putClientProperty(CLIENT_PROPERTY_KEY,
|
||||||
|
TimeCalcProperty.PROFILE_NAME.getKey());
|
||||||
}
|
}
|
||||||
if (p instanceof JComboBox) {
|
if (p instanceof JComboBox) {
|
||||||
JComboBox jComboBox = ((JComboBox) p);
|
JComboBox jComboBox = ((JComboBox) p);
|
||||||
jComboBox.setMaximumSize(new Dimension(150, 25));
|
jComboBox.setMaximumSize(new Dimension(150, 25));
|
||||||
|
|
||||||
String timeCalcPropertyKey = (String) jComboBox.getClientProperty(
|
String timeCalcPropertyKey =
|
||||||
|
(String) jComboBox.getClientProperty(
|
||||||
CLIENT_PROPERTY_KEY);
|
CLIENT_PROPERTY_KEY);
|
||||||
TimeCalcProperty timeCalcProperty
|
TimeCalcProperty timeCalcProperty
|
||||||
= TimeCalcProperty.forKey(timeCalcPropertyKey);
|
= TimeCalcProperty.forKey(timeCalcPropertyKey);
|
||||||
jComboBox.setSelectedItem(timeCalcConfiguration.getProperty(timeCalcProperty).getValue());
|
jComboBox.setSelectedItem(
|
||||||
|
timeCalcConfiguration.getProperty(timeCalcProperty)
|
||||||
|
.getValue());
|
||||||
jComboBox.addActionListener(e -> {
|
jComboBox.addActionListener(e -> {
|
||||||
((StringProperty) timeCalcConfiguration.getProperty(timeCalcProperty))
|
timeCalcConfiguration
|
||||||
|
.getProperty(timeCalcProperty)
|
||||||
.setValue(
|
.setValue(
|
||||||
(String) jComboBox.getSelectedItem());
|
(String) jComboBox.getSelectedItem());
|
||||||
});
|
});
|
||||||
@ -314,7 +368,8 @@ public class ConfigWindow extends TWindow {
|
|||||||
if (p instanceof JCheckBox) {
|
if (p instanceof JCheckBox) {
|
||||||
JCheckBox checkBox = ((JCheckBox) p);
|
JCheckBox checkBox = ((JCheckBox) p);
|
||||||
String timeCalcPropertyKey = checkBox.getText();
|
String timeCalcPropertyKey = checkBox.getText();
|
||||||
checkBox.putClientProperty(CLIENT_PROPERTY_KEY, timeCalcPropertyKey);
|
checkBox.putClientProperty(CLIENT_PROPERTY_KEY,
|
||||||
|
timeCalcPropertyKey);
|
||||||
TimeCalcProperty timeCalcProperty
|
TimeCalcProperty timeCalcProperty
|
||||||
= TimeCalcProperty.forKey(timeCalcPropertyKey);
|
= TimeCalcProperty.forKey(timeCalcPropertyKey);
|
||||||
|
|
||||||
@ -323,7 +378,8 @@ public class ConfigWindow extends TWindow {
|
|||||||
BooleanProperty property
|
BooleanProperty property
|
||||||
= (BooleanProperty) timeCalcConfiguration
|
= (BooleanProperty) timeCalcConfiguration
|
||||||
.getProperty(timeCalcProperty);
|
.getProperty(timeCalcProperty);
|
||||||
property.addListener(e -> checkBox.setSelected(property.isEnabled()));
|
property.addListener(
|
||||||
|
e -> checkBox.setSelected(property.isEnabled()));
|
||||||
checkBox.setSelected(property.isEnabled());
|
checkBox.setSelected(property.isEnabled());
|
||||||
checkBox.addItemListener(e -> {
|
checkBox.addItemListener(e -> {
|
||||||
property
|
property
|
||||||
@ -331,11 +387,14 @@ public class ConfigWindow extends TWindow {
|
|||||||
});
|
});
|
||||||
String[] array = checkBox.getText().split(" : ");
|
String[] array = checkBox.getText().split(" : ");
|
||||||
String groupName = array[0];
|
String groupName = array[0];
|
||||||
if(groupName.equals("Clock") ||groupName.equals("Battery") ||groupName.equals("Smileys")) {
|
if (groupName.equals("Clock") || groupName.equals("Battery")
|
||||||
|
|| groupName.equals("Smileys")) {
|
||||||
|
|
||||||
checkBox.setText(array.length > 1 ? (checkBox.getText().substring(groupName.length() + 3)) : "Visible");
|
checkBox.setText(array.length > 1 ? (checkBox.getText()
|
||||||
|
.substring(groupName.length() + 3)) : "Visible");
|
||||||
if (array.length == 1) {
|
if (array.length == 1) {
|
||||||
panelInsideScrollPane.add(new JSeparator(SwingConstants.VERTICAL));
|
panelInsideScrollPane
|
||||||
|
.add(new JSeparator(SwingConstants.VERTICAL));
|
||||||
JLabel label = new JLabel(groupName);
|
JLabel label = new JLabel(groupName);
|
||||||
label.setFont(BIG_FONT);
|
label.setFont(BIG_FONT);
|
||||||
panelInsideScrollPane.add(label);
|
panelInsideScrollPane.add(label);
|
||||||
@ -355,12 +414,14 @@ public class ConfigWindow extends TWindow {
|
|||||||
JColorChooser colorChooser = ((JColorChooser) p);
|
JColorChooser colorChooser = ((JColorChooser) p);
|
||||||
//jColorChooser.setMaximumSize(new Dimension(150, 25));
|
//jColorChooser.setMaximumSize(new Dimension(150, 25));
|
||||||
|
|
||||||
String timeCalcPropertyKey = (String) colorChooser.getClientProperty(
|
String timeCalcPropertyKey =
|
||||||
|
(String) colorChooser.getClientProperty(
|
||||||
CLIENT_PROPERTY_KEY);
|
CLIENT_PROPERTY_KEY);
|
||||||
TimeCalcProperty timeCalcProperty
|
TimeCalcProperty timeCalcProperty
|
||||||
= TimeCalcProperty.forKey(timeCalcPropertyKey);
|
= TimeCalcProperty.forKey(timeCalcPropertyKey);
|
||||||
|
|
||||||
String currentColor = ((StringProperty) timeCalcConfiguration.getProperty(timeCalcProperty)).getValue();
|
String currentColor = ((StringProperty) timeCalcConfiguration
|
||||||
|
.getProperty(timeCalcProperty)).getValue();
|
||||||
String[] currentColorAsStringArray = currentColor.split(",");
|
String[] currentColorAsStringArray = currentColor.split(",");
|
||||||
int red = Integer.valueOf(currentColorAsStringArray[0]);
|
int red = Integer.valueOf(currentColorAsStringArray[0]);
|
||||||
int green = Integer.valueOf(currentColorAsStringArray[1]);
|
int green = Integer.valueOf(currentColorAsStringArray[1]);
|
||||||
@ -373,11 +434,12 @@ public class ConfigWindow extends TWindow {
|
|||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
Color selectedColor = colorChooser.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) {
|
||||||
colorChooser.setColor(selectedColor);
|
colorChooser.setColor(selectedColor);
|
||||||
((StringProperty) timeCalcConfiguration
|
timeCalcConfiguration
|
||||||
.getProperty(timeCalcProperty))
|
.getProperty(timeCalcProperty)
|
||||||
.setValue(
|
.setValue(
|
||||||
selectedColor.getRed() + ","
|
selectedColor.getRed() + ","
|
||||||
+ selectedColor.getGreen() + ","
|
+ selectedColor.getGreen() + ","
|
||||||
@ -411,21 +473,27 @@ public class ConfigWindow extends TWindow {
|
|||||||
JTextField jTextField = ((JTextField) p);
|
JTextField jTextField = ((JTextField) p);
|
||||||
jTextField.setMaximumSize(new Dimension(150, 25));
|
jTextField.setMaximumSize(new Dimension(150, 25));
|
||||||
|
|
||||||
String timeCalcPropertyKey = (String) jTextField.getClientProperty(
|
String timeCalcPropertyKey =
|
||||||
|
(String) jTextField.getClientProperty(
|
||||||
CLIENT_PROPERTY_KEY);
|
CLIENT_PROPERTY_KEY);
|
||||||
TimeCalcProperty timeCalcProperty
|
TimeCalcProperty timeCalcProperty
|
||||||
= TimeCalcProperty.forKey(timeCalcPropertyKey);
|
= TimeCalcProperty.forKey(timeCalcPropertyKey);
|
||||||
jTextField.setText((String) timeCalcConfiguration.getProperty(timeCalcProperty).getValue());
|
jTextField.setText((String) timeCalcConfiguration
|
||||||
|
.getProperty(timeCalcProperty).getValue());
|
||||||
|
|
||||||
jTextField.getDocument().addDocumentListener(new DocumentListener() {
|
jTextField.getDocument()
|
||||||
|
.addDocumentListener(new DocumentListener() {
|
||||||
public void changedUpdate(DocumentEvent e) {
|
public void changedUpdate(DocumentEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeUpdate(DocumentEvent e) {
|
public void removeUpdate(DocumentEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertUpdate(DocumentEvent e) {
|
public void insertUpdate(DocumentEvent e) {
|
||||||
((StringProperty) timeCalcConfiguration.getProperty(timeCalcProperty))
|
timeCalcConfiguration
|
||||||
|
.getProperty(timeCalcProperty)
|
||||||
.setValue(
|
.setValue(
|
||||||
(String) jTextField.getText());
|
jTextField.getText());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -483,8 +551,6 @@ 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) {
|
||||||
panelInsideScrollPane.add(jComponent);
|
panelInsideScrollPane.add(jComponent);
|
||||||
@ -501,6 +567,7 @@ public class ConfigWindow extends TWindow {
|
|||||||
public void doEnableEverything() {
|
public void doEnableEverything() {
|
||||||
this.enableAsMuchAsPossible.doClick();
|
this.enableAsMuchAsPossible.doClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doDisableAlmostEverything() {
|
public void doDisableAlmostEverything() {
|
||||||
this.disableAsMuchAsPossible.doClick();
|
this.disableAsMuchAsPossible.doClick();
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,13 @@ public class HelpWindow extends TWindow {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
helpHtml = "<div style=\"font-family:sans;margin-bottom:20px;\">" + helpHtml + "</div>";
|
helpHtml = "<div style=\"font-family:sans;margin-bottom:20px;\">"
|
||||||
|
+ helpHtml + "</div>";
|
||||||
|
|
||||||
this.setLayout(null);
|
this.setLayout(null);
|
||||||
JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
JScrollPane scrollPane =
|
||||||
|
new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
|
||||||
|
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
scrollPane.setBounds(1, 1,
|
scrollPane.setBounds(1, 1,
|
||||||
getWidth() - 2 * SwingUtils.MARGIN,
|
getWidth() - 2 * SwingUtils.MARGIN,
|
||||||
getHeight() - 4 * SwingUtils.MARGIN);
|
getHeight() - 4 * SwingUtils.MARGIN);
|
||||||
|
@ -50,6 +50,7 @@ public class MainWindow extends TWindow {
|
|||||||
|
|
||||||
public static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
public static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
||||||
public static final Color FOREGROUND_COLOR = new Color(210, 210, 210);
|
public static final Color FOREGROUND_COLOR = new Color(210, 210, 210);
|
||||||
|
public static final JCheckBox hideShowCheckBox = new JCheckBox();
|
||||||
private final TButton workDaysButton;
|
private final TButton workDaysButton;
|
||||||
private final TButton activitiesButton;
|
private final TButton activitiesButton;
|
||||||
private final TButton exitButton;
|
private final TButton exitButton;
|
||||||
@ -61,15 +62,13 @@ public class MainWindow extends TWindow {
|
|||||||
private final TButton commandButton;
|
private final TButton commandButton;
|
||||||
private final TButton jokeButton;
|
private final TButton jokeButton;
|
||||||
private final AboutButton aboutButton;
|
private final AboutButton aboutButton;
|
||||||
public static final JCheckBox hideShowCheckBox = new JCheckBox();
|
private final TimeCalcConfiguration timeCalcConfiguration
|
||||||
|
= new TimeCalcConfiguration();
|
||||||
private HelpWindow helpWindow = null;
|
private HelpWindow helpWindow = null;
|
||||||
private ConfigWindow configWindow = null;
|
private ConfigWindow configWindow = null;
|
||||||
private ActivitiesWindow activitiesWindow = null;
|
private ActivitiesWindow activitiesWindow = null;
|
||||||
private WorkDaysWindow workDaysWindow = null;
|
private WorkDaysWindow workDaysWindow = null;
|
||||||
|
|
||||||
private boolean stopBeforeEnd = false;
|
private boolean stopBeforeEnd = false;
|
||||||
private final TimeCalcConfiguration timeCalcConfiguration
|
|
||||||
= new TimeCalcConfiguration();
|
|
||||||
|
|
||||||
public MainWindow(String startTimeIn, String overTimeIn,
|
public MainWindow(String startTimeIn, String overTimeIn,
|
||||||
TimeCalcApp timeCalcApp) {
|
TimeCalcApp timeCalcApp) {
|
||||||
@ -119,13 +118,18 @@ public class MainWindow extends TWindow {
|
|||||||
|
|
||||||
//window.add(weatherButton);
|
//window.add(weatherButton);
|
||||||
addAll(configButton, workDaysButton, activitiesButton, restartButton,
|
addAll(configButton, workDaysButton, activitiesButton, restartButton,
|
||||||
exitButton, focusButton, helpButton, commandButton, jokeButton, hideShowCheckBox);
|
exitButton, focusButton, helpButton, commandButton, jokeButton,
|
||||||
|
hideShowCheckBox);
|
||||||
|
|
||||||
timeCalcApp.visibilityProperty.bindTo(timeCalcConfiguration.visibilityDefaultProperty);
|
timeCalcApp.visibilityProperty
|
||||||
if (!timeCalcConfiguration.visibilitySupportedColoredProperty.isEnabled()) {
|
.bindTo(timeCalcConfiguration.visibilityDefaultProperty);
|
||||||
|
if (!timeCalcConfiguration.visibilitySupportedColoredProperty
|
||||||
|
.isEnabled()) {
|
||||||
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
|
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
|
||||||
}
|
}
|
||||||
TimeCalcKeyAdapter timeCalcKeyAdapter = new TimeCalcKeyAdapter(timeCalcConfiguration, timeCalcApp, this);
|
TimeCalcKeyAdapter timeCalcKeyAdapter =
|
||||||
|
new TimeCalcKeyAdapter(timeCalcConfiguration, timeCalcApp,
|
||||||
|
this);
|
||||||
addKeyListener(timeCalcKeyAdapter);
|
addKeyListener(timeCalcKeyAdapter);
|
||||||
|
|
||||||
AnalogClock analogClock = new AnalogClock(startTime, endTime);
|
AnalogClock analogClock = new AnalogClock(startTime, endTime);
|
||||||
@ -134,23 +138,30 @@ public class MainWindow extends TWindow {
|
|||||||
|
|
||||||
ProgressSquare progressSquare = new ProgressSquare();
|
ProgressSquare progressSquare = new ProgressSquare();
|
||||||
progressSquare
|
progressSquare
|
||||||
.setBounds(analogClock.getX() + analogClock.getWidth() + SwingUtils.MARGIN, analogClock.getY(),
|
.setBounds(analogClock.getX() + analogClock.getWidth()
|
||||||
|
+ SwingUtils.MARGIN, analogClock.getY(),
|
||||||
200);
|
200);
|
||||||
add(progressSquare);
|
add(progressSquare);
|
||||||
progressSquare.visibleProperty.bindTo(timeCalcConfiguration.squareVisibleProperty);
|
progressSquare.visibleProperty
|
||||||
|
.bindTo(timeCalcConfiguration.squareVisibleProperty);
|
||||||
|
|
||||||
ProgressCircle progressCircle = new ProgressCircle();
|
ProgressCircle progressCircle = new ProgressCircle();
|
||||||
progressCircle
|
progressCircle
|
||||||
.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.circleVisibleProperty);
|
progressCircle.visibleProperty
|
||||||
|
.bindTo(timeCalcConfiguration.circleVisibleProperty);
|
||||||
|
|
||||||
WalkingHumanProgress walkingHumanProgress
|
WalkingHumanProgress walkingHumanProgress
|
||||||
= new WalkingHumanProgress();
|
= new WalkingHumanProgress();
|
||||||
walkingHumanProgress.setBounds(analogClock.getX(), analogClock.getY() + analogClock.getHeight() + SwingUtils.MARGIN, 420, 180);
|
walkingHumanProgress.setBounds(analogClock.getX(),
|
||||||
|
analogClock.getY() + analogClock.getHeight()
|
||||||
|
+ SwingUtils.MARGIN, 420, 180);
|
||||||
add(walkingHumanProgress);
|
add(walkingHumanProgress);
|
||||||
walkingHumanProgress.visibleProperty.bindTo(timeCalcConfiguration.walkingHumanVisibleProperty);
|
walkingHumanProgress.visibleProperty
|
||||||
|
.bindTo(timeCalcConfiguration.walkingHumanVisibleProperty);
|
||||||
|
|
||||||
weatherButton
|
weatherButton
|
||||||
.setBounds(SwingUtils.MARGIN, walkingHumanProgress.getY()
|
.setBounds(SwingUtils.MARGIN, walkingHumanProgress.getY()
|
||||||
@ -169,7 +180,9 @@ public class MainWindow extends TWindow {
|
|||||||
commandButton.setBoundsFromLeft(focusButton);
|
commandButton.setBoundsFromLeft(focusButton);
|
||||||
jokeButton.setBoundsFromLeft(commandButton);
|
jokeButton.setBoundsFromLeft(commandButton);
|
||||||
hideShowCheckBox.setSelected(true);
|
hideShowCheckBox.setSelected(true);
|
||||||
hideShowCheckBox.setBounds(jokeButton.getX() + jokeButton.getWidth() + SwingUtils.MARGIN, jokeButton.getY(), 20, 20);
|
hideShowCheckBox.setBounds(
|
||||||
|
jokeButton.getX() + jokeButton.getWidth() + SwingUtils.MARGIN,
|
||||||
|
jokeButton.getY(), 20, 20);
|
||||||
//
|
//
|
||||||
aboutButton.setBounds(exitButton.getX(),
|
aboutButton.setBounds(exitButton.getX(),
|
||||||
exitButton.getY() + exitButton.getHeight() + SwingUtils.MARGIN);
|
exitButton.getY() + exitButton.getHeight() + SwingUtils.MARGIN);
|
||||||
@ -181,7 +194,8 @@ public class MainWindow extends TWindow {
|
|||||||
|
|
||||||
weatherButton
|
weatherButton
|
||||||
.addActionListener(e -> new WeatherWindow().setVisible(true));
|
.addActionListener(e -> new WeatherWindow().setVisible(true));
|
||||||
commandButton.addActionListener(new CommandActionListener(timeCalcApp, timeCalcConfiguration));
|
commandButton.addActionListener(
|
||||||
|
new CommandActionListener(timeCalcApp, timeCalcConfiguration));
|
||||||
|
|
||||||
jokeButton.addActionListener(e -> {
|
jokeButton.addActionListener(e -> {
|
||||||
for (int i = 1; i <= 1; i++) {
|
for (int i = 1; i <= 1; i++) {
|
||||||
@ -246,13 +260,24 @@ public class MainWindow extends TWindow {
|
|||||||
|
|
||||||
Time time = new Time();
|
Time time = new Time();
|
||||||
|
|
||||||
bindToIfPropertyMissing(testProperties, "test.current.day", calNow, Calendar.DAY_OF_MONTH, analogClock.dayProperty, time.dayProperty);
|
bindToIfPropertyMissing(testProperties, "test.current.day", calNow,
|
||||||
bindToIfPropertyMissing(testProperties, "test.current.month", calNow, Calendar.MONTH, analogClock.monthProperty, time.monthProperty);
|
Calendar.DAY_OF_MONTH, analogClock.dayProperty,
|
||||||
bindToIfPropertyMissing(testProperties, "test.current.year", calNow, Calendar.YEAR, analogClock.yearProperty, time.yearProperty);
|
time.dayProperty);
|
||||||
bindToIfPropertyMissing(testProperties, "test.current.hour", calNow, Calendar.HOUR, analogClock.hourProperty, time.hourProperty);
|
bindToIfPropertyMissing(testProperties, "test.current.month", calNow,
|
||||||
bindToIfPropertyMissing(testProperties, "test.current.minute", calNow, Calendar.MINUTE, analogClock.minuteProperty, time.minuteProperty);
|
Calendar.MONTH, analogClock.monthProperty, time.monthProperty);
|
||||||
bindToIfPropertyMissing(testProperties, "test.current.second", calNow, Calendar.SECOND, analogClock.secondProperty, time.secondProperty);
|
bindToIfPropertyMissing(testProperties, "test.current.year", calNow,
|
||||||
bindToIfPropertyMissing(testProperties, "test.current.millisecond", calNow, Calendar.MILLISECOND, analogClock.millisecondProperty, time.millisecondProperty);
|
Calendar.YEAR, analogClock.yearProperty, time.yearProperty);
|
||||||
|
bindToIfPropertyMissing(testProperties, "test.current.hour", calNow,
|
||||||
|
Calendar.HOUR, analogClock.hourProperty, time.hourProperty);
|
||||||
|
bindToIfPropertyMissing(testProperties, "test.current.minute", calNow,
|
||||||
|
Calendar.MINUTE, analogClock.minuteProperty,
|
||||||
|
time.minuteProperty);
|
||||||
|
bindToIfPropertyMissing(testProperties, "test.current.second", calNow,
|
||||||
|
Calendar.SECOND, analogClock.secondProperty,
|
||||||
|
time.secondProperty);
|
||||||
|
bindToIfPropertyMissing(testProperties, "test.current.millisecond",
|
||||||
|
calNow, Calendar.MILLISECOND, analogClock.millisecondProperty,
|
||||||
|
time.millisecondProperty);
|
||||||
|
|
||||||
if (testProperties.containsKey("test.current.year") || testProperties
|
if (testProperties.containsKey("test.current.year") || testProperties
|
||||||
.containsKey("test.current.month") || testProperties
|
.containsKey("test.current.month") || testProperties
|
||||||
@ -273,35 +298,54 @@ public class MainWindow extends TWindow {
|
|||||||
.bindTo(timeCalcConfiguration.clockHandsHourVisibleProperty);
|
.bindTo(timeCalcConfiguration.clockHandsHourVisibleProperty);
|
||||||
analogClock.handsLongProperty
|
analogClock.handsLongProperty
|
||||||
.bindTo(timeCalcConfiguration.clockHandsLongVisibleProperty);
|
.bindTo(timeCalcConfiguration.clockHandsLongVisibleProperty);
|
||||||
analogClock.borderVisibleProperty.bindTo(timeCalcConfiguration.clockBorderVisibleProperty);
|
analogClock.borderVisibleProperty
|
||||||
analogClock.borderOnlyHoursProperty.bindTo(timeCalcConfiguration.clockBorderOnlyHoursProperty);
|
.bindTo(timeCalcConfiguration.clockBorderVisibleProperty);
|
||||||
analogClock.numbersVisibleProperty.bindTo(timeCalcConfiguration.clockNumbersVisibleProperty);
|
analogClock.borderOnlyHoursProperty
|
||||||
analogClock.circleVisibleProperty.bindTo(timeCalcConfiguration.clockCircleVisibleProperty);
|
.bindTo(timeCalcConfiguration.clockBorderOnlyHoursProperty);
|
||||||
analogClock.circleStrongBorderProperty.bindTo(timeCalcConfiguration.clockCircleStrongBorderProperty);
|
analogClock.numbersVisibleProperty
|
||||||
analogClock.centreCircleVisibleProperty.bindTo(timeCalcConfiguration.clockCentreCircleVisibleProperty);
|
.bindTo(timeCalcConfiguration.clockNumbersVisibleProperty);
|
||||||
analogClock.centreCircleBorderColorProperty.bindTo(timeCalcConfiguration.clockCircleBorderColorProperty);
|
analogClock.circleVisibleProperty
|
||||||
analogClock.handsColoredProperty.bindTo(timeCalcConfiguration.clockHandsColoredProperty);
|
.bindTo(timeCalcConfiguration.clockCircleVisibleProperty);
|
||||||
analogClock.centreCircleBlackProperty.bindTo(timeCalcConfiguration.clockCentreCircleBlackProperty);
|
analogClock.circleStrongBorderProperty
|
||||||
analogClock.progressVisibleOnlyIfMouseMovingOverProperty.bindTo(timeCalcConfiguration.clockProgressVisibleOnlyIfMouseMovingOverProperty);
|
.bindTo(timeCalcConfiguration.clockCircleStrongBorderProperty);
|
||||||
analogClock.dateVisibleOnlyIfMouseMovingOverProperty.bindTo(timeCalcConfiguration.clockDateVisibleOnlyIfMouseMovingOverProperty);
|
analogClock.centreCircleVisibleProperty
|
||||||
analogClock.visibleProperty.bindTo(timeCalcConfiguration.clockVisibleProperty);
|
.bindTo(timeCalcConfiguration.clockCentreCircleVisibleProperty);
|
||||||
|
analogClock.centreCircleBorderColorProperty
|
||||||
|
.bindTo(timeCalcConfiguration.clockCircleBorderColorProperty);
|
||||||
|
analogClock.handsColoredProperty
|
||||||
|
.bindTo(timeCalcConfiguration.clockHandsColoredProperty);
|
||||||
|
analogClock.centreCircleBlackProperty
|
||||||
|
.bindTo(timeCalcConfiguration.clockCentreCircleBlackProperty);
|
||||||
|
analogClock.progressVisibleOnlyIfMouseMovingOverProperty
|
||||||
|
.bindTo(timeCalcConfiguration.clockProgressVisibleOnlyIfMouseMovingOverProperty);
|
||||||
|
analogClock.dateVisibleOnlyIfMouseMovingOverProperty
|
||||||
|
.bindTo(timeCalcConfiguration.clockDateVisibleOnlyIfMouseMovingOverProperty);
|
||||||
|
analogClock.visibleProperty
|
||||||
|
.bindTo(timeCalcConfiguration.clockVisibleProperty);
|
||||||
|
|
||||||
MinuteBattery minuteBattery = new MinuteBattery(progressCircle.getBounds().x,
|
MinuteBattery minuteBattery =
|
||||||
progressCircle.getY() + SwingUtils.MARGIN + progressCircle.getHeight(), 140);
|
new MinuteBattery(progressCircle.getBounds().x,
|
||||||
|
progressCircle.getY() + SwingUtils.MARGIN
|
||||||
|
+ progressCircle.getHeight(), 140);
|
||||||
add(minuteBattery);
|
add(minuteBattery);
|
||||||
Battery hourBattery = new HourBattery(minuteBattery.getBounds().x + minuteBattery.getWidth() + SwingUtils.MARGIN,
|
Battery hourBattery = new HourBattery(
|
||||||
|
minuteBattery.getBounds().x + minuteBattery.getWidth()
|
||||||
|
+ SwingUtils.MARGIN,
|
||||||
minuteBattery.getY(),
|
minuteBattery.getY(),
|
||||||
140);
|
140);
|
||||||
add(hourBattery);
|
add(hourBattery);
|
||||||
|
|
||||||
Battery dayBattery = new DayBattery(hourBattery.getBounds().x + hourBattery.getWidth() + SwingUtils.MARGIN,
|
Battery dayBattery = new DayBattery(
|
||||||
|
hourBattery.getBounds().x + hourBattery.getWidth()
|
||||||
|
+ SwingUtils.MARGIN,
|
||||||
hourBattery.getY(),
|
hourBattery.getY(),
|
||||||
140);
|
140);
|
||||||
add(dayBattery);
|
add(dayBattery);
|
||||||
|
|
||||||
Battery weekBattery = new WeekBattery(
|
Battery weekBattery = new WeekBattery(
|
||||||
minuteBattery.getBounds().x,
|
minuteBattery.getBounds().x,
|
||||||
dayBattery.getY() + dayBattery.getHeight() + SwingUtils.MARGIN, 140);
|
dayBattery.getY() + dayBattery.getHeight() + SwingUtils.MARGIN,
|
||||||
|
140);
|
||||||
add(weekBattery);
|
add(weekBattery);
|
||||||
|
|
||||||
int currentDayOfMonth = analogClock.dayProperty.getValue();
|
int currentDayOfMonth = analogClock.dayProperty.getValue();
|
||||||
@ -312,8 +356,10 @@ public class MainWindow extends TWindow {
|
|||||||
for (int dayOfMonth = 1;
|
for (int dayOfMonth = 1;
|
||||||
dayOfMonth <= calNow.getActualMaximum(Calendar.DAY_OF_MONTH);
|
dayOfMonth <= calNow.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||||
dayOfMonth++) {
|
dayOfMonth++) {
|
||||||
DayOfWeek dayOfWeek = LocalDate.of(analogClock.yearProperty.getValue(),
|
DayOfWeek dayOfWeek =
|
||||||
analogClock.monthProperty.getValue(), dayOfMonth).getDayOfWeek();
|
LocalDate.of(analogClock.yearProperty.getValue(),
|
||||||
|
analogClock.monthProperty.getValue(), dayOfMonth)
|
||||||
|
.getDayOfWeek();
|
||||||
boolean weekend
|
boolean weekend
|
||||||
= dayOfWeek.toString().equals("SATURDAY") || dayOfWeek
|
= dayOfWeek.toString().equals("SATURDAY") || dayOfWeek
|
||||||
.toString().equals("SUNDAY");
|
.toString().equals("SUNDAY");
|
||||||
@ -332,19 +378,23 @@ public class MainWindow extends TWindow {
|
|||||||
workDaysTotal = workDaysDone + (nowIsWeekend ? 0 : 1) + workDaysTodo;
|
workDaysTotal = workDaysDone + (nowIsWeekend ? 0 : 1) + workDaysTodo;
|
||||||
|
|
||||||
Battery monthBattery = new MonthBattery(
|
Battery monthBattery = new MonthBattery(
|
||||||
weekBattery.getBounds().x + weekBattery.getWidth() + SwingUtils.MARGIN,
|
weekBattery.getBounds().x + weekBattery.getWidth()
|
||||||
|
+ SwingUtils.MARGIN,
|
||||||
weekBattery.getY(), 140);
|
weekBattery.getY(), 140);
|
||||||
add(monthBattery);
|
add(monthBattery);
|
||||||
Battery yearBattery = new YearBattery(
|
Battery yearBattery = new YearBattery(
|
||||||
monthBattery.getBounds().x + monthBattery.getWidth() + SwingUtils.MARGIN,
|
monthBattery.getBounds().x + monthBattery.getWidth()
|
||||||
|
+ SwingUtils.MARGIN,
|
||||||
monthBattery.getY(), 140);
|
monthBattery.getY(), 140);
|
||||||
add(yearBattery);
|
add(yearBattery);
|
||||||
|
|
||||||
ComponentRegistry<Component> componentRegistry = new ComponentRegistry();
|
ComponentRegistry<Component> componentRegistry =
|
||||||
|
new ComponentRegistry();
|
||||||
componentRegistry.addAll(this.getContentPane().getComponents());
|
componentRegistry.addAll(this.getContentPane().getComponents());
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@ -354,49 +404,84 @@ public class MainWindow extends TWindow {
|
|||||||
componentRegistry.getSet().stream().filter(c
|
componentRegistry.getSet().stream().filter(c
|
||||||
-> GetProperty.class.isAssignableFrom(c.getClass())).forEach(c
|
-> GetProperty.class.isAssignableFrom(c.getClass())).forEach(c
|
||||||
-> {
|
-> {
|
||||||
((GetProperty) c).getVisibilityProperty().bindTo(timeCalcApp.visibilityProperty);
|
((GetProperty) c).getVisibilityProperty()
|
||||||
((GetProperty) c).getVisibilitySupportedColoredProperty().bindTo(timeCalcConfiguration.visibilitySupportedColoredProperty);
|
.bindTo(timeCalcApp.visibilityProperty);
|
||||||
|
((GetProperty) c).getVisibilitySupportedColoredProperty()
|
||||||
|
.bindTo(timeCalcConfiguration.visibilitySupportedColoredProperty);
|
||||||
});
|
});
|
||||||
|
|
||||||
componentRegistry.getSet().stream().filter(c -> c instanceof Battery).forEach(c
|
componentRegistry.getSet().stream().filter(c -> c instanceof Battery)
|
||||||
|
.forEach(c
|
||||||
-> {
|
-> {
|
||||||
Battery battery = ((Battery) c);
|
Battery battery = ((Battery) c);
|
||||||
battery.wavesVisibleProperty.bindTo(timeCalcConfiguration.batteryWavesVisibleProperty);
|
battery.wavesVisibleProperty
|
||||||
battery.circleProgressVisibleProperty.bindTo(timeCalcConfiguration.batteryCircleProgressProperty);
|
.bindTo(timeCalcConfiguration.batteryWavesVisibleProperty);
|
||||||
battery.percentProgressVisibleProperty.bindTo(timeCalcConfiguration.batteryPercentProgressProperty);
|
battery.circleProgressVisibleProperty
|
||||||
battery.chargingCharacterVisibleProperty.bindTo(timeCalcConfiguration.batteryChargingCharacterVisibleProperty);
|
.bindTo(timeCalcConfiguration.batteryCircleProgressProperty);
|
||||||
battery.nameVisibleProperty.bindTo(timeCalcConfiguration.batteryNameVisibleProperty);
|
battery.percentProgressVisibleProperty
|
||||||
battery.labelVisibleProperty.bindTo(timeCalcConfiguration.batteryLabelVisibleProperty);
|
.bindTo(timeCalcConfiguration.batteryPercentProgressProperty);
|
||||||
battery.blinkingIfCriticalLowVisibleProperty.bindTo(timeCalcConfiguration.batteryBlinkingIfCriticalLowVisibleProperty);
|
battery.chargingCharacterVisibleProperty
|
||||||
|
.bindTo(timeCalcConfiguration.batteryChargingCharacterVisibleProperty);
|
||||||
|
battery.nameVisibleProperty
|
||||||
|
.bindTo(timeCalcConfiguration.batteryNameVisibleProperty);
|
||||||
|
battery.labelVisibleProperty
|
||||||
|
.bindTo(timeCalcConfiguration.batteryLabelVisibleProperty);
|
||||||
|
battery.blinkingIfCriticalLowVisibleProperty
|
||||||
|
.bindTo(timeCalcConfiguration.batteryBlinkingIfCriticalLowVisibleProperty);
|
||||||
switch (battery.getName()) {
|
switch (battery.getName()) {
|
||||||
case MinuteBattery.MINUTE : battery.visibleProperty.bindTo(timeCalcConfiguration.batteryMinuteVisibleProperty);break;
|
case MinuteBattery.MINUTE:
|
||||||
case HourBattery.HOUR : battery.visibleProperty.bindTo(timeCalcConfiguration.batteryHourVisibleProperty);break;
|
battery.visibleProperty
|
||||||
case DayBattery.DAY : battery.visibleProperty.bindTo(timeCalcConfiguration.batteryDayVisibleProperty);break;
|
.bindTo(timeCalcConfiguration.batteryMinuteVisibleProperty);
|
||||||
case WeekBattery.WEEK : battery.visibleProperty.bindTo(timeCalcConfiguration.batteryWeekVisibleProperty);break;
|
break;
|
||||||
case MonthBattery.MONTH : battery.visibleProperty.bindTo(timeCalcConfiguration.batteryMonthVisibleProperty);break;
|
case HourBattery.HOUR:
|
||||||
case YearBattery.YEAR : battery.visibleProperty.bindTo(timeCalcConfiguration.batteryYearVisibleProperty);break;
|
battery.visibleProperty
|
||||||
default: {}
|
.bindTo(timeCalcConfiguration.batteryHourVisibleProperty);
|
||||||
};
|
break;
|
||||||
|
case DayBattery.DAY:
|
||||||
|
battery.visibleProperty
|
||||||
|
.bindTo(timeCalcConfiguration.batteryDayVisibleProperty);
|
||||||
|
break;
|
||||||
|
case WeekBattery.WEEK:
|
||||||
|
battery.visibleProperty
|
||||||
|
.bindTo(timeCalcConfiguration.batteryWeekVisibleProperty);
|
||||||
|
break;
|
||||||
|
case MonthBattery.MONTH:
|
||||||
|
battery.visibleProperty
|
||||||
|
.bindTo(timeCalcConfiguration.batteryMonthVisibleProperty);
|
||||||
|
break;
|
||||||
|
case YearBattery.YEAR:
|
||||||
|
battery.visibleProperty
|
||||||
|
.bindTo(timeCalcConfiguration.batteryYearVisibleProperty);
|
||||||
|
break;
|
||||||
|
default: {
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
componentRegistry.getSet().stream().filter(c -> c instanceof Widget)
|
||||||
componentRegistry.getSet().stream().filter(c -> c instanceof Widget).forEach(c
|
.forEach(c
|
||||||
-> {
|
-> {
|
||||||
Widget widget = (Widget) c;
|
Widget widget = (Widget) c;
|
||||||
widget.smileysVisibleProperty.bindTo(timeCalcConfiguration.smileysVisibleProperty);
|
widget.smileysVisibleProperty
|
||||||
widget.smileysVisibleOnlyIfMouseMovingOverProperty.bindTo(timeCalcConfiguration.smileysVisibleOnlyIfMouseMovingOverProperty);
|
.bindTo(timeCalcConfiguration.smileysVisibleProperty);
|
||||||
widget.smileysColoredProperty.bindTo(timeCalcConfiguration.smileysColoredProperty);
|
widget.smileysVisibleOnlyIfMouseMovingOverProperty
|
||||||
|
.bindTo(timeCalcConfiguration.smileysVisibleOnlyIfMouseMovingOverProperty);
|
||||||
|
widget.smileysColoredProperty
|
||||||
|
.bindTo(timeCalcConfiguration.smileysColoredProperty);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
setSize(dayBattery.getX() + dayBattery.getWidth() + 3 * SwingUtils.MARGIN,
|
setSize(dayBattery.getX() + dayBattery.getWidth()
|
||||||
focusButton.getY() + focusButton.getHeight() + SwingUtils.MARGIN + focusButton.getHeight() + 2 * SwingUtils.MARGIN);
|
+ 3 * 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
|
||||||
.valueOf(timeCalcApp.visibilityProperty.getValue());
|
.valueOf(timeCalcApp.visibilityProperty.getValue());
|
||||||
if (!timeCalcConfiguration.visibilitySupportedColoredProperty.isEnabled() && currentVisibility.isColored()) {
|
if (!timeCalcConfiguration.visibilitySupportedColoredProperty
|
||||||
|
.isEnabled() && currentVisibility.isColored()) {
|
||||||
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
|
timeCalcApp.visibilityProperty.setValue(Visibility.GRAY.name());
|
||||||
}
|
}
|
||||||
if (stopBeforeEnd) {
|
if (stopBeforeEnd) {
|
||||||
@ -424,14 +509,16 @@ public class MainWindow extends TWindow {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentRegistry.setVisible(c -> (c instanceof Widget ? ((Widget)c).visibleProperty.isEnabled()
|
componentRegistry.setVisible(c -> (!(c instanceof Widget)
|
||||||
: true) /*|| (c instanceof TButton ? ((Widget)c).visibleProperty.isEnabled()
|
|| ((Widget) c).visibleProperty
|
||||||
|
.isEnabled()) /*|| (c instanceof TButton ? ((Widget)c).visibleProperty.isEnabled()
|
||||||
: true)*/, currentVisibility.isNotNone());
|
: true)*/, currentVisibility.isNotNone());
|
||||||
|
|
||||||
jokeButton.setVisible(
|
jokeButton.setVisible(
|
||||||
TimeCalcProperties.getInstance().getBooleanProperty(
|
TimeCalcProperties.getInstance().getBooleanProperty(
|
||||||
TimeCalcProperty.JOKES_VISIBLE)
|
TimeCalcProperty.JOKES_VISIBLE)
|
||||||
&& !currentVisibility.isNone() && MainWindow.hideShowCheckBox.isSelected());
|
&& !currentVisibility.isNone()
|
||||||
|
&& MainWindow.hideShowCheckBox.isSelected());
|
||||||
|
|
||||||
setTitle(currentVisibility.isNone() ? "" : getWindowTitle());
|
setTitle(currentVisibility.isNone() ? "" : getWindowTitle());
|
||||||
|
|
||||||
@ -486,8 +573,10 @@ public class MainWindow extends TWindow {
|
|||||||
hourBattery.setLabel(
|
hourBattery.setLabel(
|
||||||
hourDone + "/" + (totalMinutes / 60));
|
hourDone + "/" + (totalMinutes / 60));
|
||||||
}
|
}
|
||||||
minuteBattery.setDonePercent(MinuteBattery.getMinuteProgress(secondNow, millisecondNow));
|
minuteBattery.setDonePercent(
|
||||||
yearBattery.setDonePercent(YearBattery.getYearProgress(analogClock));
|
MinuteBattery.getMinuteProgress(secondNow, millisecondNow));
|
||||||
|
yearBattery
|
||||||
|
.setDonePercent(YearBattery.getYearProgress(analogClock));
|
||||||
yearBattery.setLabel("");
|
yearBattery.setLabel("");
|
||||||
//yearBattery.setDonePercent(YearBattery.getYearProgress(2024,0,1,0,0,0,0));
|
//yearBattery.setDonePercent(YearBattery.getYearProgress(2024,0,1,0,0,0,0));
|
||||||
int totalSecondsRemains
|
int totalSecondsRemains
|
||||||
@ -568,10 +657,13 @@ public class MainWindow extends TWindow {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindToIfPropertyMissing(Properties properties, String key, Calendar cal, int timeUnit, IntegerProperty firstProperty, Property secondProperty) {
|
private void bindToIfPropertyMissing(Properties properties, String key,
|
||||||
|
Calendar cal, int timeUnit, IntegerProperty firstProperty,
|
||||||
|
Property secondProperty) {
|
||||||
if (properties.containsKey(key)) {
|
if (properties.containsKey(key)) {
|
||||||
cal.set(timeUnit, Integer.parseInt(
|
cal.set(timeUnit, Integer.parseInt(
|
||||||
(String) properties.get(key)) + (timeUnit == Calendar.MONTH ? -1 : 0));
|
(String) properties.get(key)) + (
|
||||||
|
timeUnit == Calendar.MONTH ? -1 : 0));
|
||||||
firstProperty.setValue(Integer.valueOf(
|
firstProperty.setValue(Integer.valueOf(
|
||||||
(String) properties.get(key)));
|
(String) properties.get(key)));
|
||||||
} else {
|
} else {
|
||||||
@ -615,6 +707,7 @@ public class MainWindow extends TWindow {
|
|||||||
|
|
||||||
this.configWindow.doEnableEverything();
|
this.configWindow.doEnableEverything();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doDisableAlmostEverything() {
|
public void doDisableAlmostEverything() {
|
||||||
|
|
||||||
if (this.configWindow == null) {
|
if (this.configWindow == null) {
|
||||||
|
@ -5,6 +5,7 @@ import java.awt.Color;
|
|||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
|
||||||
import static org.nanoboot.utils.timecalc.swing.common.Widget.CLOSE_BUTTON_SIDE;
|
import static org.nanoboot.utils.timecalc.swing.common.Widget.CLOSE_BUTTON_SIDE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,24 +14,32 @@ import static org.nanoboot.utils.timecalc.swing.common.Widget.CLOSE_BUTTON_SIDE;
|
|||||||
*/
|
*/
|
||||||
public class SwingUtils {
|
public class SwingUtils {
|
||||||
|
|
||||||
public static void paintCloseIcon(Graphics brush, int width) {
|
public static final int MARGIN = 10;
|
||||||
brush.setColor(SwingUtils.CLOSE_BUTTON_BACKGROUND_COLOR);
|
public static final Color CLOSE_BUTTON_BACKGROUND_COLOR =
|
||||||
brush.fillOval(width- CLOSE_BUTTON_SIDE - 1, 0 + 1, CLOSE_BUTTON_SIDE, CLOSE_BUTTON_SIDE);
|
new Color(127, 127, 127);
|
||||||
brush.setColor(Color.LIGHT_GRAY);
|
public static final Font SMALL_FONT = new Font("sans", Font.BOLD, 10);
|
||||||
Graphics2D brush2d = (Graphics2D) brush;
|
public static final Font MEDIUM_MONOSPACE_FONT =
|
||||||
brush2d.setStroke(new BasicStroke(2f));
|
new Font(Font.MONOSPACED, Font.PLAIN, 12);
|
||||||
brush.drawLine(width - CLOSE_BUTTON_SIDE - 1 + 2, 0 + 1 + 2, width - 0 * CLOSE_BUTTON_SIDE - 1 - 2, 0 + CLOSE_BUTTON_SIDE + 1 - 2);
|
|
||||||
brush.drawLine(width - CLOSE_BUTTON_SIDE - 1 + 2, 0 + CLOSE_BUTTON_SIDE + 1 - 2, width - 0 * CLOSE_BUTTON_SIDE - 1 - 2, 0 + 1 + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
private SwingUtils() {
|
private SwingUtils() {
|
||||||
//Not meant to be instantiated.
|
//Not meant to be instantiated.
|
||||||
}
|
}
|
||||||
public static final int MARGIN = 10;
|
|
||||||
public static final Color CLOSE_BUTTON_BACKGROUND_COLOR = new Color(127, 127, 127);
|
|
||||||
|
|
||||||
public static final Font SMALL_FONT = new Font("sans", Font.BOLD, 10);
|
public static void paintCloseIcon(Graphics brush, int width) {
|
||||||
public static final Font MEDIUM_MONOSPACE_FONT = new Font(Font.MONOSPACED, Font.PLAIN, 12);
|
brush.setColor(SwingUtils.CLOSE_BUTTON_BACKGROUND_COLOR);
|
||||||
|
brush.fillOval(width - CLOSE_BUTTON_SIDE - 1, 0 + 1, CLOSE_BUTTON_SIDE,
|
||||||
|
CLOSE_BUTTON_SIDE);
|
||||||
|
brush.setColor(Color.LIGHT_GRAY);
|
||||||
|
Graphics2D brush2d = (Graphics2D) brush;
|
||||||
|
brush2d.setStroke(new BasicStroke(2f));
|
||||||
|
brush.drawLine(width - CLOSE_BUTTON_SIDE - 1 + 2, 0 + 1 + 2,
|
||||||
|
width - 0 * CLOSE_BUTTON_SIDE - 1 - 2,
|
||||||
|
0 + CLOSE_BUTTON_SIDE + 1 - 2);
|
||||||
|
brush.drawLine(width - CLOSE_BUTTON_SIDE - 1 + 2,
|
||||||
|
0 + CLOSE_BUTTON_SIDE + 1 - 2,
|
||||||
|
width - 0 * CLOSE_BUTTON_SIDE - 1 - 2, 0 + 1 + 2);
|
||||||
|
}
|
||||||
|
|
||||||
public static final Color getColorFromString(String s) {
|
public static final Color getColorFromString(String s) {
|
||||||
if (s.isEmpty()) {
|
if (s.isEmpty()) {
|
||||||
System.out.println("error: empty string for color");
|
System.out.println("error: empty string for color");
|
||||||
|
@ -19,18 +19,16 @@ public class TButton extends JButton implements GetProperty {
|
|||||||
|
|
||||||
private static final int BUTTON_WIDTH = 100;
|
private static final int BUTTON_WIDTH = 100;
|
||||||
private static final int BUTTON_HEIGHT = 30;
|
private static final int BUTTON_HEIGHT = 30;
|
||||||
|
public final BooleanProperty visibilitySupportedColoredProperty
|
||||||
|
= new BooleanProperty("visibilitySupportedColoredProperty", true);
|
||||||
|
public final BooleanProperty visibleProperty
|
||||||
|
= new BooleanProperty("visibleProperty", true);
|
||||||
public StringProperty visibilityProperty
|
public StringProperty visibilityProperty
|
||||||
= new StringProperty("visibilityProperty",
|
= new StringProperty("visibilityProperty",
|
||||||
Visibility.STRONGLY_COLORED.name());
|
Visibility.STRONGLY_COLORED.name());
|
||||||
|
|
||||||
public final BooleanProperty visibilitySupportedColoredProperty
|
|
||||||
= new BooleanProperty("visibilitySupportedColoredProperty", true);
|
|
||||||
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 -> {
|
||||||
@ -68,7 +66,8 @@ public class TButton extends JButton implements GetProperty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBoundsFromLeft(JComponent jComponent) {
|
public void setBoundsFromLeft(JComponent jComponent) {
|
||||||
setBounds(jComponent.getX() + jComponent.getWidth() + SwingUtils.MARGIN, jComponent.getY());
|
setBounds(jComponent.getX() + jComponent.getWidth() + SwingUtils.MARGIN,
|
||||||
|
jComponent.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBoundsFromTop(JComponent jComponent) {
|
public void setBoundsFromTop(JComponent jComponent) {
|
||||||
@ -92,6 +91,7 @@ public class TButton extends JButton implements GetProperty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void addActionListener() {
|
void addActionListener() {
|
||||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
throw new UnsupportedOperationException(
|
||||||
|
"Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ package org.nanoboot.utils.timecalc.swing.common;
|
|||||||
* // Show a simple toaster toasterManager.showToaster( new ImageIcon(
|
* // Show a simple toaster toasterManager.showToaster( new ImageIcon(
|
||||||
* "mylogo.gif" ), "A simple toaster with an image" ); } }
|
* "mylogo.gif" ), "A simple toaster with an image" ); } }
|
||||||
*/
|
*/
|
||||||
import org.nanoboot.utils.timecalc.utils.common.Utils;
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
@ -431,7 +430,8 @@ public class Toaster {
|
|||||||
stopYPosition = startYPosition - toasterHeight - 1;
|
stopYPosition = startYPosition - toasterHeight - 1;
|
||||||
if (currentNumberOfToaster > 0) {
|
if (currentNumberOfToaster > 0) {
|
||||||
stopYPosition
|
stopYPosition
|
||||||
= stopYPosition - (maxToaster % maxToasterInSceen
|
=
|
||||||
|
stopYPosition - (maxToaster % maxToasterInSceen
|
||||||
* toasterHeight);
|
* toasterHeight);
|
||||||
} else {
|
} else {
|
||||||
maxToaster = 0;
|
maxToaster = 0;
|
||||||
@ -442,7 +442,8 @@ public class Toaster {
|
|||||||
|
|
||||||
if (currentNumberOfToaster > 0) {
|
if (currentNumberOfToaster > 0) {
|
||||||
stopYPosition
|
stopYPosition
|
||||||
= stopYPosition + (maxToaster % maxToasterInSceen
|
=
|
||||||
|
stopYPosition + (maxToaster % maxToasterInSceen
|
||||||
* toasterHeight);
|
* toasterHeight);
|
||||||
} else {
|
} else {
|
||||||
maxToaster = 0;
|
maxToaster = 0;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.nanoboot.utils.timecalc.swing.common;
|
package org.nanoboot.utils.timecalc.swing.common;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.app.GetProperty;
|
import org.nanoboot.utils.timecalc.app.GetProperty;
|
||||||
|
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressSmileyIcon;
|
import org.nanoboot.utils.timecalc.swing.progress.ProgressSmileyIcon;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.ProgressSmiley;
|
import org.nanoboot.utils.timecalc.utils.common.ProgressSmiley;
|
||||||
@ -12,7 +13,6 @@ import javax.swing.ImageIcon;
|
|||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
import java.awt.BasicStroke;
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
@ -20,7 +20,6 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.awt.event.MouseMotionListener;
|
import java.awt.event.MouseMotionListener;
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
@ -29,16 +28,12 @@ import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
|||||||
public class Widget extends JPanel implements
|
public class Widget extends JPanel implements
|
||||||
GetProperty {
|
GetProperty {
|
||||||
|
|
||||||
|
public static final int CLOSE_BUTTON_SIDE = 15;
|
||||||
protected static final Color FOREGROUND_COLOR = new Color(220, 220, 220);
|
protected static final Color FOREGROUND_COLOR = new Color(220, 220, 220);
|
||||||
protected static final Color FOREGROUND_COLOR2 = new Color(210, 210, 210);
|
protected static final Color FOREGROUND_COLOR2 = new Color(210, 210, 210);
|
||||||
protected static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
protected static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
||||||
protected static final Font BIG_FONT = new Font("sans", Font.BOLD, 24);
|
protected static final Font BIG_FONT = new Font("sans", Font.BOLD, 24);
|
||||||
protected static final Font MEDIUM_FONT = new Font("sans", Font.BOLD, 16);
|
protected static final Font MEDIUM_FONT = new Font("sans", Font.BOLD, 16);
|
||||||
public static final int CLOSE_BUTTON_SIDE = 15;
|
|
||||||
|
|
||||||
public StringProperty visibilityProperty
|
|
||||||
= new StringProperty("widget.visibilityProperty",
|
|
||||||
Visibility.STRONGLY_COLORED.name());
|
|
||||||
public final BooleanProperty visibilitySupportedColoredProperty
|
public final BooleanProperty visibilitySupportedColoredProperty
|
||||||
= new BooleanProperty("visibilitySupportedColoredProperty", true);
|
= new BooleanProperty("visibilitySupportedColoredProperty", true);
|
||||||
public final BooleanProperty visibleProperty
|
public final BooleanProperty visibleProperty
|
||||||
@ -46,9 +41,14 @@ public class Widget extends JPanel implements
|
|||||||
public final BooleanProperty smileysVisibleProperty
|
public final BooleanProperty smileysVisibleProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.SMILEYS_VISIBLE.getKey());
|
= new BooleanProperty(TimeCalcProperty.SMILEYS_VISIBLE.getKey());
|
||||||
public final BooleanProperty smileysVisibleOnlyIfMouseMovingOverProperty
|
public final BooleanProperty smileysVisibleOnlyIfMouseMovingOverProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.SMILEYS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER.getKey());
|
= new BooleanProperty(
|
||||||
|
TimeCalcProperty.SMILEYS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
|
||||||
|
.getKey());
|
||||||
public final BooleanProperty smileysColoredProperty
|
public final BooleanProperty smileysColoredProperty
|
||||||
= new BooleanProperty("smileysColoredProperty", true);
|
= new BooleanProperty("smileysColoredProperty", true);
|
||||||
|
public StringProperty visibilityProperty
|
||||||
|
= new StringProperty("widget.visibilityProperty",
|
||||||
|
Visibility.STRONGLY_COLORED.name());
|
||||||
protected int side = 0;
|
protected int side = 0;
|
||||||
protected double donePercent = 0;
|
protected double donePercent = 0;
|
||||||
protected boolean mouseOver = false;
|
protected boolean mouseOver = false;
|
||||||
@ -69,7 +69,8 @@ public class Widget extends JPanel implements
|
|||||||
|
|
||||||
int x = e.getX();
|
int x = e.getX();
|
||||||
int y = e.getY();
|
int y = e.getY();
|
||||||
mouseOverCloseButton = x >= getWidth() - CLOSE_BUTTON_SIDE && y <= CLOSE_BUTTON_SIDE;
|
mouseOverCloseButton = x >= getWidth() - CLOSE_BUTTON_SIDE
|
||||||
|
&& y <= CLOSE_BUTTON_SIDE;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addMouseListener(new MouseListener() {
|
addMouseListener(new MouseListener() {
|
||||||
@ -160,7 +161,8 @@ public class Widget extends JPanel implements
|
|||||||
}
|
}
|
||||||
Visibility visibility
|
Visibility visibility
|
||||||
= Visibility.valueOf(visibilityProperty.getValue());
|
= Visibility.valueOf(visibilityProperty.getValue());
|
||||||
super.setVisible(visibility != Visibility.NONE && visibleProperty.isEnabled());
|
super.setVisible(
|
||||||
|
visibility != Visibility.NONE && visibleProperty.isEnabled());
|
||||||
paintWidget(brush);
|
paintWidget(brush);
|
||||||
|
|
||||||
if (mouseOver && mouseOverCloseButton) {
|
if (mouseOver && mouseOverCloseButton) {
|
||||||
@ -182,8 +184,11 @@ public class Widget extends JPanel implements
|
|||||||
return visibilitySupportedColoredProperty;
|
return visibilitySupportedColoredProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void paintSmiley(Visibility visibility, Graphics2D brush, int x, int y) {
|
protected void paintSmiley(Visibility visibility, Graphics2D brush, int x,
|
||||||
if (smileysVisibleProperty.isDisabled() || (!mouseOver && smileysVisibleOnlyIfMouseMovingOverProperty.isEnabled())) {
|
int y) {
|
||||||
|
if (smileysVisibleProperty.isDisabled() || (!mouseOver
|
||||||
|
&& smileysVisibleOnlyIfMouseMovingOverProperty
|
||||||
|
.isEnabled())) {
|
||||||
if (this.smileyIcon != null) {
|
if (this.smileyIcon != null) {
|
||||||
this.remove(smileyIcon);
|
this.remove(smileyIcon);
|
||||||
this.smileyIcon = null;
|
this.smileyIcon = null;
|
||||||
@ -212,7 +217,8 @@ public class Widget extends JPanel implements
|
|||||||
brush.setColor(Color.BLACK);
|
brush.setColor(Color.BLACK);
|
||||||
}
|
}
|
||||||
Color currentColor = brush.getColor();
|
Color currentColor = brush.getColor();
|
||||||
brush.setColor(visibility.isStronglyColored() ? Color.WHITE : BACKGROUND_COLOR);
|
brush.setColor(visibility.isStronglyColored() ? Color.WHITE :
|
||||||
|
BACKGROUND_COLOR);
|
||||||
brush.fillRect(
|
brush.fillRect(
|
||||||
x, y,
|
x, y,
|
||||||
20,
|
20,
|
||||||
@ -226,7 +232,9 @@ public class Widget extends JPanel implements
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (colored) {
|
if (colored) {
|
||||||
ImageIcon imageIcon = ProgressSmileyIcon.forSmiley(ProgressSmiley.forProgress(donePercent)).getIcon();
|
ImageIcon imageIcon = ProgressSmileyIcon
|
||||||
|
.forSmiley(ProgressSmiley.forProgress(donePercent))
|
||||||
|
.getIcon();
|
||||||
if (this.smileyIcon != null) {
|
if (this.smileyIcon != null) {
|
||||||
this.remove(smileyIcon);
|
this.remove(smileyIcon);
|
||||||
this.smileyIcon = null;
|
this.smileyIcon = null;
|
||||||
|
@ -27,6 +27,40 @@ public class AnalogClock extends Widget {
|
|||||||
public static final Color COLOR_FOR_MILLISECOND_HAND_STRONGLY_COLORED
|
public static final Color COLOR_FOR_MILLISECOND_HAND_STRONGLY_COLORED
|
||||||
= new Color(246,
|
= new Color(246,
|
||||||
152, 51);
|
152, 51);
|
||||||
|
public final BooleanProperty borderVisibleProperty
|
||||||
|
= new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_VISIBLE
|
||||||
|
.getKey());
|
||||||
|
public final BooleanProperty borderOnlyHoursProperty
|
||||||
|
= new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_ONLY_HOURS
|
||||||
|
.getKey());
|
||||||
|
public final BooleanProperty numbersVisibleProperty
|
||||||
|
= new BooleanProperty(TimeCalcProperty.CLOCK_NUMBERS_VISIBLE
|
||||||
|
.getKey());
|
||||||
|
public final BooleanProperty circleVisibleProperty
|
||||||
|
= new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_VISIBLE
|
||||||
|
.getKey());
|
||||||
|
public final BooleanProperty circleStrongBorderProperty
|
||||||
|
= new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_STRONG_BORDER
|
||||||
|
.getKey());
|
||||||
|
public final BooleanProperty centreCircleVisibleProperty
|
||||||
|
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_VISIBLE
|
||||||
|
.getKey());
|
||||||
|
public final StringProperty centreCircleBorderColorProperty
|
||||||
|
= new StringProperty(TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR
|
||||||
|
.getKey());
|
||||||
|
public final BooleanProperty centreCircleBlackProperty
|
||||||
|
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK
|
||||||
|
.getKey());
|
||||||
|
public final BooleanProperty progressVisibleOnlyIfMouseMovingOverProperty
|
||||||
|
= new BooleanProperty(
|
||||||
|
TimeCalcProperty.CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
|
||||||
|
.getKey());
|
||||||
|
public final BooleanProperty dateVisibleOnlyIfMouseMovingOverProperty
|
||||||
|
= new BooleanProperty(
|
||||||
|
TimeCalcProperty.CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
|
||||||
|
.getKey());
|
||||||
|
private final TimeHM endTime;
|
||||||
|
private final int endAngle;
|
||||||
public IntegerProperty startHourProperty
|
public IntegerProperty startHourProperty
|
||||||
= new IntegerProperty("startHourProperty");
|
= new IntegerProperty("startHourProperty");
|
||||||
public IntegerProperty startMinuteProperty
|
public IntegerProperty startMinuteProperty
|
||||||
@ -59,39 +93,8 @@ public class AnalogClock extends Widget {
|
|||||||
= new BooleanProperty("handsLongProperty", true);
|
= new BooleanProperty("handsLongProperty", true);
|
||||||
public BooleanProperty handsColoredProperty
|
public BooleanProperty handsColoredProperty
|
||||||
= new BooleanProperty("handsColoredProperty", true);
|
= new BooleanProperty("handsColoredProperty", true);
|
||||||
public final BooleanProperty borderVisibleProperty
|
|
||||||
= new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_VISIBLE
|
|
||||||
.getKey());
|
|
||||||
public final BooleanProperty borderOnlyHoursProperty
|
|
||||||
= new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_ONLY_HOURS
|
|
||||||
.getKey());
|
|
||||||
public final BooleanProperty numbersVisibleProperty
|
|
||||||
= new BooleanProperty(TimeCalcProperty.CLOCK_NUMBERS_VISIBLE
|
|
||||||
.getKey());
|
|
||||||
public final BooleanProperty circleVisibleProperty
|
|
||||||
= new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_VISIBLE
|
|
||||||
.getKey());
|
|
||||||
public final BooleanProperty circleStrongBorderProperty
|
|
||||||
= new BooleanProperty(TimeCalcProperty.CLOCK_CIRCLE_STRONG_BORDER
|
|
||||||
.getKey());
|
|
||||||
|
|
||||||
public final BooleanProperty centreCircleVisibleProperty
|
|
||||||
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_VISIBLE
|
|
||||||
.getKey());
|
|
||||||
public final StringProperty centreCircleBorderColorProperty
|
|
||||||
= new StringProperty(TimeCalcProperty.CLOCK_CIRCLE_BORDER_COLOR
|
|
||||||
.getKey());
|
|
||||||
public final BooleanProperty centreCircleBlackProperty
|
|
||||||
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK
|
|
||||||
.getKey());
|
|
||||||
public final BooleanProperty progressVisibleOnlyIfMouseMovingOverProperty
|
|
||||||
= new BooleanProperty(TimeCalcProperty.CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER.getKey());
|
|
||||||
public final BooleanProperty dateVisibleOnlyIfMouseMovingOverProperty
|
|
||||||
= new BooleanProperty(TimeCalcProperty.CLOCK_DATE_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER.getKey());
|
|
||||||
private TimeHM startTime;
|
private TimeHM startTime;
|
||||||
private final TimeHM endTime;
|
|
||||||
private int startAngle;
|
private int startAngle;
|
||||||
private final int endAngle;
|
|
||||||
private Color customCircleColor = null;
|
private Color customCircleColor = null;
|
||||||
|
|
||||||
public AnalogClock(TimeHM startTimeIn,
|
public AnalogClock(TimeHM startTimeIn,
|
||||||
@ -106,13 +109,15 @@ public class AnalogClock extends Widget {
|
|||||||
}
|
}
|
||||||
this.startTime = startTimeIn.cloneInstance();
|
this.startTime = startTimeIn.cloneInstance();
|
||||||
this.startAngle
|
this.startAngle
|
||||||
= (int) ((startTime.getHour() + startTime.getMinute() / 60d) / 12d
|
=
|
||||||
|
(int) ((startTime.getHour() + startTime.getMinute() / 60d) / 12d
|
||||||
* 360d);
|
* 360d);
|
||||||
|
|
||||||
setPreferredSize(new Dimension(200, 200));
|
setPreferredSize(new Dimension(200, 200));
|
||||||
|
|
||||||
centreCircleBorderColorProperty.addListener(property
|
centreCircleBorderColorProperty.addListener(property
|
||||||
-> customCircleColor = SwingUtils.getColorFromString(centreCircleBorderColorProperty.getValue()));
|
-> customCircleColor = SwingUtils.getColorFromString(
|
||||||
|
centreCircleBorderColorProperty.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -163,9 +168,11 @@ public class AnalogClock extends Widget {
|
|||||||
int hour = hourProperty.getValue();
|
int hour = hourProperty.getValue();
|
||||||
|
|
||||||
if (customCircleColor == null) {
|
if (customCircleColor == null) {
|
||||||
customCircleColor = SwingUtils.getColorFromString(centreCircleBorderColorProperty.getValue());
|
customCircleColor = SwingUtils.getColorFromString(
|
||||||
|
centreCircleBorderColorProperty.getValue());
|
||||||
}
|
}
|
||||||
if ((mouseOver || progressVisibleOnlyIfMouseMovingOverProperty.isDisabled()) && visibility.isStronglyColored()) {
|
if ((mouseOver || progressVisibleOnlyIfMouseMovingOverProperty
|
||||||
|
.isDisabled()) && visibility.isStronglyColored()) {
|
||||||
this.startTime = new TimeHM(hour, minute);
|
this.startTime = new TimeHM(hour, minute);
|
||||||
this.startAngle
|
this.startAngle
|
||||||
= (int) ((startTime.getHour() + startTime.getMinute() / 60d)
|
= (int) ((startTime.getHour() + startTime.getMinute() / 60d)
|
||||||
@ -181,7 +188,9 @@ public class AnalogClock extends Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
if (millisecondEnabledProperty.isEnabled() && secondEnabledProperty.isEnabled() && minuteEnabledProperty.isEnabled() && hourEnabledProperty.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);
|
||||||
|
|
||||||
@ -194,7 +203,8 @@ public class AnalogClock extends Widget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (secondEnabledProperty.isEnabled() && minuteEnabledProperty.isEnabled() && hourEnabledProperty.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);
|
||||||
|
|
||||||
@ -204,7 +214,8 @@ public class AnalogClock extends Widget {
|
|||||||
Color.RED, visibility);
|
Color.RED, visibility);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (minuteEnabledProperty.isEnabled() && hourEnabledProperty.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);
|
||||||
@ -217,7 +228,8 @@ public class AnalogClock extends Widget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hourEnabledProperty.isEnabled()) {
|
if (hourEnabledProperty.isEnabled()) {
|
||||||
double hours = hour / 12.0 + minute / 60.0 / 12 + second / 60 / 60 / 12;
|
double hours =
|
||||||
|
hour / 12.0 + minute / 60.0 / 12 + second / 60 / 60 / 12;
|
||||||
drawHand(g2d, side / 2 - 40,
|
drawHand(g2d, side / 2 - 40,
|
||||||
hours, 4.0f,
|
hours, 4.0f,
|
||||||
Color.BLACK, visibility);
|
Color.BLACK, visibility);
|
||||||
@ -233,7 +245,8 @@ public class AnalogClock extends Widget {
|
|||||||
if (borderOnlyHoursProperty.isEnabled() && minuteI % 5 != 0) {
|
if (borderOnlyHoursProperty.isEnabled() && minuteI % 5 != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
drawBorder(g2d, minuteI, minuteI % 5 == 0 ? (numbersVisibleProperty.isEnabled() ? 2f : 4f) : 1f,
|
drawBorder(g2d, minuteI, minuteI % 5 == 0 ?
|
||||||
|
(numbersVisibleProperty.isEnabled() ? 2f : 4f) : 1f,
|
||||||
Color.BLACK, visibility);
|
Color.BLACK, visibility);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -249,7 +262,9 @@ public class AnalogClock extends Widget {
|
|||||||
Color currentColor = brush.getColor();
|
Color currentColor = brush.getColor();
|
||||||
Visibility visibility
|
Visibility visibility
|
||||||
= Visibility.valueOf(visibilityProperty.getValue());
|
= Visibility.valueOf(visibilityProperty.getValue());
|
||||||
brush.setColor(visibility.isStronglyColored() || mouseOver ? (centreCircleBlackProperty.isEnabled() ? Color.BLACK : Color.RED)
|
brush.setColor(visibility.isStronglyColored() || mouseOver ?
|
||||||
|
(centreCircleBlackProperty.isEnabled() ? Color.BLACK :
|
||||||
|
Color.RED)
|
||||||
: FOREGROUND_COLOR);
|
: FOREGROUND_COLOR);
|
||||||
brush.fillOval(centerX - 3, centerY - 3, 8, 8);
|
brush.fillOval(centerX - 3, centerY - 3, 8, 8);
|
||||||
brush.setColor(currentColor);
|
brush.setColor(currentColor);
|
||||||
@ -259,12 +274,19 @@ public class AnalogClock extends Widget {
|
|||||||
float stroke, Color color, Visibility visibility) {
|
float stroke, Color color, Visibility visibility) {
|
||||||
double value = ((double) forMinute) / 60d;
|
double value = ((double) forMinute) / 60d;
|
||||||
boolean hourAngle = forMinute % 5 == 0;
|
boolean hourAngle = forMinute % 5 == 0;
|
||||||
int length = side / (numbersVisibleProperty.isEnabled() ? 18 : (hourAngle ? 12 : 18));
|
int length = side / (numbersVisibleProperty.isEnabled() ? 18 :
|
||||||
|
(hourAngle ? 12 : 18));
|
||||||
double angle = Math.PI * 2 * (value - 0.25);
|
double angle = Math.PI * 2 * (value - 0.25);
|
||||||
int startX = (int) (getWidth() / 2 + (side / 2 - length) * Math.cos(angle));
|
int startX =
|
||||||
int startY = (int) (getHeight() / 2 + (side / 2 - length) * Math.sin(angle));
|
(int) (getWidth() / 2 + (side / 2 - length) * Math.cos(angle));
|
||||||
int endX = (int) (getWidth() / 2 + (side / 2 - length * 0.50d * (hourAngle ? 0.25 : 1)) * Math.cos(angle));
|
int startY =
|
||||||
int endY = (int) (getHeight() / 2 + (side / 2 - length * 0.50d * (hourAngle ? 0.25 : 1)) * Math.sin(angle));
|
(int) (getHeight() / 2 + (side / 2 - length) * Math.sin(angle));
|
||||||
|
int endX = (int) (getWidth() / 2
|
||||||
|
+ (side / 2 - length * 0.50d * (hourAngle ? 0.25 : 1))
|
||||||
|
* Math.cos(angle));
|
||||||
|
int endY = (int) (getHeight() / 2
|
||||||
|
+ (side / 2 - length * 0.50d * (hourAngle ? 0.25 : 1))
|
||||||
|
* Math.sin(angle));
|
||||||
|
|
||||||
brush.setColor((visibility.isStronglyColored() || mouseOver) ? color
|
brush.setColor((visibility.isStronglyColored() || mouseOver) ? color
|
||||||
: FOREGROUND_COLOR);
|
: FOREGROUND_COLOR);
|
||||||
@ -279,7 +301,8 @@ public class AnalogClock extends Widget {
|
|||||||
int endX = (int) (getWidth() / 2 + length * Math.cos(angle));
|
int endX = (int) (getWidth() / 2 + length * Math.cos(angle));
|
||||||
int endY = (int) (getHeight() / 2 + length * Math.sin(angle));
|
int endY = (int) (getHeight() / 2 + length * Math.sin(angle));
|
||||||
|
|
||||||
brush.setColor((visibility.isStronglyColored() || mouseOver) ? (handsColoredProperty.isEnabled() ? color : Color.BLACK)
|
brush.setColor((visibility.isStronglyColored() || mouseOver) ?
|
||||||
|
(handsColoredProperty.isEnabled() ? color : Color.BLACK)
|
||||||
: FOREGROUND_COLOR);
|
: FOREGROUND_COLOR);
|
||||||
brush.setStroke(new BasicStroke(stroke));
|
brush.setStroke(new BasicStroke(stroke));
|
||||||
brush.drawLine(getWidth() / 2, getHeight() / 2, endX, endY);
|
brush.drawLine(getWidth() / 2, getHeight() / 2, endX, endY);
|
||||||
@ -306,7 +329,8 @@ public class AnalogClock extends Widget {
|
|||||||
brush.setColor(currentColor);
|
brush.setColor(currentColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.mouseOver || dateVisibleOnlyIfMouseMovingOverProperty.isDisabled()) {
|
if (this.mouseOver || dateVisibleOnlyIfMouseMovingOverProperty
|
||||||
|
.isDisabled()) {
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.set(Calendar.YEAR, yearProperty.getValue());
|
cal.set(Calendar.YEAR, yearProperty.getValue());
|
||||||
cal.set(Calendar.MONTH, monthProperty.getValue() - 1);
|
cal.set(Calendar.MONTH, monthProperty.getValue() - 1);
|
||||||
|
@ -38,22 +38,30 @@ public class Battery extends Widget {
|
|||||||
private final String name;
|
private final String name;
|
||||||
private final double[] randomDoubles
|
private final double[] randomDoubles
|
||||||
= new double[] {1d, 1d, 1d, 1d, 1d, 1d, 1};
|
= new double[] {1d, 1d, 1d, 1d, 1d, 1d, 1};
|
||||||
public BooleanProperty wavesVisibleProperty = new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE
|
private final BooleanProperty blinking = new BooleanProperty("blinking");
|
||||||
|
public BooleanProperty wavesVisibleProperty =
|
||||||
|
new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE
|
||||||
.getKey(), true);
|
.getKey(), true);
|
||||||
public BooleanProperty circleProgressVisibleProperty = new BooleanProperty(TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE
|
public BooleanProperty circleProgressVisibleProperty =
|
||||||
|
new BooleanProperty(TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE
|
||||||
.getKey(), true);
|
.getKey(), true);
|
||||||
public BooleanProperty percentProgressVisibleProperty = new BooleanProperty(TimeCalcProperty.BATTERY_PERCENT_PROGRESS_VISIBLE
|
public BooleanProperty percentProgressVisibleProperty = new BooleanProperty(
|
||||||
|
TimeCalcProperty.BATTERY_PERCENT_PROGRESS_VISIBLE
|
||||||
.getKey(), true);
|
.getKey(), true);
|
||||||
public BooleanProperty chargingCharacterVisibleProperty = new BooleanProperty(TimeCalcProperty.BATTERY_CHARGING_CHARACTER_VISIBLE
|
public BooleanProperty chargingCharacterVisibleProperty =
|
||||||
|
new BooleanProperty(
|
||||||
|
TimeCalcProperty.BATTERY_CHARGING_CHARACTER_VISIBLE
|
||||||
.getKey(), true);
|
.getKey(), true);
|
||||||
public BooleanProperty nameVisibleProperty = new BooleanProperty(TimeCalcProperty.BATTERY_NAME_VISIBLE
|
public BooleanProperty nameVisibleProperty =
|
||||||
|
new BooleanProperty(TimeCalcProperty.BATTERY_NAME_VISIBLE
|
||||||
.getKey(), true);
|
.getKey(), true);
|
||||||
public BooleanProperty labelVisibleProperty = new BooleanProperty(TimeCalcProperty.BATTERY_LABEL_VISIBLE
|
public BooleanProperty labelVisibleProperty =
|
||||||
|
new BooleanProperty(TimeCalcProperty.BATTERY_LABEL_VISIBLE
|
||||||
.getKey(), true);
|
.getKey(), true);
|
||||||
public BooleanProperty blinkingIfCriticalLowVisibleProperty
|
public BooleanProperty blinkingIfCriticalLowVisibleProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW
|
= new BooleanProperty(
|
||||||
|
TimeCalcProperty.BATTERY_BLINKING_IF_CRITICAL_LOW
|
||||||
.getKey(), true);
|
.getKey(), true);
|
||||||
private final BooleanProperty blinking = new BooleanProperty("blinking");
|
|
||||||
private long tmpNanoTime = 0l;
|
private long tmpNanoTime = 0l;
|
||||||
private int totalHeight = 0;
|
private int totalHeight = 0;
|
||||||
private int totalWidth;
|
private int totalWidth;
|
||||||
@ -131,7 +139,8 @@ public class Battery extends Widget {
|
|||||||
int intX = 1;
|
int intX = 1;
|
||||||
int todoHeight = totalHeight - doneHeight;
|
int todoHeight = totalHeight - doneHeight;
|
||||||
double surfacePower
|
double surfacePower
|
||||||
= 1;//donePercent < 0.5 ? 0.5 : donePercent;// (donePercent * 100 - ((int)(donePercent * 100)));
|
=
|
||||||
|
1;//donePercent < 0.5 ? 0.5 : donePercent;// (donePercent * 100 - ((int)(donePercent * 100)));
|
||||||
int waterSurfaceHeight
|
int waterSurfaceHeight
|
||||||
= (int) (4 * surfacePower);//2 + (int) (Math.random() * 3);
|
= (int) (4 * surfacePower);//2 + (int) (Math.random() * 3);
|
||||||
if (waterSurfaceHeight <= 2 || wavesVisibleProperty.isDisabled()) {
|
if (waterSurfaceHeight <= 2 || wavesVisibleProperty.isDisabled()) {
|
||||||
@ -230,7 +239,9 @@ public class Battery extends Widget {
|
|||||||
if (circleProgressVisibleProperty.isEnabled()) {
|
if (circleProgressVisibleProperty.isEnabled()) {
|
||||||
Color currentColor = brush.getColor();
|
Color currentColor = brush.getColor();
|
||||||
brush.setColor(
|
brush.setColor(
|
||||||
visibility.isStronglyColored() ? HIGH_HIGHLIGHTED : (visibility.isWeaklyColored() ? HIGH : Color.lightGray));
|
visibility.isStronglyColored() ? HIGH_HIGHLIGHTED :
|
||||||
|
(visibility.isWeaklyColored() ? HIGH :
|
||||||
|
Color.lightGray));
|
||||||
|
|
||||||
double angleDouble = donePercent * 360;
|
double angleDouble = donePercent * 360;
|
||||||
|
|
||||||
@ -239,7 +250,9 @@ public class Battery extends Widget {
|
|||||||
15, 15, 90, -(int) angleDouble);
|
15, 15, 90, -(int) angleDouble);
|
||||||
brush.setColor(
|
brush.setColor(
|
||||||
visibility.isStronglyColored() ? LIGHT_RED
|
visibility.isStronglyColored() ? LIGHT_RED
|
||||||
: visibility.isWeaklyColored() ? ULTRA_LIGHT_RED : BACKGROUND_COLOR);
|
:
|
||||||
|
visibility.isWeaklyColored() ? ULTRA_LIGHT_RED :
|
||||||
|
BACKGROUND_COLOR);
|
||||||
brush.fillArc(((int) (totalWidth * 0.45)) + 15,
|
brush.fillArc(((int) (totalWidth * 0.45)) + 15,
|
||||||
totalHeight / 4 * 3 + 28,
|
totalHeight / 4 * 3 + 28,
|
||||||
15, 15, 90, +(int) (360 - angleDouble));
|
15, 15, 90, +(int) (360 - angleDouble));
|
||||||
@ -252,17 +265,20 @@ public class Battery extends Widget {
|
|||||||
NumberFormats.FORMATTER_THREE_DECIMAL_PLACES
|
NumberFormats.FORMATTER_THREE_DECIMAL_PLACES
|
||||||
.format(donePercent * 100) + "%",
|
.format(donePercent * 100) + "%",
|
||||||
((int) (totalWidth * 0.15)),
|
((int) (totalWidth * 0.15)),
|
||||||
donePercent > 0.5 ? totalHeight / 4 * 3 : totalHeight / 4 * 1);
|
donePercent > 0.5 ? totalHeight / 4 * 3 :
|
||||||
|
totalHeight / 4 * 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (labelVisibleProperty.isEnabled() && label != null && !label.isEmpty()) {
|
if (labelVisibleProperty.isEnabled() && label != null && !label
|
||||||
|
.isEmpty()) {
|
||||||
brush.drawString(
|
brush.drawString(
|
||||||
label,
|
label,
|
||||||
((int) (totalWidth * 0.15)),
|
((int) (totalWidth * 0.15)),
|
||||||
(donePercent > 0.5 ? totalHeight / 4 * 3
|
(donePercent > 0.5 ? totalHeight / 4 * 3
|
||||||
: totalHeight / 4 * 1) + 20);
|
: totalHeight / 4 * 1) + 20);
|
||||||
}
|
}
|
||||||
if (nameVisibleProperty.isEnabled() && name != null && !name.isEmpty()) {
|
if (nameVisibleProperty.isEnabled() && name != null && !name
|
||||||
|
.isEmpty()) {
|
||||||
brush.drawString(
|
brush.drawString(
|
||||||
name,
|
name,
|
||||||
((int) (totalWidth * 0.10)),
|
((int) (totalWidth * 0.10)),
|
||||||
|
@ -6,8 +6,9 @@ package org.nanoboot.utils.timecalc.swing.progress;
|
|||||||
*/
|
*/
|
||||||
public class DayBattery extends Battery {
|
public class DayBattery extends Battery {
|
||||||
|
|
||||||
|
public static final String DAY = "Day";
|
||||||
|
|
||||||
public DayBattery(int x, int i, int i1) {
|
public DayBattery(int x, int i, int i1) {
|
||||||
super(DAY, x, i, i1);
|
super(DAY, x, i, i1);
|
||||||
}
|
}
|
||||||
public static final String DAY = "Day";
|
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,11 @@ import org.nanoboot.utils.timecalc.utils.common.TimeHM;
|
|||||||
*/
|
*/
|
||||||
public class HourBattery extends Battery {
|
public class HourBattery extends Battery {
|
||||||
|
|
||||||
|
public static final String HOUR = "Hour";
|
||||||
|
|
||||||
public HourBattery(int x, int i, int i1) {
|
public HourBattery(int x, int i, int i1) {
|
||||||
super(HOUR, x, i, i1);
|
super(HOUR, x, i, i1);
|
||||||
}
|
}
|
||||||
public static final String HOUR = "Hour";
|
|
||||||
|
|
||||||
public static double getHourProgress(TimeHM timeRemains, int secondsRemains,
|
public static double getHourProgress(TimeHM timeRemains, int secondsRemains,
|
||||||
int millisecondsRemains) {
|
int millisecondsRemains) {
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
package org.nanoboot.utils.timecalc.swing.progress;
|
package org.nanoboot.utils.timecalc.swing.progress;
|
||||||
|
|
||||||
import org.nanoboot.utils.timecalc.utils.common.TimeHM;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Vokac
|
* @author Robert Vokac
|
||||||
* @since 21.02.2024
|
* @since 21.02.2024
|
||||||
*/
|
*/
|
||||||
public class MinuteBattery extends Battery {
|
public class MinuteBattery extends Battery {
|
||||||
|
|
||||||
|
public static final String MINUTE = "Minute";
|
||||||
|
|
||||||
public MinuteBattery(int x, int i, int i1) {
|
public MinuteBattery(int x, int i, int i1) {
|
||||||
super(MINUTE, x, i, i1);
|
super(MINUTE, x, i, i1);
|
||||||
}
|
}
|
||||||
public static final String MINUTE = "Minute";
|
|
||||||
|
|
||||||
public static double getMinuteProgress(int secondNow, int millisecondNow) {
|
public static double getMinuteProgress(int secondNow, int millisecondNow) {
|
||||||
return millisecondNow / 60d / 1000d + secondNow / 60d;
|
return millisecondNow / 60d / 1000d + secondNow / 60d;
|
||||||
|
@ -6,10 +6,11 @@ package org.nanoboot.utils.timecalc.swing.progress;
|
|||||||
*/
|
*/
|
||||||
public class MonthBattery extends Battery {
|
public class MonthBattery extends Battery {
|
||||||
|
|
||||||
|
public static final String MONTH = "Month";
|
||||||
|
|
||||||
public MonthBattery(int x, int i, int i1) {
|
public MonthBattery(int x, int i, int i1) {
|
||||||
super(MONTH, x, i, i1);
|
super(MONTH, x, i, i1);
|
||||||
}
|
}
|
||||||
public static final String MONTH = "Month";
|
|
||||||
|
|
||||||
public static double getMonthProgress(int weekDayWhenMondayIsOne,
|
public static double getMonthProgress(int weekDayWhenMondayIsOne,
|
||||||
int workDaysDone, int workDaysTotal, double done) {
|
int workDaysDone, int workDaysTotal, double done) {
|
||||||
|
3
modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressCircle.java
3
modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressCircle.java
@ -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;
|
||||||
|
@ -14,12 +14,22 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class ProgressSmileyIcon extends javax.swing.ImageIcon {
|
public class ProgressSmileyIcon extends javax.swing.ImageIcon {
|
||||||
|
|
||||||
private static final Map<ProgressSmiley, ProgressSmileyIcon> cache = new HashMap<>();
|
private static final Map<ProgressSmiley, ProgressSmileyIcon> cache =
|
||||||
|
new HashMap<>();
|
||||||
@Getter
|
@Getter
|
||||||
private final ProgressSmiley progressSmiley;
|
private final ProgressSmiley progressSmiley;
|
||||||
@Getter
|
@Getter
|
||||||
private final ImageIcon icon;
|
private final ImageIcon icon;
|
||||||
|
|
||||||
|
private ProgressSmileyIcon(ProgressSmiley progressSmiley) {
|
||||||
|
this.progressSmiley = progressSmiley;
|
||||||
|
java.net.URL smileyUrl = getClass()
|
||||||
|
.getResource("/smileys/" + progressSmiley.name() + ".png");
|
||||||
|
ImageIcon tmpIcon = new javax.swing.ImageIcon(smileyUrl);
|
||||||
|
this.icon = new ImageIcon(tmpIcon.getImage()
|
||||||
|
.getScaledInstance(15, 15, Image.SCALE_SMOOTH));
|
||||||
|
}
|
||||||
|
|
||||||
public static ProgressSmileyIcon forSmiley(ProgressSmiley progressSmiley) {
|
public static ProgressSmileyIcon forSmiley(ProgressSmiley progressSmiley) {
|
||||||
if (!cache.containsKey(progressSmiley)) {
|
if (!cache.containsKey(progressSmiley)) {
|
||||||
cache.put(progressSmiley, new ProgressSmileyIcon(progressSmiley));
|
cache.put(progressSmiley, new ProgressSmileyIcon(progressSmiley));
|
||||||
@ -27,11 +37,4 @@ public class ProgressSmileyIcon extends javax.swing.ImageIcon {
|
|||||||
return cache.get(progressSmiley);
|
return cache.get(progressSmiley);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProgressSmileyIcon(ProgressSmiley progressSmiley) {
|
|
||||||
this.progressSmiley = progressSmiley;
|
|
||||||
java.net.URL smileyUrl = getClass().getResource("/smileys/" + progressSmiley.name() + ".png");
|
|
||||||
ImageIcon tmpIcon = new javax.swing.ImageIcon(smileyUrl);
|
|
||||||
this.icon = new ImageIcon(tmpIcon.getImage().getScaledInstance(15, 15, Image.SCALE_SMOOTH));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,34 +10,34 @@ public class Time extends Thread {
|
|||||||
|
|
||||||
private final IntegerProperty yearReadWriteProperty
|
private final IntegerProperty yearReadWriteProperty
|
||||||
= new IntegerProperty("yearProperty");
|
= new IntegerProperty("yearProperty");
|
||||||
public ReadOnlyProperty<Integer> yearProperty
|
|
||||||
= yearReadWriteProperty.asReadOnlyProperty();
|
|
||||||
private final IntegerProperty monthReadWriteProperty
|
private final IntegerProperty monthReadWriteProperty
|
||||||
= new IntegerProperty("monthProperty");
|
= new IntegerProperty("monthProperty");
|
||||||
public ReadOnlyProperty<Integer> monthProperty
|
|
||||||
= monthReadWriteProperty.asReadOnlyProperty();
|
|
||||||
private final IntegerProperty dayReadWriteProperty
|
private final IntegerProperty dayReadWriteProperty
|
||||||
= new IntegerProperty("dayProperty");
|
= new IntegerProperty("dayProperty");
|
||||||
public ReadOnlyProperty<Integer> dayProperty
|
|
||||||
= dayReadWriteProperty.asReadOnlyProperty();
|
|
||||||
private final IntegerProperty hourReadWriteProperty
|
private final IntegerProperty hourReadWriteProperty
|
||||||
= new IntegerProperty("hourProperty");
|
= new IntegerProperty("hourProperty");
|
||||||
public ReadOnlyProperty<Integer> hourProperty
|
|
||||||
= hourReadWriteProperty.asReadOnlyProperty();
|
|
||||||
private final IntegerProperty minuteReadWriteProperty
|
private final IntegerProperty minuteReadWriteProperty
|
||||||
= new IntegerProperty("minuteProperty");
|
= new IntegerProperty("minuteProperty");
|
||||||
public ReadOnlyProperty<Integer> minuteProperty
|
|
||||||
= minuteReadWriteProperty.asReadOnlyProperty();
|
|
||||||
private final IntegerProperty secondReadWriteProperty
|
private final IntegerProperty secondReadWriteProperty
|
||||||
= new IntegerProperty("secondProperty");
|
= new IntegerProperty("secondProperty");
|
||||||
public ReadOnlyProperty<Integer> secondProperty
|
|
||||||
= secondReadWriteProperty.asReadOnlyProperty();
|
|
||||||
private final IntegerProperty millisecondReadWriteProperty
|
private final IntegerProperty millisecondReadWriteProperty
|
||||||
= new IntegerProperty("millisecondProperty");
|
= new IntegerProperty("millisecondProperty");
|
||||||
public ReadOnlyProperty<Integer> millisecondProperty
|
|
||||||
= millisecondReadWriteProperty.asReadOnlyProperty();
|
|
||||||
private final IntegerProperty dayOfWeekReadWriteProperty
|
private final IntegerProperty dayOfWeekReadWriteProperty
|
||||||
= new IntegerProperty("dayOfWeek");
|
= new IntegerProperty("dayOfWeek");
|
||||||
|
public ReadOnlyProperty<Integer> yearProperty
|
||||||
|
= yearReadWriteProperty.asReadOnlyProperty();
|
||||||
|
public ReadOnlyProperty<Integer> monthProperty
|
||||||
|
= monthReadWriteProperty.asReadOnlyProperty();
|
||||||
|
public ReadOnlyProperty<Integer> dayProperty
|
||||||
|
= dayReadWriteProperty.asReadOnlyProperty();
|
||||||
|
public ReadOnlyProperty<Integer> hourProperty
|
||||||
|
= hourReadWriteProperty.asReadOnlyProperty();
|
||||||
|
public ReadOnlyProperty<Integer> minuteProperty
|
||||||
|
= minuteReadWriteProperty.asReadOnlyProperty();
|
||||||
|
public ReadOnlyProperty<Integer> secondProperty
|
||||||
|
= secondReadWriteProperty.asReadOnlyProperty();
|
||||||
|
public ReadOnlyProperty<Integer> millisecondProperty
|
||||||
|
= millisecondReadWriteProperty.asReadOnlyProperty();
|
||||||
public ReadOnlyProperty<Integer> dayOfWeek
|
public ReadOnlyProperty<Integer> dayOfWeek
|
||||||
= dayOfWeekReadWriteProperty.asReadOnlyProperty();
|
= dayOfWeekReadWriteProperty.asReadOnlyProperty();
|
||||||
//private long lastUpdateNanoTime = 0l;
|
//private long lastUpdateNanoTime = 0l;
|
||||||
|
@ -20,7 +20,6 @@ import java.awt.Font;
|
|||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.awt.font.LineBreakMeasurer;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -42,6 +41,7 @@ public class WalkingHumanProgress extends Widget implements
|
|||||||
private double done;
|
private double done;
|
||||||
private double totalSecondsRemainsDouble;
|
private double totalSecondsRemainsDouble;
|
||||||
private TimeHM endTime;
|
private TimeHM endTime;
|
||||||
|
|
||||||
public WalkingHumanProgress() {
|
public WalkingHumanProgress() {
|
||||||
setFont(new Font(Font.MONOSPACED, Font.PLAIN, 11));
|
setFont(new Font(Font.MONOSPACED, Font.PLAIN, 11));
|
||||||
putClientProperty("mouseEntered", "false");
|
putClientProperty("mouseEntered", "false");
|
||||||
@ -117,11 +117,12 @@ public class WalkingHumanProgress extends Widget implements
|
|||||||
} else {
|
} else {
|
||||||
String[] lines = string.split("\n");
|
String[] lines = string.split("\n");
|
||||||
|
|
||||||
|
|
||||||
Visibility visibility
|
Visibility visibility
|
||||||
= Visibility.valueOf(visibilityProperty.getValue());
|
= Visibility.valueOf(visibilityProperty.getValue());
|
||||||
|
|
||||||
brush.setColor(visibility.isStronglyColored() ? Color.BLUE : visibility.isWeaklyColored() ? Color.GRAY : Color.LIGHT_GRAY);
|
brush.setColor(visibility.isStronglyColored() ? Color.BLUE :
|
||||||
|
visibility.isWeaklyColored() ? Color.GRAY :
|
||||||
|
Color.LIGHT_GRAY);
|
||||||
brush.setFont(SwingUtils.MEDIUM_MONOSPACE_FONT);
|
brush.setFont(SwingUtils.MEDIUM_MONOSPACE_FONT);
|
||||||
int y = SwingUtils.MARGIN;
|
int y = SwingUtils.MARGIN;
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
|
@ -6,10 +6,11 @@ package org.nanoboot.utils.timecalc.swing.progress;
|
|||||||
*/
|
*/
|
||||||
public class WeekBattery extends Battery {
|
public class WeekBattery extends Battery {
|
||||||
|
|
||||||
|
public static final String WEEK = "Week";
|
||||||
|
|
||||||
public WeekBattery(int x, int i, int i1) {
|
public WeekBattery(int x, int i, int i1) {
|
||||||
super(WEEK, x, i, i1);
|
super(WEEK, x, i, i1);
|
||||||
}
|
}
|
||||||
public static final String WEEK = "Week";
|
|
||||||
|
|
||||||
public static double getWeekProgress(int weekDayWhenMondayIsOne,
|
public static double getWeekProgress(int weekDayWhenMondayIsOne,
|
||||||
double done) {
|
double done) {
|
||||||
|
@ -8,12 +8,15 @@ import java.util.Calendar;
|
|||||||
*/
|
*/
|
||||||
public class YearBattery extends Battery {
|
public class YearBattery extends Battery {
|
||||||
|
|
||||||
|
public static final String YEAR = "Year";
|
||||||
|
|
||||||
public YearBattery(int x, int i, int i1) {
|
public YearBattery(int x, int i, int i1) {
|
||||||
super(YEAR, x, i, i1);
|
super(YEAR, x, i, i1);
|
||||||
}
|
}
|
||||||
public static final String YEAR = "Year";
|
|
||||||
|
|
||||||
public static double getYearProgress(Integer year, Integer month, Integer day, Integer hour, Integer minute, Integer second, Integer millisecond) {
|
public static double getYearProgress(Integer year, Integer month,
|
||||||
|
Integer day, Integer hour, Integer minute, Integer second,
|
||||||
|
Integer millisecond) {
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.set(Calendar.YEAR, year);
|
cal.set(Calendar.YEAR, year);
|
||||||
cal.set(Calendar.MONTH, month - 1);
|
cal.set(Calendar.MONTH, month - 1);
|
||||||
|
@ -8,12 +8,17 @@ import java.io.File;
|
|||||||
*/
|
*/
|
||||||
public class FileConstants {
|
public class FileConstants {
|
||||||
public static final File TC_DIRECTORY = new File(".tc");
|
public static final File TC_DIRECTORY = new File(".tc");
|
||||||
public static final File STARTTIME_TXT = new File(TC_DIRECTORY, "starttime.txt");
|
public static final File STARTTIME_TXT =
|
||||||
public static final File OVERTIME_TXT = new File(TC_DIRECTORY, "overtime.txt");
|
new File(TC_DIRECTORY, "starttime.txt");
|
||||||
|
public static final File OVERTIME_TXT =
|
||||||
|
new File(TC_DIRECTORY, "overtime.txt");
|
||||||
public static final File TEST_TXT = new File(TC_DIRECTORY, "test.txt");
|
public static final File TEST_TXT = new File(TC_DIRECTORY, "test.txt");
|
||||||
public static final File TIME_CALC_PROFILES_TXT_FILE = new File(TC_DIRECTORY, "time-calc-profiles.txt");
|
public static final File TIME_CALC_PROFILES_TXT_FILE =
|
||||||
public static final File TIME_CALC_CURRENT_PROFILE_TXT_FILE = new File(TC_DIRECTORY, "time-calc-current-profile.txt");
|
new File(TC_DIRECTORY, "time-calc-profiles.txt");
|
||||||
public static final File FILE_WITHOUT_ANY_PROFILE = new File(TC_DIRECTORY, "timecalc.conf");
|
public static final File TIME_CALC_CURRENT_PROFILE_TXT_FILE =
|
||||||
|
new File(TC_DIRECTORY, "time-calc-current-profile.txt");
|
||||||
|
public static final File FILE_WITHOUT_ANY_PROFILE =
|
||||||
|
new File(TC_DIRECTORY, "timecalc.conf");
|
||||||
|
|
||||||
private FileConstants() {
|
private FileConstants() {
|
||||||
//Not meant to be instantiated.
|
//Not meant to be instantiated.
|
||||||
|
@ -38,10 +38,6 @@ public enum ProgressSmiley {
|
|||||||
this.description = d;
|
this.description = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumber() {
|
|
||||||
return Integer.valueOf(this.name().replace("SMILEY_", ""));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ProgressSmiley forNumber(int number) {
|
public static ProgressSmiley forNumber(int number) {
|
||||||
for (ProgressSmiley s : ProgressSmiley.values()) {
|
for (ProgressSmiley s : ProgressSmiley.values()) {
|
||||||
if (s.getNumber() == number) {
|
if (s.getNumber() == number) {
|
||||||
@ -64,7 +60,8 @@ public enum ProgressSmiley {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Arrays.stream(values()).forEach(s -> {
|
Arrays.stream(values()).forEach(s -> {
|
||||||
s.getCharacter().codePoints().mapToObj(Integer::toHexString).forEach(System.out::println);
|
s.getCharacter().codePoints().mapToObj(Integer::toHexString)
|
||||||
|
.forEach(System.out::println);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -72,4 +69,8 @@ public enum ProgressSmiley {
|
|||||||
private static String toUnicode(char ch) {
|
private static String toUnicode(char ch) {
|
||||||
return String.format("\\u%04x", (int) ch);
|
return String.format("\\u%04x", (int) ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getNumber() {
|
||||||
|
return Integer.valueOf(this.name().replace("SMILEY_", ""));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,8 @@ package org.nanoboot.utils.timecalc.utils.common;
|
|||||||
|
|
||||||
import org.nanoboot.utils.timecalc.app.Main;
|
import org.nanoboot.utils.timecalc.app.Main;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.Toaster;
|
import org.nanoboot.utils.timecalc.swing.common.Toaster;
|
||||||
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.FontFormatException;
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@ -128,7 +125,8 @@ public class Utils {
|
|||||||
.decode(s.getBytes());
|
.decode(s.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String readTextFromTextResourceInJar(String pathToFile) throws IOException {
|
public static String readTextFromTextResourceInJar(String pathToFile)
|
||||||
|
throws IOException {
|
||||||
InputStream inputStream = ClassLoader.getSystemClassLoader().
|
InputStream inputStream = ClassLoader.getSystemClassLoader().
|
||||||
getSystemResourceAsStream(pathToFile);
|
getSystemResourceAsStream(pathToFile);
|
||||||
InputStreamReader streamReader = new InputStreamReader(inputStream,
|
InputStreamReader streamReader = new InputStreamReader(inputStream,
|
||||||
@ -141,13 +139,17 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showNotification(String message) {
|
public static void showNotification(String message) {
|
||||||
showNotification(message, 0);
|
showNotification(message, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showNotification(String message, int displayTime) {
|
public static void showNotification(String message, int displayTime) {
|
||||||
showNotification(message, displayTime, 0);
|
showNotification(message, displayTime, 0);
|
||||||
}
|
}
|
||||||
public static void showNotification(String message, int displayTime, int height) {
|
|
||||||
|
public static void showNotification(String message, int displayTime,
|
||||||
|
int height) {
|
||||||
Toaster toaster = new Toaster();
|
Toaster toaster = new Toaster();
|
||||||
toaster.setDisplayTime(displayTime == 0 ? 15000 : displayTime);
|
toaster.setDisplayTime(displayTime == 0 ? 15000 : displayTime);
|
||||||
if (height != 0) {
|
if (height != 0) {
|
||||||
|
@ -14,12 +14,13 @@ public class Property<T> {
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final String name;
|
private final String name;
|
||||||
|
private final List<InvalidationListener> invalidationListeners
|
||||||
|
= new ArrayList<>();
|
||||||
|
private final List<ChangeListener<T>> changeListeners =
|
||||||
|
new ArrayList<ChangeListener<T>>();
|
||||||
private boolean valid = true;
|
private boolean valid = true;
|
||||||
private T value;
|
private T value;
|
||||||
private Property<T> boundToProperty = null;
|
private Property<T> boundToProperty = null;
|
||||||
private final List<InvalidationListener> invalidationListeners
|
|
||||||
= new ArrayList<>();
|
|
||||||
private final List<ChangeListener<T>> changeListeners = new ArrayList<ChangeListener<T>>();
|
|
||||||
private ChangeListener<T> boundChangeListener = null;
|
private ChangeListener<T> boundChangeListener = null;
|
||||||
|
|
||||||
public Property(String name, T valueIn) {
|
public Property(String name, T valueIn) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user