Added new improvements

This commit is contained in:
Robert Vokac 2024-02-03 09:14:44 +00:00
parent 5f7826b9e0
commit 8ce49c669e
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
3 changed files with 32 additions and 23 deletions

View File

@ -45,3 +45,7 @@ If file test.txt exists, then user is not asked for start time and overtime. Ins
### focus.txt ### focus.txt
Requests focus for the window. Requests focus for the window.
## Key shortcuts
## Command button

View File

@ -27,7 +27,7 @@ public class Battery extends Widget {
private int totalHeight = 0; private int totalHeight = 0;
private int width_; private int totalWidth;
private String label = null; private String label = null;
private final double[] randomDoubles = new double[] {1d, 1d, 1d, 1d, 1d, 1d, 1}; private final double[] randomDoubles = new double[] {1d, 1d, 1d, 1d, 1d, 1d, 1};
@ -44,22 +44,21 @@ public class Battery extends Widget {
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
if (totalHeight == 0) { if (totalHeight == 0) {
this.totalHeight = Math.min(getWidth(), getHeight()); this.totalHeight = (int) (this.getHeight() / 10d * 7d);
this.width_ = (int) (this.totalHeight * 0.6); this.totalWidth = this.getWidth();
} }
super.paintComponent(g); super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Utils.highlighted.get() || mouseOver ? Color.YELLOW : g2d.setColor(Utils.highlighted.get() || mouseOver ? Color.YELLOW :
FOREGROUND_COLOR); FOREGROUND_COLOR);
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(1, 1, totalWidth, totalHeight - 2);
} }
g2d.setColor(Utils.highlighted.get() || mouseOver ? Color.BLACK :
Color.LIGHT_GRAY);
g2d.drawRect(width_ / 4 - 1, 0, width_ + 1, totalHeight + 0);
if (Utils.highlighted.get() || mouseOver) { if (Utils.highlighted.get() || mouseOver) {
g2d.setColor( g2d.setColor(
donePercent < 0.1 ? LOW_HIGHLIGHTED : (donePercent < 0.75 ? donePercent < 0.1 ? LOW_HIGHLIGHTED : (donePercent < 0.75 ?
@ -74,7 +73,7 @@ public class Battery extends Widget {
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 = 1;
int todoHeight = totalHeight - doneHeight; int todoHeight = totalHeight - doneHeight;
double surfacePower = double surfacePower =
1;//donePercent < 0.5 ? 0.5 : donePercent;// (donePercent * 100 - ((int)(donePercent * 100))); 1;//donePercent < 0.5 ? 0.5 : donePercent;// (donePercent * 100 - ((int)(donePercent * 100)));
@ -85,10 +84,10 @@ public class Battery extends Widget {
waterSurfaceHeight = 0; waterSurfaceHeight = 0;
} }
g2d.fillRect(intX, doneHeight < waterSurfaceHeight || donePercent >= 1 ? g2d.fillRect(intX+1, doneHeight < waterSurfaceHeight || donePercent >= 1 ?
todoHeight : todoHeight + waterSurfaceHeight, todoHeight : todoHeight + waterSurfaceHeight,
width_, doneHeight < waterSurfaceHeight || donePercent >= 1 ? totalWidth - 3, doneHeight < waterSurfaceHeight || donePercent >= 1 ?
doneHeight : doneHeight - waterSurfaceHeight); doneHeight : doneHeight - waterSurfaceHeight + 1);
int pointCount = 8; int pointCount = 8;
if (doneHeight >= waterSurfaceHeight if (doneHeight >= waterSurfaceHeight
&& donePercent < 1) {// && todoHeight > waterSurfaceHeight) { && donePercent < 1) {// && todoHeight > waterSurfaceHeight) {
@ -96,13 +95,13 @@ public class Battery extends Widget {
g2d.fillPolygon( g2d.fillPolygon(
new int[] {intX, new int[] {intX,
(int) (intX + width_ / pointCount * 0.5), (int) (intX + totalWidth / pointCount * 0.5),
intX + width_ / pointCount * 3, intX + totalWidth / pointCount * 3,
intX + width_ / pointCount * 4, intX + totalWidth / pointCount * 4,
intX + width_ / pointCount * 5, intX + totalWidth / pointCount * 5,
intX + width_ / pointCount * 6, intX + totalWidth / pointCount * 6,
intX + width_ / pointCount * 7, intX + totalWidth / pointCount * 7,
intX + width_ / pointCount * 8}, intX + totalWidth / pointCount * 8},
new int[] {todoHeight + (waterSurfaceHeight * 1), new int[] {todoHeight + (waterSurfaceHeight * 1),
todoHeight + (int) (waterSurfaceHeight * getRandom( todoHeight + (int) (waterSurfaceHeight * getRandom(
0)), 0)),
@ -123,22 +122,25 @@ public class Battery extends Widget {
Color.LIGHT_GRAY); Color.LIGHT_GRAY);
g2d.drawString( g2d.drawString(
NumberFormats.FORMATTER_THREE_DECIMAL_PLACES.format(donePercent * 100) + "%", NumberFormats.FORMATTER_THREE_DECIMAL_PLACES.format(donePercent * 100) + "%",
((int) (width_ * 0.4)), ((int) (totalWidth * 0.15)),
donePercent > 0.5 ? totalHeight / 4 * 3 : totalHeight / 4 * 1); 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) (totalWidth * 0.15)),
(donePercent > 0.5 ? totalHeight / 4 * 3 : (donePercent > 0.5 ? totalHeight / 4 * 3 :
totalHeight / 4 * 1) + 20); totalHeight / 4 * 1) + 20);
} }
if (name != null && !name.isEmpty()) { if (name != null && !name.isEmpty()) {
g2d.drawString( g2d.drawString(
name, name,
((int) (width_ * 0.4)), ((int) (totalWidth * 0.15)),
(totalHeight / 4 * 3) + 20 + 20); (totalHeight / 4 * 3) + 20 + 20);
} }
g2d.setColor(Utils.highlighted.get() || mouseOver ? Color.BLACK :
Color.LIGHT_GRAY);
g2d.drawRect(1, 1, totalWidth - 2, totalHeight);
} }
@ -162,6 +164,6 @@ public class Battery extends Widget {
} }
public void setBounds(int x, int y, int height) { public void setBounds(int x, int y, int height) {
setBounds(x, y, (int) (90d / 140d * height), height); setBounds(x, y, (int) (40d / 100d * ((double)height)), height);
} }
} }

View File

@ -232,7 +232,7 @@ public class TimeCalcManager {
window.add(dayBattery); window.add(dayBattery);
Battery weekBattery = new WeekBattery( Battery weekBattery = new WeekBattery(
dayBattery.getBounds().x + dayBattery.getWidth(), dayBattery.getBounds().x + dayBattery.getWidth() + MARGIN * 2,
dayBattery.getY(), 140); dayBattery.getY(), 140);
window.add(weekBattery); window.add(weekBattery);
@ -282,6 +282,9 @@ public class TimeCalcManager {
dayBattery.setBounds(weekRectangle); dayBattery.setBounds(weekRectangle);
weekBattery.setBounds(monthRectangle); weekBattery.setBounds(monthRectangle);
monthBattery.setBounds(hourRectangle); monthBattery.setBounds(hourRectangle);
//
weekBattery.setBounds(dayBattery.getX(), weekBattery.getY(), weekBattery.getWidth(), weekBattery.getHeight());
monthBattery.setBounds(dayBattery.getX(), monthBattery.getY(), monthBattery.getWidth(), monthBattery.getHeight());
ComponentRegistry componentRegistry = new ComponentRegistry(); ComponentRegistry componentRegistry = new ComponentRegistry();
componentRegistry.addAll( componentRegistry.addAll(