Added ProgressWater
This commit is contained in:
parent
0d2b89750a
commit
4c5823e6a2
@ -224,6 +224,13 @@ public class TimeCalcConfiguration {
|
||||
= new StringProperty(TimeCalcProperty.BAR_TYPE.getKey());
|
||||
public final IntegerProperty barHeightProperty
|
||||
= new IntegerProperty(TimeCalcProperty.BAR_HEIGHT.getKey());
|
||||
//
|
||||
public final BooleanProperty waterVisibleProperty
|
||||
= new BooleanProperty(TimeCalcProperty.WATER_VISIBLE.getKey());
|
||||
public final BooleanProperty waterHiddenProperty
|
||||
= new BooleanProperty(TimeCalcProperty.WATER_HIDDEN.getKey());
|
||||
public final StringProperty waterTypeProperty
|
||||
= new StringProperty(TimeCalcProperty.WATER_TYPE.getKey());
|
||||
|
||||
|
||||
//
|
||||
@ -362,6 +369,7 @@ public class TimeCalcConfiguration {
|
||||
squareVisibleProperty,squareTypeProperty,
|
||||
circleVisibleProperty,circleTypeProperty,circleInnerCircleVisibleProperty,circleOuterCircleOnlyBorderProperty,
|
||||
barVisibleProperty, barTypeProperty, barHiddenProperty, barHeightProperty,
|
||||
waterVisibleProperty, waterTypeProperty, waterHiddenProperty,
|
||||
colorVisibleProperty, colorTypeProperty, colorHiddenProperty, colorHeightProperty,
|
||||
dotVisibleProperty,dotTypeProperty,
|
||||
fuelVisibleProperty, fuelTypeProperty, fuelHiddenProperty,
|
||||
|
@ -110,6 +110,10 @@ public enum TimeCalcProperty {
|
||||
BAR_HIDDEN("bar.hidden", "Bar : Hidden"),
|
||||
BAR_HEIGHT("bar.height", "Bar : Height", Integer.class),
|
||||
//
|
||||
WATER_VISIBLE("water.visible", "Water"),
|
||||
WATER_TYPE("water.type", "Water : Type"),
|
||||
WATER_HIDDEN("water.hidden", "Water : Hidden"),
|
||||
//
|
||||
COLOR_VISIBLE("color.visible", "Color"),
|
||||
COLOR_TYPE("color.type", "Color : Type"),
|
||||
COLOR_HIDDEN("color.hidden", "Color : Hidden"),
|
||||
|
@ -4,10 +4,8 @@ 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;
|
||||
|
@ -0,0 +1,74 @@
|
||||
package org.nanoboot.utils.timecalc.swing.progress;
|
||||
|
||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||
import org.nanoboot.utils.timecalc.swing.common.Widget;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
|
||||
public class ProgressWater extends Widget {
|
||||
|
||||
public ProgressWater() {
|
||||
System.out.println("Starting ProgressWater");
|
||||
setPreferredSize(new Dimension(100, 400));
|
||||
}
|
||||
|
||||
private static final Color WATER_COLOR = new Color(128, 197, 222);
|
||||
|
||||
@Override
|
||||
public void paintWidget(Graphics g) {
|
||||
|
||||
Visibility visibility
|
||||
= Visibility.valueOf(visibilityProperty.getValue());
|
||||
Graphics2D brush = (Graphics2D) g;
|
||||
brush.setColor(
|
||||
visibility.isStronglyColored() || mouseOver ?
|
||||
WATER_COLOR
|
||||
: FOREGROUND_COLOR);
|
||||
brush.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
int tankHeight = (int) (getHeight() * 0.48);
|
||||
|
||||
int doneWaterHeight = (int) (tankHeight * (donePercent()));
|
||||
|
||||
int h = getHeight() - 1;
|
||||
int w = getWidth() - 1;
|
||||
int w48 = (int) (w * 0.48);
|
||||
int w52 = (int) (w * 0.52);
|
||||
int h48 = (int) (h * 0.48);
|
||||
int h52 = (int) (h * 0.52);
|
||||
|
||||
int w4 = (int) (w * 0.04);
|
||||
int h4 = (int) (h * 0.04);
|
||||
|
||||
brush.fillRect(2, doneWaterHeight, w - 1,
|
||||
(int) (tankHeight * (1d - donePercent())));
|
||||
brush.fillRect(2, h - doneWaterHeight, w - 1,
|
||||
(int) (tankHeight * (donePercent())));
|
||||
if(donePercent() < 1d) {
|
||||
brush.fillRect(w48, h48, w4 + 1, h4 + tankHeight);
|
||||
}
|
||||
brush.setColor(
|
||||
visibility.isStronglyColored() || mouseOver ?
|
||||
Color.BLACK : FOREGROUND_COLOR);
|
||||
|
||||
brush.drawPolyline(
|
||||
new int[] {w48, 1, 1, w, w, w52},
|
||||
new int[] {h48, h48, 1, 1,
|
||||
h48, h48},
|
||||
6);
|
||||
|
||||
brush.drawPolyline(
|
||||
new int[] {w52, w, w, 1, 1, w48},
|
||||
new int[] {h52, h52, h, h,
|
||||
h52, h52},
|
||||
6);
|
||||
brush.drawLine(w48, h48, w48, h52);
|
||||
brush.drawLine(w52, h48, w52, h52);
|
||||
}
|
||||
|
||||
}
|
@ -210,6 +210,13 @@ public class ConfigWindow extends TWindow {
|
||||
private final JTextField barHeightProperty
|
||||
= new JTextField(TimeCalcProperty.BAR_HEIGHT.getKey());
|
||||
//
|
||||
private final JCheckBox waterVisibleProperty
|
||||
= new JCheckBox(TimeCalcProperty.WATER_VISIBLE.getKey());
|
||||
private final JTextField waterTypeProperty
|
||||
= new JTextField(TimeCalcProperty.WATER_TYPE.getKey());
|
||||
private final JCheckBox waterHiddenProperty
|
||||
= new JCheckBox(TimeCalcProperty.WATER_HIDDEN.getKey());
|
||||
//
|
||||
private final JCheckBox colorVisibleProperty
|
||||
= new JCheckBox(TimeCalcProperty.COLOR_VISIBLE.getKey());
|
||||
private final JTextField colorTypeProperty
|
||||
@ -497,6 +504,7 @@ public class ConfigWindow extends TWindow {
|
||||
//
|
||||
barVisibleProperty.setSelected(enable);
|
||||
barHeightProperty.setText("50");
|
||||
waterVisibleProperty.setSelected(enable);
|
||||
colorVisibleProperty.setSelected(enable);
|
||||
colorHeightProperty.setText("50");
|
||||
swingVisibleProperty.setSelected(enable);
|
||||
@ -591,6 +599,7 @@ public class ConfigWindow extends TWindow {
|
||||
squareVisibleProperty,squareHiddenProperty,squareTypeProperty,
|
||||
circleVisibleProperty,circleHiddenProperty,circleTypeProperty,circleInnerCircleVisibleProperty,circleOuterCircleVisibleProperty,
|
||||
barVisibleProperty, barHiddenProperty, barTypeProperty, barHeightProperty,
|
||||
waterVisibleProperty, waterHiddenProperty, waterTypeProperty,
|
||||
colorVisibleProperty, colorHiddenProperty, colorTypeProperty, colorHeightProperty,
|
||||
dotVisibleProperty,dotHiddenProperty,dotTypeProperty,
|
||||
fuelVisibleProperty,fuelTypeProperty,fuelHiddenProperty,fuelIconVisibleProperty,
|
||||
@ -1011,7 +1020,18 @@ public class ConfigWindow extends TWindow {
|
||||
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.") || key.startsWith("bar.") || key.startsWith("color.")) {
|
||||
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.") ||
|
||||
key.startsWith("color.") ||
|
||||
key.startsWith("water.")
|
||||
) {
|
||||
index = 6;
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ import org.nanoboot.utils.timecalc.swing.progress.ProgressMoney;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressRotation;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressSquare;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressSwing;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressWater;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.Time;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.WalkingHumanProgress;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.battery.Battery;
|
||||
@ -142,6 +143,7 @@ public class MainWindow extends TWindow {
|
||||
private final ProgressRotation progressRotation;
|
||||
private final ProgressBar progressBar;
|
||||
private final ProgressColor progressColor;
|
||||
private final ProgressWater progressWater;
|
||||
private final JLabel hourGlassElapsedDayIcon;
|
||||
private final JLabel hourGlassRemainsDayIcon;
|
||||
private final JLabel hourGlassElapsedWeekIcon;
|
||||
@ -547,6 +549,21 @@ public class MainWindow extends TWindow {
|
||||
add(progressColor);
|
||||
//
|
||||
|
||||
this.progressWater = new ProgressWater();
|
||||
progressWater.setBounds(progressSquare.getX() + progressSquare.getWidth() + 4 * SwingUtils.MARGIN,
|
||||
progressSquare.getY(),
|
||||
100, 550 /*exitButton.getY() + exitButton.getHeight() - SwingUtils.MARGIN*/);
|
||||
|
||||
progressWater.visibleProperty
|
||||
.bindTo(timeCalcConfiguration.waterVisibleProperty);
|
||||
progressWater.typeProperty
|
||||
.bindTo(timeCalcConfiguration.waterTypeProperty);
|
||||
progressWater.hiddenProperty
|
||||
.bindTo(timeCalcConfiguration.waterHiddenProperty);
|
||||
|
||||
add(progressWater);
|
||||
//
|
||||
|
||||
{
|
||||
progressSquare.typeProperty
|
||||
.bindTo(timeCalcConfiguration.squareTypeProperty);
|
||||
@ -1005,8 +1022,10 @@ public class MainWindow extends TWindow {
|
||||
widget.typeVisibleProperty.bindTo(timeCalcConfiguration.typeVisibleProperty);
|
||||
}
|
||||
);
|
||||
setSize(progressSquare.getX() + progressSquare.getWidth()
|
||||
+ 5 * SwingUtils.MARGIN,
|
||||
|
||||
int standardWidth = progressSquare.getX() + progressSquare.getWidth()
|
||||
+ 5 * SwingUtils.MARGIN;
|
||||
setSize(standardWidth,
|
||||
focusButton.getY() + focusButton.getHeight() + SwingUtils.MARGIN
|
||||
+ focusButton.getHeight() + 2 * SwingUtils.MARGIN);
|
||||
|
||||
@ -1247,6 +1266,9 @@ public class MainWindow extends TWindow {
|
||||
if(ONLY_ACTIVITIES_WINDOW_IS_ALLOWED) {
|
||||
break;
|
||||
}
|
||||
setSize(standardWidth + (timeCalcConfiguration.waterVisibleProperty.isEnabled() ? 120 : 0),
|
||||
focusButton.getY() + focusButton.getHeight() + SwingUtils.MARGIN
|
||||
+ focusButton.getHeight() + 2 * SwingUtils.MARGIN);
|
||||
|
||||
boolean stronglyColored = Visibility
|
||||
.valueOf(timeCalcApp.visibilityProperty.getValue())
|
||||
@ -1625,6 +1647,7 @@ public class MainWindow extends TWindow {
|
||||
progressRotation.setProgress(progress);
|
||||
progressBar.setProgress(progress);
|
||||
progressColor.setProgress(progress);
|
||||
progressWater.setProgress(progress);
|
||||
dayBattery.setProgress(progress);
|
||||
|
||||
monthBattery.setProgress(progress);
|
||||
|
@ -64,6 +64,9 @@ bar.visible=true
|
||||
bar.type=day
|
||||
bar.hidden=false
|
||||
bar.height=25
|
||||
water.visible=true
|
||||
water.type=day
|
||||
water.hidden=false
|
||||
color.visible=true
|
||||
color.type=day
|
||||
color.hidden=false
|
||||
|
Loading…
x
Reference in New Issue
Block a user