Merge commit 'alpha/update_2_12_for_2_11_2_series_merge^2' into HEAD
[jalview.git] / src / jalview / gui / AlignViewport.java
index a5c899a..3d44a7c 100644 (file)
@@ -39,6 +39,7 @@ import jalview.datamodel.SearchResults;
 import jalview.datamodel.SearchResultsI;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
+import jalview.datamodel.features.FeatureMatcherSetI;
 import jalview.renderer.ResidueShader;
 import jalview.schemes.ColourSchemeI;
 import jalview.schemes.ColourSchemeProperty;
@@ -73,14 +74,11 @@ import javax.swing.JInternalFrame;
 public class AlignViewport extends AlignmentViewport
         implements SelectionSource
 {
-
   public final static int NO_SPLIT = 0;
 
   public final static int SPLIT_FRAME = 1;
 
   public final static int NEW_WINDOW = 2;
-
-
   Font font;
 
   boolean cursorMode = false;
@@ -170,7 +168,7 @@ public class AlignViewport extends AlignmentViewport
    * @param hiddenColumns
    * @param seqsetid
    *          (may be null)
-f   */
+   */
   public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns,
           String seqsetid)
   {
@@ -223,7 +221,7 @@ f   */
 
     setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
     setCentreColumnLabels(Cache.getDefault("CENTRE_COLUMN_LABELS", false));
-    autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
+    autoCalculateConsensusAndConservation = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
 
     setPadGaps(Cache.getDefault("PAD_GAPS", true));
     setShowNPFeats(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
@@ -264,14 +262,13 @@ f   */
 
     setFont(new Font(fontName, style, Integer.parseInt(fontSize)), true);
 
-    alignment
-            .setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0));
+               alignment.setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0));
 
     // We must set conservation and consensus before setting colour,
     // as Blosum and Clustal require this to be done
-    if (hconsensus == null && !isDataset)
+               if (hconsensus == null && !isDataset)
     {
-      if (!alignment.isNucleotide())
+                       if (!alignment.isNucleotide())
       {
         showConservation = Cache.getDefault("SHOW_CONSERVATION", true);
         showQuality = Cache.getDefault("SHOW_QUALITY", true);
@@ -283,13 +280,19 @@ f   */
       showSequenceLogo = Cache.getDefault("SHOW_CONSENSUS_LOGO", false);
       normaliseSequenceLogo = Cache.getDefault("NORMALISE_CONSENSUS_LOGO",
               false);
+      // for now, use consensus options for Information till it gets its own
+      setShowHMMSequenceLogo(showSequenceLogo);
+      setNormaliseHMMSequenceLogo(normaliseSequenceLogo);
+      setShowInformationHistogram(showConsensusHistogram);
       showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false);
       showConsensus = Cache.getDefault("SHOW_IDENTITY", true);
 
       showOccupancy = Cache.getDefault(Preferences.SHOW_OCCUPANCY, true);
     }
     initAutoAnnotation();
-    String colourProperty = alignment.isNucleotide()
+    // initInformation();
+
+               String colourProperty = alignment.isNucleotide()
             ? Preferences.DEFAULT_COLOUR_NUC
             : Preferences.DEFAULT_COLOUR_PROT;
     String schemeName = Cache.getProperty(colourProperty);
@@ -312,11 +315,12 @@ f   */
 
     if (residueShading != null)
     {
-      residueShading.setConsensus(hconsensus);
+                       residueShading.setConsensus(hconsensus);
     }
     setColourAppliesToAllGroups(true);
   }
 
+  
   boolean validCharWidth;
 
   /**
@@ -401,7 +405,7 @@ f   */
     /*
      * replace mappings on our alignment
      */
-    if (alignment != null && align != null)
+               if (alignment != null && align != null)
     {
       alignment.setCodonFrames(align.getCodonFrames());
     }
@@ -454,31 +458,6 @@ f   */
   }
 
   /**
-   * returns the visible column regions of the alignment
-   * 
-   * @param selectedRegionOnly
-   *          true to just return the contigs intersecting with the selected
-   *          area
-   * @return
-   */
-  public Iterator<int[]> getViewAsVisibleContigs(boolean selectedRegionOnly)
-  {
-    int start = 0;
-    int end = 0;
-    if (selectedRegionOnly && selectionGroup != null)
-    {
-      start = selectionGroup.getStartRes();
-      end = selectionGroup.getEndRes() + 1;
-    }
-    else
-    {
-      end = alignment.getWidth();
-    }
-    return (alignment.getHiddenColumns().getVisContigsIterator(start, end,
-            false));
-  }
-
-  /**
    * get hash of undo and redo list for the alignment
    * 
    * @return long[] { historyList.hashCode, redoList.hashCode };
@@ -591,13 +570,15 @@ f   */
             .getStructureSelectionManager(Desktop.getInstance());
   }
 
+  
   @Override
   public boolean isNormaliseSequenceLogo()
   {
     return normaliseSequenceLogo;
   }
 
-  public void setNormaliseSequenceLogo(boolean state)
+  @Override
+public void setNormaliseSequenceLogo(boolean state)
   {
     normaliseSequenceLogo = state;
   }
@@ -611,7 +592,7 @@ f   */
   {
     return validCharWidth;
   }
-
+  
   private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<>();
 
   public AutoCalcSetting getCalcIdSettingsFor(String calcId)
@@ -754,7 +735,7 @@ f   */
     }
 
     ranges.setEndSeq(getAlignment().getHeight() - 1); // BH 2019.04.18
-    firePropertyChange("alignment", null, getAlignment().getSequences());
+    notifyAlignment();
   }
 
   /**
@@ -793,10 +774,10 @@ f   */
               @Override
               public void run()
               {
+                // Make a copy of this one to open it in a splitframe
                 openLinkedAlignmentAs(getAlignPanel().alignFrame,
                         new Alignment(getAlignment()), al, title,
                         SPLIT_FRAME);
-//                us.openLinkedAlignmentAs(al, title, true);
               }
             }).setResponseHandler(NEW_WINDOW, new Runnable()
             {
@@ -812,6 +793,7 @@ f   */
             JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
             options, options[0]);
   }
+
   /**
    * Open a split frame or a new window
    * 
@@ -824,11 +806,11 @@ f   */
           AlignmentI thisAlignment, AlignmentI al, String title, int mode)
   {
     /*
-     * Identify protein and dna alignments. Make a copy of this one if opening
-     * in a new split pane.
+     * Identify protein and dna alignments. 
      */
     AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
     AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
+
     /*
      * Map sequences. At least one should get mapped as we have already passed
      * the test for 'mappability'. Any mappings made will be added to the
@@ -899,7 +881,6 @@ f   */
             AlignFrame.DEFAULT_HEIGHT);
     copyMe.setTitle(thisFrame.getTitle());
 
-
     AlignmentI al = newAlignFrame.viewport.getAlignment();
     final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
             : newAlignFrame;
@@ -1090,6 +1071,8 @@ f   */
     {
       FeatureColourI preferredColour = featureSettings
               .getFeatureColour(type);
+      FeatureMatcherSetI preferredFilters = featureSettings
+              .getFeatureFilters(type);
       FeatureColourI origColour = fr.getFeatureStyle(type);
       if (!mergeOnly || (!origRenderOrder.contains(type)
               || origColour == null
@@ -1104,10 +1087,19 @@ f   */
         {
           fr.setColour(type, preferredColour);
         }
+        if (preferredFilters != null
+                && (!mergeOnly || fr.getFeatureFilter(type) != null))
+        {
+          fr.setFeatureFilter(type, preferredFilters);
+        }
         if (featureSettings.isFeatureDisplayed(type))
         {
           displayed.setVisible(type);
         }
+        else if (featureSettings.isFeatureHidden(type))
+        {
+          displayed.setHidden(type);
+        }
       }
     }
 
@@ -1136,6 +1128,7 @@ f   */
       fr.orderFeatures(featureSettings);
     }
     fr.setTransparency(featureSettings.getTransparency());
+    fr.notifyFeaturesChanged();
   }
 
   public String getViewName()