mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
patch18
This commit is contained in:
parent
8e9b90d622
commit
3c4cdcbfec
@ -9,9 +9,9 @@ import org.nanoboot.utils.timecalc.app.TimeCalcException;
|
|||||||
public class Progress {
|
public class Progress {
|
||||||
private final double[] array = new double[6];
|
private final double[] array = new double[6];
|
||||||
public void set(WidgetType type, double value) {
|
public void set(WidgetType type, double value) {
|
||||||
array[WidgetType.DAY.getIndex()] = value;
|
array[type.getIndex()] = value > 1 ? 1 : (value < 0 ? 0 : value);
|
||||||
}
|
}
|
||||||
public double get(WidgetType type) {
|
public double get(WidgetType type) {
|
||||||
return array[WidgetType.DAY.getIndex()];
|
return array[type.getIndex()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package org.nanoboot.utils.timecalc.swing.common;
|
|||||||
|
|
||||||
import org.nanoboot.utils.timecalc.app.GetProperty;
|
import org.nanoboot.utils.timecalc.app.GetProperty;
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
||||||
|
import org.nanoboot.utils.timecalc.entity.Progress;
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
import org.nanoboot.utils.timecalc.entity.WidgetType;
|
import org.nanoboot.utils.timecalc.entity.WidgetType;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.Battery;
|
import org.nanoboot.utils.timecalc.swing.progress.Battery;
|
||||||
@ -64,7 +65,7 @@ public class Widget extends JPanel implements
|
|||||||
public StringProperty typeProperty
|
public StringProperty typeProperty
|
||||||
= new StringProperty("widget.typeProperty", WidgetType.DAY.name().toLowerCase());
|
= new StringProperty("widget.typeProperty", WidgetType.DAY.name().toLowerCase());
|
||||||
protected int side = 0;
|
protected int side = 0;
|
||||||
protected double donePercent = 0;
|
private Progress progress = null;
|
||||||
protected boolean mouseOver = false;
|
protected boolean mouseOver = false;
|
||||||
private boolean mouseOverCloseButton = false;
|
private boolean mouseOverCloseButton = false;
|
||||||
protected JLabel smileyIcon;
|
protected JLabel smileyIcon;
|
||||||
@ -153,20 +154,24 @@ public class Widget extends JPanel implements
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
public final void setDonePercent(double newDonePercent) {
|
public final void setProgress(Progress newProgress) {
|
||||||
if (newDonePercent > 1) {
|
|
||||||
newDonePercent = 1;
|
double oldDonePercent = this.progress == null ? 0 : this.progress.get(WidgetType.DAY);
|
||||||
}
|
|
||||||
if (newDonePercent < 0) {
|
|
||||||
newDonePercent = 0;
|
|
||||||
}
|
|
||||||
double oldDonePercent = this.donePercent;
|
|
||||||
int oldDonePercentInt1000Mil = (int) (oldDonePercent * 1000000000);
|
int oldDonePercentInt1000Mil = (int) (oldDonePercent * 1000000000);
|
||||||
this.donePercent = newDonePercent;
|
|
||||||
int newDonePercentInt1000Mil = (int) (newDonePercent * 1000000000);
|
int newDonePercentInt1000Mil = (int) (newProgress.get(WidgetType.DAY) * 1000000000);
|
||||||
if (newDonePercentInt1000Mil != oldDonePercentInt1000Mil) {
|
if (newDonePercentInt1000Mil != oldDonePercentInt1000Mil) {
|
||||||
lastUpdate = System.nanoTime();
|
lastUpdate = System.nanoTime();
|
||||||
}
|
}
|
||||||
|
this.progress = newProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected double donePercent() {
|
||||||
|
if(progress == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return progress.get(WidgetType.valueOf(typeProperty.getValue().toUpperCase(
|
||||||
|
Locale.ROOT)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBounds(int x, int y, int side) {
|
public void setBounds(int x, int y, int side) {
|
||||||
@ -300,7 +305,7 @@ public class Widget extends JPanel implements
|
|||||||
brush.setColor(currentColor);
|
brush.setColor(currentColor);
|
||||||
brush.setFont(MEDIUM_FONT);
|
brush.setFont(MEDIUM_FONT);
|
||||||
brush.drawString(
|
brush.drawString(
|
||||||
ProgressSmiley.forProgress(customDonePercent >= 0 ? customDonePercent : donePercent).getCharacter(),
|
ProgressSmiley.forProgress(customDonePercent >= 0 ? customDonePercent : donePercent()).getCharacter(),
|
||||||
x + 1 + (getClass() == ProgressSwing.class ? -8 : 0), y + 16
|
x + 1 + (getClass() == ProgressSwing.class ? -8 : 0), y + 16
|
||||||
);
|
);
|
||||||
brush.setFont(currentFont);
|
brush.setFont(currentFont);
|
||||||
@ -309,7 +314,7 @@ public class Widget extends JPanel implements
|
|||||||
if (colored) {
|
if (colored) {
|
||||||
x = x + 2;
|
x = x + 2;
|
||||||
ImageIcon imageIcon = ProgressSmileyIcon
|
ImageIcon imageIcon = ProgressSmileyIcon
|
||||||
.forSmiley(ProgressSmiley.forProgress(customDonePercent >= 0 ? customDonePercent : donePercent))
|
.forSmiley(ProgressSmiley.forProgress(customDonePercent >= 0 ? customDonePercent : donePercent()))
|
||||||
.getIcon();
|
.getIcon();
|
||||||
if(smileyNumber < 2) {
|
if(smileyNumber < 2) {
|
||||||
if (this.smileyIcon != null) {
|
if (this.smileyIcon != null) {
|
||||||
@ -359,8 +364,8 @@ public class Widget extends JPanel implements
|
|||||||
//Color currentBackgroundColor = brush.getBackground();
|
//Color currentBackgroundColor = brush.getBackground();
|
||||||
Font currentFont = brush.getFont();
|
Font currentFont = brush.getFont();
|
||||||
brush.setFont(BIG_FONT);
|
brush.setFont(BIG_FONT);
|
||||||
int q = donePercent < 0.25 ? 0 : (donePercent < 0.5 ? 1 :
|
int q = donePercent() < 0.25 ? 0 : (donePercent() < 0.5 ? 1 :
|
||||||
(donePercent < 0.75 ? 2 : (donePercent < 1.0 ? 3 : 4)));
|
(donePercent() < 0.75 ? 2 : (donePercent() < 1.0 ? 3 : 4)));
|
||||||
Color color;
|
Color color;
|
||||||
Color backgroundColor;
|
Color backgroundColor;
|
||||||
switch (visibility) {
|
switch (visibility) {
|
||||||
@ -400,7 +405,7 @@ public class Widget extends JPanel implements
|
|||||||
brush.setColor(backgroundColor);
|
brush.setColor(backgroundColor);
|
||||||
if(x< 0 || y < 0) {
|
if(x< 0 || y < 0) {
|
||||||
brush.fillRect(((int) (totalWidth * 0.08)),
|
brush.fillRect(((int) (totalWidth * 0.08)),
|
||||||
(donePercent < 0.5 ? totalHeight / 4 * 3
|
(donePercent() < 0.5 ? totalHeight / 4 * 3
|
||||||
: (totalHeight / 4 * 1) + 10) + -8, 20, 20);
|
: (totalHeight / 4 * 1) + 10) + -8, 20, 20);
|
||||||
} else {
|
} else {
|
||||||
brush.fillRect(x, y, 20, 20);
|
brush.fillRect(x, y, 20, 20);
|
||||||
@ -409,7 +414,7 @@ public class Widget extends JPanel implements
|
|||||||
if(x< 0 || y < 0) {
|
if(x< 0 || y < 0) {
|
||||||
brush.drawString(
|
brush.drawString(
|
||||||
String.valueOf(q), ((int) (totalWidth * 0.13)),
|
String.valueOf(q), ((int) (totalWidth * 0.13)),
|
||||||
(donePercent < 0.5 ? totalHeight / 4 * 3
|
(donePercent() < 0.5 ? totalHeight / 4 * 3
|
||||||
: (totalHeight / 4 * 1) + 10) + 10
|
: (totalHeight / 4 * 1) + 10) + 10
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,6 +2,7 @@ package org.nanoboot.utils.timecalc.swing.progress;
|
|||||||
|
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
|
import org.nanoboot.utils.timecalc.entity.WidgetType;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.SwingUtils;
|
import org.nanoboot.utils.timecalc.swing.common.SwingUtils;
|
||||||
import org.nanoboot.utils.timecalc.swing.common.Widget;
|
import org.nanoboot.utils.timecalc.swing.common.Widget;
|
||||||
import org.nanoboot.utils.timecalc.utils.common.DateFormats;
|
import org.nanoboot.utils.timecalc.utils.common.DateFormats;
|
||||||
@ -21,6 +22,7 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
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 Widget {
|
public class AnalogClock extends Widget {
|
||||||
@ -96,8 +98,10 @@ public class AnalogClock extends Widget {
|
|||||||
public final BooleanProperty smileyVisibleProperty = new BooleanProperty("smileyVisibleProperty");
|
public final BooleanProperty smileyVisibleProperty = new BooleanProperty("smileyVisibleProperty");
|
||||||
public final BooleanProperty percentProgressVisibleProperty = new BooleanProperty("percentProgressVisibleProperty");
|
public final BooleanProperty percentProgressVisibleProperty = new BooleanProperty("percentProgressVisibleProperty");
|
||||||
private Color customCircleColor = null;
|
private Color customCircleColor = null;
|
||||||
|
private double dayProgress;
|
||||||
|
|
||||||
public AnalogClock() {
|
public AnalogClock() {
|
||||||
|
typeProperty.setValue(WidgetType.DAY.name().toLowerCase(Locale.ROOT));
|
||||||
|
|
||||||
setPreferredSize(new Dimension(200, 200));
|
setPreferredSize(new Dimension(200, 200));
|
||||||
|
|
||||||
@ -181,7 +185,7 @@ public class AnalogClock extends Widget {
|
|||||||
int total = endMS - startMS;
|
int total = endMS - startMS;
|
||||||
int done = nowMS - startMS;
|
int done = nowMS - startMS;
|
||||||
double progress = ((double)done) / ((double)total);
|
double progress = ((double)done) / ((double)total);
|
||||||
setDonePercent(progress);
|
this.dayProgress = progress;
|
||||||
|
|
||||||
//System.out.println("clock.handsLongProperty=" + handsLongProperty.isEnabled());
|
//System.out.println("clock.handsLongProperty=" + handsLongProperty.isEnabled());
|
||||||
Visibility visibility
|
Visibility visibility
|
||||||
@ -380,7 +384,7 @@ public class AnalogClock extends Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(percentProgressVisibleProperty.isEnabled()) {
|
if(percentProgressVisibleProperty.isEnabled()) {
|
||||||
brush.drawString(((int) Math.floor(donePercent * 100)) + "%",
|
brush.drawString(((int) Math.floor(dayProgress * 100)) + "%",
|
||||||
((int) (side * 0.25)),
|
((int) (side * 0.25)),
|
||||||
((int) (side * 0.35)) + 35);
|
((int) (side * 0.35)) + 35);
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import java.awt.Graphics;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Battery extends Widget {
|
public class Battery extends Widget {
|
||||||
@ -171,6 +172,8 @@ public class Battery extends Widget {
|
|||||||
protected Battery(String name) {
|
protected Battery(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
setPreferredSize(new Dimension(40, 100));
|
setPreferredSize(new Dimension(40, 100));
|
||||||
|
this.typeProperty.setValue(getClass().getSimpleName().replace("Battery", "").toLowerCase(
|
||||||
|
Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Battery(String name, int i, int y, int height) {
|
protected Battery(String name, int i, int y, int height) {
|
||||||
@ -184,9 +187,10 @@ public class Battery extends Widget {
|
|||||||
this.totalHeight = (int) (this.getHeight() / 10d * 7d);
|
this.totalHeight = (int) (this.getHeight() / 10d * 7d);
|
||||||
this.totalWidth = this.getWidth();
|
this.totalWidth = this.getWidth();
|
||||||
}
|
}
|
||||||
|
double donePercent = donePercent();
|
||||||
if (blinkingIfCriticalLowVisibleProperty.isEnabled()) {
|
if (blinkingIfCriticalLowVisibleProperty.isEnabled()) {
|
||||||
if (donePercent > 0 && donePercent <= CRITICAL_LOW_ENERGY
|
if (donePercent > 0 && donePercent <= CRITICAL_LOW_ENERGY
|
||||||
&& (System.nanoTime() - tmpNanoTime) > (1000000000l) / 2l) {
|
&& (System.nanoTime() - tmpNanoTime) > (1000000000l) / 2l) {
|
||||||
blinking.flip();
|
blinking.flip();
|
||||||
tmpNanoTime = System.nanoTime();
|
tmpNanoTime = System.nanoTime();
|
||||||
}
|
}
|
||||||
@ -239,7 +243,7 @@ public class Battery extends Widget {
|
|||||||
? doneHeight : doneHeight - waterSurfaceHeight + 1);
|
? doneHeight : doneHeight - waterSurfaceHeight + 1);
|
||||||
int pointCount = 8;
|
int pointCount = 8;
|
||||||
if (doneHeight >= waterSurfaceHeight
|
if (doneHeight >= waterSurfaceHeight
|
||||||
&& donePercent < 1) {// && todoHeight > waterSurfaceHeight) {
|
&& donePercent < 1) {// && todoHeight > waterSurfaceHeight) {
|
||||||
//g2d.fillArc(intX, intY, width_, intHeight - waterSurfaceHeight, 30, 60);
|
//g2d.fillArc(intX, intY, width_, intHeight - waterSurfaceHeight, 30, 60);
|
||||||
|
|
||||||
brush.fillPolygon(
|
brush.fillPolygon(
|
||||||
@ -367,7 +371,7 @@ public class Battery extends Widget {
|
|||||||
public void paintChargingCharacter(Graphics2D brush) {
|
public void paintChargingCharacter(Graphics2D brush) {
|
||||||
brush.drawString(
|
brush.drawString(
|
||||||
CHARCHING, ((int) (totalWidth * 0.45)),
|
CHARCHING, ((int) (totalWidth * 0.45)),
|
||||||
(donePercent < 0.5 ? totalHeight / 4 * 3
|
(donePercent() < 0.5 ? totalHeight / 4 * 3
|
||||||
: (totalHeight / 4 * 1) + 10) + 10
|
: (totalHeight / 4 * 1) + 10) + 10
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -379,7 +383,7 @@ public class Battery extends Widget {
|
|||||||
: (visibility.isWeaklyColored() ? HIGH_WEAKLY_COLORED
|
: (visibility.isWeaklyColored() ? HIGH_WEAKLY_COLORED
|
||||||
: Color.lightGray));
|
: Color.lightGray));
|
||||||
|
|
||||||
double angleDouble = donePercent * 360;
|
double angleDouble = donePercent() * 360;
|
||||||
|
|
||||||
brush.fillArc(((int) (totalWidth * 0.45)) + 15,
|
brush.fillArc(((int) (totalWidth * 0.45)) + 15,
|
||||||
totalHeight / 4 * 3 + 28,
|
totalHeight / 4 * 3 + 28,
|
||||||
|
@ -30,7 +30,7 @@ public class ProgressCircle extends Widget {
|
|||||||
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
|
||||||
double angleDouble = donePercent * 360;
|
double angleDouble = donePercent() * 360;
|
||||||
double angleDouble2 = (angleDouble - (int) (angleDouble)) * 360;
|
double angleDouble2 = (angleDouble - (int) (angleDouble)) * 360;
|
||||||
// System.out.println("remainingAngle=" + angleDouble2);
|
// System.out.println("remainingAngle=" + angleDouble2);
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ public class ProgressCircle extends Widget {
|
|||||||
|
|
||||||
brush.drawString(
|
brush.drawString(
|
||||||
NumberFormats.FORMATTER_ZERO_DECIMAL_PLACES
|
NumberFormats.FORMATTER_ZERO_DECIMAL_PLACES
|
||||||
.format(donePercent * 100) + "%",
|
.format(donePercent() * 100) + "%",
|
||||||
(int) (side / 8d * 0d), (int) (side / 8d * 7.5d));
|
(int) (side / 8d * 0d), (int) (side / 8d * 7.5d));
|
||||||
paintSmiley(visibility, brush, (int) (side / 8d * 0d) + 30,
|
paintSmiley(visibility, brush, (int) (side / 8d * 0d) + 30,
|
||||||
(int) (side / 8d * 7.5d - 16d));
|
(int) (side / 8d * 7.5d - 16d));
|
||||||
|
@ -75,7 +75,7 @@ public class ProgressLife extends Widget implements GetProperty {
|
|||||||
Date now = time.asCalendar().getTime();
|
Date now = time.asCalendar().getTime();
|
||||||
long diff = now.getTime() - birthDate.getTime();
|
long diff = now.getTime() - birthDate.getTime();
|
||||||
Date result = new Date(
|
Date result = new Date(
|
||||||
(long) (birthDate.getTime() + diff * donePercent));
|
(long) (birthDate.getTime() + diff * donePercent()));
|
||||||
|
|
||||||
String date =
|
String date =
|
||||||
DateFormats.DATE_TIME_FORMATTER_YYYYMMDD.format(result);
|
DateFormats.DATE_TIME_FORMATTER_YYYYMMDD.format(result);
|
||||||
@ -97,6 +97,9 @@ public class ProgressLife extends Widget implements GetProperty {
|
|||||||
brush.drawString(time, SwingUtils.MARGIN, (int) (SwingUtils.MARGIN
|
brush.drawString(time, SwingUtils.MARGIN, (int) (SwingUtils.MARGIN
|
||||||
+ (getHeight() - SwingUtils.MARGIN)
|
+ (getHeight() - SwingUtils.MARGIN)
|
||||||
* 0.6d));
|
* 0.6d));
|
||||||
|
brush.drawString(typeProperty.getValue(), SwingUtils.MARGIN, (int) (SwingUtils.MARGIN
|
||||||
|
+ (getHeight() - SwingUtils.MARGIN)
|
||||||
|
* 0.6d) + 20);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class ProgressSquare extends Widget {
|
|||||||
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
brush.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;
|
||||||
int x = dotNumber - y * side;
|
int x = dotNumber - y * side;
|
||||||
@ -78,11 +78,11 @@ public class ProgressSquare extends Widget {
|
|||||||
: BACKGROUND_COLOR);
|
: BACKGROUND_COLOR);
|
||||||
|
|
||||||
brush.drawString(NumberFormats.FORMATTER_FIVE_DECIMAL_PLACES
|
brush.drawString(NumberFormats.FORMATTER_FIVE_DECIMAL_PLACES
|
||||||
.format(donePercent * 100) + "%",
|
.format(donePercent() * 100) + "%",
|
||||||
(int) (side / 8d * 3d),
|
(int) (side / 8d * 3d),
|
||||||
(int) (side / 8d * (donePercent > 0.5 ? 3d : 5d)));
|
(int) (side / 8d * (donePercent() > 0.5 ? 3d : 5d)));
|
||||||
paintSmiley(visibility, brush, (int) (side / 8d * 3d),
|
paintSmiley(visibility, brush, (int) (side / 8d * 3d),
|
||||||
(int) ((side / 8d * (donePercent > 0.5 ? 3d : 5d)) - 32d));
|
(int) ((side / 8d * (donePercent() > 0.5 ? 3d : 5d)) - 32d));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ public class ProgressSwing extends Widget {
|
|||||||
(int) (getHeight() * 0.66) - 10 - 3, 6, 6);
|
(int) (getHeight() * 0.66) - 10 - 3, 6, 6);
|
||||||
brush.drawLine(1, getHeight() - 2, getWidth(), getHeight() - 2);
|
brush.drawLine(1, getHeight() - 2, getWidth(), getHeight() - 2);
|
||||||
int startX = (int) (getWidth() * 0.10);
|
int startX = (int) (getWidth() * 0.10);
|
||||||
|
double donePercent = donePercent();
|
||||||
int startY = (int) (getHeight() - getHeight() * 0.66 * (1 - donePercent)) - 10;
|
int startY = (int) (getHeight() - getHeight() * 0.66 * (1 - donePercent)) - 10;
|
||||||
int endX = (int) (getWidth() * 0.90);
|
int endX = (int) (getWidth() * 0.90);
|
||||||
int endY = (int) (getHeight() - getHeight() * 0.66 * donePercent) - 10;
|
int endY = (int) (getHeight() - getHeight() * 0.66 * donePercent) - 10;
|
||||||
|
@ -92,7 +92,7 @@ public class WalkingHumanProgress extends Widget implements
|
|||||||
paintSmiley(visibility,
|
paintSmiley(visibility,
|
||||||
(Graphics2D) brush,
|
(Graphics2D) brush,
|
||||||
//29 309
|
//29 309
|
||||||
29 + ((int) (280 * donePercent)),
|
29 + ((int) (280 * donePercent())),
|
||||||
y - 4, true);
|
y - 4, true);
|
||||||
}
|
}
|
||||||
y = y + SwingUtils.MARGIN;
|
y = y + SwingUtils.MARGIN;
|
||||||
@ -112,7 +112,7 @@ public class WalkingHumanProgress extends Widget implements
|
|||||||
this.setVisible(visibility != Visibility.NONE);
|
this.setVisible(visibility != Visibility.NONE);
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
final int donePercentInt = (int) (Math.floor(donePercent * 100));
|
final int donePercentInt = (int) (Math.floor(donePercent() * 100));
|
||||||
|
|
||||||
int percentInt = donePercentInt;
|
int percentInt = donePercentInt;
|
||||||
if (donePercentInt % 5 == 0 && !alreadyShownPercents.contains(donePercentInt)) {
|
if (donePercentInt % 5 == 0 && !alreadyShownPercents.contains(donePercentInt)) {
|
||||||
@ -147,7 +147,7 @@ public class WalkingHumanProgress extends Widget implements
|
|||||||
|
|
||||||
}
|
}
|
||||||
int spacesTotal = 40;
|
int spacesTotal = 40;
|
||||||
int spacesDone = (int) (donePercent * spacesTotal);
|
int spacesDone = (int) (donePercent() * spacesTotal);
|
||||||
if (spacesDone > spacesTotal) {
|
if (spacesDone > spacesTotal) {
|
||||||
spacesDone = spacesTotal;
|
spacesDone = spacesTotal;
|
||||||
}
|
}
|
||||||
@ -174,9 +174,9 @@ public class WalkingHumanProgress extends Widget implements
|
|||||||
+ createRepeatedString(spacesTotal + 14, '=')
|
+ createRepeatedString(spacesTotal + 14, '=')
|
||||||
+ Constants.NEW_LINE + "Steps: "
|
+ Constants.NEW_LINE + "Steps: "
|
||||||
+ NumberFormats.FORMATTER_FIVE_DECIMAL_PLACES
|
+ NumberFormats.FORMATTER_FIVE_DECIMAL_PLACES
|
||||||
.format(donePercent * ((double) spacesTotal)) + "/"
|
.format(donePercent() * ((double) spacesTotal)) + "/"
|
||||||
+ spacesTotal + " Done: " + NumberFormats.FORMATTER_EIGHT_DECIMAL_PLACES
|
+ spacesTotal + " Done: " + NumberFormats.FORMATTER_EIGHT_DECIMAL_PLACES
|
||||||
.format(donePercent * 100d) + "%"
|
.format(donePercent() * 100d) + "%"
|
||||||
);
|
);
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,9 @@ import org.nanoboot.utils.timecalc.app.TimeCalcConfiguration;
|
|||||||
import org.nanoboot.utils.timecalc.app.TimeCalcKeyAdapter;
|
import org.nanoboot.utils.timecalc.app.TimeCalcKeyAdapter;
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcProperties;
|
import org.nanoboot.utils.timecalc.app.TimeCalcProperties;
|
||||||
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
import org.nanoboot.utils.timecalc.app.TimeCalcProperty;
|
||||||
|
import org.nanoboot.utils.timecalc.entity.Progress;
|
||||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
|
import org.nanoboot.utils.timecalc.entity.WidgetType;
|
||||||
import org.nanoboot.utils.timecalc.entity.WorkingDay;
|
import org.nanoboot.utils.timecalc.entity.WorkingDay;
|
||||||
import org.nanoboot.utils.timecalc.persistence.api.ActivityRepositoryApi;
|
import org.nanoboot.utils.timecalc.persistence.api.ActivityRepositoryApi;
|
||||||
import org.nanoboot.utils.timecalc.persistence.impl.sqlite.ActivityRepositorySQLiteImpl;
|
import org.nanoboot.utils.timecalc.persistence.impl.sqlite.ActivityRepositorySQLiteImpl;
|
||||||
@ -328,7 +330,7 @@ public class MainWindow extends TWindow {
|
|||||||
progressSwing.typeProperty
|
progressSwing.typeProperty
|
||||||
.bindTo(timeCalcConfiguration.swingTypeProperty);
|
.bindTo(timeCalcConfiguration.swingTypeProperty);
|
||||||
progressLife.typeProperty
|
progressLife.typeProperty
|
||||||
.bindTo(timeCalcConfiguration.squareTypeProperty);
|
.bindTo(timeCalcConfiguration.lifeTypeProperty);
|
||||||
progressLife.birthDateProperty
|
progressLife.birthDateProperty
|
||||||
.bindTo(timeCalcConfiguration.lifeBirthDateProperty);
|
.bindTo(timeCalcConfiguration.lifeBirthDateProperty);
|
||||||
}
|
}
|
||||||
@ -974,52 +976,66 @@ public class MainWindow extends TWindow {
|
|||||||
if (done > 1) {
|
if (done > 1) {
|
||||||
done = 1;
|
done = 1;
|
||||||
}
|
}
|
||||||
progressSquare.setDonePercent(done);
|
Progress progress = new Progress();
|
||||||
progressCircle.setDonePercent(done);
|
progress.set(WidgetType.DAY, done);
|
||||||
progressSwing.setDonePercent(done);
|
|
||||||
progressLife.setDonePercent(done);
|
|
||||||
dayBattery.setDonePercent(done);
|
|
||||||
try {
|
|
||||||
WeekStatistics weekStatisticsTmp = new WeekStatistics(clock, time);
|
|
||||||
weekStatistics = weekStatisticsTmp;
|
|
||||||
} catch (DateTimeException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
WeekStatistics weekStatisticsTmp = new WeekStatistics(clock, time);
|
||||||
} catch (InterruptedException interruptedException) {
|
weekStatistics = weekStatisticsTmp;
|
||||||
interruptedException.printStackTrace();
|
} catch (DateTimeException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException interruptedException) {
|
||||||
|
interruptedException.printStackTrace();
|
||||||
|
}
|
||||||
|
// return false;
|
||||||
}
|
}
|
||||||
// return false;
|
final boolean nowIsWeekend = weekStatistics.isNowIsWeekend();
|
||||||
}
|
final int workDaysDone = weekStatistics.getWorkDaysDone();
|
||||||
final boolean nowIsWeekend = weekStatistics.isNowIsWeekend();
|
final int workDaysTotal = weekStatistics.getWorkDaysTotal();
|
||||||
final int workDaysDone = weekStatistics.getWorkDaysDone();
|
|
||||||
final int workDaysTotal = weekStatistics.getWorkDaysTotal();
|
|
||||||
|
|
||||||
int weekDayWhenMondayIsOne = clock.dayOfWeekProperty.getValue();
|
int weekDayWhenMondayIsOne = clock.dayOfWeekProperty.getValue();
|
||||||
weekBattery.setDonePercent(
|
double weekProgress = WeekBattery.getWeekProgress(weekDayWhenMondayIsOne, done);
|
||||||
WeekBattery.getWeekProgress(weekDayWhenMondayIsOne, done));
|
weekBattery.setProgress(progress);
|
||||||
weekBattery.setLabel(
|
weekBattery.setLabel(
|
||||||
nowIsWeekend ? "5/5" : (weekDayWhenMondayIsOne + "/5"));
|
nowIsWeekend ? "5/5" : (weekDayWhenMondayIsOne + "/5"));
|
||||||
|
|
||||||
monthBattery.setDonePercent(MonthBattery
|
double monthProgress = MonthBattery
|
||||||
.getMonthProgress(weekDayWhenMondayIsOne, workDaysDone,
|
.getMonthProgress(weekDayWhenMondayIsOne, workDaysDone,
|
||||||
workDaysTotal, done));
|
workDaysTotal, done);
|
||||||
|
progress.set(WidgetType.MONTH, monthProgress);
|
||||||
|
double hourProgress =
|
||||||
|
HourBattery.getHourProgress(timeRemains, secondsRemains,
|
||||||
|
millisecondsRemains);
|
||||||
|
double minuteProgress =
|
||||||
|
MinuteBattery.getMinuteProgress(secondNow, millisecondNow);
|
||||||
|
double yearProgress = YearBattery.getYearProgress(clock);
|
||||||
|
progress.set(WidgetType.HOUR, hourProgress);
|
||||||
|
progress.set(WidgetType.WEEK, weekProgress);
|
||||||
|
progress.set(WidgetType.MINUTE, minuteProgress);
|
||||||
|
progress.set(WidgetType.YEAR, yearProgress);
|
||||||
|
progressSquare.setProgress(progress);
|
||||||
|
progressCircle.setProgress(progress);
|
||||||
|
progressSwing.setProgress(progress);
|
||||||
|
progressLife.setProgress(progress);
|
||||||
|
dayBattery.setProgress(progress);
|
||||||
|
|
||||||
|
monthBattery.setProgress(progress);
|
||||||
monthBattery.setLabel(
|
monthBattery.setLabel(
|
||||||
(nowIsWeekend ? workDaysDone : workDaysDone + 1) + "/"
|
(nowIsWeekend ? workDaysDone : workDaysDone + 1) + "/"
|
||||||
+ (workDaysTotal));
|
+ (workDaysTotal));
|
||||||
|
|
||||||
hourBattery.setDonePercent(
|
hourBattery.setProgress(progress);
|
||||||
HourBattery.getHourProgress(timeRemains, secondsRemains,
|
|
||||||
millisecondsRemains));
|
|
||||||
|
|
||||||
if (!nowIsWeekend) {
|
if (!nowIsWeekend) {
|
||||||
hourBattery.setLabel(
|
hourBattery.setLabel(
|
||||||
totalHoursDone + "/" + (totalMinutes / 60));
|
totalHoursDone + "/" + (totalMinutes / 60));
|
||||||
}
|
}
|
||||||
minuteBattery.setDonePercent(
|
|
||||||
MinuteBattery.getMinuteProgress(secondNow, millisecondNow));
|
minuteBattery.setProgress(progress);
|
||||||
yearBattery
|
|
||||||
.setDonePercent(YearBattery.getYearProgress(clock));
|
yearBattery.setProgress(progress);
|
||||||
yearBattery.setLabel("");
|
yearBattery.setLabel("");
|
||||||
|
|
||||||
if (timeRemains.getHour() <= 0 && timeRemains.getMinute() <= 0 && timeRemains.getSecond() <= 0 && timeRemains.getMillisecond() <= 0) {
|
if (timeRemains.getHour() <= 0 && timeRemains.getMinute() <= 0 && timeRemains.getSecond() <= 0 && timeRemains.getMillisecond() <= 0) {
|
||||||
@ -1028,7 +1044,7 @@ public class MainWindow extends TWindow {
|
|||||||
toasterManager.showToaster(
|
toasterManager.showToaster(
|
||||||
"Congratulation :-) It is the time to go home.");
|
"Congratulation :-) It is the time to go home.");
|
||||||
walkingHumanProgress
|
walkingHumanProgress
|
||||||
.setDonePercent(done);
|
.setProgress(progress);
|
||||||
try {
|
try {
|
||||||
Thread.sleep(10000);
|
Thread.sleep(10000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@ -1042,7 +1058,7 @@ public class MainWindow extends TWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
walkingHumanProgress.setDonePercent(done);
|
walkingHumanProgress.setProgress(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user