JAL-3055 corrected logo drawing in JS
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 28 Aug 2018 15:55:58 +0000 (16:55 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 28 Aug 2018 15:55:58 +0000 (16:55 +0100)
src/jalview/renderer/AnnotationRenderer.java

index eb998bb..0aeb45a 100644 (file)
@@ -1468,12 +1468,12 @@ public class AnnotationRenderer
             double sy = newHeight / asc;
             double newAsc = asc * sy; 
             double newDec = dec * sy;
-            // it is not necessary to recalculated lm for the new font.
+            // it is not necessary to recalculate lm for the new font.
             // note: lm.getBaselineOffsets()[lm.getBaselineIndex()]) must be 0
             // by definition. Was:
-            // int hght = (int) (ht + (newAsc - newDec - lm.getBaselineOffsets()[lm.getBaselineIndex()]));
+            // int hght = (int) (ht + (newAsc - newDec);
+            // - lm.getBaselineOffsets()[lm.getBaselineIndex()]));
 
-            final int hght = (int) (ht + (newAsc - newDec)); 
             if (Jalview.isJS())
             {
               /*
@@ -1481,17 +1481,19 @@ public class AnnotationRenderer
                * so use a scaling transform to draw instead,
                * this is off by a very small amount
                */
+              final int hght = (int) (ht2 + (newAsc - newDec));
               Graphics2D gg = (Graphics2D) g.create();
               gg.setFont(ofont);
-              gg.translate(x*charWidth, hght);
+              int xShift = (int) (x * charWidth / sx);
+              int yShift = (int) (hght / sy);
               gg.transform(AffineTransform.getScaleInstance(sx, sy));
-              gg.drawString(s, 0, 0); 
-              gg.translate(-x*charWidth, -hght);
+              gg.drawString(s, xShift, yShift);
               gg.dispose();
               ht2 += newHeight;
             }
             else
             {
+              final int hght = (int) (ht + (newAsc - newDec));
               Font font = ofont
                       .deriveFont(AffineTransform.getScaleInstance(sx, sy));
               g.setFont(font);