JAL-4071 boring GUI bits - add togglable menu item for show/hide sequence feature...
[jalview.git] / src / jalview / viewmodel / AlignmentViewport.java
index ae101a3..72eb9c0 100644 (file)
  */
 package jalview.viewmodel;
 
+import java.awt.Color;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.analysis.Conservation;
 import jalview.analysis.TreeModel;
@@ -61,18 +73,6 @@ import jalview.workers.ComplementConsensusThread;
 import jalview.workers.ConsensusThread;
 import jalview.workers.StrucConsensusThread;
 
-import java.awt.Color;
-import java.beans.PropertyChangeSupport;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 /**
  * base class holding visualization and analysis attributes and common logic for
  * an active alignment view displayed in the GUI
@@ -571,6 +571,28 @@ public abstract class AlignmentViewport
     viewStyle.setSeqNameItalics(default1);
   }
 
+  /**
+   * Set the flag indicating that feature count annotation tracks are to be
+   * displayed
+   * 
+   * @see jalview.api.ViewStyleI#setShowSequenceFeatureCounts(boolean)
+   */
+  @Override
+  public void setShowSequenceFeatureCounts(boolean show)
+  {
+    viewStyle.setShowSequenceFeatureCounts(show);
+  }
+
+  /**
+   * @return true if feature count annotation tracks are to be displayed
+   * @see jalview.api.ViewStyleI#isShowSequenceFeatureCounts()
+   */
+  @Override
+  public boolean isShowSequenceFeatureCounts()
+  {
+    return viewStyle.isShowSequenceFeatureCounts();
+  }
+
   @Override
   public AlignmentI getAlignment()
   {
@@ -664,8 +686,7 @@ public abstract class AlignmentViewport
          * retain any colour thresholds per group while
          * changing choice of colour scheme (JAL-2386)
          */
-        sg.setColourScheme(
-                cs == null ? null : cs.getInstance(this, sg));
+        sg.setColourScheme(cs == null ? null : cs.getInstance(this, sg));
         if (cs != null)
         {
           sg.getGroupColourScheme().alignmentChanged(sg,
@@ -963,6 +984,7 @@ public abstract class AlignmentViewport
     ranges = null;
     currentTree = null;
     selectionGroup = null;
+    colSel = null;
     setAlignment(null);
   }
 
@@ -1323,21 +1345,6 @@ public abstract class AlignmentViewport
    */
   private boolean followHighlight = true;
 
-  // private boolean disableFastPaint; // BH 2019.04.18
-  //
-  // /**
-  // * BH 2019.04.18 When gap filling is on and a modification is made to fill
-  // * those, we need to disallow fast painting for paste just once
-  // *
-  // * @return
-  // */
-  // public boolean isFastPaintDisabled()
-  // {
-  // boolean ret = disableFastPaint;
-  // disableFastPaint = false;
-  // return ret;
-  // }
-
   /**
    * Property change listener for changes in alignment
    * 
@@ -1835,9 +1842,8 @@ public abstract class AlignmentViewport
         AlignmentAnnotation clone = new AlignmentAnnotation(annot);
         if (selectedOnly && selectionGroup != null)
         {
-          clone.makeVisibleAnnotation(
-                  selectionGroup.getStartRes(), selectionGroup.getEndRes(),
-                  alignment.getHiddenColumns());
+          clone.makeVisibleAnnotation(selectionGroup.getStartRes(),
+                  selectionGroup.getEndRes(), alignment.getHiddenColumns());
         }
         else
         {
@@ -1873,11 +1879,6 @@ public abstract class AlignmentViewport
     if (isPadGaps())
     {
       alignment.padGaps();
-      // if (alignment.padGaps())
-      // {
-      // // the new alignment has been modified -- can't fast paint
-      // disableFastPaint = true;
-      // }
     }
     if (autoCalculateConsensus)
     {
@@ -2287,7 +2288,7 @@ public abstract class AlignmentViewport
   public void clearSequenceColours()
   {
     sequenceColours.clear();
-  };
+  }
 
   @Override
   public AlignViewportI getCodingComplement()
@@ -2740,6 +2741,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
@@ -2982,7 +3007,8 @@ public abstract class AlignmentViewport
   }
 
   @Override
-  public AlignmentExportData getAlignExportData(AlignExportSettingsI options)
+  public AlignmentExportData getAlignExportData(
+          AlignExportSettingsI options)
   {
     AlignmentI alignmentToExport = null;
     String[] omitHidden = null;
@@ -3010,7 +3036,7 @@ public abstract class AlignmentViewport
             omitHidden, alignmentStartEnd);
     return ed;
   }
-  
+
   /**
    * flag set to indicate if structure views might be out of sync with sequences
    * in the alignment
@@ -3074,4 +3100,22 @@ public abstract class AlignmentViewport
       codingComplement.setUpdateStructures(needToUpdateStructureViews);
     }
   }
+
+  @Override
+  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));
+  }
 }