From: Jim Procter Date: Tue, 3 Jul 2018 16:34:05 +0000 (+0100) Subject: JAL-2347 first pass at JAL-2347 - doesn’t quite work in Java or Javascript yet ! X-Git-Tag: Release_2_11_4_0~45^2~18^2~595^2~1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=60f8836113d73ba0c60a9cda585d787faff8d340;p=jalview.git JAL-2347 first pass at JAL-2347 - doesn’t quite work in Java or Javascript yet ! --- 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)