JAL-244 Allow wrap manual adjustments to be smaller than the actual id widths.
[jalview.git] / src / jalview / gui / IdCanvas.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;
+  }
 }