Added fuel gauge
This commit is contained in:
parent
a9ee1ed4c9
commit
12371d8bb3
@ -191,6 +191,12 @@ public class TimeCalcConfiguration {
|
||||
= new BooleanProperty(TimeCalcProperty.DOT_HIDDEN.getKey());
|
||||
public final StringProperty dotTypeProperty
|
||||
= new StringProperty(TimeCalcProperty.DOT_TYPE.getKey());
|
||||
public final BooleanProperty fuelVisibleProperty
|
||||
= new BooleanProperty(TimeCalcProperty.FUEL_VISIBLE.getKey());
|
||||
public final BooleanProperty fuelHiddenProperty
|
||||
= new BooleanProperty(TimeCalcProperty.FUEL_HIDDEN.getKey());
|
||||
public final StringProperty fuelTypeProperty
|
||||
= new StringProperty(TimeCalcProperty.FUEL_TYPE.getKey());
|
||||
public final BooleanProperty circleVisibleProperty
|
||||
= new BooleanProperty(TimeCalcProperty.CIRCLE_VISIBLE.getKey());
|
||||
public final BooleanProperty circleHiddenProperty
|
||||
@ -318,12 +324,10 @@ public class TimeCalcConfiguration {
|
||||
smileysVisibleProperty,
|
||||
smileysVisibleOnlyIfMouseMovingOverProperty,
|
||||
smileysColoredProperty,
|
||||
squareVisibleProperty,
|
||||
squareTypeProperty,
|
||||
dotVisibleProperty,
|
||||
dotTypeProperty,
|
||||
circleVisibleProperty,
|
||||
circleTypeProperty,
|
||||
squareVisibleProperty,squareTypeProperty,
|
||||
circleVisibleProperty,circleTypeProperty,
|
||||
dotVisibleProperty,dotTypeProperty,
|
||||
fuelVisibleProperty, fuelTypeProperty, fuelHiddenProperty,
|
||||
swingVisibleProperty,
|
||||
swingTypeProperty,
|
||||
swingQuarterIconVisibleProperty,
|
||||
|
@ -92,6 +92,9 @@ public enum TimeCalcProperty {
|
||||
DOT_VISIBLE("dot.visible", "Dot"),
|
||||
DOT_TYPE("dot.type", "Dot : Type"),
|
||||
DOT_HIDDEN("dot.hidden", "Dot : Hidden"),
|
||||
FUEL_VISIBLE("fuel.visible", "Fuel"),
|
||||
FUEL_TYPE("fuel.type", "Fuel : Type"),
|
||||
FUEL_HIDDEN("fuel.hidden", "Fuel : Hidden"),
|
||||
CIRCLE_VISIBLE("circle.visible", "Circle"),
|
||||
CIRCLE_TYPE("circle.type", "Circle : Type"),
|
||||
CIRCLE_HIDDEN("circle.hidden", "Circle : Hidden"),
|
||||
|
@ -0,0 +1,142 @@
|
||||
package org.nanoboot.utils.timecalc.swing.progress.weather;
|
||||
|
||||
import org.nanoboot.utils.timecalc.app.GetProperty;
|
||||
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.Widget;
|
||||
import org.nanoboot.utils.timecalc.swing.windows.MainWindow;
|
||||
import org.nanoboot.utils.timecalc.utils.common.NumberFormats;
|
||||
import org.nanoboot.utils.timecalc.utils.property.Property;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.Timer;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* @author Robert Vokac
|
||||
* @since 21.02.2024
|
||||
*/
|
||||
public class ProgressFuelGauge extends Widget implements GetProperty {
|
||||
|
||||
public static final Color BLACK2 = new Color(32, 32, 32);
|
||||
public static final Color LIGHT_GRAY2 = new Color(160,160,160);
|
||||
|
||||
private List<JMenuItem> menuItems = null;
|
||||
|
||||
public ProgressFuelGauge() {
|
||||
|
||||
setFont(new Font(Font.MONOSPACED, Font.PLAIN, 11));
|
||||
|
||||
setFocusable(false);
|
||||
setForeground(Color.GRAY);
|
||||
setBackground(MainWindow.BACKGROUND_COLOR);
|
||||
this.typeProperty.setValue(WidgetType.DAY.name().toLowerCase(Locale.ROOT));
|
||||
|
||||
new Timer(100, e -> {
|
||||
Visibility visibility
|
||||
= Visibility.valueOf(visibilityProperty.getValue());
|
||||
setForeground(
|
||||
visibility.isStronglyColored()
|
||||
|| mouseOver
|
||||
? Color.BLACK : Color.LIGHT_GRAY);
|
||||
}).start();
|
||||
|
||||
}
|
||||
|
||||
public int getTimerDelay() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintWidget(Graphics brush) {
|
||||
|
||||
((Graphics2D)brush).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
Visibility visibility
|
||||
= Visibility.valueOf(visibilityProperty.getValue());
|
||||
|
||||
brush.setColor(visibility.isStronglyColored() ? Color.BLACK
|
||||
: visibility.isWeaklyColored() ? Color.GRAY
|
||||
: Color.LIGHT_GRAY);
|
||||
brush.setFont(SwingUtils.MEDIUM_MONOSPACE_FONT);
|
||||
brush.fillRect(1, 1, getWidth(), getHeight());
|
||||
brush.setColor(visibility.isStronglyColored() ? BLACK2
|
||||
: visibility.isWeaklyColored() ? Color.LIGHT_GRAY
|
||||
: LIGHT_GRAY2);
|
||||
int ovalWidth = (int) (getWidth() * 0.4);
|
||||
brush.fillOval(
|
||||
(int)((getWidth() - ovalWidth) /2d),
|
||||
(int) (getHeight() * 0.6),
|
||||
ovalWidth,
|
||||
ovalWidth
|
||||
);
|
||||
brush.setColor(Color.WHITE);
|
||||
|
||||
|
||||
int startX = getWidth() / 2;
|
||||
int startY = getHeight() - (ovalWidth / 2);
|
||||
int length = (int) (ovalWidth * 1.5d);
|
||||
double angle = Math.PI * 2 * (donePercent() * 0.25d + 2.5d * 0.25d);
|
||||
int endX = (int) (startX + length * Math.cos(angle));
|
||||
int endY = (int) (startY + length * Math.sin(angle));
|
||||
|
||||
((Graphics2D)brush).setStroke(new BasicStroke(3f));
|
||||
brush.drawLine(startX, startY, endX, endY);
|
||||
//
|
||||
length = (int) (ovalWidth / 2d * 0.9d);
|
||||
angle = Math.PI * 2 * (donePercent() * 0.25d + 2.5d * 0.25d + 0.5d);
|
||||
endX = (int) (startX + length * Math.cos(angle));
|
||||
endY = (int) (startY + length * Math.sin(angle));
|
||||
|
||||
brush.drawLine(startX, startY, endX, endY);
|
||||
//
|
||||
((Graphics2D)brush).setStroke(new BasicStroke(1f));
|
||||
int length_ = (int) (ovalWidth * 1.5d);
|
||||
//brush.drawOval(startX - length_, startY - length_, (int)(length_ * 2d), (int)(length_ * 2d));
|
||||
brush.drawArc(startX - length_, startY - length_ - 2, (int)(length_ * 2d), (int)(length_ * 2d), 180 + 45, 180 + 45 + 90);
|
||||
brush.drawArc(startX - length_, startY - length_ + 6, (int)(length_ * 2d), (int)(length_ * 2d), 180 + 45, 180 + 45 + 90);
|
||||
|
||||
brush.setColor(visibility.isStronglyColored() ? Color.BLACK
|
||||
: visibility.isWeaklyColored() ? Color.GRAY
|
||||
: Color.LIGHT_GRAY);
|
||||
int width_ = (int) (ovalWidth / 4d);
|
||||
brush.fillOval(
|
||||
(int) (startX - width_ / 2d),
|
||||
(int) (startY - width_ / 2d),
|
||||
width_,
|
||||
width_
|
||||
);
|
||||
this.setToolTipText(NumberFormats.FORMATTER_TWO_DECIMAL_PLACES.format(donePercent() * 100d) + "%");
|
||||
}
|
||||
|
||||
//private boolean w = false;
|
||||
|
||||
@Override
|
||||
public Property getVisibilityProperty() {
|
||||
return visibilityProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getVisibilitySupportedColoredProperty() {
|
||||
return visibilitySupportedColoredProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JMenuItem> createAdditionalMenus() {
|
||||
if (this.menuItems == null) {
|
||||
menuItems = new ArrayList<>();
|
||||
|
||||
}
|
||||
return this.menuItems;
|
||||
}
|
||||
}
|
@ -234,7 +234,13 @@ public class ConfigWindow extends TWindow {
|
||||
= new JCheckBox(TimeCalcProperty.SPEED_NEGATIVE.getKey());
|
||||
public final JCheckBox speedFloatingProperty
|
||||
= new JCheckBox(TimeCalcProperty.SPEED_FLOATING.getKey());
|
||||
|
||||
//
|
||||
private final JCheckBox fuelVisibleProperty
|
||||
= new JCheckBox(TimeCalcProperty.FUEL_VISIBLE.getKey());
|
||||
private final JTextField fuelTypeProperty =
|
||||
new JTextField(TimeCalcProperty.FUEL_TYPE.getKey());
|
||||
private final JCheckBox fuelHiddenProperty
|
||||
= new JCheckBox(TimeCalcProperty.FUEL_HIDDEN.getKey());
|
||||
//
|
||||
public final JCheckBox clockHiddenProperty
|
||||
= new JCheckBox(TimeCalcProperty.CLOCK_HIDDEN.getKey());
|
||||
@ -455,6 +461,7 @@ public class ConfigWindow extends TWindow {
|
||||
swingVisibleProperty.setSelected(enable);
|
||||
swingQuarterIconVisibleProperty.setSelected(enable);
|
||||
walkingHumanVisibleProperty.setSelected(enable);
|
||||
fuelVisibleProperty.setSelected(enable);
|
||||
// clockHiddenProperty.setSelected(!enable);
|
||||
// batteryMinuteHiddenProperty.setSelected(!enable);
|
||||
// batteryHourHiddenProperty.setSelected(!enable);
|
||||
@ -525,9 +532,7 @@ public class ConfigWindow extends TWindow {
|
||||
batteryBlinkingIfCriticalLowVisibleProperty,
|
||||
batteryQuarterIconVisibleProperty,
|
||||
//
|
||||
smileysVisibleProperty,
|
||||
smileysVisibleOnlyIfMouseMovingOverProperty,
|
||||
smileysColoredProperty,
|
||||
smileysVisibleProperty,smileysVisibleOnlyIfMouseMovingOverProperty,smileysColoredProperty,
|
||||
testEnabledProperty,
|
||||
testClockCustomYearProperty,
|
||||
testClockCustomMonthProperty,
|
||||
@ -539,33 +544,15 @@ public class ConfigWindow extends TWindow {
|
||||
jokesVisibleProperty,
|
||||
commandsVisibleProperty,
|
||||
notificationsVisibleProperty,
|
||||
squareVisibleProperty,
|
||||
squareHiddenProperty,
|
||||
squareTypeProperty,
|
||||
circleVisibleProperty,
|
||||
circleHiddenProperty,
|
||||
circleTypeProperty,
|
||||
dotVisibleProperty,
|
||||
dotHiddenProperty,
|
||||
dotTypeProperty,
|
||||
swingVisibleProperty,
|
||||
swingHiddenProperty,
|
||||
swingTypeProperty,
|
||||
swingQuarterIconVisibleProperty,
|
||||
walkingHumanVisibleProperty,
|
||||
walkingHumanHiddenProperty,
|
||||
walkingHumanTypeProperty,
|
||||
lifeVisibleProperty,
|
||||
lifeHiddenProperty,
|
||||
lifeTypeProperty,
|
||||
lifeBirthDateProperty,
|
||||
moneyVisibleProperty,
|
||||
moneyHiddenProperty,
|
||||
moneyTypeProperty,
|
||||
moneyPerMonthProperty,
|
||||
moneyCurrencyProperty,
|
||||
weatherVisibleProperty,
|
||||
weatherHiddenProperty,
|
||||
squareVisibleProperty,squareHiddenProperty,squareTypeProperty,
|
||||
circleVisibleProperty,circleHiddenProperty,circleTypeProperty,
|
||||
dotVisibleProperty,dotHiddenProperty,dotTypeProperty,
|
||||
fuelVisibleProperty,fuelTypeProperty,fuelHiddenProperty,
|
||||
swingVisibleProperty,swingHiddenProperty,swingTypeProperty,swingQuarterIconVisibleProperty,
|
||||
walkingHumanVisibleProperty,walkingHumanHiddenProperty,walkingHumanTypeProperty,
|
||||
lifeVisibleProperty,lifeHiddenProperty,lifeTypeProperty,lifeBirthDateProperty,
|
||||
moneyVisibleProperty,moneyHiddenProperty,moneyTypeProperty,moneyPerMonthProperty,moneyCurrencyProperty,
|
||||
weatherVisibleProperty,weatherHiddenProperty,
|
||||
mainWindowCustomTitleProperty,
|
||||
profileNameProperty,
|
||||
activityNeededFlagsProperty,
|
||||
|
@ -37,6 +37,7 @@ import org.nanoboot.utils.timecalc.swing.progress.ProgressLife;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressMoney;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressSquare;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.ProgressSwing;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.weather.ProgressFuelGauge;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.weather.ProgressWeather;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.Time;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.WalkingHumanProgress;
|
||||
@ -110,6 +111,7 @@ public class MainWindow extends TWindow {
|
||||
private final ProgressLife progressLife;
|
||||
private final ProgressMoney progressMoney;
|
||||
private final ProgressWeather progressWeather;
|
||||
private final ProgressFuelGauge progressFuelGauge;
|
||||
private HelpWindow helpWindow = null;
|
||||
private ConfigWindow configWindow = null;
|
||||
private ActivitiesWindow activitiesWindow = null;
|
||||
@ -409,10 +411,21 @@ public class MainWindow extends TWindow {
|
||||
progressDot.setBounds(progressWeather.getX() + progressWeather.getWidth() + SwingUtils.MARGIN, progressWeather.getY(),
|
||||
100, 100);
|
||||
|
||||
progressDot.visibleProperty
|
||||
.bindTo(timeCalcConfiguration.weatherVisibleProperty);
|
||||
add(progressDot);
|
||||
|
||||
this.progressFuelGauge = new ProgressFuelGauge();
|
||||
progressFuelGauge.setBounds(progressDot.getX() + progressDot.getWidth() + SwingUtils.MARGIN, progressDot.getY(),
|
||||
100, 100);
|
||||
|
||||
progressFuelGauge.visibleProperty
|
||||
.bindTo(timeCalcConfiguration.fuelVisibleProperty);
|
||||
progressFuelGauge.typeProperty
|
||||
.bindTo(timeCalcConfiguration.fuelTypeProperty);
|
||||
progressFuelGauge.hiddenProperty
|
||||
.bindTo(timeCalcConfiguration.fuelHiddenProperty);
|
||||
|
||||
add(progressFuelGauge);
|
||||
|
||||
{
|
||||
progressSquare.typeProperty
|
||||
.bindTo(timeCalcConfiguration.squareTypeProperty);
|
||||
@ -1274,6 +1287,7 @@ public class MainWindow extends TWindow {
|
||||
progressLife.setProgress(progress);
|
||||
progressMoney.setProgress(progress);
|
||||
progressDot.setProgress(progress);
|
||||
progressFuelGauge.setProgress(progress);
|
||||
dayBattery.setProgress(progress);
|
||||
|
||||
monthBattery.setProgress(progress);
|
||||
|
@ -55,12 +55,15 @@ smileys.colored=true
|
||||
square.visible=true
|
||||
square.type=day
|
||||
square.hidden=false
|
||||
dot.visible=true
|
||||
dot.type=day
|
||||
dot.hidden=false
|
||||
circle.visible=true
|
||||
circle.type=day
|
||||
circle.hidden=false
|
||||
dot.visible=true
|
||||
dot.type=day
|
||||
dot.hidden=false
|
||||
fuel.visible=true
|
||||
fuel.type=day
|
||||
fuel.hidden=false
|
||||
swing.visible=true
|
||||
swing.type=day
|
||||
swing.hidden=false
|
||||
|
Loading…
x
Reference in New Issue
Block a user