JAL-244 Allow wrap manual adjustments to be smaller than the actual id widths.
authorBen Soares <b.soares@dundee.ac.uk>
Thu, 27 Jul 2023 19:14:25 +0000 (20:14 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Thu, 27 Jul 2023 19:14:25 +0000 (20:14 +0100)
src/jalview/gui/IdCanvas.java
src/jalview/gui/IdwidthAdjuster.java

index d9997a0..ab21714 100755 (executable)
@@ -435,15 +435,19 @@ public class IdCanvas extends JPanel implements ViewportListenerI
 
       if (labels != null && alignViewport.isShowAnnotation())
       {
+        int thisIdWidth = getWidth();
         g.translate(0, ypos + (alheight * charHeight));
-        int getAnnotationsIdWidth = labels.drawLabels(g, false, -1, false,
-                null);
-        int thisIdWidth = idWidth < 0 ? getAnnotationsIdWidth : idWidth;
-        if (thisIdWidth > getWidth())
+        if (!manuallyAdjusted())
         {
-          this.setPreferredSize(
-                  new Dimension(this.getHeight(), thisIdWidth));
-          this.repaint();
+          int getAnnotationsIdWidth = labels.drawLabels(g, false, -1, false,
+                  null);
+          thisIdWidth = idWidth < 0 ? getAnnotationsIdWidth : idWidth;
+          if (thisIdWidth > getWidth())
+          {
+            this.setPreferredSize(
+                    new Dimension(this.getHeight(), thisIdWidth));
+            this.repaint();
+          }
         }
         labels.drawComponent(g, false, thisIdWidth);
         g.translate(0, -ypos - (alheight * charHeight));
@@ -601,4 +605,16 @@ public class IdCanvas extends JPanel implements ViewportListenerI
       repaint();
     }
   }
+
+  private boolean manuallyAdjusted = false;
+
+  public boolean manuallyAdjusted()
+  {
+    return manuallyAdjusted;
+  }
+
+  public void setManuallyAdjusted(boolean b)
+  {
+    manuallyAdjusted = b;
+  }
 }
index eef5bfb..0ebdfa1 100755 (executable)
@@ -46,8 +46,6 @@ public class IdwidthAdjuster extends JPanel
 
   AlignmentPanel ap;
 
-  private boolean manuallyAdjusted = false;
-
   /**
    * Creates a new IdwidthAdjuster object.
    * 
@@ -151,7 +149,7 @@ public class IdwidthAdjuster extends JPanel
     ap.validateAnnotationDimensions(false);
     ap.paintAlignment(true, false);
 
-    manuallyAdjusted = true;
+    ap.getIdPanel().getIdCanvas().setManuallyAdjusted(true);
   }
 
   public void setWidth(int newWidth)
@@ -167,7 +165,7 @@ public class IdwidthAdjuster extends JPanel
 
   public boolean manuallyAdjusted()
   {
-    return manuallyAdjusted;
+    return ap.getIdPanel().getIdCanvas().manuallyAdjusted();
   }
 
   @Override