From 60f8836113d73ba0c60a9cda585d787faff8d340 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 3 Jul 2018 17:34:05 +0100 Subject: [PATCH] =?utf8?q?JAL-2347=20first=20pass=20at=20JAL-2347=20-=20does?= =?utf8?q?n=E2=80=99t=20quite=20work=20in=20Java=20or=20Javascript=20yet=20!?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/renderer/AnnotationRenderer.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/jalview/renderer/AnnotationRenderer.java b/src/jalview/renderer/AnnotationRenderer.java index f883b13..4dd91da 100644 --- a/src/jalview/renderer/AnnotationRenderer.java +++ b/src/jalview/renderer/AnnotationRenderer.java @@ -43,7 +43,6 @@ import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; -import java.awt.font.LineMetrics; import java.awt.geom.AffineTransform; import java.awt.image.ImageObserver; import java.util.BitSet; @@ -653,7 +652,8 @@ public class AnnotationRenderer if (validCharWidth && validRes && displayChar != null && (displayChar.length() > 0)) { - + Graphics2D gg = ((Graphics2D) g); + AffineTransform t = gg.getTransform(); fmWidth = fm.charsWidth(displayChar.toCharArray(), 0, displayChar.length()); if (/* centreColLabels || */scaleColLabel) @@ -669,8 +669,9 @@ public class AnnotationRenderer // scale only if the current font isn't already small enough fmScaling = charWidth; fmScaling /= fmWidth; - g.setFont(ofont.deriveFont(AffineTransform - .getScaleInstance(fmScaling, 1.0))); + gg.setFont(ofont); + gg.transform( + AffineTransform.getScaleInstance(fmScaling, 1.0)); // and update the label's width to reflect the scaling. fmWidth = charWidth; } @@ -685,16 +686,16 @@ public class AnnotationRenderer if (row_annotations[column].colour == null) { - g.setColor(Color.black); + gg.setColor(Color.black); } else { - g.setColor(row_annotations[column].colour); + gg.setColor(row_annotations[column].colour); } if (column == 0 || row.graph > 0) { - g.drawString(displayChar, (x * charWidth) + charOffset, + gg.drawString(displayChar, (x * charWidth) + charOffset, y + iconOffset); } else if (row_annotations[column - 1] == null || (labelAllCols @@ -703,10 +704,11 @@ public class AnnotationRenderer || (displayChar.length() < 2 && row_annotations[column].secondaryStructure == ' '))) { - g.drawString(displayChar, x * charWidth + charOffset, + gg.drawString(displayChar, x * charWidth + charOffset, y + iconOffset); } g.setFont(ofont); + gg.setTransform(t); } } if (row.hasIcons) -- 1.7.10.2