mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
Added new improvements
This commit is contained in:
parent
8901aff6e1
commit
a3fe9c0d4c
@ -10,9 +10,6 @@ import java.awt.Font;
|
|||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
import java.sql.Time;
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@ -21,49 +18,10 @@ import java.util.GregorianCalendar;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
//https://kodejava.org/how-do-i-write-a-simple-analog-clock-using-java-2d/
|
//https://kodejava.org/how-do-i-write-a-simple-analog-clock-using-java-2d/
|
||||||
public class AnalogClock extends JPanel {
|
public class AnalogClock extends Widget {
|
||||||
|
|
||||||
private static final Color FOREGROUND_COLOR = new Color(220, 220, 220);
|
|
||||||
private static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
|
||||||
|
|
||||||
private boolean coloured = false;
|
|
||||||
private boolean mouseOver = false;
|
|
||||||
private int side;
|
|
||||||
private Color[] colors = Utils.getRandomColors();
|
|
||||||
|
|
||||||
public AnalogClock() {
|
public AnalogClock() {
|
||||||
setPreferredSize(new Dimension(400, 300));
|
setPreferredSize(new Dimension(400, 300));
|
||||||
setBackground(BACKGROUND_COLOR);
|
|
||||||
new Timer(20, e -> repaint()).start();
|
|
||||||
|
|
||||||
addMouseListener(new MouseListener() {
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(MouseEvent e) {
|
|
||||||
Utils.highlighted.flip();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mousePressed(MouseEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseReleased(MouseEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseEntered(MouseEvent e) {
|
|
||||||
coloured = true;
|
|
||||||
mouseOver = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseExited(MouseEvent e) {
|
|
||||||
coloured = false;
|
|
||||||
mouseOver = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,34 +33,6 @@ public class AnalogClock extends JPanel {
|
|||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Color modifyColourALittleBit(Color colorIn) {
|
|
||||||
int r = colorIn.getRed();
|
|
||||||
int g = colorIn.getGreen();
|
|
||||||
int b = colorIn.getBlue();
|
|
||||||
Color color = new Color(
|
|
||||||
modifyByteALittleBit(r),
|
|
||||||
modifyByteALittleBit(g),
|
|
||||||
modifyByteALittleBit(b)
|
|
||||||
);
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int modifyByteALittleBit(int n) {
|
|
||||||
// if(Math.random() <= 0.75) {
|
|
||||||
// return n;
|
|
||||||
// }
|
|
||||||
boolean negative = Math.random() > 0.5;
|
|
||||||
int result = n + ((negative ? (-1) : 1)) * ((int) (Math.random() * (
|
|
||||||
Math.random() * 20)));
|
|
||||||
if (result > 255) {
|
|
||||||
return 255;
|
|
||||||
}
|
|
||||||
if (result < 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintComponent(Graphics g) {
|
public void paintComponent(Graphics g) {
|
||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
@ -171,35 +101,12 @@ public class AnalogClock extends JPanel {
|
|||||||
// g2d.drawOval(3, 3, centerX * 2 - 6, centerY * 2 - 6);
|
// g2d.drawOval(3, 3, centerX * 2 - 6, centerY * 2 - 6);
|
||||||
// g2d.drawOval(4, 4, centerX * 2 - 8, centerY * 2 - 8);
|
// g2d.drawOval(4, 4, centerX * 2 - 8, centerY * 2 - 8);
|
||||||
|
|
||||||
if(Utils.highlighted.get() && TimeCalcConf.getInstance().isClockColorful() && Math.random()>0.9) {colors = Utils.getRandomColors();}
|
|
||||||
if (Utils.highlighted.get() && coloured) {
|
|
||||||
for (int i = 0; i < 12; i++) {
|
|
||||||
//if(Math.random() > 0.75) {
|
|
||||||
colors[i] = modifyColourALittleBit(colors[i]);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if(Math.random() > (1 - (1/200))) {
|
|
||||||
// for(int i = 0; i<12; i++) {
|
|
||||||
// colors[i] = i == 11 ? colors[0] :colors[i + 1];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
DateFormat formatter2 =
|
DateFormat formatter2 =
|
||||||
new SimpleDateFormat("HH:mm:ss", Locale.ENGLISH);
|
new SimpleDateFormat("HH:mm:ss", Locale.ENGLISH);
|
||||||
String now = formatter2.format(new Date());
|
String now = formatter2.format(new Date());
|
||||||
|
|
||||||
if (coloured) {
|
|
||||||
g2d.setColor(Utils.highlighted.get() || mouseOver ? Color.BLACK :
|
|
||||||
FOREGROUND_COLOR);
|
|
||||||
g2d.setFont(new Font("sans", Font.PLAIN, 12));
|
|
||||||
DateFormat formatter =
|
|
||||||
new SimpleDateFormat("EEEE : yyyy-MM-dd", Locale.ENGLISH);
|
|
||||||
g2d.drawString(formatter.format(new Date()), ((int) (side * 0.25)),
|
|
||||||
((int) (side * 0.35)));
|
|
||||||
//
|
|
||||||
g2d.drawString(now, ((int) (side * 0.25) + 30),
|
|
||||||
((int) (side * 0.35)) + 60);
|
|
||||||
}
|
|
||||||
for (int i = 1; i <= 12; i++) {
|
for (int i = 1; i <= 12; i++) {
|
||||||
double angle = Math.PI * 2 * (i / 12.0 - 0.25);
|
double angle = Math.PI * 2 * (i / 12.0 - 0.25);
|
||||||
int dx = centerX + (int) ((radius + 20) * Math.cos(angle)) - 4;
|
int dx = centerX + (int) ((radius + 20) * Math.cos(angle)) - 4;
|
||||||
@ -207,12 +114,13 @@ public class AnalogClock extends JPanel {
|
|||||||
|
|
||||||
int seconds = Integer.valueOf(now.split(":")[2]);
|
int seconds = Integer.valueOf(now.split(":")[2]);
|
||||||
|
|
||||||
if (Utils.highlighted.get() && coloured && TimeCalcConf.getInstance()
|
|
||||||
.isClockColorful()) {g2d.setColor(colors[i - 1]);}
|
|
||||||
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() {
|
||||||
|
return 20;
|
||||||
|
}
|
||||||
}
|
}
|
@ -12,7 +12,7 @@ import java.awt.event.MouseListener;
|
|||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
|
||||||
public class Battery extends JPanel {
|
public class Battery extends Widget {
|
||||||
|
|
||||||
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);
|
||||||
@ -22,48 +22,14 @@ public class Battery extends JPanel {
|
|||||||
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;
|
||||||
private static final Color FOREGROUND_COLOR = new Color(220, 220, 220);
|
|
||||||
private static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
|
||||||
NumberFormat formatter3 = new DecimalFormat("#0.000");
|
NumberFormat formatter3 = new DecimalFormat("#0.000");
|
||||||
private int totalHeight = 0;
|
private int totalHeight = 0;
|
||||||
private double donePercent = 0;
|
|
||||||
private boolean mouseOver = false;
|
|
||||||
private int width_;
|
private int width_;
|
||||||
|
|
||||||
public Battery() {
|
public Battery() {
|
||||||
setPreferredSize(new Dimension(40, 100));
|
setPreferredSize(new Dimension(40, 100));
|
||||||
setBackground(BACKGROUND_COLOR);
|
|
||||||
new Timer(250, e -> repaint()).start();
|
|
||||||
addMouseListener(new MouseListener() {
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(MouseEvent e) {
|
|
||||||
Utils.highlighted.flip();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mousePressed(MouseEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseReleased(MouseEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseEntered(MouseEvent e) {
|
|
||||||
mouseOver = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseExited(MouseEvent e) {
|
|
||||||
mouseOver = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDonePercent(double donePercent) {
|
|
||||||
this.donePercent = donePercent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -141,4 +107,7 @@ public class Battery extends JPanel {
|
|||||||
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() {
|
||||||
|
return 250;
|
||||||
|
}
|
||||||
}
|
}
|
@ -10,10 +10,10 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert
|
* @author pc00289
|
||||||
* @since 09.02.2024
|
* @since 09.02.2024
|
||||||
*/
|
*/
|
||||||
public class Vtipy {
|
public class Jokes {
|
||||||
/**
|
/**
|
||||||
* https://bestvtip.cz/
|
* https://bestvtip.cz/
|
||||||
* https://www.vtipbaze.cz/
|
* https://www.vtipbaze.cz/
|
||||||
@ -29,7 +29,7 @@ public class Vtipy {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
array = VtipyTxt.getAsArray();
|
array = JokesTxt.getAsArray();
|
||||||
Set<String> set = new HashSet<>();
|
Set<String> set = new HashSet<>();
|
||||||
for (String vtip : array) {
|
for (String vtip : array) {
|
||||||
if (vtip.trim().isEmpty()) {
|
if (vtip.trim().isEmpty()) {
|
@ -7,11 +7,11 @@ import java.io.InputStreamReader;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert
|
* @author pc00289
|
||||||
* @since 15.02.2024
|
* @since 15.02.2024
|
||||||
*/
|
*/
|
||||||
public class VtipyTxt {
|
public class JokesTxt {
|
||||||
private VtipyTxt() {
|
private JokesTxt() {
|
||||||
//Not meant to be instantiated.
|
//Not meant to be instantiated.
|
||||||
}
|
}
|
||||||
|
|
@ -1,58 +1,15 @@
|
|||||||
package rvc.timecalc;
|
package rvc.timecalc;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.Timer;
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
|
|
||||||
public class ProgressCircle extends JPanel {
|
public class ProgressCircle extends Widget {
|
||||||
|
|
||||||
private static final Color FOREGROUND_COLOR = new Color(220, 220, 220);
|
|
||||||
private static final Color FOREGROUND_COLOR2 = new Color(210, 210, 210);
|
|
||||||
private static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
|
||||||
private int side = 0;
|
|
||||||
private double donePercent = 0;
|
|
||||||
private boolean mouseOver = false;
|
|
||||||
|
|
||||||
public ProgressCircle() {
|
public ProgressCircle() {
|
||||||
setPreferredSize(new Dimension(200, 200));
|
setPreferredSize(new Dimension(200, 200));
|
||||||
setBackground(BACKGROUND_COLOR);
|
|
||||||
new Timer(100, e -> repaint()).start();
|
|
||||||
addMouseListener(new MouseListener() {
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(MouseEvent e) {
|
|
||||||
Utils.highlighted.flip();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mousePressed(MouseEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseReleased(MouseEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseEntered(MouseEvent e) {
|
|
||||||
mouseOver = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseExited(MouseEvent e) {
|
|
||||||
mouseOver = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDonePercent(double donePercent) {
|
|
||||||
this.donePercent = donePercent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -66,14 +23,8 @@ public class ProgressCircle extends JPanel {
|
|||||||
FOREGROUND_COLOR);
|
FOREGROUND_COLOR);
|
||||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
// if (highlight) {
|
|
||||||
// g2d.setColor(Color.BLUE);
|
|
||||||
// }
|
|
||||||
|
|
||||||
double angleDouble = donePercent * 360;
|
double angleDouble = donePercent * 360;
|
||||||
// System.out.println("angleDouble=" + angleDouble);
|
|
||||||
////
|
|
||||||
|
|
||||||
double angleDouble2 = (angleDouble - (int) (angleDouble)) * 360;
|
double angleDouble2 = (angleDouble - (int) (angleDouble)) * 360;
|
||||||
// System.out.println("remainingAngle=" + angleDouble2);
|
// System.out.println("remainingAngle=" + angleDouble2);
|
||||||
|
|
||||||
|
@ -10,49 +10,12 @@ import java.awt.RenderingHints;
|
|||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
|
|
||||||
public class ProgressSquare extends JPanel {
|
public class ProgressSquare extends Widget {
|
||||||
|
|
||||||
private static final Color FOREGROUND_COLOR = new Color(220, 220, 220);
|
|
||||||
private static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
|
||||||
private int side = 0;
|
|
||||||
private int square;
|
private int square;
|
||||||
private double donePercent = 0;
|
|
||||||
private boolean mouseOver = false;
|
|
||||||
|
|
||||||
public ProgressSquare() {
|
public ProgressSquare() {
|
||||||
setPreferredSize(new Dimension(400, 400));
|
setPreferredSize(new Dimension(400, 400));
|
||||||
setBackground(BACKGROUND_COLOR);
|
|
||||||
new Timer(100, e -> repaint()).start();
|
|
||||||
addMouseListener(new MouseListener() {
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(MouseEvent e) {
|
|
||||||
Utils.highlighted.flip();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mousePressed(MouseEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseReleased(MouseEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseEntered(MouseEvent e) {
|
|
||||||
mouseOver = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseExited(MouseEvent e) {
|
|
||||||
mouseOver = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDonePercent(double donePercent) {
|
|
||||||
this.donePercent = donePercent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -67,7 +30,7 @@ public class ProgressSquare extends JPanel {
|
|||||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
|
||||||
// System.out.println("square=" + square);
|
|
||||||
int dotNumber = (int) (donePercent * square);
|
int dotNumber = (int) (donePercent * square);
|
||||||
int y = dotNumber / side;
|
int y = dotNumber / side;
|
||||||
int yOrig = y;
|
int yOrig = y;
|
||||||
@ -111,16 +74,6 @@ public class ProgressSquare extends JPanel {
|
|||||||
}
|
}
|
||||||
g2d.setColor(FOREGROUND_COLOR);
|
g2d.setColor(FOREGROUND_COLOR);
|
||||||
}
|
}
|
||||||
// int nextX = (int) (Math.random() * 200);
|
|
||||||
// int nextY = (int) (Math.random() * (yOrig- 1));
|
|
||||||
// for(int i = 0;i< yOrig / 8;i++) {
|
|
||||||
// g2d.setColor(Color.GRAY/*Utils.getRandomColor()*/);
|
|
||||||
// g2d.drawLine(x, y, nextX, nextY);
|
|
||||||
// x = nextX;
|
|
||||||
// y = nextY;
|
|
||||||
// nextX = (int) (Math.random() * 200);
|
|
||||||
// nextY = (int) (Math.random() * (yOrig - 1));
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ import java.util.Properties;
|
|||||||
* @since 20.02.2024
|
* @since 20.02.2024
|
||||||
*/
|
*/
|
||||||
public class TimeCalcConf {
|
public class TimeCalcConf {
|
||||||
private static final String CLOCK_COLORFUL = "clock.colorful";
|
|
||||||
private static final String CLOCK_HANDS_LONG = "clock.hands.long";
|
private static final String CLOCK_HANDS_LONG = "clock.hands.long";
|
||||||
private static final String JOKE_VISIBLE = "jokes.visible";
|
private static final String JOKE_VISIBLE = "jokes.visible";
|
||||||
private static final String BATTERY_WAVES_ENABLED = "battery.waves.enabled";
|
private static final String BATTERY_WAVES_ENABLED = "battery.waves.enabled";
|
||||||
@ -35,12 +34,6 @@ public class TimeCalcConf {
|
|||||||
System.err.println(e);
|
System.err.println(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public boolean isClockColorful() {
|
|
||||||
if(!properties.containsKey(CLOCK_COLORFUL)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return properties.get(CLOCK_COLORFUL).equals("true");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean areClockHandsLong() {
|
public boolean areClockHandsLong() {
|
||||||
if(!properties.containsKey(CLOCK_HANDS_LONG)) {
|
if(!properties.containsKey(CLOCK_HANDS_LONG)) {
|
||||||
|
@ -164,7 +164,7 @@ public class TimeCalcWindow {
|
|||||||
.addActionListener(e -> new WeatherWindow().setVisible(true));
|
.addActionListener(e -> new WeatherWindow().setVisible(true));
|
||||||
jokeButton.addActionListener(e -> {
|
jokeButton.addActionListener(e -> {
|
||||||
for (int i = 1; i <= 1; i++) {
|
for (int i = 1; i <= 1; i++) {
|
||||||
Vtipy.showRandom();
|
Jokes.showRandom();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
exitButton.addActionListener(e -> System.exit(0));
|
exitButton.addActionListener(e -> System.exit(0));
|
||||||
@ -223,9 +223,9 @@ public class TimeCalcWindow {
|
|||||||
boolean nowIsWeekend = currentDayOfWeekAsString.equals("SATURDAY") || currentDayOfWeekAsString.equals("SUNDAY");
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ public class TimeCalcWindow {
|
|||||||
// }
|
// }
|
||||||
if (hourRemains == 0 && minuteRemains == 1 && !vtipyShown) {
|
if (hourRemains == 0 && minuteRemains == 1 && !vtipyShown) {
|
||||||
vtipyShown = true;
|
vtipyShown = true;
|
||||||
Vtipy.showRandom();
|
Jokes.showRandom();
|
||||||
}
|
}
|
||||||
if (hourRemains == 0 && minuteRemains <= 3) {
|
if (hourRemains == 0 && minuteRemains <= 3) {
|
||||||
Utils.highlighted.set(true);
|
Utils.highlighted.set(true);
|
||||||
|
@ -39,7 +39,6 @@ public class Utils {
|
|||||||
System.err.println(e);
|
System.err.println(e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
57
src/main/java/rvc/timecalc/Widget.java
Normal file
57
src/main/java/rvc/timecalc/Widget.java
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package rvc.timecalc;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.Timer;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert
|
||||||
|
* @since 20.02.2024
|
||||||
|
*/
|
||||||
|
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_COLOR2 = new Color(210, 210, 210);
|
||||||
|
protected static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
||||||
|
public Widget() {
|
||||||
|
setBackground(BACKGROUND_COLOR);
|
||||||
|
new Timer(getTimerDelay(), e -> repaint()).start();
|
||||||
|
addMouseListener(new MouseListener() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
Utils.highlighted.flip();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseEntered(MouseEvent e) {
|
||||||
|
mouseOver = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseExited(MouseEvent e) {
|
||||||
|
mouseOver = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public int getTimerDelay() {
|
||||||
|
return 100;
|
||||||
|
}
|
||||||
|
public final void setDonePercent(double donePercent) {
|
||||||
|
this.donePercent = donePercent;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user