extend alignPanel api with OOMHandler call to raise OOM events appropriately in GUI
[jalview.git] / src / jalview / gui / AlignmentPanel.java
old mode 100755 (executable)
new mode 100644 (file)
index e50b522..bcfb088
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
+ * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
  * 
  * This file is part of Jalview.
  * 
@@ -32,13 +32,13 @@ import jalview.bin.Cache;
 import jalview.datamodel.*;
 import jalview.jbgui.*;
 import jalview.schemes.*;
-import jalview.structure.SelectionSource;
+import jalview.structure.StructureSelectionManager;
 
 /**
  * DOCUMENT ME!
  * 
  * @author $author$
- * @version $Revision$
+ * @version $Revision: 1.161 $
  */
 public class AlignmentPanel extends GAlignmentPanel implements
         AdjustmentListener, Printable, AlignmentViewPanel
@@ -393,9 +393,17 @@ public class AlignmentPanel extends GAlignmentPanel implements
     {
       System.out.println("NEEDS FIXING");
     }
-
+    validateAnnotationDimensions(true);
+    addNotify();
+    paintAlignment(true);
+  }
+  /**
+   * calculate the annotation dimensions and refresh slider values accordingly.
+   * need to do repaints/notifys afterwards. 
+   */
+  protected void validateAnnotationDimensions(boolean adjustPanelHeight) {
     int height = annotationPanel.adjustPanelHeight();
-
+    
     if (hscroll.isVisible())
     {
       height += hscroll.getPreferredSize().height;
@@ -404,17 +412,20 @@ public class AlignmentPanel extends GAlignmentPanel implements
     {
       height = alignFrame.getHeight() / 2;
     }
-
+    if (!adjustPanelHeight)
+    {
+      // maintain same window layout whilst updating sliders
+      height=annotationScroller.getSize().height;
+    }
     hscroll.addNotify();
-
+    
     annotationScroller.setPreferredSize(new Dimension(annotationScroller
             .getWidth(), height));
 
     annotationSpaceFillerHolder.setPreferredSize(new Dimension(
             annotationSpaceFillerHolder.getWidth(), height));
     annotationScroller.validate();// repaint();
-    addNotify();
-    repaint();
+    annotationScroller.addNotify();
   }
 
   /**
@@ -672,8 +683,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
     if (updateOverview)
     {
-      jalview.structure.StructureSelectionManager
-              .getStructureSelectionManager().sequenceColoursChanged(this);
+      av.getStructureSelectionManager().sequenceColoursChanged(this);
 
       if (overviewPanel != null)
       {
@@ -901,7 +911,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
       pg.translate(-idWidth - 3, (endSeq - startSeq) * av.charHeight + 3);
       alabels.drawComponent((Graphics2D) pg, idWidth);
       pg.translate(idWidth + 3, 0);
-      annotationPanel.drawComponent((Graphics2D) pg, startRes, endRes + 1);
+      annotationPanel.renderer.drawComponent(annotationPanel, av, (Graphics2D) pg, -1, startRes, endRes + 1);
     }
 
     return Printable.PAGE_EXISTS;
@@ -1309,15 +1319,14 @@ public class AlignmentPanel extends GAlignmentPanel implements
    */
   public void closePanel()
   {
-    jalview.structure.StructureSelectionManager ssm = jalview.structure.StructureSelectionManager
-            .getStructureSelectionManager();
-    ssm.removeStructureViewerListener(seqPanel, null);
-    ssm.removeSelectionListener(seqPanel);
     PaintRefresher.RemoveComponent(seqPanel.seqCanvas);
     PaintRefresher.RemoveComponent(idPanel.idCanvas);
     PaintRefresher.RemoveComponent(this);
     if (av != null)
     {
+      jalview.structure.StructureSelectionManager ssm = av.getStructureSelectionManager();
+      ssm.removeStructureViewerListener(seqPanel, null);
+      ssm.removeSelectionListener(seqPanel);
       av.alignment = null;
       av = null;
     }
@@ -1347,6 +1356,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
     boolean cons = av.isShowGroupConsensus();
     boolean showprf = av.isShowSequenceLogo();
     boolean showConsHist = av.isShowConsensusHistogram();
+    boolean normLogo = av.isNormaliseSequenceLogo();
 
     boolean sortg = true;
 
@@ -1382,6 +1392,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
           // set defaults for this group's conservation/consensus
           sg.setshowSequenceLogo(showprf);
           sg.setShowConsensusHistogram(showConsHist);
+          sg.setNormaliseSequenceLogo(normLogo);
         }
         if (conv)
         {
@@ -1434,4 +1445,16 @@ public class AlignmentPanel extends GAlignmentPanel implements
       alignFrame.setDisplayedView(this);
     } 
   }
+
+  @Override
+  public StructureSelectionManager getStructureSelectionManager()
+  {
+    return av.getStructureSelectionManager();
+  }
+
+  @Override
+  public void raiseOOMWarning(String string, OutOfMemoryError error)
+  {
+    new OOMWarning(string,  error, this);
+  }
 }