JAL-2629 removed SequenceI.get/setLastPosition and related code
[jalview.git] / src / jalview / viewmodel / AlignmentViewport.java
index eeea831..2651b79 100644 (file)
@@ -22,6 +22,7 @@ package jalview.viewmodel;
 
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.analysis.Conservation;
+import jalview.analysis.TreeModel;
 import jalview.api.AlignCalcManagerI;
 import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
@@ -33,7 +34,6 @@ import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentView;
 import jalview.datamodel.Annotation;
-import jalview.datamodel.CigarArray;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.HiddenSequences;
@@ -83,7 +83,7 @@ import java.util.Map;
 public abstract class AlignmentViewport
         implements AlignViewportI, CommandListener, VamsasSource
 {
-  final protected ViewportRanges ranges;
+  protected ViewportRanges ranges;
 
   protected ViewStyleI viewStyle = new ViewStyle();
 
@@ -616,6 +616,8 @@ public abstract class AlignmentViewport
 
   protected boolean ignoreBelowBackGroundFrequencyCalculation = false;
 
+  protected boolean infoLetterHeight = false;
+
   protected ResidueShaderI residueShading = new ResidueShader();
 
   @Override
@@ -1019,11 +1021,15 @@ public abstract class AlignmentViewport
     groupConsensus = null;
     groupConservation = null;
     hconsensus = null;
+    hconservation = null;
     hcomplementConsensus = null;
-    // colour scheme may hold reference to consensus
-    residueShading = null;
-    // TODO remove listeners from changeSupport?
+    gapcounts = null;
+    calculator = null;
+    residueShading = null; // may hold a reference to Consensus
     changeSupport = null;
+    ranges = null;
+    currentTree = null;
+    selectionGroup = null;
     setAlignment(null);
   }
 
@@ -1370,6 +1376,16 @@ public abstract class AlignmentViewport
 
   }
 
+  public void setInfoLetterHeight(boolean b, AlignmentViewPanel ap)
+  {
+    infoLetterHeight = b;
+    if (ap != null)
+    {
+      updateInformation(ap);
+    }
+
+  }
+
   private long sgrouphash = -1, colselhash = -1;
 
   /**
@@ -1430,6 +1446,12 @@ public abstract class AlignmentViewport
     return ignoreBelowBackGroundFrequencyCalculation;
   }
 
+  @Override
+  public boolean isInfoLetterHeight()
+  {
+    return infoLetterHeight;
+  }
+
   // property change stuff
   // JBPNote Prolly only need this in the applet version.
   private PropertyChangeSupport changeSupport = new PropertyChangeSupport(
@@ -1475,7 +1497,10 @@ public abstract class AlignmentViewport
   public void removePropertyChangeListener(
           java.beans.PropertyChangeListener listener)
   {
-    changeSupport.removePropertyChangeListener(listener);
+    if (changeSupport != null)
+    {
+      changeSupport.removePropertyChangeListener(listener);
+    }
   }
 
   /**
@@ -1814,13 +1839,6 @@ public abstract class AlignmentViewport
   }
 
   @Override
-  public CigarArray getViewAsCigars(boolean selectedRegionOnly)
-  {
-    return new CigarArray(alignment, alignment.getHiddenColumns(),
-            (selectedRegionOnly ? selectionGroup : null));
-  }
-
-  @Override
   public jalview.datamodel.AlignmentView getAlignmentView(
           boolean selectedOnly)
   {
@@ -2005,7 +2023,7 @@ public abstract class AlignmentViewport
     updateInformation(ap);
 
     List<SequenceI> hmmSequences;
-    hmmSequences = alignment.getHMMConsensusSequences(false);
+    hmmSequences = alignment.getHMMConsensusSequences();
 
     for (SequenceI seq : hmmSequences)
     {
@@ -2147,30 +2165,28 @@ public abstract class AlignmentViewport
   @Override
   public void initInformation()
   {
-    for (SequenceI seq : alignment.getHMMConsensusSequences(false))
+    for (SequenceI seq : alignment.getHMMConsensusSequences())
     {
       if (!seq.hasHMMAnnotation())
       {
-        AlignmentAnnotation information;
-        information = new AlignmentAnnotation(seq.getName(),
+        AlignmentAnnotation info = new AlignmentAnnotation(seq.getName(),
                 MessageManager.getString("label.information_description"),
                 new Annotation[1], 0f, 6.52f,
                 AlignmentAnnotation.BAR_GRAPH);
-        information.hasText = true;
-        information.autoCalculated = true;
-        information.hasText = true;
-        information.autoCalculated = false;
-        information.sequenceRef = seq;
-        information.setCalcId("HMM");
-        this.information.add(information);
+        info.hasText = true;
+        info.autoCalculated = true;
+        info.hasText = true;
+        info.autoCalculated = false;
+        info.sequenceRef = seq;
+        info.setCalcId("HMM");
+        this.information.add(info);
         hinformation.add(new Profiles(new ProfileI[1]));
-        alignment.addAnnotation(information);
+        alignment.addAnnotation(info);
         seq.updateHMMMapping();
         seq.setHasInfo(true);
-        seq.addAlignmentAnnotation(information);
+        seq.addAlignmentAnnotation(info);
       }
     }
-
   }
 
   // these should be extracted from the view model - style and settings for
@@ -3064,6 +3080,8 @@ public abstract class AlignmentViewport
    */
   private SearchResultsI searchResults = null;
 
+  protected TreeModel currentTree = null;
+
   @Override
   public boolean hasSearchResults()
   {
@@ -3122,4 +3140,29 @@ public abstract class AlignmentViewport
             + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
     return sq;
   }
+
+  public boolean hasReferenceAnnotation()
+  {
+    AlignmentAnnotation[] annots = this.alignment.getAlignmentAnnotation();
+    for (AlignmentAnnotation annot : annots)
+    {
+      if ("RF".equals(annot.label) || annot.label.contains("Reference"))
+      {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  @Override
+  public void setCurrentTree(TreeModel tree)
+  {
+    currentTree = tree;
+  }
+
+  @Override
+  public TreeModel getCurrentTree()
+  {
+    return currentTree;
+  }
 }