JAL-2347 first pass at JAL-2347 - doesn’t quite work in Java or Javascript yet !
authorJim Procter <jprocter@issues.jalview.org>
Tue, 3 Jul 2018 16:34:05 +0000 (17:34 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Tue, 3 Jul 2018 16:34:05 +0000 (17:34 +0100)
src/jalview/renderer/AnnotationRenderer.java

index f883b13..4dd91da 100644 (file)
@@ -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)