From c54910528425c919c008f59ff854764cc2c12db6 Mon Sep 17 00:00:00 2001 From: Robert Vokac Date: Thu, 28 Mar 2024 14:37:10 +0100 Subject: [PATCH] Fixed Fuel Gauge icon - should be rendered just after rendering the background --- .../swing/progress/ProgressFuelGauge.java | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressFuelGauge.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressFuelGauge.java index 8d23bbd..12a0560 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressFuelGauge.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/ProgressFuelGauge.java @@ -93,6 +93,27 @@ public class ProgressFuelGauge extends Widget implements GetProperty { : Color.LIGHT_GRAY); brush.setFont(SwingUtils.MEDIUM_MONOSPACE_FONT); brush.fillRect(1, 1, getWidth(), getHeight()); + + if (fuelIconVisibleProperty.isEnabled() && visibility == Visibility.STRONGLY_COLORED) { + if(this.orangeIcon == null) { + try { + this.orangeIcon = ImageIO.read(getClass().getResource( + FUEL_GAUGE_FUEL_GAUGE_ICON_ORANGE_PNG)); + } catch (IOException e) { + e.printStackTrace(); + } + } + if(this.darkGrayIcon == null) { + try { + this.darkGrayIcon = ImageIO.read(getClass().getResource( + FUEL_GAUGE_FUEL_GAUGE_ICON_DARK_GRAY_PNG)); + } catch (IOException e) { + e.printStackTrace(); + } + } + brush.drawImage(donePercent() <= 0.15d ? this.orangeIcon : this.darkGrayIcon, getWidth() - 32, getHeight() - 48, 32, 32, null); + + } brush.setColor(visibility.isStronglyColored() ? BLACK2 : visibility.isWeaklyColored() ? Color.LIGHT_GRAY : LIGHT_GRAY2); @@ -176,27 +197,6 @@ public class ProgressFuelGauge extends Widget implements GetProperty { ); brush.setColor(Color.WHITE); - if (fuelIconVisibleProperty.isEnabled()) { - if(this.orangeIcon == null) { - try { - this.orangeIcon = ImageIO.read(getClass().getResource( - FUEL_GAUGE_FUEL_GAUGE_ICON_ORANGE_PNG)); - } catch (IOException e) { - e.printStackTrace(); - } - } - if(this.darkGrayIcon == null) { - try { - this.darkGrayIcon = ImageIO.read(getClass().getResource( - FUEL_GAUGE_FUEL_GAUGE_ICON_DARK_GRAY_PNG)); - } catch (IOException e) { - e.printStackTrace(); - } - } - brush.drawImage(donePercent() <= 0.15d ? this.orangeIcon : this.darkGrayIcon, getWidth() - 32, getHeight() - 48, 32, 32, null); - - } - //tBrush.drawBorder(startX, startY, 10, length_ - 4 - 5, getAngle.apply(donePercent()), 3f, brush.getColor()); this.setToolTipText(NumberFormats.FORMATTER_TWO_DECIMAL_PLACES.format(donePercent() * 100d) + "%"); }