mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
New improvements
This commit is contained in:
parent
30356e2b5d
commit
621875c325
@ -1 +1 @@
|
|||||||
0:09
|
0:00
|
@ -12,7 +12,7 @@ public class Main {
|
|||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
while (true) {
|
while (true) {
|
||||||
boolean test = false;
|
boolean test = true;
|
||||||
File starttimeTxt = new File("starttime.txt");
|
File starttimeTxt = new File("starttime.txt");
|
||||||
File overtimeTxt = new File("overtime.txt");
|
File overtimeTxt = new File("overtime.txt");
|
||||||
String lastStartTime = Utils.readTextFromFile(starttimeTxt);
|
String lastStartTime = Utils.readTextFromFile(starttimeTxt);
|
||||||
|
112
src/main/java/rvc/timecalc/ProgressCircle.java
Normal file
112
src/main/java/rvc/timecalc/ProgressCircle.java
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
package rvc.timecalc;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.Timer;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ProgressCircle extends JPanel {
|
||||||
|
|
||||||
|
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 highlight = false;
|
||||||
|
|
||||||
|
public void setHighlight(boolean highlight) {
|
||||||
|
this.highlight = highlight;
|
||||||
|
if (highlight && !Utils.highlightTxt.exists()) {
|
||||||
|
try {
|
||||||
|
Utils.highlightTxt.createNewFile();
|
||||||
|
} catch (IOException ioException) {
|
||||||
|
System.out.println(ioException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!highlight && Utils.highlightTxt.exists()) {
|
||||||
|
Utils.highlightTxt.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProgressCircle() {
|
||||||
|
setPreferredSize(new Dimension(200, 200));
|
||||||
|
setBackground(BACKGROUND_COLOR);
|
||||||
|
new Timer(100, e -> repaint()).start();
|
||||||
|
addMouseListener(new MouseListener() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
highlight = !highlight;
|
||||||
|
if (highlight && !Utils.highlightTxt.exists()) {
|
||||||
|
try {
|
||||||
|
Utils.highlightTxt.createNewFile();
|
||||||
|
} catch (IOException ioException) {
|
||||||
|
System.out.println(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!highlight && Utils.highlightTxt.exists()) {
|
||||||
|
Utils.highlightTxt.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseEntered(MouseEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseExited(MouseEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDonePercent(double donePercent) {
|
||||||
|
this.donePercent = donePercent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paintComponent(Graphics g) {
|
||||||
|
if (side == 0) {
|
||||||
|
this.side = Math.min(getWidth(), getHeight());
|
||||||
|
}
|
||||||
|
super.paintComponent(g);
|
||||||
|
Graphics2D g2d = (Graphics2D) g;
|
||||||
|
g2d.setColor(FOREGROUND_COLOR);
|
||||||
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
// if (highlight) {
|
||||||
|
// g2d.setColor(Color.BLUE);
|
||||||
|
// }
|
||||||
|
|
||||||
|
double angleDouble = donePercent * 360;
|
||||||
|
// System.out.println("angleDouble=" + angleDouble);
|
||||||
|
////
|
||||||
|
|
||||||
|
double angleDouble2 = (angleDouble - (int)(angleDouble)) * 360;
|
||||||
|
// System.out.println("remainingAngle=" + angleDouble2);
|
||||||
|
|
||||||
|
g2d.fillArc(0,0,side,side,90, -(int) angleDouble);
|
||||||
|
int side2 = ((int)(side/2));
|
||||||
|
g2d.setColor(FOREGROUND_COLOR2);
|
||||||
|
g2d.fillArc(0+(side2/2),0+(side2/2),side2, side2,90, -(int) angleDouble2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -117,10 +117,16 @@ public class TimeCalcWindow {
|
|||||||
.setBounds(10 + analogClock.getWidth() + 10, 10, 200, 200);
|
.setBounds(10 + analogClock.getWidth() + 10, 10, 200, 200);
|
||||||
window.add(progressSquare);
|
window.add(progressSquare);
|
||||||
|
|
||||||
|
ProgressCircle progressCircle = new ProgressCircle();
|
||||||
|
progressCircle
|
||||||
|
.setBounds(10 + progressSquare.getBounds().x + progressSquare.getWidth() + 10, 10, 80, 80);
|
||||||
|
window.add(progressCircle);
|
||||||
|
|
||||||
|
|
||||||
if(Utils.highlightTxt.exists()) {
|
if(Utils.highlightTxt.exists()) {
|
||||||
analogClock.setHighlight(true);
|
analogClock.setHighlight(true);
|
||||||
progressSquare.setHighlight(true);
|
progressSquare.setHighlight(true);
|
||||||
|
progressCircle.setHighlight(true);
|
||||||
}
|
}
|
||||||
StringBuilder sb = null;
|
StringBuilder sb = null;
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -176,6 +182,7 @@ public class TimeCalcWindow {
|
|||||||
double done = ((double) totalMillisecondsDone)
|
double done = ((double) totalMillisecondsDone)
|
||||||
/ ((double) totalMilliseconds);
|
/ ((double) totalMilliseconds);
|
||||||
progressSquare.setDonePercent(done);
|
progressSquare.setDonePercent(done);
|
||||||
|
progressCircle.setDonePercent(done);
|
||||||
|
|
||||||
int totalSecondsRemains = (hourRemains * 60 * 60 + minuteRemains * 60 + secondsRemains);
|
int totalSecondsRemains = (hourRemains * 60 * 60 + minuteRemains * 60 + secondsRemains);
|
||||||
int totalMillisecondsRemains = totalSecondsRemains * 1000 + millisecondsRemains;
|
int totalMillisecondsRemains = totalSecondsRemains * 1000 + millisecondsRemains;
|
||||||
@ -271,7 +278,7 @@ public class TimeCalcWindow {
|
|||||||
toasterManager.setDisplayTime(10000);
|
toasterManager.setDisplayTime(10000);
|
||||||
toasterManager.setToasterWidth(600);
|
toasterManager.setToasterWidth(600);
|
||||||
toasterManager.setToasterHeight(400);
|
toasterManager.setToasterHeight(400);
|
||||||
toasterManager.setToasterColor(Color.YELLOW);
|
toasterManager.setToasterColor(new Color(255,255,102));
|
||||||
Base64.Decoder base64Decoder = Base64.getDecoder();
|
Base64.Decoder base64Decoder = Base64.getDecoder();
|
||||||
|
|
||||||
byte[] btDataFile = base64Decoder
|
byte[] btDataFile = base64Decoder
|
||||||
|
@ -1 +1 @@
|
|||||||
6:39
|
7:00
|
Loading…
x
Reference in New Issue
Block a user