mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
Time improvements - wip2
This commit is contained in:
parent
4ab6553c11
commit
5bd75ddd70
@ -244,11 +244,55 @@ public class TimeCalcManager {
|
|||||||
stopBeforeEnd = true;
|
stopBeforeEnd = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Calendar calNow = Calendar.getInstance();
|
||||||
|
calNow.setTime(new Date());
|
||||||
|
|
||||||
AnalogClock analogClock = new AnalogClock(startTime, endTime);
|
AnalogClock analogClock = new AnalogClock(startTime, endTime);
|
||||||
analogClock.setBounds(MARGIN, MARGIN, 200);
|
analogClock.setBounds(MARGIN, MARGIN, 200);
|
||||||
|
|
||||||
|
Properties testProperties = new Properties();
|
||||||
|
File testPropertiesFile = new File("test.txt");
|
||||||
|
try {
|
||||||
|
if(testPropertiesFile.exists()) {
|
||||||
|
testProperties.load(new FileInputStream(testPropertiesFile));
|
||||||
|
}
|
||||||
|
} catch (FileNotFoundException ex) {
|
||||||
|
Logger.getLogger(TimeCalcManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
} catch (IOException rex) {
|
||||||
|
Logger.getLogger(TimeCalcManager.class.getName()).log(Level.SEVERE, null, rex);
|
||||||
|
}
|
||||||
|
System.out.println("current dir=" + new File(".").getAbsolutePath());
|
||||||
|
if(testProperties.containsKey("current.day")) {
|
||||||
|
calNow.set(Calendar.DAY_OF_MONTH, Integer.parseInt((String) testProperties.get("current.day")));
|
||||||
|
analogClock.dayProperty.setValue(Integer.valueOf((String) testProperties.get("current.day")));
|
||||||
|
} else {
|
||||||
|
analogClock.dayProperty.bindTo(time.dayProperty);
|
||||||
|
}
|
||||||
|
if(testProperties.containsKey("current.month")) {
|
||||||
|
calNow.set(Calendar.MONTH, Integer.parseInt((String) testProperties.get("current.month")) - 1);
|
||||||
|
analogClock.monthProperty.setValue(Integer.valueOf((String) testProperties.get("current.month")));
|
||||||
|
} else {
|
||||||
|
analogClock.monthProperty.bindTo(time.monthProperty);
|
||||||
|
}
|
||||||
|
if(testProperties.containsKey("current.year")) {
|
||||||
|
calNow.set(Calendar.YEAR, Integer.parseInt((String) testProperties.get("current.year")));
|
||||||
|
analogClock.yearProperty.setValue(Integer.valueOf((String) testProperties.get("current.year")));
|
||||||
|
} else {
|
||||||
|
analogClock.yearProperty.bindTo(time.yearProperty);
|
||||||
|
}
|
||||||
|
if(testProperties.containsKey("current.year") || testProperties.containsKey("current.month") ||testProperties.containsKey("current.day")) {
|
||||||
|
analogClock.dayOfWeekProperty.setValue(calNow.get(Calendar.DAY_OF_WEEK));
|
||||||
|
} else {
|
||||||
|
analogClock.dayOfWeekProperty.bindTo(time.dayOfWeek);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
analogClock.hourProperty.bindTo(time.hourProperty);
|
analogClock.hourProperty.bindTo(time.hourProperty);
|
||||||
analogClock.minuteProperty.bindTo(time.minuteProperty);
|
analogClock.minuteProperty.bindTo(time.minuteProperty);
|
||||||
analogClock.secondProperty.bindTo(time.secondProperty);
|
analogClock.secondProperty.bindTo(time.secondProperty);
|
||||||
|
analogClock.millisecondProperty.bindTo(time.millisecondProperty);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
window.add(analogClock);
|
window.add(analogClock);
|
||||||
|
|
||||||
@ -277,30 +321,6 @@ public class TimeCalcManager {
|
|||||||
dayBattery.getY(), 140);
|
dayBattery.getY(), 140);
|
||||||
window.add(weekBattery);
|
window.add(weekBattery);
|
||||||
|
|
||||||
Calendar calNow = Calendar.getInstance();
|
|
||||||
calNow.setTime(new Date());
|
|
||||||
|
|
||||||
Properties testProperties = new Properties();
|
|
||||||
File testPropertiesFile = new File("test.txt");
|
|
||||||
try {
|
|
||||||
if(testPropertiesFile.exists()) {
|
|
||||||
testProperties.load(new FileInputStream(testPropertiesFile));
|
|
||||||
}
|
|
||||||
} catch (FileNotFoundException ex) {
|
|
||||||
Logger.getLogger(TimeCalcManager.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
} catch (IOException rex) {
|
|
||||||
Logger.getLogger(TimeCalcManager.class.getName()).log(Level.SEVERE, null, rex);
|
|
||||||
}
|
|
||||||
System.out.println("current dir=" + new File(".").getAbsolutePath());
|
|
||||||
if(testProperties.containsKey("current.day")) {
|
|
||||||
calNow.set(Calendar.DAY_OF_MONTH, Integer.parseInt((String) testProperties.get("current.day")));
|
|
||||||
}
|
|
||||||
if(testProperties.containsKey("current.month")) {
|
|
||||||
calNow.set(Calendar.MONTH, Integer.parseInt((String) testProperties.get("current.month")) - 1);
|
|
||||||
}
|
|
||||||
if(testProperties.containsKey("current.year")) {
|
|
||||||
calNow.set(Calendar.YEAR, Integer.parseInt((String) testProperties.get("current.year")));
|
|
||||||
}
|
|
||||||
int currentDayOfMonth = calNow.get(Calendar.DAY_OF_MONTH);
|
int currentDayOfMonth = calNow.get(Calendar.DAY_OF_MONTH);
|
||||||
|
|
||||||
int workDaysDone = 0;
|
int workDaysDone = 0;
|
||||||
|
@ -204,9 +204,14 @@ public class AnalogClock extends Widget {
|
|||||||
if(this.mouseOver)
|
if(this.mouseOver)
|
||||||
{
|
{
|
||||||
|
|
||||||
g2d.drawString(DateFormats.DATE_TIME_FORMATTER_LONG.format(new Date()), ((int) (side * 0.25)),
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.set(Calendar.YEAR, yearProperty.getValue());
|
||||||
|
cal.set(Calendar.MONTH, monthProperty.getValue() -1);
|
||||||
|
cal.set(Calendar.DAY_OF_MONTH, dayProperty.getValue());
|
||||||
|
Date date = cal.getTime();
|
||||||
|
g2d.drawString(DateFormats.DATE_TIME_FORMATTER_LONG.format(date), ((int) (side * 0.25)),
|
||||||
((int) (side * 0.35)));
|
((int) (side * 0.35)));
|
||||||
g2d.drawString(DateFormats.DATE_TIME_FORMATTER_TIME.format(new Date()),
|
g2d.drawString(DateFormats.DATE_TIME_FORMATTER_TIME.format(date),
|
||||||
((int) (side * 0.25) + 30),
|
((int) (side * 0.25) + 30),
|
||||||
((int) (side * 0.35)) + 60);
|
((int) (side * 0.35)) + 60);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user