Added new improvements
This commit is contained in:
parent
51e79d02b0
commit
da901e30e1
3391
src/main/java/rvc/timecalc/A.java
Normal file
3391
src/main/java/rvc/timecalc/A.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,7 @@ public class Battery extends JPanel {
|
||||
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");
|
||||
private int height_ = 0;
|
||||
private int totalHeight = 0;
|
||||
private double donePercent = 0;
|
||||
private boolean mouseOver = false;
|
||||
private int width_;
|
||||
@ -33,7 +33,7 @@ public class Battery extends JPanel {
|
||||
public Battery() {
|
||||
setPreferredSize(new Dimension(40, 100));
|
||||
setBackground(BACKGROUND_COLOR);
|
||||
new Timer(100, e -> repaint()).start();
|
||||
new Timer(250, e -> repaint()).start();
|
||||
addMouseListener(new MouseListener() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
@ -68,9 +68,9 @@ public class Battery extends JPanel {
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
if (height_ == 0) {
|
||||
this.height_ = Math.min(getWidth(), getHeight());
|
||||
this.width_ = (int) (this.height_ * 0.6);
|
||||
if (totalHeight == 0) {
|
||||
this.totalHeight = Math.min(getWidth(), getHeight());
|
||||
this.width_ = (int) (this.totalHeight * 0.6);
|
||||
}
|
||||
super.paintComponent(g);
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
@ -79,28 +79,65 @@ public class Battery extends JPanel {
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
g2d.fillRect(width_ / 4, 1, width_, height_ - 2);
|
||||
g2d.fillRect(width_ / 4, 1, width_, totalHeight - 2);
|
||||
g2d.setColor(Utils.highlighted.get() || mouseOver ? Color.BLACK :
|
||||
Color.LIGHT_GRAY);
|
||||
g2d.drawRect(width_ / 4 - 1, 0, width_ + 1, height_ + 0);
|
||||
g2d.drawRect(width_ / 4 - 1, 0, width_ + 1, totalHeight + 0);
|
||||
if (Utils.highlighted.get() || mouseOver) {
|
||||
g2d.setColor(
|
||||
donePercent < 0.1 ? LOW_HIGHLIGHTED : (donePercent < 0.75 ?
|
||||
MEDIUM_HIGHLIGHTED :
|
||||
(donePercent < 0.9 ? HIGH_HIGHLIGHTED :
|
||||
HIGHEST_HIGHLIGHTED)));
|
||||
HIGHEST_HIGHLIGHTED)));
|
||||
} else {
|
||||
g2d.setColor(donePercent < 0.1 ? LOW : (donePercent < 0.75 ?
|
||||
MEDIUM : (donePercent < 0.9 ? HIGH : HIGHEST)));
|
||||
}
|
||||
g2d.fillRect(width_ / 4, height_ - (int) (height_ * donePercent),
|
||||
width_, (int) (height_ * donePercent));
|
||||
int doneHeight = (int) (totalHeight * donePercent);
|
||||
int intX = width_ / 4;
|
||||
int todoHeight = totalHeight - doneHeight;
|
||||
double surfacePower = 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) {
|
||||
waterSurfaceHeight = 0;
|
||||
}
|
||||
|
||||
g2d.fillRect(intX, doneHeight < waterSurfaceHeight || donePercent >= 1 ? todoHeight : todoHeight + waterSurfaceHeight,
|
||||
width_, doneHeight < waterSurfaceHeight || donePercent >= 1 ? doneHeight : doneHeight - waterSurfaceHeight);
|
||||
int pointCount = 8;
|
||||
if(doneHeight >= waterSurfaceHeight && donePercent < 1) {// && todoHeight > waterSurfaceHeight) {
|
||||
//g2d.fillArc(intX, intY, width_, intHeight - waterSurfaceHeight, 30, 60);
|
||||
|
||||
g2d.fillPolygon(
|
||||
new int[]{intX,
|
||||
(int) (intX + width_ / pointCount * 0.5),
|
||||
intX + width_ / pointCount * 3,
|
||||
intX + width_ / pointCount * 4,
|
||||
intX + width_ / pointCount * 5,
|
||||
intX + width_ / pointCount * 6,
|
||||
(int) (intX + width_ / pointCount * 7.9),
|
||||
intX + width_ / pointCount * 8},
|
||||
new int[]{(int) (todoHeight + (waterSurfaceHeight * 1)),
|
||||
todoHeight + (int) (waterSurfaceHeight * getRandom(0)),
|
||||
todoHeight + (int) (waterSurfaceHeight * getRandom(1)),
|
||||
todoHeight + (int) (waterSurfaceHeight * getRandom(2)),
|
||||
todoHeight + (int) (waterSurfaceHeight * getRandom(3)),
|
||||
todoHeight + (int) (waterSurfaceHeight * getRandom(4)),
|
||||
todoHeight + (int) (waterSurfaceHeight * getRandom(5)),
|
||||
(int) (todoHeight + (waterSurfaceHeight * 1))},
|
||||
pointCount);
|
||||
}
|
||||
g2d.setColor(Utils.highlighted.get() || mouseOver ? Color.BLACK :
|
||||
Color.LIGHT_GRAY);
|
||||
g2d.drawString(
|
||||
formatter3.format(donePercent * 100) + "%",
|
||||
((int) (width_ * 0.4)), height_ / 2);
|
||||
((int) (width_ * 0.4)), donePercent > 0.5 ? totalHeight / 4 * 3 : totalHeight / 4 * 1);
|
||||
|
||||
}
|
||||
|
||||
private double[] randomDoubles = new double[]{1d,1d,1d,1d,1d,1d,1};
|
||||
private double getRandom(int index) {
|
||||
if(Math.random() > 0.7) {randomDoubles[index] = Math.random();}
|
||||
return randomDoubles[index];
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@ public class Main {
|
||||
String lastStartTime = Utils.readTextFromFile(starttimeTxt);
|
||||
String lastOvertime = Utils.readTextFromFile(overtimeTxt);
|
||||
String startTime =
|
||||
test ? "7:00" : (String) JOptionPane.showInputDialog(
|
||||
test ? (lastStartTime != null ? lastStartTime : "7:00") : (String) JOptionPane.showInputDialog(
|
||||
null,
|
||||
"Start Time:",
|
||||
"Start Time",
|
||||
@ -28,7 +28,7 @@ public class Main {
|
||||
lastStartTime == null ? "7:00" : lastStartTime
|
||||
);
|
||||
String overTime =
|
||||
test ? "0:00" : (String) JOptionPane.showInputDialog(
|
||||
test ? (lastOvertime != null ? lastOvertime : "0:00") : (String) JOptionPane.showInputDialog(
|
||||
null,
|
||||
"Overtime:",
|
||||
"Overtime",
|
||||
|
@ -32,7 +32,7 @@ public class TimeCalcWindow {
|
||||
private final static DateTimeFormatter DATE_TIME_FORMATTER =
|
||||
DateTimeFormatter.ofPattern("HH:mm:ss:SSS");
|
||||
private final String startTime;
|
||||
private final String overTime;
|
||||
private String overTime;
|
||||
private final int startHour;
|
||||
private final int startMinute;
|
||||
private final int overtimeHour;
|
||||
@ -53,11 +53,13 @@ public class TimeCalcWindow {
|
||||
this.startHour = Integer.valueOf(startTime.split(":")[0]);
|
||||
this.startMinute = Integer.valueOf(startTime.split(":")[1]);
|
||||
|
||||
this.overtimeHour = Integer.valueOf(overTime.split(":")[0]);
|
||||
this.overtimeMinute = Integer.valueOf(overTime.split(":")[1]);
|
||||
boolean overtimeIsNegative = overTime.startsWith("-");
|
||||
if(overtimeIsNegative) {overTime = overTime.replace("-","");}
|
||||
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.endMinute = startMinute + WORKING_MINUTES_LENGTH - overtimeMinute;
|
||||
this.endHour = startHour + WORKING_HOURS_LENGTH + overtimeHour;
|
||||
this.endMinute = startMinute + WORKING_MINUTES_LENGTH + overtimeMinute;
|
||||
while (endMinute >= 60) {
|
||||
endMinute = endMinute - 60;
|
||||
endHour = endHour + 1;
|
||||
@ -180,8 +182,8 @@ public class TimeCalcWindow {
|
||||
int secondsRemains = 60 - secondNow;
|
||||
int millisecondsRemains = 1000 - millisecondNow;
|
||||
|
||||
int hourDone = WORKING_HOURS_LENGTH - overtimeHour - hourRemains;
|
||||
int minutesDone = 30 - overtimeMinute - minuteRemains;
|
||||
int hourDone = WORKING_HOURS_LENGTH + overtimeHour - hourRemains;
|
||||
int minutesDone = 30 + overtimeMinute - minuteRemains;
|
||||
int secondsDone = secondNow;
|
||||
int millisecondsDone = millisecondNow;
|
||||
|
||||
@ -207,7 +209,7 @@ public class TimeCalcWindow {
|
||||
cal.setTime(new Date());
|
||||
int weekDayWhenMondayIsOne = cal.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
batteryForWeek.setDonePercent((weekDayWhenMondayIsOne == 0
|
||||
|| weekDayWhenMondayIsOne == 6) ?
|
||||
|| weekDayWhenMondayIsOne == 6) ?
|
||||
100 : ((weekDayWhenMondayIsOne - 1) * 0.20 + done * 0.20));
|
||||
|
||||
int totalSecondsRemains =
|
||||
|
@ -423,7 +423,7 @@ public class Toaster {
|
||||
if (currentNumberOfToaster > 0) {
|
||||
stopYPosition =
|
||||
stopYPosition - (maxToaster % maxToasterInSceen
|
||||
* toasterHeight);
|
||||
* toasterHeight);
|
||||
} else {
|
||||
maxToaster = 0;
|
||||
}
|
||||
@ -434,7 +434,7 @@ public class Toaster {
|
||||
if (currentNumberOfToaster > 0) {
|
||||
stopYPosition =
|
||||
stopYPosition + (maxToaster % maxToasterInSceen
|
||||
* toasterHeight);
|
||||
* toasterHeight);
|
||||
} else {
|
||||
maxToaster = 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user