Skip to content

Commit

Permalink
Fix glitch in plot scales, leading to overlapping text. Resolves #291.
Browse files Browse the repository at this point in the history
  • Loading branch information
bengtmartensson committed Jan 5, 2024
1 parent 61a80a0 commit ed76718
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/org/harctoolbox/guicomponents/IrPlotter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit ed76718

Please sign in to comment.