From ed76718f9136ff3b83ab2e9e448c4d5f8a09ad4e Mon Sep 17 00:00:00 2001 From: Bengt Martensson Date: Fri, 5 Jan 2024 15:20:09 +0100 Subject: [PATCH] Fix glitch in plot scales, leading to overlapping text. Resolves #291. --- .../java/org/harctoolbox/guicomponents/IrPlotter.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/harctoolbox/guicomponents/IrPlotter.java b/src/main/java/org/harctoolbox/guicomponents/IrPlotter.java index 40938f97..2bf9379d 100644 --- a/src/main/java/org/harctoolbox/guicomponents/IrPlotter.java +++ b/src/main/java/org/harctoolbox/guicomponents/IrPlotter.java @@ -378,11 +378,11 @@ private void drawTick(int x, Graphics graphics) { String str = Integer.toString(useMilliSeconds ? x/1000 : x); graphics.setColor(numberColor); int strLength = charWidth*str.length(); // silly, but accurate enough here - int xcoord = x2screenX(x) - strLength/2 < leftMargin ? leftMargin - : x2screenX(x) + strLength/2 > getWidth() - rightMargin ? getWidth() - rightMargin - strLength - : x2screenX(x) - strLength/2; - - graphics.drawString(str, xcoord, offY+numberOffset); + int xUnclipped = x2screenX(x) - strLength/2; + int xLeftclipped = Math.max(xUnclipped, leftMargin); + if (xLeftclipped < getWidth() - rightMargin) + graphics.drawString(str, xLeftclipped, offY+numberOffset); + // otherwise too far right, just ignore, since it would probably overwrite something } private void initializeMouse() {