JAL-4133 update validChar width when font is changed so characters are suppressed...
authorJames Procter <j.procter@dundee.ac.uk>
Thu, 23 Feb 2023 11:58:09 +0000 (11:58 +0000)
committerJames Procter <j.procter@dundee.ac.uk>
Thu, 23 Feb 2023 11:58:09 +0000 (11:58 +0000)
src/jalview/gui/AlignmentPanel.java
src/jalview/project/Jalview2XML.java

index e545776..2d057bb 100644 (file)
@@ -229,6 +229,9 @@ public class AlignmentPanel extends GAlignmentPanel implements
     // set idCanvas bufferedImage to null
     // to prevent drawing old image
     FontMetrics fm = getFontMetrics(av.getFont());
+    
+    // update the flag controlling whether the grid is too small to render the font
+    av.validCharWidth = fm.charWidth('M') <= av.getCharWidth();
 
     scalePanelHolder.setPreferredSize(
             new Dimension(10, av.getCharHeight() + fm.getDescent()));
index 8142435..14803df 100644 (file)
@@ -26,6 +26,7 @@ import static jalview.math.RotatableMatrix.Axis.Z;
 
 import java.awt.Color;
 import java.awt.Font;
+import java.awt.FontMetrics;
 import java.awt.Rectangle;
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
@@ -4882,14 +4883,14 @@ public class Jalview2XML
     viewport.setIncrement(safeInt(view.getConsThreshold()));
     viewport.setShowJVSuffix(safeBoolean(view.isShowFullId()));
     viewport.setRightAlignIds(safeBoolean(view.isRightAlignIds()));
+    viewport.setFont(new Font(view.getFontName(),
+            safeInt(view.getFontStyle()), safeInt(view.getFontSize())),
+            (view.getCharWidth()!=null) ? false : true);
     if (view.getCharWidth()!=null)
     {
       viewport.setCharWidth(view.getCharWidth());
       viewport.setCharHeight(view.getCharHeight());
     }
-    viewport.setFont(new Font(view.getFontName(),
-            safeInt(view.getFontStyle()), safeInt(view.getFontSize())),
-            true);
     ViewStyleI vs = viewport.getViewStyle();
     vs.setScaleProteinAsCdna(view.isScaleProteinAsCdna());
     viewport.setViewStyle(vs);