mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 15:37:51 +01:00
Formatted code
This commit is contained in:
parent
e12d5aaf25
commit
6930b3e8ed
@ -17,8 +17,8 @@ import java.util.Properties;
|
||||
*/
|
||||
public class TimeCalcConfiguration {
|
||||
|
||||
public final StringProperty visibilityDefaultProperty =
|
||||
new StringProperty(TimeCalcProperty.VISIBILITY_DEFAULT
|
||||
public final StringProperty visibilityDefaultProperty
|
||||
= new StringProperty(TimeCalcProperty.VISIBILITY_DEFAULT
|
||||
.getKey());
|
||||
public final BooleanProperty visibilitySupportedColoredProperty
|
||||
= new BooleanProperty(TimeCalcProperty.VISIBILITY_SUPPORTED_COLORED
|
||||
@ -43,8 +43,7 @@ public class TimeCalcConfiguration {
|
||||
= new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_SECOND_VISIBLE
|
||||
.getKey());
|
||||
public final BooleanProperty clockHandsMillisecondVisibleProperty
|
||||
=
|
||||
new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_MILLISECOND_VISIBLE
|
||||
= new BooleanProperty(TimeCalcProperty.CLOCK_HANDS_MILLISECOND_VISIBLE
|
||||
.getKey());
|
||||
public final BooleanProperty clockBorderVisibleProperty
|
||||
= new BooleanProperty(TimeCalcProperty.CLOCK_BORDER_VISIBLE
|
||||
@ -71,8 +70,7 @@ public class TimeCalcConfiguration {
|
||||
public final BooleanProperty clockCentreCircleBlackProperty
|
||||
= new BooleanProperty(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK
|
||||
.getKey());
|
||||
public final BooleanProperty
|
||||
clockProgressVisibleOnlyIfMouseMovingOverProperty
|
||||
public final BooleanProperty clockProgressVisibleOnlyIfMouseMovingOverProperty
|
||||
= new BooleanProperty(
|
||||
TimeCalcProperty.CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
|
||||
.getKey());
|
||||
@ -85,8 +83,7 @@ public class TimeCalcConfiguration {
|
||||
= new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE
|
||||
.getKey());
|
||||
public final BooleanProperty batteryCircleProgressProperty
|
||||
=
|
||||
new BooleanProperty(TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE
|
||||
= new BooleanProperty(TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE
|
||||
.getKey());
|
||||
public final BooleanProperty batteryPercentProgressProperty
|
||||
= new BooleanProperty(
|
||||
@ -176,8 +173,8 @@ public class TimeCalcConfiguration {
|
||||
.getKey(), Integer.MAX_VALUE);
|
||||
|
||||
//
|
||||
private final Map<TimeCalcProperty, Property> mapOfProperties =
|
||||
new HashMap<>();
|
||||
private final Map<TimeCalcProperty, Property> mapOfProperties
|
||||
= new HashMap<>();
|
||||
private final List<Property> allProperties = new ArrayList<>();
|
||||
|
||||
private TimeCalcProperties timeCalcProperties;
|
||||
@ -234,8 +231,7 @@ public class TimeCalcConfiguration {
|
||||
testHourCustomProperty,
|
||||
testMinuteCustomProperty,
|
||||
testSecondCustomProperty,
|
||||
testMillisecondCustomProperty,
|
||||
}) {
|
||||
testMillisecondCustomProperty,}) {
|
||||
allProperties.add(p);
|
||||
}
|
||||
allProperties.stream().forEach(p -> mapOfProperties
|
||||
@ -264,6 +260,7 @@ public class TimeCalcConfiguration {
|
||||
}
|
||||
return mapOfProperties.get(timeCalcProperty);
|
||||
}
|
||||
|
||||
public String print() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Property p : allProperties) {
|
||||
|
@ -145,14 +145,29 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
||||
|
||||
if ((increase || decrease) && currentValue == Integer.MAX_VALUE) {
|
||||
switch (timeUnit) {
|
||||
case Calendar.YEAR: integerProperty.setValue(time.yearProperty.getValue());break;
|
||||
case Calendar.MONTH:integerProperty.setValue(time.monthProperty.getValue());break;
|
||||
case Calendar.DAY_OF_MONTH:integerProperty.setValue(time.dayProperty.getValue());break;
|
||||
case Calendar.HOUR_OF_DAY:integerProperty.setValue(time.hourProperty.getValue());break;
|
||||
case Calendar.MINUTE:integerProperty.setValue(time.minuteProperty.getValue());break;
|
||||
case Calendar.SECOND:integerProperty.setValue(time.secondProperty.getValue());break;
|
||||
case Calendar.MILLISECOND:integerProperty.setValue(time.millisecondProperty.getValue());break;
|
||||
default: throw new TimeCalcException("Unsupported time unit: " + timeUnit);
|
||||
case Calendar.YEAR:
|
||||
integerProperty.setValue(time.yearProperty.getValue());
|
||||
break;
|
||||
case Calendar.MONTH:
|
||||
integerProperty.setValue(time.monthProperty.getValue());
|
||||
break;
|
||||
case Calendar.DAY_OF_MONTH:
|
||||
integerProperty.setValue(time.dayProperty.getValue());
|
||||
break;
|
||||
case Calendar.HOUR_OF_DAY:
|
||||
integerProperty.setValue(time.hourProperty.getValue());
|
||||
break;
|
||||
case Calendar.MINUTE:
|
||||
integerProperty.setValue(time.minuteProperty.getValue());
|
||||
break;
|
||||
case Calendar.SECOND:
|
||||
integerProperty.setValue(time.secondProperty.getValue());
|
||||
break;
|
||||
case Calendar.MILLISECOND:
|
||||
integerProperty.setValue(time.millisecondProperty.getValue());
|
||||
break;
|
||||
default:
|
||||
throw new TimeCalcException("Unsupported time unit: " + timeUnit);
|
||||
}
|
||||
}
|
||||
Calendar cal = time.asCalendar();
|
||||
@ -181,26 +196,78 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
||||
int newMillisecond = cal.get(Calendar.MILLISECOND);
|
||||
if (increase) {
|
||||
switch (timeUnit) {
|
||||
case Calendar.YEAR: break;
|
||||
case Calendar.MONTH: if(oldYear != newYear) { updateProperty(timeCalcConfiguration.testYearCustomProperty, increase, decrease, reset, Calendar.YEAR);}break;
|
||||
case Calendar.DAY_OF_MONTH:if(oldMonth != newMonth) { updateProperty(timeCalcConfiguration.testMonthCustomProperty, increase, decrease, reset, Calendar.MONTH);}break;
|
||||
case Calendar.HOUR_OF_DAY:if(oldDay != newDay) { updateProperty(timeCalcConfiguration.testDayCustomProperty, increase, decrease, reset, Calendar.DAY_OF_MONTH);}break;
|
||||
case Calendar.MINUTE:if(oldHour != newHour) { updateProperty(timeCalcConfiguration.testHourCustomProperty, increase, decrease, reset, Calendar.HOUR_OF_DAY);}break;
|
||||
case Calendar.SECOND:if(oldMinute != newMinute) { updateProperty(timeCalcConfiguration.testMinuteCustomProperty, increase, decrease, reset, Calendar.MINUTE);}break;
|
||||
case Calendar.MILLISECOND:if(oldSecond != newSecond) { updateProperty(timeCalcConfiguration.testSecondCustomProperty, increase, decrease, reset, Calendar.SECOND);}break;
|
||||
default: throw new TimeCalcException("Unsupported time unit: " + timeUnit);
|
||||
case Calendar.YEAR:
|
||||
break;
|
||||
case Calendar.MONTH:
|
||||
if (oldYear != newYear) {
|
||||
updateProperty(timeCalcConfiguration.testYearCustomProperty, increase, decrease, reset, Calendar.YEAR);
|
||||
}
|
||||
break;
|
||||
case Calendar.DAY_OF_MONTH:
|
||||
if (oldMonth != newMonth) {
|
||||
updateProperty(timeCalcConfiguration.testMonthCustomProperty, increase, decrease, reset, Calendar.MONTH);
|
||||
}
|
||||
break;
|
||||
case Calendar.HOUR_OF_DAY:
|
||||
if (oldDay != newDay) {
|
||||
updateProperty(timeCalcConfiguration.testDayCustomProperty, increase, decrease, reset, Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
break;
|
||||
case Calendar.MINUTE:
|
||||
if (oldHour != newHour) {
|
||||
updateProperty(timeCalcConfiguration.testHourCustomProperty, increase, decrease, reset, Calendar.HOUR_OF_DAY);
|
||||
}
|
||||
break;
|
||||
case Calendar.SECOND:
|
||||
if (oldMinute != newMinute) {
|
||||
updateProperty(timeCalcConfiguration.testMinuteCustomProperty, increase, decrease, reset, Calendar.MINUTE);
|
||||
}
|
||||
break;
|
||||
case Calendar.MILLISECOND:
|
||||
if (oldSecond != newSecond) {
|
||||
updateProperty(timeCalcConfiguration.testSecondCustomProperty, increase, decrease, reset, Calendar.SECOND);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new TimeCalcException("Unsupported time unit: " + timeUnit);
|
||||
}
|
||||
}
|
||||
if (decrease) {
|
||||
switch (timeUnit) {
|
||||
case Calendar.YEAR: break;
|
||||
case Calendar.MONTH:if(oldYear != newYear) { updateProperty(timeCalcConfiguration.testYearCustomProperty, increase, decrease, reset, Calendar.YEAR);}break;
|
||||
case Calendar.DAY_OF_MONTH:if(oldMonth != newMonth) { updateProperty(timeCalcConfiguration.testMinuteCustomProperty, increase, decrease, reset, Calendar.MONTH);}break;
|
||||
case Calendar.HOUR_OF_DAY:if(oldDay != newDay) { updateProperty(timeCalcConfiguration.testSecondCustomProperty, increase, decrease, reset, Calendar.DAY_OF_MONTH);}break;
|
||||
case Calendar.MINUTE:if(oldHour != newHour) { updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.HOUR_OF_DAY);}break;
|
||||
case Calendar.SECOND:if(oldMinute != newMinute) { updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.MINUTE);}break;
|
||||
case Calendar.MILLISECOND: if(oldSecond != newSecond) { updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.SECOND);}break;
|
||||
default: throw new TimeCalcException("Unsupported time unit: " + timeUnit);
|
||||
case Calendar.YEAR:
|
||||
break;
|
||||
case Calendar.MONTH:
|
||||
if (oldYear != newYear) {
|
||||
updateProperty(timeCalcConfiguration.testYearCustomProperty, increase, decrease, reset, Calendar.YEAR);
|
||||
}
|
||||
break;
|
||||
case Calendar.DAY_OF_MONTH:
|
||||
if (oldMonth != newMonth) {
|
||||
updateProperty(timeCalcConfiguration.testMinuteCustomProperty, increase, decrease, reset, Calendar.MONTH);
|
||||
}
|
||||
break;
|
||||
case Calendar.HOUR_OF_DAY:
|
||||
if (oldDay != newDay) {
|
||||
updateProperty(timeCalcConfiguration.testSecondCustomProperty, increase, decrease, reset, Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
break;
|
||||
case Calendar.MINUTE:
|
||||
if (oldHour != newHour) {
|
||||
updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.HOUR_OF_DAY);
|
||||
}
|
||||
break;
|
||||
case Calendar.SECOND:
|
||||
if (oldMinute != newMinute) {
|
||||
updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.MINUTE);
|
||||
}
|
||||
break;
|
||||
case Calendar.MILLISECOND:
|
||||
if (oldSecond != newSecond) {
|
||||
updateProperty(timeCalcConfiguration.testMillisecondCustomProperty, increase, decrease, reset, Calendar.SECOND);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new TimeCalcException("Unsupported time unit: " + timeUnit);
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,16 +279,16 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
||||
.isDisabled();
|
||||
Visibility visibility = Visibility
|
||||
.valueOf(timeCalcApp.visibilityProperty.getValue());
|
||||
boolean numberKeyWasPressed = keyCode == KeyEvent.VK_0 ||
|
||||
keyCode == KeyEvent.VK_1 ||
|
||||
keyCode == KeyEvent.VK_2 ||
|
||||
keyCode == KeyEvent.VK_3 ||
|
||||
keyCode == KeyEvent.VK_4 ||
|
||||
keyCode == KeyEvent.VK_5 ||
|
||||
keyCode == KeyEvent.VK_6 ||
|
||||
keyCode == KeyEvent.VK_7 ||
|
||||
keyCode == KeyEvent.VK_8 ||
|
||||
keyCode == KeyEvent.VK_9;
|
||||
boolean numberKeyWasPressed = keyCode == KeyEvent.VK_0
|
||||
|| keyCode == KeyEvent.VK_1
|
||||
|| keyCode == KeyEvent.VK_2
|
||||
|| keyCode == KeyEvent.VK_3
|
||||
|| keyCode == KeyEvent.VK_4
|
||||
|| keyCode == KeyEvent.VK_5
|
||||
|| keyCode == KeyEvent.VK_6
|
||||
|| keyCode == KeyEvent.VK_7
|
||||
|| keyCode == KeyEvent.VK_8
|
||||
|| keyCode == KeyEvent.VK_9;
|
||||
|
||||
if (numberKeyWasPressed && !FileConstants.TIME_CALC_PROFILES_TXT_FILE
|
||||
.exists()) {
|
||||
@ -511,9 +578,8 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
|
||||
+ "\" is already active. Nothing to do",
|
||||
5000);
|
||||
} else {
|
||||
Utils.showNotification("Info: Changing profile to: #" + profileNumber + " " + ((
|
||||
profileName.isEmpty() ? "{Default profile}" :
|
||||
profileName)), 5000);
|
||||
Utils.showNotification("Info: Changing profile to: #" + profileNumber + " " + ((profileName.isEmpty() ? "{Default profile}"
|
||||
: profileName)), 5000);
|
||||
timeCalcConfiguration.saveToTimeCalcProperties();
|
||||
TimeCalcProperties.getInstance().loadProfile(profileName);
|
||||
timeCalcConfiguration.loadFromTimeCalcProperties(
|
||||
|
@ -28,11 +28,11 @@ public class TimeCalcProperties {
|
||||
System.out.println("Loading configuration - start");
|
||||
String profileName = "";
|
||||
try {
|
||||
profileName =
|
||||
FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE.exists() ?
|
||||
Utils.readTextFromFile(
|
||||
FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE) :
|
||||
"";
|
||||
profileName
|
||||
= FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE.exists()
|
||||
? Utils.readTextFromFile(
|
||||
FileConstants.TIME_CALC_CURRENT_PROFILE_TXT_FILE)
|
||||
: "";
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new TimeCalcException(e);
|
||||
@ -115,6 +115,7 @@ public class TimeCalcProperties {
|
||||
}
|
||||
return (String) properties.get(key);
|
||||
}
|
||||
|
||||
public int getIntegerProperty(TimeCalcProperty timeCalcProperty) {
|
||||
return getIntegerProperty(timeCalcProperty,
|
||||
Integer.valueOf(getDefaultStringValue(timeCalcProperty)));
|
||||
@ -128,6 +129,7 @@ public class TimeCalcProperties {
|
||||
}
|
||||
return Integer.valueOf((String) properties.get(key));
|
||||
}
|
||||
|
||||
private String getVisibilityProperty(TimeCalcProperty timeCalcProperty) {
|
||||
return getStringProperty(timeCalcProperty,
|
||||
Visibility.STRONGLY_COLORED.name());
|
||||
@ -178,9 +180,9 @@ public class TimeCalcProperties {
|
||||
}
|
||||
|
||||
private File getFile(String profileName) {
|
||||
return profileName == null || profileName.isEmpty() ?
|
||||
FileConstants.FILE_WITHOUT_ANY_PROFILE :
|
||||
new File(FileConstants.FILE_WITHOUT_ANY_PROFILE.getParentFile(),
|
||||
return profileName == null || profileName.isEmpty()
|
||||
? FileConstants.FILE_WITHOUT_ANY_PROFILE
|
||||
: new File(FileConstants.FILE_WITHOUT_ANY_PROFILE.getParentFile(),
|
||||
"timecalc." + profileName + ".conf");
|
||||
}
|
||||
|
||||
|
@ -45,19 +45,16 @@ public enum TimeCalcProperty {
|
||||
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_CIRCLE_PROGRESS_VISIBLE("battery.circle-progress.visible",
|
||||
"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_NAME_VISIBLE("battery.name.visible", "Battery : Name"),
|
||||
BATTERY_LABEL_VISIBLE("battery.label.visible", "Battery : Label"),
|
||||
|
||||
BATTERY_VISIBLE("battery.visible", "Battery"),
|
||||
BATTERY_MINUTE_VISIBLE("battery.minute.visible", "Battery : Minute"),
|
||||
BATTERY_HOUR_VISIBLE("battery.hour.visible", "Battery : Hour"),
|
||||
@ -67,7 +64,6 @@ public enum TimeCalcProperty {
|
||||
BATTERY_YEAR_VISIBLE("battery.year.visible", "Battery : Year"),
|
||||
BATTERY_BLINKING_IF_CRITICAL_LOW("battery.blinking-if-critical-low",
|
||||
"Battery : Blinking, if critical low"),
|
||||
|
||||
JOKES_VISIBLE("jokes.visible", "Jokes"),
|
||||
COMMANDS_VISIBLE("commands.visible", "Commands"),
|
||||
NOTIFICATIONS_VISIBLE("notifications.visible", "Notifications"),
|
||||
@ -76,7 +72,6 @@ public enum TimeCalcProperty {
|
||||
"smileys.visible-only-if-mouse-moving-over",
|
||||
"Smileys : Visible only, if mouse moving over"),
|
||||
SMILEYS_COLORED("smileys.colored", "Smileys : Colored"),
|
||||
|
||||
SQUARE_VISIBLE("square.visible", "Square"),
|
||||
CIRCLE_VISIBLE("circle.visible", "Circle"),
|
||||
WALKING_HUMAN_VISIBLE("walking-human.visible", "Walking Human"),
|
||||
@ -109,8 +104,8 @@ public enum TimeCalcProperty {
|
||||
}
|
||||
|
||||
public static TimeCalcProperty forKey(String key) {
|
||||
Optional<TimeCalcProperty> timeCalcPropertyOptional =
|
||||
Arrays.stream(values()).filter(t -> t.getKey().equals(key))
|
||||
Optional<TimeCalcProperty> timeCalcPropertyOptional
|
||||
= Arrays.stream(values()).filter(t -> t.getKey().equals(key))
|
||||
.findFirst();
|
||||
if (timeCalcPropertyOptional.isPresent()) {
|
||||
return timeCalcPropertyOptional.get();
|
||||
|
@ -16,6 +16,7 @@ public class ActivityForStats extends Activity {
|
||||
|
||||
public ActivityForStats() {
|
||||
}
|
||||
|
||||
public List<ActivityForStats> createList(List<Activity> list) {
|
||||
return null;//todo
|
||||
}
|
||||
|
@ -10,9 +10,13 @@ import java.util.List;
|
||||
* @since 23.02.2024
|
||||
*/
|
||||
public interface ActivityRepositoryApi {
|
||||
|
||||
void create(Activity activity);
|
||||
|
||||
List<Activity> list(int year, int month, int day);
|
||||
|
||||
void update(Activity activity);
|
||||
|
||||
WorkingDay read(String id);
|
||||
|
||||
}
|
||||
|
@ -9,9 +9,13 @@ import java.util.List;
|
||||
* @since 23.02.2024
|
||||
*/
|
||||
public interface WorkingDayRepositoryApi {
|
||||
|
||||
void create(WorkingDay workingDay);
|
||||
|
||||
List<WorkingDay> list(int year, int month);
|
||||
|
||||
void update(WorkingDay workingDay);
|
||||
|
||||
WorkingDay read(int year, int month, int day);
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package org.nanoboot.utils.timecalc.persistence.impl.sqlite;
|
||||
|
||||
|
||||
import org.nanoboot.utils.timecalc.persistence.api.ConnectionFactory;
|
||||
import org.nanoboot.utils.timecalc.utils.common.FileConstants;
|
||||
|
||||
@ -31,14 +30,17 @@ import java.sql.SQLException;
|
||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
||||
*/
|
||||
public class SqliteConnectionFactory implements ConnectionFactory {
|
||||
|
||||
private final String jdbcUrl;
|
||||
|
||||
private static String createJdbcUrl(String directoryWhereSqliteFileIs) {
|
||||
return "jdbc:sqlite:" + directoryWhereSqliteFileIs + "/" + ".time-calc.sqlite3?foreign_keys=on;";
|
||||
}
|
||||
|
||||
public SqliteConnectionFactory() {
|
||||
this(FileConstants.TC_DIRECTORY.getName());
|
||||
}
|
||||
|
||||
public SqliteConnectionFactory(String directoryWhereSqliteFileIs) {
|
||||
this.jdbcUrl = createJdbcUrl(directoryWhereSqliteFileIs);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import java.util.List;
|
||||
* @since 23.02.2024
|
||||
*/
|
||||
public class WorkingDayRepositorySQLiteImpl implements WorkingDayRepositoryApi {
|
||||
|
||||
@Override
|
||||
public void create(WorkingDay workingDay) {
|
||||
|
||||
@ -31,9 +32,6 @@ public class WorkingDayRepositorySQLiteImpl implements WorkingDayRepositoryApi {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// private org.nanoboot.bitinspector.persistence.impl.sqlite.SqliteConnectionFactory
|
||||
// sqliteConnectionFactory;
|
||||
//
|
||||
|
@ -23,6 +23,7 @@ package org.nanoboot.utils.timecalc.persistence.impl.sqlite;
|
||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
||||
*/
|
||||
class WorkingDayTable {
|
||||
|
||||
public static final String TABLE_NAME = "WORKING_DAY";
|
||||
|
||||
public static final String ID = "ID";
|
||||
@ -44,5 +45,4 @@ class WorkingDayTable {
|
||||
//Not meant to be instantiated.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ public class ConfigWindow extends TWindow {
|
||||
|
||||
public static final int WIDTH1 = 600;
|
||||
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 = "---";
|
||||
private static final Font BIG_FONT = new Font("sans", Font.BOLD, 24);
|
||||
private static final String FIVE_SPACES = " ";
|
||||
@ -55,10 +55,10 @@ public class ConfigWindow extends TWindow {
|
||||
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 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());
|
||||
@ -71,11 +71,9 @@ public class ConfigWindow extends TWindow {
|
||||
private final JCheckBox clockHandsHourVisibleProperty
|
||||
= new JCheckBox(TimeCalcProperty.CLOCK_HANDS_HOUR_VISIBLE.getKey());
|
||||
private final JCheckBox clockHandsMinuteVisibleProperty
|
||||
=
|
||||
new JCheckBox(TimeCalcProperty.CLOCK_HANDS_MINUTE_VISIBLE.getKey());
|
||||
= new JCheckBox(TimeCalcProperty.CLOCK_HANDS_MINUTE_VISIBLE.getKey());
|
||||
private final JCheckBox clockHandsSecondVisibleProperty
|
||||
=
|
||||
new JCheckBox(TimeCalcProperty.CLOCK_HANDS_SECOND_VISIBLE.getKey());
|
||||
= new JCheckBox(TimeCalcProperty.CLOCK_HANDS_SECOND_VISIBLE.getKey());
|
||||
private final JCheckBox clockHandsMillisecondVisibleProperty
|
||||
= new JCheckBox(
|
||||
TimeCalcProperty.CLOCK_HANDS_MILLISECOND_VISIBLE.getKey());
|
||||
@ -88,16 +86,14 @@ public class ConfigWindow extends TWindow {
|
||||
private final JCheckBox clockCircleVisibleProperty
|
||||
= new JCheckBox(TimeCalcProperty.CLOCK_CIRCLE_VISIBLE.getKey());
|
||||
private final JCheckBox clockCircleStrongBorderProperty
|
||||
=
|
||||
new JCheckBox(TimeCalcProperty.CLOCK_CIRCLE_STRONG_BORDER.getKey());
|
||||
= 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());
|
||||
= new JCheckBox(TimeCalcProperty.CLOCK_CENTRE_CIRCLE_BLACK.getKey());
|
||||
private final JCheckBox clockProgressVisibleOnlyIfMouseMovingOverProperty
|
||||
= new JCheckBox(
|
||||
TimeCalcProperty.CLOCK_PROGRESS_VISIBLE_ONLY_IF_MOUSE_MOVING_OVER
|
||||
@ -120,24 +116,24 @@ public class ConfigWindow extends TWindow {
|
||||
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(
|
||||
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());
|
||||
@ -177,6 +173,7 @@ public class ConfigWindow extends TWindow {
|
||||
= new JTextField(TimeCalcProperty.TEST_CLOCK_CUSTOM_SECOND.getKey());
|
||||
private final JTextField testClockCustomMillisecondProperty
|
||||
= new JTextField(TimeCalcProperty.TEST_CLOCK_CUSTOM_MILLISECOND.getKey());
|
||||
|
||||
public ConfigWindow(TimeCalcConfiguration timeCalcConfiguration) {
|
||||
this.timeCalcConfiguration = timeCalcConfiguration;
|
||||
setTitle("Configuration");
|
||||
@ -186,8 +183,8 @@ public class ConfigWindow extends TWindow {
|
||||
mainPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE,
|
||||
getHeight() - 6 * SwingUtils.MARGIN));
|
||||
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);
|
||||
mainPanel.setAlignmentX(LEFT_ALIGNMENT);
|
||||
|
||||
@ -226,8 +223,8 @@ public class ConfigWindow extends TWindow {
|
||||
mainPanel.add(scrollPane);
|
||||
|
||||
for (boolean enable : new boolean[]{true, false}) {
|
||||
TButton button =
|
||||
enable ? enableAsMuchAsPossible : disableAsMuchAsPossible;
|
||||
TButton button
|
||||
= enable ? enableAsMuchAsPossible : disableAsMuchAsPossible;
|
||||
|
||||
button.addActionListener(e -> {
|
||||
visibilityDefaultProperty
|
||||
@ -376,8 +373,8 @@ public class ConfigWindow extends TWindow {
|
||||
JComboBox jComboBox = ((JComboBox) p);
|
||||
jComboBox.setMaximumSize(new Dimension(150, 25));
|
||||
|
||||
String timeCalcPropertyKey =
|
||||
(String) jComboBox.getClientProperty(
|
||||
String timeCalcPropertyKey
|
||||
= (String) jComboBox.getClientProperty(
|
||||
CLIENT_PROPERTY_KEY);
|
||||
TimeCalcProperty timeCalcProperty
|
||||
= TimeCalcProperty.forKey(timeCalcPropertyKey);
|
||||
@ -428,11 +425,8 @@ public class ConfigWindow extends TWindow {
|
||||
panelInsideScrollPane.add(label);
|
||||
}
|
||||
}
|
||||
if (
|
||||
timeCalcProperty == TimeCalcProperty.VISIBILITY_DEFAULT
|
||||
||
|
||||
timeCalcProperty == TimeCalcProperty.JOKES_VISIBLE
|
||||
) {
|
||||
if (timeCalcProperty == TimeCalcProperty.VISIBILITY_DEFAULT
|
||||
|| timeCalcProperty == TimeCalcProperty.JOKES_VISIBLE) {
|
||||
JLabel label = new JLabel("Misc");
|
||||
label.setFont(BIG_FONT);
|
||||
panelInsideScrollPane.add(label);
|
||||
@ -442,8 +436,8 @@ public class ConfigWindow extends TWindow {
|
||||
JColorChooser colorChooser = ((JColorChooser) p);
|
||||
//jColorChooser.setMaximumSize(new Dimension(150, 25));
|
||||
|
||||
String timeCalcPropertyKey =
|
||||
(String) colorChooser.getClientProperty(
|
||||
String timeCalcPropertyKey
|
||||
= (String) colorChooser.getClientProperty(
|
||||
CLIENT_PROPERTY_KEY);
|
||||
TimeCalcProperty timeCalcProperty
|
||||
= TimeCalcProperty.forKey(timeCalcPropertyKey);
|
||||
@ -507,8 +501,8 @@ public class ConfigWindow extends TWindow {
|
||||
}
|
||||
textField.setMaximumSize(new Dimension(150, 25));
|
||||
|
||||
String timeCalcPropertyKey =
|
||||
(String) textField.getClientProperty(
|
||||
String timeCalcPropertyKey
|
||||
= (String) textField.getClientProperty(
|
||||
CLIENT_PROPERTY_KEY);
|
||||
TimeCalcProperty timeCalcProperty
|
||||
= TimeCalcProperty.forKey(timeCalcPropertyKey);
|
||||
@ -517,19 +511,15 @@ public class ConfigWindow extends TWindow {
|
||||
.getProperty(timeCalcProperty).addListener(e -> {
|
||||
|
||||
textField.setText(isInteger
|
||||
?
|
||||
String.valueOf(timeCalcConfiguration
|
||||
? String.valueOf(timeCalcConfiguration
|
||||
.getProperty(timeCalcProperty).getValue())
|
||||
:
|
||||
(String) timeCalcConfiguration
|
||||
: (String) timeCalcConfiguration
|
||||
.getProperty(timeCalcProperty).getValue());
|
||||
});
|
||||
textField.setText(isInteger
|
||||
?
|
||||
String.valueOf(timeCalcConfiguration
|
||||
? String.valueOf(timeCalcConfiguration
|
||||
.getProperty(timeCalcProperty).getValue())
|
||||
:
|
||||
(String) timeCalcConfiguration
|
||||
: (String) timeCalcConfiguration
|
||||
.getProperty(timeCalcProperty).getValue());
|
||||
|
||||
textField.getDocument()
|
||||
@ -543,13 +533,14 @@ public class ConfigWindow extends TWindow {
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
update(e);
|
||||
}
|
||||
|
||||
private void update(DocumentEvent e) {
|
||||
String text = textField.getText();
|
||||
boolean isInteger = Integer.class == timeCalcProperty.getClazz();
|
||||
timeCalcConfiguration
|
||||
.getProperty(timeCalcProperty)
|
||||
.setValue(isInteger ? Integer.valueOf(text):
|
||||
text);
|
||||
.setValue(isInteger ? Integer.valueOf(text)
|
||||
: text);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ public class HelpWindow extends TWindow {
|
||||
+ helpHtml + "</div>";
|
||||
|
||||
this.setLayout(null);
|
||||
JScrollPane scrollPane =
|
||||
new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
|
||||
JScrollPane scrollPane
|
||||
= new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
|
||||
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
scrollPane.setBounds(1, 1,
|
||||
getWidth() - 2 * SwingUtils.MARGIN,
|
||||
|
@ -80,6 +80,7 @@ public class MainWindow extends TWindow {
|
||||
this.elapsedTextField = new TTextField("", 100);
|
||||
this.remainingTextField = new TTextField("", 100);
|
||||
}
|
||||
|
||||
public MainWindow(String startTimeIn, String overTimeIn,
|
||||
TimeCalcApp timeCalcApp) {
|
||||
setFocusable(true);
|
||||
@ -145,8 +146,8 @@ public class MainWindow extends TWindow {
|
||||
Toaster.notificationsVisibleProperty.bindTo(timeCalcConfiguration.notificationsVisibleProperty);
|
||||
|
||||
Time time = new Time();
|
||||
TimeCalcKeyAdapter timeCalcKeyAdapter =
|
||||
new TimeCalcKeyAdapter(timeCalcConfiguration, timeCalcApp,
|
||||
TimeCalcKeyAdapter timeCalcKeyAdapter
|
||||
= new TimeCalcKeyAdapter(timeCalcConfiguration, timeCalcApp,
|
||||
this, time);
|
||||
addKeyListener(timeCalcKeyAdapter);
|
||||
|
||||
@ -182,8 +183,8 @@ public class MainWindow extends TWindow {
|
||||
clock.setBounds(SwingUtils.MARGIN, SwingUtils.MARGIN, 200);
|
||||
add(clock);
|
||||
|
||||
MinuteBattery minuteBattery =
|
||||
new MinuteBattery(clock.getBounds().x + clock.getWidth() + SwingUtils.MARGIN,
|
||||
MinuteBattery minuteBattery
|
||||
= new MinuteBattery(clock.getBounds().x + clock.getWidth() + SwingUtils.MARGIN,
|
||||
clock.getY(), BATTERY_WIDTH);
|
||||
add(minuteBattery);
|
||||
Battery hourBattery = new HourBattery(
|
||||
@ -330,7 +331,6 @@ public class MainWindow extends TWindow {
|
||||
exitButton.setBounds(saveButton.getX() + saveButton.getWidth() - activitiesButton.getWidth(), workDaysButton.getY(), activitiesButton.getWidth(), activitiesButton.getHeight());
|
||||
restartButton.setBounds(exitButton.getX() - SwingUtils.MARGIN - activitiesButton.getWidth(), activitiesButton.getY(), activitiesButton.getWidth(), activitiesButton.getHeight());
|
||||
|
||||
|
||||
//
|
||||
helpButton.setBoundsFromTop(exitButton, 2);
|
||||
focusButton.setBoundsFromLeft(helpButton);
|
||||
@ -462,8 +462,8 @@ public class MainWindow extends TWindow {
|
||||
clock.visibleProperty
|
||||
.bindTo(timeCalcConfiguration.clockVisibleProperty);
|
||||
|
||||
ComponentRegistry<Component> componentRegistry =
|
||||
new ComponentRegistry();
|
||||
ComponentRegistry<Component> componentRegistry
|
||||
= new ComponentRegistry();
|
||||
componentRegistry.addAll(this.getContentPane().getComponents());
|
||||
|
||||
ComponentRegistry<TButton> buttonRegistry = new ComponentRegistry();
|
||||
@ -858,16 +858,20 @@ public class MainWindow extends TWindow {
|
||||
|
||||
this.configWindow.doDisableAlmostEverything();
|
||||
}
|
||||
|
||||
public void increaseArrivalByOneMinute() {
|
||||
arrivalTextField.valueProperty.setValue(new TTime(this.arrivalTextField.valueProperty.getValue()).add(new TTime(0, 1)).toString().substring(0, 5));
|
||||
}
|
||||
|
||||
public void decreaseArrivalByOneMinute() {
|
||||
arrivalTextField.valueProperty.setValue(new TTime(this.arrivalTextField.valueProperty.getValue()).remove(new TTime(0, 1)).toString().substring(0, 5));
|
||||
}
|
||||
|
||||
public void increaseOvertimeByOneMinute() {
|
||||
TTime newOvertime = new TTime(this.overtimeTextField.valueProperty.getValue()).add(new TTime(0, 1));
|
||||
overtimeTextField.valueProperty.setValue(newOvertime.toString().substring(0, newOvertime.isNegative() ? 6 : 5));
|
||||
}
|
||||
|
||||
public void decreaseOvertimeByOneMinute() {
|
||||
TTime newOvertime = new TTime(this.overtimeTextField.valueProperty.getValue()).remove(new TTime(0, 1));
|
||||
overtimeTextField.valueProperty.setValue(newOvertime.toString().substring(0, newOvertime.isNegative() ? 6 : 5));
|
||||
|
@ -11,8 +11,8 @@ public class SwingUtils {
|
||||
|
||||
public static final int MARGIN = 10;
|
||||
public static final Font SMALL_FONT = new Font("sans", Font.BOLD, 10);
|
||||
public static final Font MEDIUM_MONOSPACE_FONT =
|
||||
new Font(Font.MONOSPACED, Font.PLAIN, 12);
|
||||
public static final Font MEDIUM_MONOSPACE_FONT
|
||||
= new Font(Font.MONOSPACED, Font.PLAIN, 12);
|
||||
|
||||
private SwingUtils() {
|
||||
//Not meant to be instantiated.
|
||||
|
@ -33,6 +33,7 @@ public class TButton extends JButton implements GetProperty {
|
||||
public TButton(String label) {
|
||||
this(label, 0);
|
||||
}
|
||||
|
||||
public TButton(String label, int customWidth) {
|
||||
super(label);
|
||||
this.customWidth = customWidth;
|
||||
|
@ -21,6 +21,7 @@ public class TCheckBox extends JCheckBox implements GetProperty {
|
||||
private static final int HEIGHT = 30;
|
||||
private Color originalBackground;
|
||||
private Color originalForeground;
|
||||
|
||||
public TCheckBox(String text) {
|
||||
this(text, false);
|
||||
}
|
||||
@ -31,14 +32,15 @@ public class TCheckBox extends JCheckBox implements GetProperty {
|
||||
public StringProperty visibilityProperty
|
||||
= new StringProperty("visibilityProperty",
|
||||
Visibility.STRONGLY_COLORED.name());
|
||||
|
||||
public TCheckBox(String text, boolean b) {
|
||||
super(text, b);
|
||||
|
||||
valueProperty.setValue(b);
|
||||
|
||||
addActionListener(e -> valueProperty.setValue(isSelected()));
|
||||
valueProperty.addListener(e ->
|
||||
{
|
||||
valueProperty.addListener(e
|
||||
-> {
|
||||
if (valueProperty.getValue().equals(getText())) {
|
||||
setSelected(valueProperty.isEnabled());
|
||||
}
|
||||
@ -64,6 +66,7 @@ public class TCheckBox extends JCheckBox implements GetProperty {
|
||||
}).start();
|
||||
}
|
||||
public final BooleanProperty valueProperty = new BooleanProperty("");
|
||||
|
||||
public void setBounds(int x, int y) {
|
||||
setBounds(x, y, WIDTH, HEIGHT);
|
||||
this.originalBackground = getBackground();
|
||||
@ -84,6 +87,7 @@ public class TCheckBox extends JCheckBox implements GetProperty {
|
||||
+ jComponent.getHeight()
|
||||
+ marginCount * SwingUtils.MARGIN);
|
||||
}
|
||||
|
||||
public void setOriginalBackground() {
|
||||
this.setBackground(originalBackground);
|
||||
}
|
||||
@ -91,6 +95,7 @@ public class TCheckBox extends JCheckBox implements GetProperty {
|
||||
public void setOriginalForeground() {
|
||||
this.setForeground(originalForeground);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getVisibilityProperty() {
|
||||
return visibilityProperty;
|
||||
|
@ -29,9 +29,11 @@ public class TLabel extends JLabel implements GetProperty {
|
||||
public StringProperty visibilityProperty
|
||||
= new StringProperty("visibilityProperty",
|
||||
Visibility.STRONGLY_COLORED.name());
|
||||
|
||||
public TLabel(String text) {
|
||||
this(text, 0);
|
||||
}
|
||||
|
||||
public TLabel(String text, int customWidth) {
|
||||
super(text);
|
||||
this.customWidth = customWidth;
|
||||
@ -61,7 +63,6 @@ public class TLabel extends JLabel implements GetProperty {
|
||||
this.originalForeground = getForeground();
|
||||
}
|
||||
|
||||
|
||||
public void setBoundsFromLeft(JComponent jComponent) {
|
||||
setBounds(jComponent.getX() + jComponent.getWidth() + SwingUtils.MARGIN,
|
||||
jComponent.getY());
|
||||
@ -76,6 +77,7 @@ public class TLabel extends JLabel implements GetProperty {
|
||||
+ jComponent.getHeight()
|
||||
+ marginCount * SwingUtils.MARGIN);
|
||||
}
|
||||
|
||||
public void setOriginalBackground() {
|
||||
this.setBackground(originalBackground);
|
||||
}
|
||||
@ -83,6 +85,7 @@ public class TLabel extends JLabel implements GetProperty {
|
||||
public void setOriginalForeground() {
|
||||
this.setForeground(originalForeground);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getVisibilityProperty() {
|
||||
return visibilityProperty;
|
||||
|
@ -33,12 +33,15 @@ public class TTextField extends JTextField implements GetProperty {
|
||||
= new StringProperty("visibilityProperty",
|
||||
Visibility.STRONGLY_COLORED.name());
|
||||
public final StringProperty valueProperty = new StringProperty();
|
||||
|
||||
public TTextField() {
|
||||
this("", 0);
|
||||
}
|
||||
|
||||
public TTextField(String s) {
|
||||
this(s, 0);
|
||||
}
|
||||
|
||||
public TTextField(String s, int customWidth) {
|
||||
super(s);
|
||||
this.customWidth = customWidth;
|
||||
@ -56,13 +59,14 @@ public class TTextField extends JTextField implements GetProperty {
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
update(e);
|
||||
}
|
||||
|
||||
private void update(DocumentEvent e) {
|
||||
valueProperty.setValue(getText());
|
||||
}
|
||||
|
||||
});
|
||||
valueProperty.addListener(e ->
|
||||
{
|
||||
valueProperty.addListener(e
|
||||
-> {
|
||||
if (!valueProperty.getValue().equals(getText())) {
|
||||
setText(valueProperty.getValue());
|
||||
}
|
||||
@ -93,9 +97,11 @@ public class TTextField extends JTextField implements GetProperty {
|
||||
this.originalBackground = getBackground();
|
||||
this.originalForeground = getForeground();
|
||||
}
|
||||
|
||||
public void setBoundsFromLeft(JComponent jComponent) {
|
||||
setBoundsFromLeft(jComponent, 0);
|
||||
}
|
||||
|
||||
public void setBoundsFromLeft(JComponent jComponent, int additionalY) {
|
||||
setBounds(jComponent.getX() + jComponent.getWidth() + SwingUtils.MARGIN,
|
||||
jComponent.getY() + additionalY);
|
||||
@ -110,6 +116,7 @@ public class TTextField extends JTextField implements GetProperty {
|
||||
+ jComponent.getHeight()
|
||||
+ marginCount * SwingUtils.MARGIN);
|
||||
}
|
||||
|
||||
public void setOriginalBackground() {
|
||||
this.setBackground(originalBackground);
|
||||
}
|
||||
@ -117,6 +124,7 @@ public class TTextField extends JTextField implements GetProperty {
|
||||
public void setOriginalForeground() {
|
||||
this.setForeground(originalForeground);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getVisibilityProperty() {
|
||||
return visibilityProperty;
|
||||
@ -126,9 +134,9 @@ public class TTextField extends JTextField implements GetProperty {
|
||||
public Property getVisibilitySupportedColoredProperty() {
|
||||
return visibilitySupportedColoredProperty;
|
||||
}
|
||||
|
||||
public TTime asTTime() {
|
||||
return new TTime(valueProperty.getValue());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ package org.nanoboot.utils.timecalc.swing.common;
|
||||
* // Show a simple toaster toasterManager.showToaster( new ImageIcon(
|
||||
* "mylogo.gif" ), "A simple toaster with an image" ); } }
|
||||
*/
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JButton;
|
||||
@ -437,8 +436,7 @@ public class Toaster {
|
||||
stopYPosition = startYPosition - toasterHeight - 1;
|
||||
if (currentNumberOfToaster > 0) {
|
||||
stopYPosition
|
||||
=
|
||||
stopYPosition - (maxToaster % maxToasterInSceen
|
||||
= stopYPosition - (maxToaster % maxToasterInSceen
|
||||
* toasterHeight);
|
||||
} else {
|
||||
maxToaster = 0;
|
||||
@ -449,8 +447,7 @@ public class Toaster {
|
||||
|
||||
if (currentNumberOfToaster > 0) {
|
||||
stopYPosition
|
||||
=
|
||||
stopYPosition + (maxToaster % maxToasterInSceen
|
||||
= stopYPosition + (maxToaster % maxToasterInSceen
|
||||
* toasterHeight);
|
||||
} else {
|
||||
maxToaster = 0;
|
||||
|
@ -14,6 +14,7 @@ import java.util.Calendar;
|
||||
*/
|
||||
@Getter
|
||||
public class WeekStatistics {
|
||||
|
||||
private final boolean nowIsWeekend;
|
||||
private final int workDaysDone;
|
||||
private final int workDaysTotal;
|
||||
@ -29,8 +30,8 @@ public class WeekStatistics {
|
||||
dayOfMonth <= time.asCalendar()
|
||||
.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||
dayOfMonth++) {
|
||||
DayOfWeek dayOfWeek =
|
||||
LocalDate.of(analogClock.yearProperty.getValue(),
|
||||
DayOfWeek dayOfWeek
|
||||
= LocalDate.of(analogClock.yearProperty.getValue(),
|
||||
analogClock.monthProperty.getValue(),
|
||||
dayOfMonth)
|
||||
.getDayOfWeek();
|
||||
@ -53,8 +54,8 @@ public class WeekStatistics {
|
||||
.toString();
|
||||
this.nowIsWeekend = currentDayOfWeekAsString.equals("SATURDAY")
|
||||
|| currentDayOfWeekAsString.equals("SUNDAY");
|
||||
workDaysTotalTmp =
|
||||
workDaysDoneTmp + (nowIsWeekend ? 0 : 1) + workDaysTodoTmp;
|
||||
workDaysTotalTmp
|
||||
= workDaysDoneTmp + (nowIsWeekend ? 0 : 1) + workDaysTodoTmp;
|
||||
this.workDaysDone = workDaysDoneTmp;
|
||||
this.workDaysTotal = workDaysTotalTmp;
|
||||
// System.out.println("currentDayOfWeekAsString=" + currentDayOfWeekAsString);
|
||||
|
@ -36,8 +36,8 @@ public class Widget extends JPanel implements
|
||||
protected static final Font BIG_FONT = new Font("sans", Font.BOLD, 24);
|
||||
protected static final Font MEDIUM_FONT = new Font("sans", Font.BOLD, 16);
|
||||
|
||||
public static final Color CLOSE_BUTTON_FOREGROUND_COLOR =
|
||||
new Color(127, 127, 127);
|
||||
public static final Color CLOSE_BUTTON_FOREGROUND_COLOR
|
||||
= new Color(127, 127, 127);
|
||||
public static final Color CLOSE_BUTTON_BACKGROUND_COLOR = Color.LIGHT_GRAY;
|
||||
public static final Color CLOSE_BUTTON_BACKGROUND_COLOR_MOUSE_OVER_CLOSE_ICON = new Color(255, 153, 153);
|
||||
public final BooleanProperty visibilitySupportedColoredProperty
|
||||
@ -203,7 +203,6 @@ public class Widget extends JPanel implements
|
||||
// CLOSE_BUTTON_SIDE - 2);
|
||||
// return;
|
||||
// }
|
||||
|
||||
brush.fillOval(width - CLOSE_BUTTON_SIDE - 1, 0 + 1, CLOSE_BUTTON_SIDE,
|
||||
CLOSE_BUTTON_SIDE);
|
||||
brush.setColor(CLOSE_BUTTON_FOREGROUND_COLOR);
|
||||
@ -264,8 +263,8 @@ public class Widget extends JPanel implements
|
||||
brush.setColor(Color.BLACK);
|
||||
}
|
||||
Color currentColor = brush.getColor();
|
||||
brush.setColor(visibility.isStronglyColored() ? Color.WHITE :
|
||||
BACKGROUND_COLOR);
|
||||
brush.setColor(visibility.isStronglyColored() ? Color.WHITE
|
||||
: BACKGROUND_COLOR);
|
||||
brush.fillRect(
|
||||
x, y,
|
||||
20,
|
||||
@ -291,6 +290,7 @@ public class Widget extends JPanel implements
|
||||
this.add(smileyIcon);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean changedInTheLastXMilliseconds(int milliseconds) {
|
||||
return (System.nanoTime() - lastUpdate) < milliseconds * 1000000;
|
||||
}
|
||||
|
@ -102,22 +102,27 @@ public class AnalogClock extends Widget {
|
||||
-> customCircleColor = SwingUtils.getColorFromString(
|
||||
centreCircleBorderColorProperty.getValue()));
|
||||
}
|
||||
|
||||
private int computeStartAngle() {
|
||||
return computeAngle(startHourProperty.getValue(), startMinuteProperty.getValue());
|
||||
}
|
||||
|
||||
private int computeEndAngle() {
|
||||
return computeAngle(endHourProperty.getValue(), endMinuteProperty.getValue());
|
||||
}
|
||||
|
||||
private int computeAngle(TTime TTime) {
|
||||
if (TTime.getHour() > 12) {
|
||||
TTime.setHour(TTime.getHour() - 12);
|
||||
}
|
||||
return computeAngle(TTime.getHour(), TTime.getMinute());
|
||||
}
|
||||
|
||||
private int computeAngle(int hour, int minute) {
|
||||
return (int) ((hour + minute / 60d) / 12d
|
||||
* 360d);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
JFrame window = new JFrame("Analog Clock");
|
||||
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
@ -187,7 +192,6 @@ public class AnalogClock extends Widget {
|
||||
if ((mouseOver || progressVisibleOnlyIfMouseMovingOverProperty
|
||||
.isDisabled()) && visibility.isStronglyColored()) {
|
||||
|
||||
|
||||
Color currentColor = g2d.getColor();
|
||||
g2d.setColor(Color.YELLOW);
|
||||
int startAngle = computeStartAngle();
|
||||
@ -239,8 +243,8 @@ public class AnalogClock extends Widget {
|
||||
}
|
||||
}
|
||||
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,
|
||||
hours, 4.0f,
|
||||
Color.BLACK, visibility);
|
||||
@ -256,8 +260,8 @@ public class AnalogClock extends Widget {
|
||||
if (borderOnlyHoursProperty.isEnabled() && minuteI % 5 != 0) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -273,9 +277,9 @@ public class AnalogClock extends Widget {
|
||||
Color currentColor = brush.getColor();
|
||||
Visibility visibility
|
||||
= 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);
|
||||
brush.fillOval(centerX - 3, centerY - 3, 8, 8);
|
||||
brush.setColor(currentColor);
|
||||
@ -285,13 +289,13 @@ public class AnalogClock extends Widget {
|
||||
float stroke, Color color, Visibility visibility) {
|
||||
double value = ((double) forMinute) / 60d;
|
||||
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);
|
||||
int startX =
|
||||
(int) (getWidth() / 2 + (side / 2 - length) * Math.cos(angle));
|
||||
int startY =
|
||||
(int) (getHeight() / 2 + (side / 2 - length) * Math.sin(angle));
|
||||
int startX
|
||||
= (int) (getWidth() / 2 + (side / 2 - length) * Math.cos(angle));
|
||||
int startY
|
||||
= (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));
|
||||
@ -312,8 +316,8 @@ public class AnalogClock extends Widget {
|
||||
int endX = (int) (getWidth() / 2 + length * Math.cos(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);
|
||||
brush.setStroke(new BasicStroke(stroke));
|
||||
brush.drawLine(getWidth() / 2, getHeight() / 2, endX, endY);
|
||||
|
@ -39,24 +39,24 @@ public class Battery extends Widget {
|
||||
private final double[] randomDoubles
|
||||
= new double[]{1d, 1d, 1d, 1d, 1d, 1d, 1};
|
||||
private final BooleanProperty blinking = new BooleanProperty("blinking");
|
||||
public BooleanProperty wavesVisibleProperty =
|
||||
new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE
|
||||
public BooleanProperty wavesVisibleProperty
|
||||
= new BooleanProperty(TimeCalcProperty.BATTERY_WAVES_VISIBLE
|
||||
.getKey(), true);
|
||||
public BooleanProperty circleProgressVisibleProperty =
|
||||
new BooleanProperty(TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE
|
||||
public BooleanProperty circleProgressVisibleProperty
|
||||
= new BooleanProperty(TimeCalcProperty.BATTERY_CIRCLE_PROGRESS_VISIBLE
|
||||
.getKey(), true);
|
||||
public BooleanProperty percentProgressVisibleProperty = new BooleanProperty(
|
||||
TimeCalcProperty.BATTERY_PERCENT_PROGRESS_VISIBLE
|
||||
.getKey(), true);
|
||||
public BooleanProperty chargingCharacterVisibleProperty =
|
||||
new BooleanProperty(
|
||||
public BooleanProperty chargingCharacterVisibleProperty
|
||||
= new BooleanProperty(
|
||||
TimeCalcProperty.BATTERY_CHARGING_CHARACTER_VISIBLE
|
||||
.getKey(), true);
|
||||
public BooleanProperty nameVisibleProperty =
|
||||
new BooleanProperty(TimeCalcProperty.BATTERY_NAME_VISIBLE
|
||||
public BooleanProperty nameVisibleProperty
|
||||
= new BooleanProperty(TimeCalcProperty.BATTERY_NAME_VISIBLE
|
||||
.getKey(), true);
|
||||
public BooleanProperty labelVisibleProperty =
|
||||
new BooleanProperty(TimeCalcProperty.BATTERY_LABEL_VISIBLE
|
||||
public BooleanProperty labelVisibleProperty
|
||||
= new BooleanProperty(TimeCalcProperty.BATTERY_LABEL_VISIBLE
|
||||
.getKey(), true);
|
||||
public BooleanProperty blinkingIfCriticalLowVisibleProperty
|
||||
= new BooleanProperty(
|
||||
@ -139,8 +139,7 @@ public class Battery extends Widget {
|
||||
int intX = 1;
|
||||
int todoHeight = totalHeight - doneHeight;
|
||||
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) (4 * surfacePower);//2 + (int) (Math.random() * 3);
|
||||
if (waterSurfaceHeight <= 2 || wavesVisibleProperty.isDisabled() || !changedInTheLastXMilliseconds(1000)) {
|
||||
@ -250,8 +249,8 @@ public class Battery extends Widget {
|
||||
(donePercent == 1 ? 100 : (NumberFormats.FORMATTER_THREE_DECIMAL_PLACES
|
||||
.format(donePercent * 100))) + "%",
|
||||
((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
|
||||
@ -286,9 +285,9 @@ public class Battery extends Widget {
|
||||
private void paintCircleProgress(Graphics2D brush, Visibility visibility) {
|
||||
Color currentColor = brush.getColor();
|
||||
brush.setColor(
|
||||
visibility.isStronglyColored() ? HIGH_HIGHLIGHTED :
|
||||
(visibility.isWeaklyColored() ? HIGH :
|
||||
Color.lightGray));
|
||||
visibility.isStronglyColored() ? HIGH_HIGHLIGHTED
|
||||
: (visibility.isWeaklyColored() ? HIGH
|
||||
: Color.lightGray));
|
||||
|
||||
double angleDouble = donePercent * 360;
|
||||
|
||||
@ -297,9 +296,8 @@ public class Battery extends Widget {
|
||||
15, 15, 90, -(int) angleDouble);
|
||||
brush.setColor(
|
||||
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,
|
||||
totalHeight / 4 * 3 + 28,
|
||||
15, 15, 90, +(int) (360 - angleDouble));
|
||||
|
@ -14,8 +14,8 @@ import java.util.Map;
|
||||
*/
|
||||
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
|
||||
private final ProgressSmiley progressSmiley;
|
||||
@Getter
|
||||
|
@ -8,6 +8,7 @@ import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class Time extends Thread {
|
||||
|
||||
private final IntegerProperty yearReadWriteProperty
|
||||
= new IntegerProperty("yearProperty");
|
||||
private final IntegerProperty monthReadWriteProperty
|
||||
@ -74,6 +75,7 @@ public class Time extends Thread {
|
||||
cal.set(Calendar.MILLISECOND, millisecondProperty.getValue());
|
||||
return cal;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
||||
while (true) {
|
||||
@ -114,6 +116,7 @@ public class Time extends Thread {
|
||||
+ dayOfWeekProperty.getValue() + " "
|
||||
);
|
||||
}
|
||||
|
||||
private int returnCustomValueIfNeeded(Calendar cal, int timeUnit,
|
||||
IntegerProperty custom,
|
||||
ReadOnlyProperty<Integer> real) {
|
||||
|
@ -75,9 +75,9 @@ public class WalkingHumanProgress extends Widget implements
|
||||
Visibility visibility
|
||||
= 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);
|
||||
// if(mouseOver) {
|
||||
// brush.drawRect(1,1,getWidth() - 2, getHeight() - 2);
|
||||
// }
|
||||
|
@ -7,18 +7,19 @@ import java.io.File;
|
||||
* @since 21.02.2024
|
||||
*/
|
||||
public class FileConstants {
|
||||
|
||||
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 OVERTIME_TXT =
|
||||
new File(TC_DIRECTORY, "overtime.txt");
|
||||
public static final File STARTTIME_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 TIME_CALC_PROFILES_TXT_FILE =
|
||||
new File(TC_DIRECTORY, "time-calc-profiles.txt");
|
||||
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");
|
||||
public static final File TIME_CALC_PROFILES_TXT_FILE
|
||||
= new File(TC_DIRECTORY, "time-calc-profiles.txt");
|
||||
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");
|
||||
public static final File JOKES_TXT = new File(TC_DIRECTORY, "time-calc-jokes.txt");
|
||||
|
||||
private FileConstants() {
|
||||
|
@ -74,6 +74,7 @@ public class TTime implements Comparable<TTime> {
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
|
||||
public static TTime of(Calendar cal) {
|
||||
return new TTime(
|
||||
cal.get(Calendar.HOUR_OF_DAY),
|
||||
@ -81,6 +82,7 @@ public class TTime implements Comparable<TTime> {
|
||||
cal.get(Calendar.SECOND),
|
||||
cal.get(Calendar.MILLISECOND));
|
||||
}
|
||||
|
||||
public static TTime of(Duration duration) {
|
||||
return new TTime(
|
||||
duration.get(ChronoUnit.HOURS),
|
||||
@ -88,6 +90,7 @@ public class TTime implements Comparable<TTime> {
|
||||
duration.get(ChronoUnit.SECONDS),
|
||||
duration.get(ChronoUnit.MILLIS));
|
||||
}
|
||||
|
||||
public TTime(String string) {
|
||||
this.negative = string.startsWith("-");
|
||||
if (negative) {
|
||||
@ -99,9 +102,11 @@ public class TTime implements Comparable<TTime> {
|
||||
this.second = array.length >= 3 ? ((negative ? (1) : 1) * Integer.valueOf(array[2])) : 0;
|
||||
this.millisecond = array.length >= 4 ? ((negative ? (1) : 1) * Integer.valueOf(array[3])) : 0;
|
||||
}
|
||||
|
||||
public TTime(int hourIn, int minuteIn, int secondIn, int millisecondIn) {
|
||||
this(false, hourIn, minuteIn, secondIn, millisecondIn);
|
||||
}
|
||||
|
||||
public TTime(boolean negative, int hourIn, int minuteIn, int secondIn, int millisecondIn) {
|
||||
this.hour = Math.abs(hourIn);
|
||||
this.minute = Math.abs(minuteIn);
|
||||
@ -117,6 +122,7 @@ public class TTime implements Comparable<TTime> {
|
||||
hour = hour - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public TTime remove(TTime tTimeToBeRemoved) {
|
||||
int s1 = this.toTotalMilliseconds();
|
||||
int s2 = tTimeToBeRemoved.toTotalMilliseconds();
|
||||
@ -166,6 +172,7 @@ public class TTime implements Comparable<TTime> {
|
||||
public String toString() {
|
||||
return (negative ? "-" : "") + (hour < 10 ? "0" : "") + hour + ":" + (minute < 10 ? "0" : "") + minute + ":" + (second < 10 ? "0" : "") + second + ":" + (millisecond < 10 ? "00" : (millisecond < 100 ? "0" : "")) + millisecond;
|
||||
}
|
||||
|
||||
public Calendar asCalendar() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.HOUR_OF_DAY, hour);
|
||||
@ -174,9 +181,11 @@ public class TTime implements Comparable<TTime> {
|
||||
cal.set(Calendar.MILLISECOND, millisecond);
|
||||
return cal;
|
||||
}
|
||||
|
||||
public Date asDate() {
|
||||
return asCalendar().getTime();
|
||||
}
|
||||
|
||||
public int toTotalMilliseconds() {
|
||||
return ((negative ? (-1) : 1)) * (hour * 60 * 60 * 1000 + minute * 60 * 1000 + second * 1000 + millisecond);
|
||||
}
|
||||
|
@ -14,6 +14,11 @@ public class IntegerProperty extends Property<Integer> {
|
||||
this(name, 0);
|
||||
}
|
||||
|
||||
public void increment() {this.setValue(getValue() + 1);}
|
||||
public void decrement() {this.setValue(getValue() - 1);}
|
||||
public void increment() {
|
||||
this.setValue(getValue() + 1);
|
||||
}
|
||||
|
||||
public void decrement() {
|
||||
this.setValue(getValue() - 1);
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ public class Property<T> {
|
||||
private final String name;
|
||||
private final List<InvalidationListener> invalidationListeners
|
||||
= new ArrayList<>();
|
||||
private final List<ChangeListener<T>> changeListeners =
|
||||
new ArrayList<ChangeListener<T>>();
|
||||
private final List<ChangeListener<T>> changeListeners
|
||||
= new ArrayList<ChangeListener<T>>();
|
||||
private boolean valid = true;
|
||||
private T value;
|
||||
private Property<T> boundToProperty = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user