JAL-3751 only merge strictly contiguous ranges of mappings
[jalview.git] / src / jalview / viewmodel / AlignmentViewport.java
index 6427b45..cbc2189 100644 (file)
@@ -662,7 +662,8 @@ public abstract class AlignmentViewport
          * retain any colour thresholds per group while
          * changing choice of colour scheme (JAL-2386)
          */
-        sg.setColourScheme(cs);
+        sg.setColourScheme(
+                cs == null ? null : cs.getInstance(this, sg));
         if (cs != null)
         {
           sg.getGroupColourScheme().alignmentChanged(sg,
@@ -958,6 +959,7 @@ public abstract class AlignmentViewport
     ranges = null;
     currentTree = null;
     selectionGroup = null;
+    colSel = null;
     setAlignment(null);
   }
 
@@ -1636,6 +1638,7 @@ public abstract class AlignmentViewport
   public void invertColumnSelection()
   {
     colSel.invertColumnSelection(0, alignment.getWidth(), alignment);
+    isColSelChanged(true);
   }
 
   @Override
@@ -1691,11 +1694,29 @@ public abstract class AlignmentViewport
   public jalview.datamodel.AlignmentView getAlignmentView(
           boolean selectedOnly, boolean markGroups)
   {
-    return new AlignmentView(alignment, alignment.getHiddenColumns(),
-            selectionGroup,
+    return getAlignmentViewWithComplement(selectedOnly,markGroups,true);
+  }
+  
+  @Override
+  public jalview.datamodel.AlignmentView getAlignmentViewWithComplement(
+          boolean selectedOnly, boolean markGroups,boolean withComplment)
+  {
+    AlignmentView complementView = null;
+    if (withComplment)
+    {
+      if (codingComplement != null)
+      {
+        complementView = codingComplement.getAlignmentViewWithComplement(
+                selectedOnly, markGroups, false);
+      }
+    }
+    AlignmentView thisView = new AlignmentView(alignment,
+            alignment.getHiddenColumns(), selectionGroup,
             alignment.getHiddenColumns() != null
                     && alignment.getHiddenColumns().hasHiddenColumns(),
             selectedOnly, markGroups);
+    thisView.setComplement(complementView);
+    return thisView;
   }
 
   @Override
@@ -2714,6 +2735,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
@@ -3018,4 +3063,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));
+  }
 }