3253-omnibus save
[jalview.git] / src / jalview / viewmodel / AlignmentViewport.java
index 148ea16..b1f595f 100644 (file)
@@ -24,6 +24,7 @@ import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.analysis.Conservation;
 import jalview.analysis.TreeModel;
 import jalview.api.AlignCalcManagerI;
+import jalview.api.AlignExportSettingsI;
 import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
 import jalview.api.FeaturesDisplayedI;
@@ -31,6 +32,7 @@ import jalview.api.ViewStyleI;
 import jalview.commands.CommandI;
 import jalview.datamodel.AlignedCodonFrame;
 import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentExportData;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentView;
 import jalview.datamodel.Annotation;
@@ -603,10 +605,30 @@ public abstract class AlignmentViewport
 
   protected ColumnSelection colSel = new ColumnSelection();
 
-  public boolean autoCalculateConsensus = true;
+  protected boolean autoCalculateConsensusAndConservation = true;
+
+  public boolean getAutoCalculateConsensusAndConservation()
+  { // BH 2019.07.24
+    return autoCalculateConsensusAndConservation;
+  }
+
+  public void setAutoCalculateConsensusAndConservation(boolean b)
+  {
+    autoCalculateConsensusAndConservation = b;
+  }
 
   protected boolean autoCalculateStrucConsensus = true;
 
+  public boolean getAutoCalculateStrucConsensus()
+  { // BH 2019.07.24
+    return autoCalculateStrucConsensus;
+  }
+
+  public void setAutoCalculateStrucConsensus(boolean b)
+  {
+    autoCalculateStrucConsensus = b;
+  }
+
   protected boolean ignoreGapsInConsensusCalculation = false;
 
   protected ResidueShaderI residueShading = new ResidueShader();
@@ -709,13 +731,13 @@ public abstract class AlignmentViewport
   /**
    * results of cDNA complement consensus visible portion of view
    */
-  protected Hashtable[] hcomplementConsensus = null;
+  protected Hashtable<String, Object>[] hcomplementConsensus = null;
 
   /**
    * results of secondary structure base pair consensus for visible portion of
    * view
    */
-  protected Hashtable[] hStrucConsensus = null;
+  protected Hashtable<String, Object>[] hStrucConsensus = null;
 
   protected Conservation hconservation = null;
 
@@ -744,7 +766,8 @@ public abstract class AlignmentViewport
   }
 
   @Override
-  public void setComplementConsensusHash(Hashtable[] hconsensus)
+  public void setComplementConsensusHash(
+          Hashtable<String, Object>[] hconsensus)
   {
     this.hcomplementConsensus = hconsensus;
   }
@@ -756,19 +779,20 @@ public abstract class AlignmentViewport
   }
 
   @Override
-  public Hashtable[] getComplementConsensusHash()
+  public Hashtable<String, Object>[] getComplementConsensusHash()
   {
     return hcomplementConsensus;
   }
 
   @Override
-  public Hashtable[] getRnaStructureConsensusHash()
+  public Hashtable<String, Object>[] getRnaStructureConsensusHash()
   {
     return hStrucConsensus;
   }
 
   @Override
-  public void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus)
+  public void setRnaStructureConsensusHash(
+          Hashtable<String, Object>[] hStrucConsensus)
   {
     this.hStrucConsensus = hStrucConsensus;
 
@@ -820,7 +844,7 @@ public abstract class AlignmentViewport
     // see note in mantis : issue number 8585
     if (alignment.isNucleotide()
             || (conservation == null && quality == null)
-            || !autoCalculateConsensus)
+            || !autoCalculateConsensusAndConservation)
     {
       return;
     }
@@ -838,7 +862,7 @@ public abstract class AlignmentViewport
   public void updateConsensus(final AlignmentViewPanel ap)
   {
     // see note in mantis : issue number 8585
-    if (consensus == null || !autoCalculateConsensus)
+    if (consensus == null || !autoCalculateConsensusAndConservation)
     {
       return;
     }
@@ -1191,6 +1215,13 @@ public abstract class AlignmentViewport
 
   public void setSequenceSetId(String newid)
   {
+    // // BH 2020.04.07 do we need to do this if it is the same?
+    // // (Jalview project files)
+    // if (newid.equals(sequenceSetID))
+    // {
+    // return;
+    // }
+
     if (sequenceSetID != null)
     {
       System.err.println(
@@ -1798,7 +1829,7 @@ public abstract class AlignmentViewport
       }
     } while (end < max);
 
-    int[][] startEnd = new int[regions.size()][2];
+    // int[][] startEnd = new int[regions.size()][2];
 
     return regions;
   }
@@ -1855,11 +1886,11 @@ public abstract class AlignmentViewport
     {
       alignment.padGaps();
     }
-    if (autoCalculateConsensus)
+    if (autoCalculateConsensusAndConservation)
     {
       updateConsensus(ap);
     }
-    if (hconsensus != null && autoCalculateConsensus)
+    if (hconsensus != null && autoCalculateConsensusAndConservation)
     {
       updateConservation(ap);
     }
@@ -2153,7 +2184,7 @@ public abstract class AlignmentViewport
      * TODO reorder the annotation rows according to group/sequence ordering on
      * alignment
      */
-    boolean sortg = true;
+    // boolean sortg = true;
 
     // remove old automatic annotation
     // add any new annotation
@@ -2263,7 +2294,7 @@ public abstract class AlignmentViewport
   public void clearSequenceColours()
   {
     sequenceColours.clear();
-  };
+  }
 
   @Override
   public AlignViewportI getCodingComplement()
@@ -2716,6 +2747,30 @@ public abstract class AlignmentViewport
     viewStyle.setProteinFontAsCdna(b);
   }
 
+  @Override
+  public void setShowComplementFeatures(boolean b)
+  {
+    viewStyle.setShowComplementFeatures(b);
+  }
+
+  @Override
+  public boolean isShowComplementFeatures()
+  {
+    return viewStyle.isShowComplementFeatures();
+  }
+
+  @Override
+  public void setShowComplementFeaturesOnTop(boolean b)
+  {
+    viewStyle.setShowComplementFeaturesOnTop(b);
+  }
+
+  @Override
+  public boolean isShowComplementFeaturesOnTop()
+  {
+    return viewStyle.isShowComplementFeaturesOnTop();
+  }
+
   /**
    * @return true if view should scroll to show the highlighted region of a
    *         sequence
@@ -2957,6 +3012,36 @@ public abstract class AlignmentViewport
     return currentTree;
   }
 
+  @Override
+  public AlignmentExportData getAlignExportData(AlignExportSettingsI options)
+  {
+    AlignmentI alignmentToExport = null;
+    String[] omitHidden = null;
+    alignmentToExport = null;
+
+    if (hasHiddenColumns() && !options.isExportHiddenColumns())
+    {
+      omitHidden = getViewAsString(false,
+              options.isExportHiddenSequences());
+    }
+
+    int[] alignmentStartEnd = new int[2];
+    if (hasHiddenRows() && options.isExportHiddenSequences())
+    {
+      alignmentToExport = getAlignment().getHiddenSequences()
+              .getFullAlignment();
+    }
+    else
+    {
+      alignmentToExport = getAlignment();
+    }
+    alignmentStartEnd = getAlignment().getHiddenColumns()
+            .getVisibleStartAndEndIndex(alignmentToExport.getWidth());
+    AlignmentExportData ed = new AlignmentExportData(alignmentToExport,
+            omitHidden, alignmentStartEnd);
+    return ed;
+  }
+  
   /**
    * flag set to indicate if structure views might be out of sync with sequences
    * in the alignment