JAL-1155 fix panel length calculation for grouped graphs and refactor to alignment...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Wed, 29 Aug 2012 20:01:31 +0000 (21:01 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Wed, 29 Aug 2012 20:01:31 +0000 (21:01 +0100)
src/jalview/api/AlignViewportI.java
src/jalview/appletgui/AlignmentPanel.java
src/jalview/appletgui/AnnotationLabels.java
src/jalview/appletgui/AnnotationPanel.java
src/jalview/gui/AnnotationPanel.java
src/jalview/viewmodel/AlignmentViewport.java

index ab9efb1..54a1d6f 100644 (file)
@@ -28,6 +28,14 @@ public interface AlignViewportI
 
   int getCharHeight();
 
+  /**
+   * calculate the height for visible annotation, revalidating bounds where
+   * necessary ABSTRACT GUI METHOD
+   *
+   * @return total height of annotation
+   */
+  public int calcPanelHeight();
+
   boolean hasHiddenColumns();
 
   boolean isValidCharWidth();
index e9d418e..ba6d873 100644 (file)
@@ -464,7 +464,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, Alignme
    */
   protected void validateAnnotationDimensions(boolean adjustPanelHeight) {
     boolean modified=false;
-    int height = annotationPanel.calcPanelHeight();
+    int height = av.calcPanelHeight();
     int minsize=0;
     if (hscroll.isVisible())
     {
index 635535c..5393b07 100755 (executable)
@@ -290,7 +290,7 @@ public class AnnotationLabels extends Panel implements ActionListener,
         ap.annotationPanelHolder.setSize(new Dimension(d.width, d.height
                 - dif));
         ap.apvscroll.setValues(ap.apvscroll.getValue(), d.height - dif, 0,
-                ap.annotationPanel.calcPanelHeight());
+                av.calcPanelHeight());
         f.height += dif;
         ap.seqPanelHolder.setPreferredSize(f);
         ap.setScrollValues(av.getStartRes(), av.getStartSeq());
index 492683d..45a5f1e 100755 (executable)
@@ -390,7 +390,7 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen
         av.getAlignment().getAlignmentAnnotation()[graphStretch].graphHeight = 0;
       }
       graphStretchY = evt.getY();
-      calcPanelHeight();
+      av.calcPanelHeight();
       needValidating = true;
       ap.paintAlignment(true);
     }
@@ -464,7 +464,7 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen
 
   public int adjustPanelHeight(boolean repaint)
   {
-    int height = calcPanelHeight();
+    int height = av.calcPanelHeight();
     this.setSize(new Dimension(getSize().width, height));
     if (repaint)
     {
@@ -477,54 +477,6 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, Adjustmen
    * ABSTRACT GUI METHOD
    * @return total height of annotation
    */
-  public int calcPanelHeight()
-  {
-    // setHeight of panels
-    AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
-    int height = 0;
-
-    if (aa != null)
-    {
-      for (int i = 0; i < aa.length; i++)
-      {
-        if (!aa[i].visible)
-        {
-          continue;
-        }
-
-        aa[i].height = 0;
-
-        if (aa[i].hasText)
-        {
-          aa[i].height += av.charHeight;
-        }
-
-        if (aa[i].hasIcons)
-        {
-          aa[i].height += 16;
-        }
-
-        if (aa[i].graph > 0)
-        {
-          aa[i].height += aa[i].graphHeight;
-        }
-
-        if (aa[i].height == 0)
-        {
-          aa[i].height = 20;
-        }
-
-        height += aa[i].height;
-      }
-    }
-    if (height == 0)
-    {
-      height = 20;
-    }
-
-    return height;
-
-  }
 
   public void addEditableColumn(int i)
   {
index c8784a5..03670d2 100755 (executable)
@@ -146,7 +146,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
    */
   public int adjustPanelHeight()
   {
-    int height = calcPanelHeight();
+    int height = av.calcPanelHeight();
     this.setPreferredSize(new Dimension(1, height));
     if (ap != null)
     {
@@ -158,65 +158,6 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
   }
 
   /**
-   * calculate the height for visible annotation, revalidating bounds where
-   * necessary ABSTRACT GUI METHOD
-   *
-   * @return total height of annotation
-   */
-  public int calcPanelHeight()
-  {
-    // setHeight of panels
-    AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
-    int height = 0;
-
-    if (aa != null)
-    {
-      for (int i = 0; i < aa.length; i++)
-      {
-        if (aa[i] == null)
-        {
-          System.err.println("Null annotation row: ignoring.");
-          continue;
-        }
-        if (!aa[i].visible)
-        {
-          continue;
-        }
-
-        aa[i].height = 0;
-
-        if (aa[i].hasText)
-        {
-          aa[i].height += av.charHeight;
-        }
-
-        if (aa[i].hasIcons)
-        {
-          aa[i].height += 16;
-        }
-
-        if (aa[i].graph > 0)
-        {
-          aa[i].height += aa[i].graphHeight;
-        }
-
-        if (aa[i].height == 0)
-        {
-          aa[i].height = 20;
-        }
-
-        height += aa[i].height;
-      }
-    }
-    if (height == 0)
-    {
-      // set minimum
-      height = 20;
-    }
-    return height;
-  }
-
-  /**
    * DOCUMENT ME!
    *
    * @param evt
index 8c34f31..27af11e 100644 (file)
@@ -1374,4 +1374,75 @@ public abstract class AlignmentViewport implements AlignViewportI
     }
   }
 
+  /*
+   * (non-Javadoc)
+   * @see jalview.api.AlignViewportI#calcPanelHeight()
+   */
+  public int calcPanelHeight()
+  {
+    // setHeight of panels
+    AlignmentAnnotation[] aa = getAlignment().getAlignmentAnnotation();
+    int height = 0;
+    int charHeight=getCharHeight();
+    if (aa != null)
+    {
+      boolean graphgrp[] = null;
+      for (int i = 0; i < aa.length; i++)
+      {
+        if (aa[i] == null)
+        {
+          System.err.println("Null annotation row: ignoring.");
+          continue;
+        }
+        if (!aa[i].visible)
+        {
+          continue;
+        }
+        if (aa[i].graphGroup > -1)
+        {
+          if (graphgrp == null)
+          {
+            graphgrp = new boolean[aa.length];
+          }
+          if (graphgrp[aa[i].graphGroup])
+          {
+            continue;
+          }
+          else
+          {
+            graphgrp[aa[i].graphGroup] = true;
+          }
+        }
+        aa[i].height = 0;
+  
+        if (aa[i].hasText)
+        {
+          aa[i].height += charHeight;
+        }
+  
+        if (aa[i].hasIcons)
+        {
+          aa[i].height += 16;
+        }
+  
+        if (aa[i].graph > 0)
+        {
+          aa[i].height += aa[i].graphHeight;
+        }
+  
+        if (aa[i].height == 0)
+        {
+          aa[i].height = 20;
+        }
+  
+        height += aa[i].height;
+      }
+    }
+    if (height == 0)
+    {
+      // set minimum
+      height = 20;
+    }
+    return height;
+  }
 }