JAL-1683 replace year/version strings with tokens in source
[jalview.git] / src / jalview / appletgui / AlignmentPanel.java
index 5a49281..7c4882a 100644 (file)
@@ -1,30 +1,44 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  * Jalview is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License 
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
  *  
  * Jalview is distributed in the hope that it will be useful, but 
  * WITHOUT ANY WARRANTY; without even the implied warranty 
  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
  * PURPOSE.  See the GNU General Public License for more details.
  * 
- * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.appletgui;
 
-import java.awt.*;
-import java.awt.event.*;
-
 import jalview.api.AlignmentViewPanel;
-import jalview.datamodel.*;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SearchResults;
+import jalview.datamodel.SequenceI;
 import jalview.structure.StructureSelectionManager;
 
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.FontMetrics;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Panel;
+import java.awt.Scrollbar;
+import java.awt.event.AdjustmentEvent;
+import java.awt.event.AdjustmentListener;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+
 public class AlignmentPanel extends Panel implements AdjustmentListener,
         AlignmentViewPanel
 {
@@ -143,12 +157,18 @@ public class AlignmentPanel extends Panel implements AdjustmentListener,
   {
     return seqPanel.seqCanvas.sr;
   }
-
-  public FeatureRenderer getFeatureRenderer()
+  @Override
+  public jalview.api.FeatureRenderer getFeatureRenderer()
   {
     return seqPanel.seqCanvas.fr;
   }
-
+  @Override
+  public jalview.api.FeatureRenderer cloneFeatureRenderer()
+  {
+    FeatureRenderer nfr = new FeatureRenderer(av);
+    nfr.transferSettings(seqPanel.seqCanvas.fr);
+    return nfr;
+  }
   public void alignmentChanged()
   {
     av.alignmentChanged(this);
@@ -434,6 +454,11 @@ public class AlignmentPanel extends Panel implements AdjustmentListener,
       annotationSpaceFillerHolder.setVisible(b);
       annotationPanelHolder.setVisible(b);
     }
+    else
+    {
+      annotationSpaceFillerHolder.setVisible(false);
+      annotationPanelHolder.setVisible(false);
+    }
     validate();
     repaint();
   }
@@ -481,10 +506,12 @@ public class AlignmentPanel extends Panel implements AdjustmentListener,
 
     if (adjustPanelHeight)
     {
-      // NOTE: this logic is different in the application. Need a better algorithm to define behaviour
+      // NOTE: this logic is different in the application. Need a better
+      // algorithm to define behaviour
       // sets initial preferred height
       // try and set height according to alignment
-      float sscaling = (float) ((av.getCharHeight() * av.getAlignment().getHeight())/(1.0*mheight));
+      float sscaling = (float) ((av.getCharHeight() * av.getAlignment()
+              .getHeight()) / (1.0 * mheight));
       if (sscaling > 0.5)
       {
         // if the alignment is too big then
@@ -493,7 +520,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener,
       }
       else
       {
-        // otherwise just set the panel so that one row of sequence is visible 
+        // otherwise just set the panel so that one row of sequence is visible
         height = -av.getCharHeight() * 1
                 + (int) (seqandannot * (1 - sscaling));
       }
@@ -512,7 +539,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener,
     alabels.setSize(new Dimension(e.width, height));
     annotationSpaceFillerHolder.setSize(new Dimension(e.width, height));
     annotationPanelHolder.setSize(new Dimension(d.width, height));
-    seqPanelHolder.setSize(d.width, seqandannot - height);
+    // seqPanelHolder.setSize(d.width, seqandannot - height);
     seqPanel.seqCanvas
             .setSize(d.width, seqPanel.seqCanvas.getSize().height);
     int s = apvscroll.getValue();
@@ -521,8 +548,8 @@ public class AlignmentPanel extends Panel implements AdjustmentListener,
       s = 0;
     }
     apvscroll.setValues(s, height, 0, mheight);
-    annotationPanel.setScrollOffset(apvscroll.getValue());
-    alabels.setScrollOffset(apvscroll.getValue());
+    annotationPanel.setScrollOffset(apvscroll.getValue(), false);
+    alabels.setScrollOffset(apvscroll.getValue(), false);
   }
 
   public void setWrapAlignment(boolean wrap)
@@ -550,6 +577,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener,
     fontChanged(); // This is so that the scalePanel is resized correctly
 
     validate();
+    sequenceHolderPanel.validate();
     repaint();
 
   }
@@ -686,8 +714,8 @@ public class AlignmentPanel extends Panel implements AdjustmentListener,
 
     if (evt == null || evt.getSource() == apvscroll)
     {
-      annotationPanel.setScrollOffset(apvscroll.getValue());
-      alabels.setScrollOffset(apvscroll.getValue());
+      annotationPanel.setScrollOffset(apvscroll.getValue(), false);
+      alabels.setScrollOffset(apvscroll.getValue(), false);
       // annotationPanel.image=null;
       // alabels.image=null;
       // alabels.repaint();
@@ -817,12 +845,18 @@ public class AlignmentPanel extends Panel implements AdjustmentListener,
       setScrollValues(av.getStartRes(), av.getStartSeq());
     }
 
-    alabels.repaint();
-
     seqPanel.seqCanvas.repaint();
-    scalePanel.repaint();
-    annotationPanel.repaint();
     idPanel.idCanvas.repaint();
+    if (!av.wrapAlignment)
+    {
+      if (av.showAnnotation)
+      {
+        alabels.repaint();
+        annotationPanel.repaint();
+      }
+      scalePanel.repaint();
+    }
+
   }
 
   protected Panel sequenceHolderPanel = new Panel();
@@ -949,6 +983,12 @@ public class AlignmentPanel extends Panel implements AdjustmentListener,
   }
 
   @Override
+  public String getViewName()
+  {
+    return getName();
+  }
+
+  @Override
   public StructureSelectionManager getStructureSelectionManager()
   {
     return StructureSelectionManager