mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
Added ProgressBar
This commit is contained in:
parent
32d122c351
commit
db3e368b2d
@ -216,6 +216,15 @@ public class TimeCalcConfiguration {
|
|||||||
public final BooleanProperty circleOuterCircleOnlyBorderProperty
|
public final BooleanProperty circleOuterCircleOnlyBorderProperty
|
||||||
= new BooleanProperty(TimeCalcProperty.CIRCLE_OUTER_CIRCLE_ONLY_BORDER.getKey());
|
= new BooleanProperty(TimeCalcProperty.CIRCLE_OUTER_CIRCLE_ONLY_BORDER.getKey());
|
||||||
//
|
//
|
||||||
|
public final BooleanProperty barVisibleProperty
|
||||||
|
= new BooleanProperty(TimeCalcProperty.BAR_VISIBLE.getKey());
|
||||||
|
public final BooleanProperty barHiddenProperty
|
||||||
|
= new BooleanProperty(TimeCalcProperty.BAR_HIDDEN.getKey());
|
||||||
|
public final StringProperty barTypeProperty
|
||||||
|
= new StringProperty(TimeCalcProperty.BAR_TYPE.getKey());
|
||||||
|
public final IntegerProperty barHeightProperty
|
||||||
|
= new IntegerProperty(TimeCalcProperty.BAR_HEIGHT.getKey());
|
||||||
|
//
|
||||||
public final BooleanProperty walkingHumanVisibleProperty
|
public final BooleanProperty walkingHumanVisibleProperty
|
||||||
= new BooleanProperty(
|
= new BooleanProperty(
|
||||||
TimeCalcProperty.WALKING_HUMAN_VISIBLE.getKey());
|
TimeCalcProperty.WALKING_HUMAN_VISIBLE.getKey());
|
||||||
@ -341,6 +350,7 @@ public class TimeCalcConfiguration {
|
|||||||
smileysColoredProperty,
|
smileysColoredProperty,
|
||||||
squareVisibleProperty,squareTypeProperty,
|
squareVisibleProperty,squareTypeProperty,
|
||||||
circleVisibleProperty,circleTypeProperty,circleInnerCircleVisibleProperty,circleOuterCircleOnlyBorderProperty,
|
circleVisibleProperty,circleTypeProperty,circleInnerCircleVisibleProperty,circleOuterCircleOnlyBorderProperty,
|
||||||
|
barVisibleProperty, barTypeProperty, barHiddenProperty, barHeightProperty,
|
||||||
dotVisibleProperty,dotTypeProperty,
|
dotVisibleProperty,dotTypeProperty,
|
||||||
fuelVisibleProperty, fuelTypeProperty, fuelHiddenProperty,
|
fuelVisibleProperty, fuelTypeProperty, fuelHiddenProperty,
|
||||||
fuelIconVisibleProperty,
|
fuelIconVisibleProperty,
|
||||||
|
@ -105,6 +105,11 @@ public enum TimeCalcProperty {
|
|||||||
CIRCLE_INNER_CIRCLE_VISIBLE("circle.inner-circle.visible", "Circle : Inner circle"),
|
CIRCLE_INNER_CIRCLE_VISIBLE("circle.inner-circle.visible", "Circle : Inner circle"),
|
||||||
CIRCLE_OUTER_CIRCLE_ONLY_BORDER("circle.outer-circle.only-border", "Circle : Outer circle : Only border"),
|
CIRCLE_OUTER_CIRCLE_ONLY_BORDER("circle.outer-circle.only-border", "Circle : Outer circle : Only border"),
|
||||||
//
|
//
|
||||||
|
BAR_VISIBLE("bar.visible", "Bar"),
|
||||||
|
BAR_TYPE("bar.type", "Bar : Type"),
|
||||||
|
BAR_HIDDEN("bar.hidden", "Bar : Hidden"),
|
||||||
|
BAR_HEIGHT("bar.height", "Bar : Height", Integer.class),
|
||||||
|
//
|
||||||
WALKING_HUMAN_VISIBLE("walking-human.visible", "Walking Human"),
|
WALKING_HUMAN_VISIBLE("walking-human.visible", "Walking Human"),
|
||||||
WALKING_HUMAN_TYPE("walking-human.type", "Walking Human : Type"),
|
WALKING_HUMAN_TYPE("walking-human.type", "Walking Human : Type"),
|
||||||
WALKING_HUMAN_HIDDEN("walking-human.hidden", "Walking Human : Hidden"),
|
WALKING_HUMAN_HIDDEN("walking-human.hidden", "Walking Human : Hidden"),
|
||||||
|
@ -306,16 +306,21 @@ public class Widget extends JPanel implements
|
|||||||
}
|
}
|
||||||
int row = 10;
|
int row = 10;
|
||||||
int x = (int)(getWidth() > 100 ? (int) (getWidth() * 0.4) : (int) (getWidth() * 0.1));
|
int x = (int)(getWidth() > 100 ? (int) (getWidth() * 0.4) : (int) (getWidth() * 0.1));
|
||||||
brush.drawString("Show", x, row);
|
if(getHeight() <= 50) {
|
||||||
row = row + 20;
|
brush.drawString("Show" + ' ' + getHumanName(), x, row);
|
||||||
String[] nameArray = getHumanName().split(" ");
|
} else {
|
||||||
for(int i = 0; i< nameArray.length; i++) {
|
brush.drawString("Show", x, row);
|
||||||
brush.drawString(
|
row = row + 20;
|
||||||
nameArray[i],
|
String[] nameArray = getHumanName().split(" ");
|
||||||
x
|
for(int i = 0; i< nameArray.length; i++) {
|
||||||
, row);
|
brush.drawString(
|
||||||
row = row + 12;
|
nameArray[i],
|
||||||
|
x
|
||||||
|
, row);
|
||||||
|
row = row + 12;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//nothing to do
|
//nothing to do
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
package org.nanoboot.utils.timecalc.swing.progress;
|
||||||
|
|
||||||
|
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.common.Widget;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.progress.battery.Battery;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.property.BooleanProperty;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.property.IntegerProperty;
|
||||||
|
|
||||||
|
import java.awt.BasicStroke;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
|
||||||
|
public class ProgressBar extends Widget {
|
||||||
|
|
||||||
|
public IntegerProperty heightProperty = new IntegerProperty("heightProperty", 50);
|
||||||
|
public ProgressBar() {
|
||||||
|
setPreferredSize(new Dimension(600, 50));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paintWidget(Graphics g) {
|
||||||
|
Visibility visibility
|
||||||
|
= Visibility.valueOf(visibilityProperty.getValue());
|
||||||
|
Graphics2D brush = (Graphics2D) g;
|
||||||
|
brush.setColor(
|
||||||
|
visibility.isStronglyColored() || mouseOver ?
|
||||||
|
Battery.getColourForProgress(donePercent(), visibility, mouseOver)/*Color.darkGray*/
|
||||||
|
: FOREGROUND_COLOR);
|
||||||
|
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
int progressWidth = (int) (getWidth() * donePercent());
|
||||||
|
int remainsWidth = getWidth() - progressWidth;
|
||||||
|
|
||||||
|
brush.setColor(
|
||||||
|
visibility.isStronglyColored() || mouseOver ?
|
||||||
|
Color.WHITE
|
||||||
|
: BACKGROUND_COLOR);
|
||||||
|
int h = heightProperty.getValue() > getHeight() ? getHeight() :
|
||||||
|
heightProperty.getValue();
|
||||||
|
if(h < 1) {h = 1;}
|
||||||
|
brush.fillRect(0, 0, getWidth(), h);
|
||||||
|
brush.setColor(
|
||||||
|
visibility.isStronglyColored() || mouseOver ?
|
||||||
|
Battery.getColourForProgress(donePercent(), visibility, mouseOver)/*Color.darkGray*/
|
||||||
|
: FOREGROUND_COLOR);
|
||||||
|
brush.fillRect(0, 0, progressWidth, h);
|
||||||
|
brush.setColor(h <= 15 || progressWidth < 40 ? (visibility.isStronglyColored() ? Color.BLACK : Color.GRAY) : Color.WHITE);
|
||||||
|
brush.drawString(
|
||||||
|
NumberFormats.FORMATTER_ONE_DECIMAL_PLACE
|
||||||
|
.format(donePercent() * 100) + "%",
|
||||||
|
progressWidth < 40 ? 40 : progressWidth - 40,
|
||||||
|
h <= 15 ? h + 15 : 15);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -200,6 +200,16 @@ public class ConfigWindow extends TWindow {
|
|||||||
= new JCheckBox(TimeCalcProperty.CIRCLE_INNER_CIRCLE_VISIBLE.getKey());
|
= new JCheckBox(TimeCalcProperty.CIRCLE_INNER_CIRCLE_VISIBLE.getKey());
|
||||||
private final JCheckBox circleOuterCircleVisibleProperty
|
private final JCheckBox circleOuterCircleVisibleProperty
|
||||||
= new JCheckBox(TimeCalcProperty.CIRCLE_OUTER_CIRCLE_ONLY_BORDER.getKey());
|
= new JCheckBox(TimeCalcProperty.CIRCLE_OUTER_CIRCLE_ONLY_BORDER.getKey());
|
||||||
|
//
|
||||||
|
private final JCheckBox barVisibleProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.BAR_VISIBLE.getKey());
|
||||||
|
private final JTextField barTypeProperty
|
||||||
|
= new JTextField(TimeCalcProperty.BAR_TYPE.getKey());
|
||||||
|
private final JCheckBox barHiddenProperty
|
||||||
|
= new JCheckBox(TimeCalcProperty.BAR_HIDDEN.getKey());
|
||||||
|
private final JTextField barHeightProperty
|
||||||
|
= new JTextField(TimeCalcProperty.BAR_HEIGHT.getKey());
|
||||||
|
//
|
||||||
private final JCheckBox swingVisibleProperty
|
private final JCheckBox swingVisibleProperty
|
||||||
= new JCheckBox(TimeCalcProperty.SWING_VISIBLE.getKey());
|
= new JCheckBox(TimeCalcProperty.SWING_VISIBLE.getKey());
|
||||||
private final JTextField swingTypeProperty
|
private final JTextField swingTypeProperty
|
||||||
@ -475,6 +485,9 @@ public class ConfigWindow extends TWindow {
|
|||||||
circleVisibleProperty.setSelected(enable);
|
circleVisibleProperty.setSelected(enable);
|
||||||
circleInnerCircleVisibleProperty.setSelected(enable);
|
circleInnerCircleVisibleProperty.setSelected(enable);
|
||||||
circleOuterCircleVisibleProperty.setSelected(!enable);
|
circleOuterCircleVisibleProperty.setSelected(!enable);
|
||||||
|
//
|
||||||
|
barVisibleProperty.setSelected(enable);
|
||||||
|
barHeightProperty.setText("50");
|
||||||
swingVisibleProperty.setSelected(enable);
|
swingVisibleProperty.setSelected(enable);
|
||||||
swingQuarterIconVisibleProperty.setSelected(enable);
|
swingQuarterIconVisibleProperty.setSelected(enable);
|
||||||
walkingHumanVisibleProperty.setSelected(enable);
|
walkingHumanVisibleProperty.setSelected(enable);
|
||||||
@ -566,6 +579,7 @@ public class ConfigWindow extends TWindow {
|
|||||||
notificationsVisibleProperty,
|
notificationsVisibleProperty,
|
||||||
squareVisibleProperty,squareHiddenProperty,squareTypeProperty,
|
squareVisibleProperty,squareHiddenProperty,squareTypeProperty,
|
||||||
circleVisibleProperty,circleHiddenProperty,circleTypeProperty,circleInnerCircleVisibleProperty,circleOuterCircleVisibleProperty,
|
circleVisibleProperty,circleHiddenProperty,circleTypeProperty,circleInnerCircleVisibleProperty,circleOuterCircleVisibleProperty,
|
||||||
|
barVisibleProperty, barHiddenProperty, barTypeProperty, barHeightProperty,
|
||||||
dotVisibleProperty,dotHiddenProperty,dotTypeProperty,
|
dotVisibleProperty,dotHiddenProperty,dotTypeProperty,
|
||||||
fuelVisibleProperty,fuelTypeProperty,fuelHiddenProperty,fuelIconVisibleProperty,
|
fuelVisibleProperty,fuelTypeProperty,fuelHiddenProperty,fuelIconVisibleProperty,
|
||||||
rotationVisibleProperty, rotationTypeProperty, rotationHiddenProperty,
|
rotationVisibleProperty, rotationTypeProperty, rotationHiddenProperty,
|
||||||
@ -985,7 +999,7 @@ public class ConfigWindow extends TWindow {
|
|||||||
index = 5;
|
index = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key.startsWith("square.")||key.startsWith("circle.")||key.startsWith("dot.")||key.startsWith("swing.")||key.startsWith("walking-human.") || key.startsWith("fuel.") || key.startsWith("rotation.")) {
|
if (key.startsWith("square.")||key.startsWith("circle.")||key.startsWith("dot.")||key.startsWith("swing.")||key.startsWith("walking-human.") || key.startsWith("fuel.") || key.startsWith("rotation.") || key.startsWith("bar.")) {
|
||||||
index = 6;
|
index = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import org.nanoboot.utils.timecalc.swing.controls.TLabel;
|
|||||||
import org.nanoboot.utils.timecalc.swing.controls.TTextField;
|
import org.nanoboot.utils.timecalc.swing.controls.TTextField;
|
||||||
import org.nanoboot.utils.timecalc.swing.controls.TWindow;
|
import org.nanoboot.utils.timecalc.swing.controls.TWindow;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.AnalogClock;
|
import org.nanoboot.utils.timecalc.swing.progress.AnalogClock;
|
||||||
|
import org.nanoboot.utils.timecalc.swing.progress.ProgressBar;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressRotation;
|
import org.nanoboot.utils.timecalc.swing.progress.ProgressRotation;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.battery.Battery;
|
import org.nanoboot.utils.timecalc.swing.progress.battery.Battery;
|
||||||
import org.nanoboot.utils.timecalc.swing.progress.battery.DayBattery;
|
import org.nanoboot.utils.timecalc.swing.progress.battery.DayBattery;
|
||||||
@ -122,6 +123,7 @@ public class MainWindow extends TWindow {
|
|||||||
private final ProgressWeather progressWeather;
|
private final ProgressWeather progressWeather;
|
||||||
private final ProgressFuelGauge progressFuelGauge;
|
private final ProgressFuelGauge progressFuelGauge;
|
||||||
private final ProgressRotation progressRotation;
|
private final ProgressRotation progressRotation;
|
||||||
|
private final ProgressBar progressBar;
|
||||||
private HelpWindow helpWindow = null;
|
private HelpWindow helpWindow = null;
|
||||||
private ConfigWindow configWindow = null;
|
private ConfigWindow configWindow = null;
|
||||||
private ActivitiesWindow activitiesWindow = null;
|
private ActivitiesWindow activitiesWindow = null;
|
||||||
@ -451,6 +453,21 @@ public class MainWindow extends TWindow {
|
|||||||
|
|
||||||
add(progressRotation);
|
add(progressRotation);
|
||||||
//
|
//
|
||||||
|
this.progressBar = new ProgressBar();
|
||||||
|
progressBar.setBounds(progressSwing.getX(), progressSwing.getY() + progressSwing.getHeight() + SwingUtils.MARGIN,
|
||||||
|
progressRotation.getX() + progressRotation.getWidth() - 2 * SwingUtils.MARGIN, 50);
|
||||||
|
|
||||||
|
progressBar.visibleProperty
|
||||||
|
.bindTo(timeCalcConfiguration.barVisibleProperty);
|
||||||
|
progressBar.typeProperty
|
||||||
|
.bindTo(timeCalcConfiguration.barTypeProperty);
|
||||||
|
progressBar.hiddenProperty
|
||||||
|
.bindTo(timeCalcConfiguration.barHiddenProperty);
|
||||||
|
progressBar.heightProperty
|
||||||
|
.bindTo(timeCalcConfiguration.barHeightProperty);
|
||||||
|
|
||||||
|
add(progressBar);
|
||||||
|
//
|
||||||
|
|
||||||
{
|
{
|
||||||
progressSquare.typeProperty
|
progressSquare.typeProperty
|
||||||
@ -499,7 +516,7 @@ public class MainWindow extends TWindow {
|
|||||||
progressWeather.hiddenProperty.bindTo(timeCalcConfiguration.weatherHiddenProperty);
|
progressWeather.hiddenProperty.bindTo(timeCalcConfiguration.weatherHiddenProperty);
|
||||||
}
|
}
|
||||||
TLabel arrivalTextFieldLabel = new TLabel("Arrival:", 70);
|
TLabel arrivalTextFieldLabel = new TLabel("Arrival:", 70);
|
||||||
arrivalTextFieldLabel.setBoundsFromTop(progressSwing, 3);
|
arrivalTextFieldLabel.setBoundsFromTop(progressBar, 3);
|
||||||
|
|
||||||
arrivalTextField.setBoundsFromLeft(arrivalTextFieldLabel);
|
arrivalTextField.setBoundsFromLeft(arrivalTextFieldLabel);
|
||||||
TButton arrivalIncreaseButton = new SmallTButton('+');
|
TButton arrivalIncreaseButton = new SmallTButton('+');
|
||||||
@ -1089,7 +1106,7 @@ public class MainWindow extends TWindow {
|
|||||||
long diff = now - Files.getLastModifiedTime(file.toPath()).toMillis();
|
long diff = now - Files.getLastModifiedTime(file.toPath()).toMillis();
|
||||||
int fileAgeInDays = (int) (diff / 1000 / 60 / 60 / 24);
|
int fileAgeInDays = (int) (diff / 1000 / 60 / 60 / 24);
|
||||||
System.out.println("Found backup file " + file.getName() + " with age: " + fileAgeInDays);
|
System.out.println("Found backup file " + file.getName() + " with age: " + fileAgeInDays);
|
||||||
if (fileAgeInDays > 14) {
|
if (fileAgeInDays > 28) {
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1329,6 +1346,7 @@ public class MainWindow extends TWindow {
|
|||||||
progressDot.setProgress(progress);
|
progressDot.setProgress(progress);
|
||||||
progressFuelGauge.setProgress(progress);
|
progressFuelGauge.setProgress(progress);
|
||||||
progressRotation.setProgress(progress);
|
progressRotation.setProgress(progress);
|
||||||
|
progressBar.setProgress(progress);
|
||||||
dayBattery.setProgress(progress);
|
dayBattery.setProgress(progress);
|
||||||
|
|
||||||
monthBattery.setProgress(progress);
|
monthBattery.setProgress(progress);
|
||||||
|
@ -60,6 +60,10 @@ circle.type=day
|
|||||||
circle.hidden=false
|
circle.hidden=false
|
||||||
circle.inner-circle.visible=true
|
circle.inner-circle.visible=true
|
||||||
circle.outer-circle.only-border=false
|
circle.outer-circle.only-border=false
|
||||||
|
bar.visible=true
|
||||||
|
bar.type=day
|
||||||
|
bar.hidden=false
|
||||||
|
bar.height=20
|
||||||
dot.visible=true
|
dot.visible=true
|
||||||
dot.type=day
|
dot.type=day
|
||||||
dot.hidden=false
|
dot.hidden=false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user