JAL-4367 Limit right and top adjustments
authorBen Soares <b.soares@dundee.ac.uk>
Wed, 20 Dec 2023 13:23:07 +0000 (13:23 +0000)
committerJames Procter <j.procter@dundee.ac.uk>
Tue, 23 Jan 2024 16:54:50 +0000 (16:54 +0000)
src/jalview/gui/AnnotationLabels.java
src/jalview/gui/IdwidthAdjuster.java
src/jalview/jbgui/GAlignmentPanel.java

index 70fef2a..7c5afcd 100755 (executable)
@@ -793,9 +793,15 @@ public class AnnotationLabels extends JPanel
     {
       Dimension d = ap.annotationScroller.getPreferredSize();
       int dif = evt.getY() - oldY;
+      dif -= dif % ap.av.getCharHeight();
 
-      dif /= ap.av.getCharHeight();
-      dif *= ap.av.getCharHeight();
+      // don't allow setting an annotation panel height larger than visible
+      // (otherwise you can't get back)
+      if (d.height - dif > ap.idPanelHolder.getHeight()
+              - ap.getIdSpaceFillerPanel1().getHeight())
+      {
+        return;
+      }
 
       if ((d.height - dif) > 20)
       {
index 99a39d4..029f184 100755 (executable)
@@ -132,7 +132,7 @@ public class IdwidthAdjuster extends JPanel
     /*
      * don't drag below minimum width
      */
-    if (newWidth < MIN_ID_WIDTH)
+    if (newWidth < MIN_ID_WIDTH || newWidth > this.ap.getWidth())
     {
       return;
     }
index 2f0c75e..2d6f569 100755 (executable)
@@ -145,4 +145,9 @@ public class GAlignmentPanel extends JPanel
     hscrollHolder.add(hscrollFillerPanel, BorderLayout.WEST);
     this.add(sequenceHolderPanel, BorderLayout.CENTER);
   }
+
+  public JPanel getIdSpaceFillerPanel1()
+  {
+    return idSpaceFillerPanel1;
+  }
 }