From 3e7f0b5e7302d159826d985f504368f58c7eed00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ha=C3=9Fel?= Date: Fri, 17 May 2024 10:10:02 +0200 Subject: [PATCH] label rotation fix --- .../ph87/electro/circuit/part/impl/PartBattery.java | 6 +++--- .../ph87/electro/circuit/part/impl/PartLight.java | 13 +++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/ph87/electro/circuit/part/impl/PartBattery.java b/src/main/java/de/ph87/electro/circuit/part/impl/PartBattery.java index 280d526..29a1ffd 100644 --- a/src/main/java/de/ph87/electro/circuit/part/impl/PartBattery.java +++ b/src/main/java/de/ph87/electro/circuit/part/impl/PartBattery.java @@ -78,11 +78,11 @@ public class PartBattery extends Part { final int y0; final int y1; if (getOrientation() == Orientation.R180) { - y0 = P05; - y1 = P95 - LABEL_FONT.getSize(); - } else { y0 = P95 - LABEL_FONT.getSize(); y1 = P05; + } else { + y0 = P05; + y1 = P95 - LABEL_FONT.getSize(); } textCenter(g, LABEL_FONT, "%.1fV".formatted(voltage), y0, Color.BLACK); if (shortCircuit != null) { diff --git a/src/main/java/de/ph87/electro/circuit/part/impl/PartLight.java b/src/main/java/de/ph87/electro/circuit/part/impl/PartLight.java index 11d1c67..0496d8e 100644 --- a/src/main/java/de/ph87/electro/circuit/part/impl/PartLight.java +++ b/src/main/java/de/ph87/electro/circuit/part/impl/PartLight.java @@ -102,9 +102,18 @@ public class PartLight extends PartOther { @Override protected void _labels(final Graphics2D g) { - textCenter(g, LABEL_FONT, "%.1fV (max)".formatted(maxVoltage), P05, Color.BLACK); + final int y0; + final int y1; + if (getOrientation() == Orientation.R180) { + y0 = P95 - LABEL_FONT.getSize(); + y1 = P05; + } else { + y0 = P05; + y1 = P95 - LABEL_FONT.getSize(); + } + textCenter(g, LABEL_FONT, "%.1fV (max)".formatted(maxVoltage), y0, Color.BLACK); if (defect) { - textCenter(g, LABEL_FONT, "DEFEKT", P95 - LABEL_FONT.getSize(), Color.RED); + textCenter(g, LABEL_FONT, "DEFEKT", y1, Color.RED); } }