Code was formatted

This commit is contained in:
Robert Vokac 2024-02-03 00:47:02 +00:00
parent 43324c8f03
commit a10faea532
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
14 changed files with 280 additions and 168 deletions

View File

@ -9,9 +9,11 @@ import javax.swing.JButton;
public class TimeCalcButton extends JButton { public class TimeCalcButton extends JButton {
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 TimeCalcButton(String label) { public TimeCalcButton(String label) {
super(label); super(label);
} }
public void setBounds(int x, int y) { public void setBounds(int x, int y) {
setBounds(x, y, BUTTON_WIDTH, BUTTON_HEIGHT); setBounds(x, y, BUTTON_WIDTH, BUTTON_HEIGHT);
} }

View File

@ -113,7 +113,7 @@ public class Toaster {
* Show a toaster with the specified message and the associated icon. * Show a toaster with the specified message and the associated icon.
*/ */
public void showToaster(Icon icon, String msg) { public void showToaster(Icon icon, String msg) {
if(Utils.everythingHidden.get() || !Utils.toastsAreEnabled.get()) { if (Utils.everythingHidden.get() || !Utils.toastsAreEnabled.get()) {
//nothing to do //nothing to do
return; return;
} }
@ -429,7 +429,7 @@ 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;
} }
@ -440,7 +440,7 @@ 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;
} }

View File

@ -13,12 +13,13 @@ import java.awt.event.MouseListener;
* @since 20.02.2024 * @since 20.02.2024
*/ */
public class Widget extends JPanel { public class Widget extends JPanel {
protected int side = 0;
protected double donePercent = 0;
protected boolean mouseOver = false;
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 int side = 0;
protected double donePercent = 0;
protected boolean mouseOver = false;
public Widget() { public Widget() {
setBackground(BACKGROUND_COLOR); setBackground(BACKGROUND_COLOR);
new Timer(getTimerDelay(), e -> repaint()).start(); new Timer(getTimerDelay(), e -> repaint()).start();
@ -49,15 +50,18 @@ public class Widget extends JPanel {
} }
}); });
} }
public int getTimerDelay() { public int getTimerDelay() {
return 100; return 100;
} }
public final void setDonePercent(double donePercent) { public final void setDonePercent(double donePercent) {
if(donePercent > 1) { if (donePercent > 1) {
donePercent = 1; donePercent = 1;
} }
this.donePercent = donePercent; this.donePercent = donePercent;
} }
public void setBounds(int x, int y, int side) { public void setBounds(int x, int y, int side) {
setBounds(x, y, side, side); setBounds(x, y, side, side);
} }

View File

@ -56,25 +56,32 @@ public class AnalogClock extends Widget {
drawHand(g2d, side / 2 - 10, second / 60.0, 0.5f, Color.RED); drawHand(g2d, side / 2 - 10, second / 60.0, 0.5f, Color.RED);
if(TimeCalcConf.getInstance().areClockHandsLong()) drawHand(g2d, (side / 2 - 10) / 4, if (TimeCalcConf.getInstance().areClockHandsLong()) {
(second > 30 ? second - 30 : second + 30) / 60.0, 0.5f, drawHand(g2d, (side / 2 - 10) / 4,
Color.RED); (second > 30 ? second - 30 : second + 30) / 60.0, 0.5f,
Color.RED);
}
// //
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); Color.BLUE);
if(TimeCalcConf.getInstance().areClockHandsLong()) drawHand(g2d, (side / 2 - 20) / 4, if (TimeCalcConf.getInstance().areClockHandsLong()) {
minutes + minutes > 0.5 ? minutes - 0.5 : drawHand(g2d, (side / 2 - 20) / 4,
minutes + (minutes > 0.5 ? (-1) : 1) * 0.5, 2.0f, minutes + minutes > 0.5 ? minutes - 0.5 :
Color.BLUE); minutes + (minutes > 0.5 ? (-1) : 1) * 0.5, 2.0f,
Color.BLUE);
}
// //
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); Color.BLACK);
if(TimeCalcConf.getInstance().areClockHandsLong()) drawHand(g2d, (side / 2 - 40) / 4, hours + hours > 0.5 ? hours - 0.5 : if (TimeCalcConf.getInstance().areClockHandsLong()) {
hours + (hours > 0.5 ? (-1) : 1) * 0.5, 4.0f, drawHand(g2d, (side / 2 - 40) / 4,
Color.BLACK); hours + hours > 0.5 ? hours - 0.5 :
hours + (hours > 0.5 ? (-1) : 1) * 0.5, 4.0f,
Color.BLACK);
}
drawCentre(g2d, centerX, centerY); drawCentre(g2d, centerX, centerY);
} }
@ -125,12 +132,12 @@ public class AnalogClock extends Widget {
int seconds = Integer.valueOf(now.split(":")[2]); int seconds = Integer.valueOf(now.split(":")[2]);
g2d.setFont(new Font("sans", Font.BOLD, 16)); g2d.setFont(new Font("sans", Font.BOLD, 16));
g2d.drawString(Integer.toString(i), dx, dy); g2d.drawString(Integer.toString(i), dx, dy);
} }
} }
public int getTimerDelay() { public int getTimerDelay() {
return 20; return 20;
} }

View File

@ -13,7 +13,6 @@ import java.text.DecimalFormat;
import java.text.NumberFormat; import java.text.NumberFormat;
public class Battery extends Widget { public class Battery extends Widget {
public static boolean wavesOff = false;
public static final Color LOW = new Color(253, 130, 130); public static final Color LOW = new Color(253, 130, 130);
public static final Color MEDIUM = new Color(255, 204, 153); public static final Color MEDIUM = new Color(255, 204, 153);
public static final Color HIGH = new Color(204, 255, 204); public static final Color HIGH = new Color(204, 255, 204);
@ -22,12 +21,13 @@ public class Battery extends Widget {
public static final Color MEDIUM_HIGHLIGHTED = Color.ORANGE; public static final Color MEDIUM_HIGHLIGHTED = Color.ORANGE;
public static final Color HIGH_HIGHLIGHTED = new Color(158, 227, 158); public static final Color HIGH_HIGHLIGHTED = new Color(158, 227, 158);
public static final Color HIGHEST_HIGHLIGHTED = Color.green; public static final Color HIGHEST_HIGHLIGHTED = Color.green;
public static boolean wavesOff = false;
NumberFormat formatter3 = new DecimalFormat("#0.000"); NumberFormat formatter3 = new DecimalFormat("#0.000");
private int totalHeight = 0; private int totalHeight = 0;
private int width_; private int width_;
private String label = null; private String label = null;
private final double[] randomDoubles = new double[] {1d, 1d, 1d, 1d, 1d, 1d, 1};
public Battery() { public Battery() {
setPreferredSize(new Dimension(40, 100)); setPreferredSize(new Dimension(40, 100));
@ -46,7 +46,7 @@ public class Battery extends Widget {
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON); RenderingHints.VALUE_ANTIALIAS_ON);
if(!Utils.ultraLight.get()) { if (!Utils.ultraLight.get()) {
g2d.fillRect(width_ / 4, 1, width_, totalHeight - 2); g2d.fillRect(width_ / 4, 1, width_, totalHeight - 2);
} }
g2d.setColor(Utils.highlighted.get() || mouseOver ? Color.BLACK : g2d.setColor(Utils.highlighted.get() || mouseOver ? Color.BLACK :
@ -57,77 +57,93 @@ public class Battery extends Widget {
donePercent < 0.1 ? LOW_HIGHLIGHTED : (donePercent < 0.75 ? donePercent < 0.1 ? LOW_HIGHLIGHTED : (donePercent < 0.75 ?
MEDIUM_HIGHLIGHTED : MEDIUM_HIGHLIGHTED :
(donePercent < 0.9 ? HIGH_HIGHLIGHTED : (donePercent < 0.9 ? HIGH_HIGHLIGHTED :
HIGHEST_HIGHLIGHTED))); HIGHEST_HIGHLIGHTED)));
} else { } else {
g2d.setColor(donePercent < 0.1 ? LOW : (donePercent < 0.75 ? g2d.setColor(donePercent < 0.1 ? LOW : (donePercent < 0.75 ?
MEDIUM : (donePercent < 0.9 ? HIGH : HIGHEST))); MEDIUM : (donePercent < 0.9 ? HIGH : HIGHEST)));
} }
if(Utils.ultraLight.get()) { if (Utils.ultraLight.get()) {
g2d.setColor(Utils.ULTRA_LIGHT_GRAY); g2d.setColor(Utils.ULTRA_LIGHT_GRAY);
} }
int doneHeight = (int) (totalHeight * donePercent); int doneHeight = (int) (totalHeight * donePercent);
int intX = width_ / 4; int intX = width_ / 4;
int todoHeight = totalHeight - doneHeight; int todoHeight = totalHeight - doneHeight;
double surfacePower = 1;//donePercent < 0.5 ? 0.5 : donePercent;// (donePercent * 100 - ((int)(donePercent * 100))); double surfacePower =
int waterSurfaceHeight = (int) (4 * surfacePower);//2 + (int) (Math.random() * 3); 1;//donePercent < 0.5 ? 0.5 : donePercent;// (donePercent * 100 - ((int)(donePercent * 100)));
if(waterSurfaceHeight <= 2 || !TimeCalcConf.getInstance() int waterSurfaceHeight =
(int) (4 * surfacePower);//2 + (int) (Math.random() * 3);
if (waterSurfaceHeight <= 2 || !TimeCalcConf.getInstance()
.areBatteryWavesEnabled() || wavesOff) { .areBatteryWavesEnabled() || wavesOff) {
waterSurfaceHeight = 0; waterSurfaceHeight = 0;
} }
g2d.fillRect(intX, doneHeight < waterSurfaceHeight || donePercent >= 1 ? todoHeight : todoHeight + waterSurfaceHeight, g2d.fillRect(intX, doneHeight < waterSurfaceHeight || donePercent >= 1 ?
width_, doneHeight < waterSurfaceHeight || donePercent >= 1 ? doneHeight : doneHeight - waterSurfaceHeight); todoHeight : todoHeight + waterSurfaceHeight,
width_, doneHeight < waterSurfaceHeight || donePercent >= 1 ?
doneHeight : doneHeight - waterSurfaceHeight);
int pointCount = 8; int pointCount = 8;
if(doneHeight >= waterSurfaceHeight && donePercent < 1) {// && todoHeight > waterSurfaceHeight) { if (doneHeight >= waterSurfaceHeight
&& donePercent < 1) {// && todoHeight > waterSurfaceHeight) {
//g2d.fillArc(intX, intY, width_, intHeight - waterSurfaceHeight, 30, 60); //g2d.fillArc(intX, intY, width_, intHeight - waterSurfaceHeight, 30, 60);
g2d.fillPolygon( g2d.fillPolygon(
new int[]{intX, new int[] {intX,
(int) (intX + width_ / pointCount * 0.5), (int) (intX + width_ / pointCount * 0.5),
intX + width_ / pointCount * 3, intX + width_ / pointCount * 3,
intX + width_ / pointCount * 4, intX + width_ / pointCount * 4,
intX + width_ / pointCount * 5, intX + width_ / pointCount * 5,
intX + width_ / pointCount * 6, intX + width_ / pointCount * 6,
(int) (intX + width_ / pointCount * 7), intX + width_ / pointCount * 7,
intX + width_ / pointCount * 8}, intX + width_ / pointCount * 8},
new int[]{(int) (todoHeight + (waterSurfaceHeight * 1)), new int[] {todoHeight + (waterSurfaceHeight * 1),
todoHeight + (int) (waterSurfaceHeight * getRandom(0)), todoHeight + (int) (waterSurfaceHeight * getRandom(
todoHeight + (int) (waterSurfaceHeight * getRandom(1)), 0)),
todoHeight + (int) (waterSurfaceHeight * getRandom(2)), todoHeight + (int) (waterSurfaceHeight * getRandom(
todoHeight + (int) (waterSurfaceHeight * getRandom(3)), 1)),
todoHeight + (int) (waterSurfaceHeight * getRandom(4)), todoHeight + (int) (waterSurfaceHeight * getRandom(
todoHeight + (int) (waterSurfaceHeight * getRandom(5)), 2)),
(int) (todoHeight + (waterSurfaceHeight * 1))}, todoHeight + (int) (waterSurfaceHeight * getRandom(
3)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
4)),
todoHeight + (int) (waterSurfaceHeight * getRandom(
5)),
todoHeight + (waterSurfaceHeight * 1)},
pointCount); pointCount);
} }
g2d.setColor(Utils.highlighted.get() || mouseOver ? Color.BLACK : g2d.setColor(Utils.highlighted.get() || mouseOver ? Color.BLACK :
Color.LIGHT_GRAY); Color.LIGHT_GRAY);
g2d.drawString( g2d.drawString(
formatter3.format(donePercent * 100) + "%", formatter3.format(donePercent * 100) + "%",
((int) (width_ * 0.4)), donePercent > 0.5 ? totalHeight / 4 * 3 : totalHeight / 4 * 1); ((int) (width_ * 0.4)),
donePercent > 0.5 ? totalHeight / 4 * 3 : totalHeight / 4 * 1);
if(label!= null && !label.isEmpty()) { if (label != null && !label.isEmpty()) {
g2d.drawString( g2d.drawString(
label, label,
((int) (width_ * 0.4)), ((int) (width_ * 0.4)),
(donePercent > 0.5 ? totalHeight / 4 * 3 : (donePercent > 0.5 ? totalHeight / 4 * 3 :
totalHeight / 4 * 1)+ 20); totalHeight / 4 * 1) + 20);
} }
} }
private double[] randomDoubles = new double[]{1d,1d,1d,1d,1d,1d,1};
private double getRandom(int index) { private double getRandom(int index) {
if(Math.random() > 0.7) {randomDoubles[index] = Math.random();} if (Math.random() > 0.7) {
randomDoubles[index] = Math.random();
}
return randomDoubles[index]; return randomDoubles[index];
} }
public int getTimerDelay() { public int getTimerDelay() {
return 250; return 250;
} }
public void setLabel(String label) {
this.label = label;
}
public String getLabel() { public String getLabel() {
return this.label; return this.label;
} }
public void setLabel(String label) {
this.label = label;
}
} }

View File

@ -29,7 +29,6 @@ public class ProgressSquare extends Widget {
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON); RenderingHints.VALUE_ANTIALIAS_ON);
int dotNumber = (int) (donePercent * square); int dotNumber = (int) (donePercent * square);
int y = dotNumber / side; int y = dotNumber / side;
int yOrig = y; int yOrig = y;

View File

@ -1,8 +1,8 @@
package org.nanoboot.utils.timecalc.main; package org.nanoboot.utils.timecalc.main;
import org.nanoboot.utils.timecalc.utils.Constants; import org.nanoboot.utils.timecalc.utils.Constants;
import org.nanoboot.utils.timecalc.utils.Utils;
import org.nanoboot.utils.timecalc.utils.FileConstants; import org.nanoboot.utils.timecalc.utils.FileConstants;
import org.nanoboot.utils.timecalc.utils.Utils;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import java.io.IOException; import java.io.IOException;
@ -13,7 +13,6 @@ import java.io.IOException;
*/ */
public class Main { public class Main {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
while (true) { while (true) {
@ -23,25 +22,33 @@ public class Main {
String oldOvertime = Utils.readTextFromFile( String oldOvertime = Utils.readTextFromFile(
FileConstants.OVERTIME_TXT); FileConstants.OVERTIME_TXT);
String newStartTime = String newStartTime =
test ? (oldStartTime != null ? oldStartTime : Constants.DEFAULT_START_TIME) : (String) JOptionPane.showInputDialog( test ? (oldStartTime != null ? oldStartTime :
null, Constants.DEFAULT_START_TIME) :
"Start Time:", (String) JOptionPane.showInputDialog(
"Start Time", null,
JOptionPane.PLAIN_MESSAGE, "Start Time:",
null, "Start Time",
null, JOptionPane.PLAIN_MESSAGE,
oldStartTime == null ? Constants.DEFAULT_START_TIME : oldStartTime null,
); null,
oldStartTime == null ?
Constants.DEFAULT_START_TIME :
oldStartTime
);
String newOvertime = String newOvertime =
test ? (oldOvertime != null ? oldOvertime : Constants.DEFAULT_OVERTIME) : (String) JOptionPane.showInputDialog( test ? (oldOvertime != null ? oldOvertime :
null, Constants.DEFAULT_OVERTIME) :
"Overtime:", (String) JOptionPane.showInputDialog(
"Overtime", null,
JOptionPane.PLAIN_MESSAGE, "Overtime:",
null, "Overtime",
null, JOptionPane.PLAIN_MESSAGE,
oldOvertime == null ? Constants.DEFAULT_OVERTIME : oldOvertime null,
); null,
oldOvertime == null ?
Constants.DEFAULT_OVERTIME :
oldOvertime
);
Utils.writeTextToFile(FileConstants.STARTTIME_TXT, newStartTime); Utils.writeTextToFile(FileConstants.STARTTIME_TXT, newStartTime);
Utils.writeTextToFile(FileConstants.OVERTIME_TXT, newOvertime); Utils.writeTextToFile(FileConstants.OVERTIME_TXT, newOvertime);

View File

@ -17,15 +17,10 @@ public class TimeCalcConf {
private static final String TOASTS_ENABLED = "toasts.enabled"; private static final String TOASTS_ENABLED = "toasts.enabled";
private static TimeCalcConf INSTANCE; private static TimeCalcConf INSTANCE;
private Properties properties = new Properties(); private final Properties properties = new Properties();
public static TimeCalcConf getInstance() {
if(INSTANCE == null) {
INSTANCE = new TimeCalcConf();
}
return INSTANCE;
}
private TimeCalcConf() { private TimeCalcConf() {
if(!new File("timecalc.conf").exists()) { if (!new File("timecalc.conf").exists()) {
//nothing to do; //nothing to do;
return; return;
} }
@ -36,23 +31,35 @@ public class TimeCalcConf {
} }
} }
public static TimeCalcConf getInstance() {
if (INSTANCE == null) {
INSTANCE = new TimeCalcConf();
}
return INSTANCE;
}
public boolean areClockHandsLong() { public boolean areClockHandsLong() {
return getBooleanProperty(CLOCK_HANDS_LONG, true); return getBooleanProperty(CLOCK_HANDS_LONG, true);
} }
public boolean isJokeVisible() { public boolean isJokeVisible() {
return getBooleanProperty(JOKE_VISIBLE, true); return getBooleanProperty(JOKE_VISIBLE, true);
} }
public boolean areBatteryWavesEnabled() { public boolean areBatteryWavesEnabled() {
return getBooleanProperty(BATTERY_WAVES_ENABLED, true); return getBooleanProperty(BATTERY_WAVES_ENABLED, true);
} }
public boolean isEverythingHidden() { public boolean isEverythingHidden() {
return getBooleanProperty(EVERYTHING_HIDDEN, false); return getBooleanProperty(EVERYTHING_HIDDEN, false);
} }
public boolean areToastsEnabled() { public boolean areToastsEnabled() {
return getBooleanProperty(TOASTS_ENABLED, true); return getBooleanProperty(TOASTS_ENABLED, true);
} }
private boolean getBooleanProperty(String key, boolean defaultValue) { private boolean getBooleanProperty(String key, boolean defaultValue) {
if(!properties.containsKey(key)) { if (!properties.containsKey(key)) {
return defaultValue; return defaultValue;
} }
return properties.get(key).equals("true"); return properties.get(key).equals("true");

View File

@ -4,7 +4,7 @@ package org.nanoboot.utils.timecalc.main;
* @author Robert * @author Robert
* @since 21.02.2024 * @since 21.02.2024
*/ */
public class TimeCalcException extends RuntimeException{ public class TimeCalcException extends RuntimeException {
public TimeCalcException(String msg) { public TimeCalcException(String msg) {
super(msg); super(msg);
} }

View File

@ -26,7 +26,6 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.time.DayOfWeek; import java.time.DayOfWeek;
@ -55,21 +54,23 @@ public class TimeCalcWindow {
private final String startTime; private final String startTime;
private final String windowTitle; private final String windowTitle;
private String overTime;
private final int startHour; private final int startHour;
private final int startMinute; private final int startMinute;
private final int overtimeHour; private final int overtimeHour;
private final int overtimeMinute; private final int overtimeMinute;
private final int totalMinutes; private final int totalMinutes;
private final Set<Integer> alreadyShownPercents = new HashSet<>(); private final Set<Integer> alreadyShownPercents = new HashSet<>();
private String overTime;
private int endHour; private int endHour;
private int endMinute; private int endMinute;
private boolean stopBeforeEnd = false; private boolean stopBeforeEnd = false;
private boolean vtipyShown = false; private boolean vtipyShown = false;
public TimeCalcWindow(String startTimeIn, String overTimeIn) { public TimeCalcWindow(String startTimeIn, String overTimeIn) {
Utils.everythingHidden.set(TimeCalcConf.getInstance().isEverythingHidden()); Utils.everythingHidden
Utils.toastsAreEnabled.set(TimeCalcConf.getInstance().areToastsEnabled()); .set(TimeCalcConf.getInstance().isEverythingHidden());
Utils.toastsAreEnabled
.set(TimeCalcConf.getInstance().areToastsEnabled());
this.startTime = startTimeIn; this.startTime = startTimeIn;
this.overTime = (overTimeIn == null || overTimeIn.isEmpty()) ? this.overTime = (overTimeIn == null || overTimeIn.isEmpty()) ?
@ -80,9 +81,13 @@ public class TimeCalcWindow {
this.startMinute = Integer.valueOf(startTimeAsArray[1]); this.startMinute = Integer.valueOf(startTimeAsArray[1]);
boolean overtimeIsNegative = overTime.startsWith("-"); boolean overtimeIsNegative = overTime.startsWith("-");
if(overtimeIsNegative) {overTime = overTime.replace("-","");} if (overtimeIsNegative) {
this.overtimeHour =(overtimeIsNegative ? (-1) : 1) * Integer.valueOf(overTime.split(":")[0]); overTime = overTime.replace("-", "");
this.overtimeMinute = (overtimeIsNegative ? (-1) : 1) * Integer.valueOf(overTime.split(":")[1]); }
this.overtimeHour = (overtimeIsNegative ? (-1) : 1) * Integer
.valueOf(overTime.split(":")[0]);
this.overtimeMinute = (overtimeIsNegative ? (-1) : 1) * Integer
.valueOf(overTime.split(":")[1]);
this.endHour = startHour + WORKING_HOURS_LENGTH + overtimeHour; this.endHour = startHour + WORKING_HOURS_LENGTH + overtimeHour;
this.endMinute = startMinute + WORKING_MINUTES_LENGTH + overtimeMinute; this.endMinute = startMinute + WORKING_MINUTES_LENGTH + overtimeMinute;
@ -117,7 +122,10 @@ public class TimeCalcWindow {
if (buildDate == null) { if (buildDate == null) {
buildDate = "unknown"; buildDate = "unknown";
} }
JOptionPane.showMessageDialog(null, "Version: " + version + "\n" + "Built on (universal time): " + buildDate, "About \"Pdf DME Downloader\"", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null,
"Version: " + version + "\n" + "Built on (universal time): "
+ buildDate, "About \"Pdf DME Downloader\"",
JOptionPane.INFORMATION_MESSAGE);
}); });
//window.add(weatherButton); //window.add(weatherButton);
@ -131,27 +139,27 @@ public class TimeCalcWindow {
window.addKeyListener(new KeyAdapter() { window.addKeyListener(new KeyAdapter() {
// Key Pressed method // Key Pressed method
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_UP){ if (e.getKeyCode() == KeyEvent.VK_UP) {
Utils.everythingHidden.set(false); Utils.everythingHidden.set(false);
} }
if(e.getKeyCode() == KeyEvent.VK_DOWN){ if (e.getKeyCode() == KeyEvent.VK_DOWN) {
Utils.everythingHidden.set(true); Utils.everythingHidden.set(true);
} }
if(e.getKeyCode() == KeyEvent.VK_G){ if (e.getKeyCode() == KeyEvent.VK_G) {
Utils.ultraLight.flip(); Utils.ultraLight.flip();
} }
if(e.getKeyCode() == KeyEvent.VK_C){ if (e.getKeyCode() == KeyEvent.VK_C) {
Utils.highlighted.flip(); Utils.highlighted.flip();
} }
if(e.getKeyCode() == KeyEvent.VK_V){ if (e.getKeyCode() == KeyEvent.VK_V) {
Utils.everythingHidden.flip(); Utils.everythingHidden.flip();
} }
if(e.getKeyCode() == KeyEvent.VK_R){ if (e.getKeyCode() == KeyEvent.VK_R) {
commandButton.doClick(); commandButton.doClick();
} }
if(e.getKeyCode() == KeyEvent.VK_T){ if (e.getKeyCode() == KeyEvent.VK_T) {
Utils.toastsAreEnabled.flip(); Utils.toastsAreEnabled.flip();
} }
@ -202,9 +210,12 @@ public class TimeCalcWindow {
restartButton restartButton
.setBounds(280, text.getY() + text.getHeight() + MARGIN); .setBounds(280, text.getY() + text.getHeight() + MARGIN);
exitButton.setBounds(390, text.getY() + text.getHeight() + MARGIN); exitButton.setBounds(390, text.getY() + text.getHeight() + MARGIN);
aboutButton.setBounds(exitButton.getX(), exitButton.getY() + exitButton.getHeight() + MARGIN); aboutButton.setBounds(exitButton.getX(),
exitButton.getY() + exitButton.getHeight() + MARGIN);
focusButton.setBounds(exitButton.getX() + 3 * MARGIN + exitButton.getWidth() + 20, MARGIN, 60, aboutButton.getHeight()); focusButton.setBounds(
exitButton.getX() + 3 * MARGIN + exitButton.getWidth() + 20,
MARGIN, 60, aboutButton.getHeight());
window.setSize(520 + 20 + 100, 580 + MARGIN + aboutButton.getHeight()); window.setSize(520 + 20 + 100, 580 + MARGIN + aboutButton.getHeight());
window.setLayout(null); window.setLayout(null);
@ -234,12 +245,26 @@ public class TimeCalcWindow {
"test" "test"
); );
String[] commandsAsArray = commands.split(" "); String[] commandsAsArray = commands.split(" ");
switch(commandsAsArray[0]) { switch (commandsAsArray[0]) {
case "test": JOptionPane.showMessageDialog(null, "Test");break; case "test":
case "color": Utils.highlighted.set(commandsAsArray[1].equals("1"));break; JOptionPane.showMessageDialog(null, "Test");
case "gray": Utils.ultraLight.set(commandsAsArray[1].equals("1"));break; break;
case "waves": Battery.wavesOff = commandsAsArray[1].equals("0");break; case "color":
case "uptime": JOptionPane.showMessageDialog(null, Utils.getCountOfMinutesSinceAppStarted() + " minutes");break; Utils.highlighted
.set(commandsAsArray[1].equals("1"));
break;
case "gray":
Utils.ultraLight
.set(commandsAsArray[1].equals("1"));
break;
case "waves":
Battery.wavesOff = commandsAsArray[1].equals("0");
break;
case "uptime":
JOptionPane.showMessageDialog(null,
Utils.getCountOfMinutesSinceAppStarted()
+ " minutes");
break;
case "toast": case "toast":
Toaster t = new Toaster(); Toaster t = new Toaster();
t.setToasterWidth(800); t.setToasterWidth(800);
@ -247,9 +272,17 @@ public class TimeCalcWindow {
t.setDisplayTime(60000 * 5); t.setDisplayTime(60000 * 5);
t.setToasterColor(Color.GRAY); t.setToasterColor(Color.GRAY);
Font font = new Font("sans", Font.PLAIN, 12); Font font = new Font("sans", Font.PLAIN, 12);
t.setToasterMessageFont(font);t.setDisplayTime(5000); t.showToaster(commands.substring(6));break; t.setToasterMessageFont(font);
case "toasts": Utils.toastsAreEnabled.set(commandsAsArray[1].equals("1"));break; t.setDisplayTime(5000);
default: JOptionPane.showMessageDialog(null, "Unknown command: " + commandsAsArray[0]); t.showToaster(commands.substring(6));
break;
case "toasts":
Utils.toastsAreEnabled
.set(commandsAsArray[1].equals("1"));
break;
default:
JOptionPane.showMessageDialog(null,
"Unknown command: " + commandsAsArray[0]);
} }
}); });
@ -273,13 +306,15 @@ public class TimeCalcWindow {
ProgressSquare progressSquare = new ProgressSquare(); ProgressSquare progressSquare = new ProgressSquare();
progressSquare progressSquare
.setBounds(MARGIN + analogClock.getWidth() + MARGIN, MARGIN, 200); .setBounds(MARGIN + analogClock.getWidth() + MARGIN, MARGIN,
200);
window.add(progressSquare); window.add(progressSquare);
ProgressCircle progressCircle = new ProgressCircle(); ProgressCircle progressCircle = new ProgressCircle();
progressCircle progressCircle
.setBounds(MARGIN + progressSquare.getBounds().x + progressSquare .setBounds(
.getWidth() + MARGIN, MARGIN, 80); MARGIN + progressSquare.getBounds().x + progressSquare
.getWidth() + MARGIN, MARGIN, 80);
window.add(progressCircle); window.add(progressCircle);
Battery batteryForDay = new Battery(); Battery batteryForDay = new Battery();
@ -289,47 +324,59 @@ public class TimeCalcWindow {
window.add(batteryForDay); window.add(batteryForDay);
Battery batteryForWeek = new Battery(); Battery batteryForWeek = new Battery();
batteryForWeek.setBounds(batteryForDay.getBounds().x + batteryForDay.getWidth(), batteryForWeek.setBounds(
batteryForDay.getBounds().x + batteryForDay.getWidth(),
batteryForDay.getY(), 90, 140); batteryForDay.getY(), 90, 140);
window.add(batteryForWeek); window.add(batteryForWeek);
Calendar calNow = Calendar.getInstance(); Calendar calNow = Calendar.getInstance();
calNow.setTime(new Date()); calNow.setTime(new Date());
LocalDate ld = LocalDate.of(calNow.get(Calendar.YEAR),calNow.get(Calendar.MONTH) + 1,1); LocalDate ld = LocalDate
.of(calNow.get(Calendar.YEAR), calNow.get(Calendar.MONTH) + 1,
1);
int currentDayOfMonth = calNow.get(Calendar.DAY_OF_MONTH); int currentDayOfMonth = calNow.get(Calendar.DAY_OF_MONTH);
int workDaysDone = 0; int workDaysDone = 0;
int workDaysTodo = 0; int workDaysTodo = 0;
int workDaysTotal; int workDaysTotal;
for(int dayOfMonth=1; dayOfMonth <= calNow.getActualMaximum(Calendar.DAY_OF_MONTH); dayOfMonth++) { for (int dayOfMonth = 1;
DayOfWeek dayOfWeek = LocalDate.of(calNow.get(Calendar.YEAR), calNow.get(Calendar.MONTH) + 1, dayOfMonth).getDayOfWeek(); dayOfMonth <= calNow.getActualMaximum(Calendar.DAY_OF_MONTH);
boolean weekend = dayOfWeek.toString().equals("SATURDAY") || dayOfWeek.toString().equals("SUNDAY"); dayOfMonth++) {
if(dayOfMonth < currentDayOfMonth && !weekend) { DayOfWeek dayOfWeek = LocalDate.of(calNow.get(Calendar.YEAR),
calNow.get(Calendar.MONTH) + 1, dayOfMonth).getDayOfWeek();
boolean weekend =
dayOfWeek.toString().equals("SATURDAY") || dayOfWeek
.toString().equals("SUNDAY");
if (dayOfMonth < currentDayOfMonth && !weekend) {
++workDaysDone; ++workDaysDone;
} }
if(dayOfMonth > currentDayOfMonth && !weekend) { if (dayOfMonth > currentDayOfMonth && !weekend) {
++workDaysTodo; ++workDaysTodo;
} }
} }
String currentDayOfWeekAsString = LocalDate.of(calNow.get(Calendar.YEAR), calNow.get(Calendar.MONTH) + 1, currentDayOfMonth).getDayOfWeek().toString(); String currentDayOfWeekAsString = LocalDate
boolean nowIsWeekend = currentDayOfWeekAsString.equals("SATURDAY") || currentDayOfWeekAsString.equals("SUNDAY"); .of(calNow.get(Calendar.YEAR), calNow.get(Calendar.MONTH) + 1,
currentDayOfMonth).getDayOfWeek().toString();
boolean nowIsWeekend = currentDayOfWeekAsString.equals("SATURDAY")
|| currentDayOfWeekAsString.equals("SUNDAY");
workDaysTotal = workDaysDone + (nowIsWeekend ? 0 : 1) + workDaysTodo; workDaysTotal = workDaysDone + (nowIsWeekend ? 0 : 1) + workDaysTodo;
// System.out.println("workDaysDone" + workDaysDone); // System.out.println("workDaysDone" + workDaysDone);
// System.out.println("workDaysTodo" + workDaysTodo); // System.out.println("workDaysTodo" + workDaysTodo);
// System.out.println("currentDayOfMonth" + currentDayOfMonth); // System.out.println("currentDayOfMonth" + currentDayOfMonth);
Battery batteryForMonth = new Battery(); Battery batteryForMonth = new Battery();
batteryForMonth.setBounds(batteryForDay.getBounds().x + batteryForDay.getWidth(), batteryForMonth.setBounds(
batteryForDay.getY() + batteryForWeek.getHeight() + MARGIN, 90, 140); batteryForDay.getBounds().x + batteryForDay.getWidth(),
batteryForDay.getY() + batteryForWeek.getHeight() + MARGIN, 90,
140);
window.add(batteryForMonth); window.add(batteryForMonth);
Battery batteryForHour = new Battery(); Battery batteryForHour = new Battery();
batteryForHour.setBounds(batteryForMonth.getBounds().x, batteryForHour.setBounds(batteryForMonth.getBounds().x,
batteryForMonth.getY() + batteryForMonth.getHeight() + MARGIN, 90, 140); batteryForMonth.getY() + batteryForMonth.getHeight() + MARGIN,
90, 140);
window.add(batteryForHour); window.add(batteryForHour);
Rectangle hourRectangle = batteryForHour.getBounds(); Rectangle hourRectangle = batteryForHour.getBounds();
Rectangle dayRectangle = batteryForDay.getBounds(); Rectangle dayRectangle = batteryForDay.getBounds();
@ -349,13 +396,13 @@ public class TimeCalcWindow {
break; break;
} }
if(Math.random() > 0.9) { if (Math.random() > 0.9) {
if(FOCUS_TXT.exists()) { if (FOCUS_TXT.exists()) {
window.requestFocus(); window.requestFocus();
FOCUS_TXT.delete(); FOCUS_TXT.delete();
} }
} }
if(Utils.highlighted.get()) { if (Utils.highlighted.get()) {
Utils.ultraLight.set(false); Utils.ultraLight.set(false);
} }
@ -367,7 +414,9 @@ public class TimeCalcWindow {
batteryForWeek.setVisible(!Utils.everythingHidden.get()); batteryForWeek.setVisible(!Utils.everythingHidden.get());
batteryForMonth.setVisible(!Utils.everythingHidden.get()); batteryForMonth.setVisible(!Utils.everythingHidden.get());
batteryForHour.setVisible(!Utils.everythingHidden.get()); batteryForHour.setVisible(!Utils.everythingHidden.get());
jokeButton.setVisible(!TimeCalcConf.getInstance().isJokeVisible()? false : !Utils.everythingHidden.get()); jokeButton.setVisible(
TimeCalcConf.getInstance().isJokeVisible()
&& !Utils.everythingHidden.get());
focusButton.setVisible(!Utils.everythingHidden.get()); focusButton.setVisible(!Utils.everythingHidden.get());
commandButton.setVisible(!Utils.everythingHidden.get()); commandButton.setVisible(!Utils.everythingHidden.get());
@ -376,7 +425,8 @@ public class TimeCalcWindow {
window.setTitle(Utils.everythingHidden.get() ? "" : windowTitle); window.setTitle(Utils.everythingHidden.get() ? "" : windowTitle);
sb = new StringBuilder(); sb = new StringBuilder();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
String nowString = DateFormats.DATE_TIME_FORMATTER_HHmmssSSS.format(now); String nowString =
DateFormats.DATE_TIME_FORMATTER_HHmmssSSS.format(now);
// if (alreadyShownTimes.contains(nowString)) { // if (alreadyShownTimes.contains(nowString)) {
// //nothing to do // //nothing to do
// try { // try {
@ -426,30 +476,40 @@ public class TimeCalcWindow {
int weekDayWhenMondayIsOne = calNow.get(Calendar.DAY_OF_WEEK) - 1; int weekDayWhenMondayIsOne = calNow.get(Calendar.DAY_OF_WEEK) - 1;
batteryForWeek.setDonePercent((weekDayWhenMondayIsOne == 0 batteryForWeek.setDonePercent((weekDayWhenMondayIsOne == 0
|| weekDayWhenMondayIsOne == 6) ? || weekDayWhenMondayIsOne == 6) ?
100 : ((weekDayWhenMondayIsOne - 1) * 0.20 + done * 0.20)); 100 : ((weekDayWhenMondayIsOne - 1) * 0.20 + done * 0.20));
batteryForWeek.setLabel(nowIsWeekend ? "5/5" : (weekDayWhenMondayIsOne + "/5")); batteryForWeek.setLabel(
nowIsWeekend ? "5/5" : (weekDayWhenMondayIsOne + "/5"));
batteryForMonth.setDonePercent(weekDayWhenMondayIsOne == 0 batteryForMonth.setDonePercent(weekDayWhenMondayIsOne == 0
|| weekDayWhenMondayIsOne == 6 ? workDaysDone/workDaysTotal : (workDaysDone + done) / workDaysTotal); || weekDayWhenMondayIsOne == 6 ?
batteryForMonth.setLabel((nowIsWeekend ? workDaysDone : workDaysDone + 1) + "/" + (workDaysTotal)); workDaysDone / workDaysTotal :
(workDaysDone + done) / workDaysTotal);
batteryForMonth.setLabel(
(nowIsWeekend ? workDaysDone : workDaysDone + 1) + "/"
+ (workDaysTotal));
double minutesRemainsD = minuteRemains;
double minutesRemainsD = (double) minuteRemains; double secondsRemainsD = secondsRemains;
double secondsRemainsD = (double) secondsRemains; double millisecondsRemainsD = millisecondsRemains;
double millisecondsRemainsD = (double) millisecondsRemains;
minutesRemainsD = minutesRemainsD + secondsRemainsD / 60d; minutesRemainsD = minutesRemainsD + secondsRemainsD / 60d;
minutesRemainsD = minutesRemainsD + millisecondsRemainsD / 1000d / 60d; minutesRemainsD =
if(secondsRemainsD > 0) { minutesRemainsD + millisecondsRemainsD / 1000d / 60d;
if (secondsRemainsD > 0) {
minutesRemainsD = minutesRemainsD - 1d; minutesRemainsD = minutesRemainsD - 1d;
} }
if(millisecondsRemainsD > 0) { if (millisecondsRemainsD > 0) {
minutesRemainsD = minutesRemainsD - 1d/1000d; minutesRemainsD = minutesRemainsD - 1d / 1000d;
} }
batteryForHour.setDonePercent(done >= 1 ? 1 :(1 - ((minutesRemainsD%60d)/60d))); batteryForHour.setDonePercent(
if(!nowIsWeekend) { done >= 1 ? 1 : (1 - ((minutesRemainsD % 60d) / 60d)));
int hoursForLabel = (minuteRemains == 0 ? minuteRemains / 60 + 1 : minuteRemains/ 60); if (!nowIsWeekend) {
batteryForHour.setLabel( ((totalMinutes / 60) - hoursForLabel) + "/" + (totalMinutes / 60)); int hoursForLabel =
(minuteRemains == 0 ? minuteRemains / 60 + 1 :
minuteRemains / 60);
batteryForHour.setLabel(
((totalMinutes / 60) - hoursForLabel) + "/" + (
totalMinutes / 60));
} }
int totalSecondsRemains = int totalSecondsRemains =
@ -515,16 +575,14 @@ public class TimeCalcWindow {
} }
text.setForeground( text.setForeground(
Utils.highlighted.get() || text.getClientProperty("mouseEntered").equals("true") ? Color.BLACK : Color.LIGHT_GRAY); Utils.highlighted.get() || text
.getClientProperty("mouseEntered").equals("true") ?
Color.BLACK : Color.LIGHT_GRAY);
} }
window.setVisible(false); window.setVisible(false);
window.dispose(); window.dispose();
} }
private String createWindowTitle() {
return "Time Calc " + Utils.getVersion();
}
private static final String createSpaces(int spaceCount) { private static final String createSpaces(int spaceCount) {
return create(spaceCount, ' '); return create(spaceCount, ' ');
} }
@ -537,6 +595,10 @@ public class TimeCalcWindow {
return sb.toString(); return sb.toString();
} }
private String createWindowTitle() {
return "Time Calc " + Utils.getVersion();
}
private void printPercentToAscii(double percent, private void printPercentToAscii(double percent,
String msg, StringBuilder sb) { String msg, StringBuilder sb) {
NumberFormat formatter = new DecimalFormat("#00.00"); NumberFormat formatter = new DecimalFormat("#00.00");
@ -582,7 +644,7 @@ public class TimeCalcWindow {
int spacesTotal = 48; int spacesTotal = 48;
int spacesDone = (int) (percent * spacesTotal); int spacesDone = (int) (percent * spacesTotal);
if(spacesDone > spacesTotal) { if (spacesDone > spacesTotal) {
spacesDone = spacesTotal; spacesDone = spacesTotal;
} }
int spacesTodo = spacesTotal - (spacesDone < 0 ? 0 : spacesDone); int spacesTodo = spacesTotal - (spacesDone < 0 ? 0 : spacesDone);
@ -608,7 +670,8 @@ public class TimeCalcWindow {
"| |") + /*WALL +*/ NEW_LINE + "| |") + /*WALL +*/ NEW_LINE +
"================================================================" "================================================================"
+ NEW_LINE + "Steps: " + formatter3 + NEW_LINE + "Steps: " + formatter3
.format(percent * ((double) spacesTotal)) + "/" + spacesTotal .format(percent * ((double) spacesTotal)) + "/"
+ spacesTotal
); );
} }

View File

@ -7,9 +7,10 @@ import java.time.format.DateTimeFormatter;
* @since 21.02.2024 * @since 21.02.2024
*/ */
public class DateFormats { public class DateFormats {
public final static DateTimeFormatter DATE_TIME_FORMATTER_HHmmssSSS =
DateTimeFormatter.ofPattern("HH:mm:ss:SSS");
private DateFormats() { private DateFormats() {
//Not meant to be instantiated. //Not meant to be instantiated.
} }
public final static DateTimeFormatter DATE_TIME_FORMATTER_HHmmssSSS =
DateTimeFormatter.ofPattern("HH:mm:ss:SSS");
} }

View File

@ -7,11 +7,11 @@ import java.io.File;
* @since 21.02.2024 * @since 21.02.2024
*/ */
public class FileConstants { public class FileConstants {
private FileConstants() {
//Not meant to be instantiated.
}
public static final File STARTTIME_TXT = new File("starttime.txt"); public static final File STARTTIME_TXT = new File("starttime.txt");
public static final File OVERTIME_TXT = new File("overtime.txt"); public static final File OVERTIME_TXT = new File("overtime.txt");
public static final File TEST_TXT = new File("test.txt"); public static final File TEST_TXT = new File("test.txt");
public static final File FOCUS_TXT = new File("focus.txt"); public static final File FOCUS_TXT = new File("focus.txt");
private FileConstants() {
//Not meant to be instantiated.
}
} }

View File

@ -63,7 +63,7 @@ public class Jokes {
} }
public static void showRandom() { public static void showRandom() {
if(!TimeCalcConf.getInstance().isJokeVisible()) { if (!TimeCalcConf.getInstance().isJokeVisible()) {
//nothing to do //nothing to do
return; return;
} }

View File

@ -18,25 +18,28 @@ import java.util.jar.Manifest;
* @since 15.02.2024 * @since 15.02.2024
*/ */
public class Utils { public class Utils {
private static long startNanoTime;
public static final BooleanHolder highlighted = new BooleanHolder(); public static final BooleanHolder highlighted = new BooleanHolder();
public static final BooleanHolder ultraLight = new BooleanHolder(); public static final BooleanHolder ultraLight = new BooleanHolder();
public static final BooleanHolder everythingHidden = new BooleanHolder(); public static final BooleanHolder everythingHidden = new BooleanHolder();
public static final BooleanHolder toastsAreEnabled = new BooleanHolder(true); public static final BooleanHolder toastsAreEnabled =
public static final Color ULTRA_LIGHT_GRAY = new Color(216,216,216); new BooleanHolder(true);
public static final Color ULTRA_LIGHT_GRAY = new Color(216, 216, 216);
/** /**
* Count of bytes per one kilobyte. * Count of bytes per one kilobyte.
*/ */
private static final int COUNT_OF_BYTES_PER_ONE_KILOBYTE = 1024; private static final int COUNT_OF_BYTES_PER_ONE_KILOBYTE = 1024;
private static long startNanoTime;
private Utils() {
//Not meant to be instantiated.
}
public static void startApp() { public static void startApp() {
if(startNanoTime == 0) { if (startNanoTime == 0) {
throw new TimeCalcException("App is already started."); throw new TimeCalcException("App is already started.");
} }
startNanoTime = System.nanoTime(); startNanoTime = System.nanoTime();
} }
private Utils() {
//Not meant to be instantiated.
}
/** /**
* Writes text to a file. * Writes text to a file.
@ -89,11 +92,12 @@ public class Utils {
} }
public static int getCountOfMinutesSinceAppStarted() { public static int getCountOfMinutesSinceAppStarted() {
return ((int)((System.nanoTime() - startNanoTime) / 1000000000 / 60)); return ((int) ((System.nanoTime() - startNanoTime) / 1000000000 / 60));
} }
/** /**
* Returns version of "Time Calc" from jar file. * Returns version of "Time Calc" from jar file.
*
* @return version * @return version
*/ */
public static String getVersion() { public static String getVersion() {
@ -103,6 +107,7 @@ public class Utils {
/** /**
* Returns build date of "Time Calc" from jar file. * Returns build date of "Time Calc" from jar file.
*
* @return build date * @return build date
*/ */
public static String getBuildDate() { public static String getBuildDate() {
@ -112,8 +117,9 @@ public class Utils {
if (!classPath.startsWith("jar")) { if (!classPath.startsWith("jar")) {
return null; return null;
} }
String manifestPath = classPath.substring(0, classPath.lastIndexOf("!") + 1) String manifestPath =
+ "/META-INF/MANIFEST.MF"; classPath.substring(0, classPath.lastIndexOf("!") + 1)
+ "/META-INF/MANIFEST.MF";
Manifest manifest; Manifest manifest;
try { try {
manifest = new Manifest(new URL(manifestPath).openStream()); manifest = new Manifest(new URL(manifestPath).openStream());