JAL-2388 Preliminary refactor check-in, does not compile
[jalview.git] / src / jalview / viewmodel / AlignmentViewport.java
index 69879b7..b62c61c 100644 (file)
@@ -42,11 +42,9 @@ import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
-import jalview.schemes.Blosum62ColourScheme;
-import jalview.schemes.CollectionColourScheme;
-import jalview.schemes.CollectionColourSchemeI;
+import jalview.renderer.ResidueShader;
+import jalview.renderer.ResidueShaderI;
 import jalview.schemes.ColourSchemeI;
-import jalview.schemes.PIDColourScheme;
 import jalview.structure.CommandListener;
 import jalview.structure.StructureSelectionManager;
 import jalview.structure.VamsasSource;
@@ -80,6 +78,8 @@ import java.util.Map;
 public abstract class AlignmentViewport implements AlignViewportI,
         CommandListener, VamsasSource
 {
+  protected ViewportPositionProps posProps;
+
   protected ViewStyleI viewStyle = new ViewStyle();
 
   /**
@@ -589,9 +589,9 @@ public abstract class AlignmentViewport implements AlignViewportI,
     return isDataset;
   }
 
-  private Map<SequenceI, SequenceCollectionI> hiddenRepSequences;
 
-  protected ColumnSelection colSel = new ColumnSelection();
+
+  // protected ColumnSelection colSel = new ColumnSelection();
 
   public boolean autoCalculateConsensus = true;
 
@@ -599,7 +599,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
 
   protected boolean ignoreGapsInConsensusCalculation = false;
 
-  protected CollectionColourSchemeI globalColourScheme;
+  protected ResidueShaderI residueShading;
 
   @Override
   public void setGlobalColourScheme(ColourSchemeI cs)
@@ -607,37 +607,32 @@ public abstract class AlignmentViewport implements AlignViewportI,
     // TODO: logic refactored from AlignFrame changeColour -
     // TODO: autorecalc stuff should be changed to rely on the worker system
     // check to see if we should implement a changeColour(cs) method rather than
-    // put th logic in here
+    // put the logic in here
     // - means that caller decides if they want to just modify state and defer
     // calculation till later or to do all calculations in thread.
     // via changecolour
 
     /*
-     * only instantiate collection colour scheme once, thereafter update it
+     * only instantiate alignment colouring once, thereafter update it;
      * this means that any conservation or PID threshold settings
      * persist when the alignment colour scheme is changed
      */
-    if (globalColourScheme == null)
+    if (residueShading == null)
     {
-      globalColourScheme = new CollectionColourScheme();
+      residueShading = new ResidueShader(viewStyle);
     }
-    globalColourScheme.setColourScheme(cs);
+    residueShading.setColourScheme(cs);
 
-    // boolean recalc = false;
-    // TODO: do threshold and increment belong in ViewStyle or colour scheme?
-    // problem: groups need this but do not currently have a ViewStyle
+    // TODO: do threshold and increment belong in ViewStyle or ResidueShader?
+    // ...problem: groups need these, but do not currently have a ViewStyle
 
     if (cs != null)
     {
-      if (getConservationSelected() || getAbovePIDThreshold()
-              || cs instanceof PIDColourScheme
-              || cs instanceof Blosum62ColourScheme)
+      if (getConservationSelected())
       {
-        globalColourScheme.setConservation(hconservation);
-        globalColourScheme
-                .setConservationApplied(getConservationSelected());
+        residueShading.setConservation(hconservation);
       }
-      globalColourScheme.alignmentChanged(alignment, hiddenRepSequences);
+      residueShading.alignmentChanged(alignment, getHiddenRepSequences());
     }
 
     /*
@@ -656,7 +651,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
         if (cs != null)
         {
           sg.getGroupColourScheme()
-                  .alignmentChanged(sg, hiddenRepSequences);
+.alignmentChanged(sg,
+                  getHiddenRepSequences());
         }
       }
     }
@@ -665,14 +661,14 @@ public abstract class AlignmentViewport implements AlignViewportI,
   @Override
   public ColourSchemeI getGlobalColourScheme()
   {
-    return globalColourScheme == null ? null : globalColourScheme
+    return residueShading == null ? null : residueShading
             .getColourScheme();
   }
 
   @Override
-  public CollectionColourSchemeI getViewportColourScheme()
+  public ResidueShaderI getResidueShading()
   {
-    return globalColourScheme;
+    return residueShading;
   }
 
   protected AlignmentAnnotation consensus;
@@ -932,7 +928,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
     hconsensus = null;
     hcomplementConsensus = null;
     // colour scheme may hold reference to consensus
-    globalColourScheme = null;
+    residueShading = null;
     // TODO remove listeners from changeSupport?
     changeSupport = null;
     setAlignment(null);
@@ -1080,7 +1076,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
   }
 
   /**
-   * Set the selection group for this window.
+   * Set the selection group for this window. Also sets the current alignment as
+   * the context for the group, if it does not already have one.
    * 
    * @param sg
    *          - group holding references to sequences in this alignment view
@@ -1090,28 +1087,35 @@ public abstract class AlignmentViewport implements AlignViewportI,
   public void setSelectionGroup(SequenceGroup sg)
   {
     selectionGroup = sg;
+    if (sg != null && sg.getContext() == null)
+    {
+      sg.setContext(alignment);
+    }
   }
 
   public void setHiddenColumns(ColumnSelection colsel)
   {
-    this.colSel = colsel;
+    posProps.setHiddenColumns(colsel);
+    // this.colSel = colsel;
   }
 
   @Override
   public ColumnSelection getColumnSelection()
   {
-    return colSel;
+    return posProps.getColumnSelection();
+    // return colSel;
   }
 
   @Override
   public void setColumnSelection(ColumnSelection colSel)
   {
-    this.colSel = colSel;
+    posProps.setColumnSelection(colSel);
+    /*this.colSel = colSel;
     if (colSel != null)
     {
       updateHiddenColumns();
     }
-    isColSelChanged(true);
+    isColSelChanged(true);*/
   }
 
   /**
@@ -1121,14 +1125,14 @@ public abstract class AlignmentViewport implements AlignViewportI,
   @Override
   public Map<SequenceI, SequenceCollectionI> getHiddenRepSequences()
   {
-    return hiddenRepSequences;
+    return posProps.getHiddenRepSequences();
   }
 
   @Override
   public void setHiddenRepSequences(
           Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
   {
-    this.hiddenRepSequences = hiddenRepSequences;
+    posProps.getHiddenRepSequences();
   }
 
   @Override
@@ -1141,7 +1145,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
   @Override
   public boolean hasHiddenColumns()
   {
-    return colSel != null && colSel.hasHiddenColumns();
+    return posProps.hasHiddenColumns();
+    // return colSel != null && colSel.hasHiddenColumns();
   }
 
   public void updateHiddenColumns()
@@ -1202,16 +1207,16 @@ public abstract class AlignmentViewport implements AlignViewportI,
     if (ap != null)
     {
       updateConsensus(ap);
-      if (globalColourScheme != null)
+      if (residueShading != null)
       {
-        globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
+        residueShading.setThreshold(residueShading.getThreshold(),
                 ignoreGapsInConsensusCalculation);
       }
     }
 
   }
 
-  private long sgrouphash = -1, colselhash = -1;
+  private long sgrouphash = -1;
 
   /**
    * checks current SelectionGroup against record of last hash value, and
@@ -1247,7 +1252,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
    */
   public boolean isColSelChanged(boolean b)
   {
-    int hc = (colSel == null || colSel.isEmpty()) ? -1 : colSel.hashCode();
+    return posProps.isColSelChanged(b);
+    /*int hc = (colSel == null || colSel.isEmpty()) ? -1 : colSel.hashCode();
     if (hc != -1 && hc != colselhash)
     {
       if (b)
@@ -1256,7 +1262,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
       }
       return true;
     }
-    return false;
+    return false;*/
   }
 
   @Override
@@ -1287,14 +1293,13 @@ public abstract class AlignmentViewport implements AlignViewportI,
    */
   private boolean followHighlight = true;
 
-  // TODO private with getters and setters?
-  public int startRes;
+  /*private int startRes;
 
-  public int endRes;
+  private int endRes;
 
-  public int startSeq;
+  private int startSeq;
 
-  public int endSeq;
+  private int endSeq;*/
 
   /**
    * Property change listener for changes in alignment
@@ -1338,6 +1343,21 @@ public abstract class AlignmentViewport implements AlignViewportI,
 
   // common hide/show column stuff
 
+  public void hideColumns(int start, int end)
+  {
+    posProps.hideColumns(start, end);
+  }
+
+  public void showColumn(int col)
+  {
+    posProps.showColumn(col);
+  }
+
+  public void showAllHiddenColumns()
+  {
+    posProps.showAllHiddenColumns();
+  }
+
   public void hideSelectedColumns()
   {
     if (colSel.isEmpty())
@@ -1350,61 +1370,41 @@ public abstract class AlignmentViewport implements AlignViewportI,
     isColSelChanged(true);
   }
 
-  public void hideColumns(int start, int end)
-  {
-    if (start == end)
-    {
-      colSel.hideColumns(start);
-    }
-    else
-    {
-      colSel.hideColumns(start, end);
-    }
-    isColSelChanged(true);
-  }
-
-  public void showColumn(int col)
-  {
-    colSel.revealHiddenColumns(col);
-    isColSelChanged(true);
-  }
 
-  public void showAllHiddenColumns()
-  {
-    colSel.revealAllHiddenColumns();
-    isColSelChanged(true);
-  }
 
   // common hide/show seq stuff
   public void showAllHiddenSeqs()
   {
-    if (alignment.getHiddenSequences().getSize() > 0)
-    {
-      if (selectionGroup == null)
-      {
-        selectionGroup = new SequenceGroup();
-        selectionGroup.setEndRes(alignment.getWidth() - 1);
-      }
-      List<SequenceI> tmp = alignment.getHiddenSequences().showAll(
-              hiddenRepSequences);
-      for (SequenceI seq : tmp)
-      {
-        selectionGroup.addSequence(seq, false);
-        setSequenceAnnotationsVisible(seq, true);
-      }
+    selectionGroup = posProps.showAllHiddenSeqs(selectionGroup);
+
+    /*    if (alignment.getHiddenSequences().getSize() > 0)
+        {
+          if (selectionGroup == null)
+          {
+            selectionGroup = new SequenceGroup();
+            selectionGroup.setEndRes(alignment.getWidth() - 1);
+          }
+          List<SequenceI> tmp = alignment.getHiddenSequences().showAll(
+                  hiddenRepSequences);
+          for (SequenceI seq : tmp)
+          {
+            selectionGroup.addSequence(seq, false);
+            setSequenceAnnotationsVisible(seq, true);
+          }
 
-      hiddenRepSequences = null;
+          hiddenRepSequences = null;
 
-      firePropertyChange("alignment", null, alignment.getSequences());
-      // used to set hasHiddenRows/hiddenRepSequences here, after the property
-      // changed event
-      sendSelection();
-    }
+          firePropertyChange("alignment", null, alignment.getSequences());
+          // used to set hasHiddenRows/hiddenRepSequences here, after the property
+          // changed event
+          sendSelection();
+        }*/
   }
 
   public void showSequence(int index)
   {
-    List<SequenceI> tmp = alignment.getHiddenSequences().showSequence(
+    posProps.showSequence(index, selectionGroup);
+    /*List<SequenceI> tmp = alignment.getHiddenSequences().showSequence(
             index, hiddenRepSequences);
     if (tmp.size() > 0)
     {
@@ -1421,12 +1421,13 @@ public abstract class AlignmentViewport implements AlignViewportI,
       }
       firePropertyChange("alignment", null, alignment.getSequences());
       sendSelection();
-    }
+    }*/
   }
 
   public void hideAllSelectedSeqs()
   {
-    if (selectionGroup == null || selectionGroup.getSize() < 1)
+    posProps.hideAllSelectedSeqs(selectionGroup);
+    /*if (selectionGroup == null || selectionGroup.getSize() < 1)
     {
       return;
     }
@@ -1435,12 +1436,13 @@ public abstract class AlignmentViewport implements AlignViewportI,
 
     hideSequence(seqs);
 
-    setSelectionGroup(null);
+    setSelectionGroup(null);*/
   }
 
   public void hideSequence(SequenceI[] seq)
   {
-    if (seq != null)
+    posProps.hideSequence(seq);
+    /*if (seq != null)
     {
       for (int i = 0; i < seq.length; i++)
       {
@@ -1448,7 +1450,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
         setSequenceAnnotationsVisible(seq[i], false);
       }
       firePropertyChange("alignment", null, alignment.getSequences());
-    }
+    }*/
   }
 
   /**
@@ -1462,7 +1464,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
    */
   public void hideSequences(SequenceI sequence, boolean representGroup)
   {
-    if (selectionGroup == null || selectionGroup.getSize() < 1)
+    posProps.hideSequences(sequence, representGroup, selectionGroup);
+    /*if (selectionGroup == null || selectionGroup.getSize() < 1)
     {
       hideSequence(new SequenceI[] { sequence });
       return;
@@ -1481,33 +1484,14 @@ public abstract class AlignmentViewport implements AlignViewportI,
 
     hideSequence(hseqs);
     setSelectionGroup(null);
-    sendSelection();
+    sendSelection();*/
   }
 
-  /**
-   * Set visibility for any annotations for the given sequence.
-   * 
-   * @param sequenceI
-   */
-  protected void setSequenceAnnotationsVisible(SequenceI sequenceI,
-          boolean visible)
-  {
-    AlignmentAnnotation[] anns = alignment.getAlignmentAnnotation();
-    if (anns != null)
-    {
-      for (AlignmentAnnotation ann : anns)
-      {
-        if (ann.sequenceRef == sequenceI)
-        {
-          ann.visible = visible;
-        }
-      }
-    }
-  }
 
   public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
   {
-    int sSize = sg.getSize();
+    posProps.hideRepSequences(repSequence, sg);
+    /*int sSize = sg.getSize();
     if (sSize < 2)
     {
       return;
@@ -1537,7 +1521,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
     }
     sg.setSeqrep(repSequence); // note: not done in 2.7applet
     sg.setHidereps(true); // note: not done in 2.7applet
-    hideSequence(seqs);
+    hideSequence(seqs);*/
 
   }
 
@@ -1567,8 +1551,9 @@ public abstract class AlignmentViewport implements AlignViewportI,
    */
   public boolean isHiddenRepSequence(SequenceI seq)
   {
-    return (hiddenRepSequences != null && hiddenRepSequences
-            .containsKey(seq));
+    return posProps.isHiddenRepSequence(seq);
+    // return (hiddenRepSequences != null && hiddenRepSequences
+    // .containsKey(seq));
   }
 
   /**
@@ -1579,21 +1564,24 @@ public abstract class AlignmentViewport implements AlignViewportI,
    */
   public SequenceGroup getRepresentedSequences(SequenceI seq)
   {
-    return (SequenceGroup) (hiddenRepSequences == null ? null
-            : hiddenRepSequences.get(seq));
+    return posProps.getRepresentedSequences(seq);
+    // return (SequenceGroup) (hiddenRepSequences == null ? null
+    // : hiddenRepSequences.get(seq));
   }
 
   @Override
   public int adjustForHiddenSeqs(int alignmentIndex)
   {
-    return alignment.getHiddenSequences().adjustForHiddenSeqs(
-            alignmentIndex);
+    return posProps.adjustForHiddenSeqs(alignmentIndex);
+    // return alignment.getHiddenSequences().adjustForHiddenSeqs(
+    // alignmentIndex);
   }
 
   @Override
   public void invertColumnSelection()
   {
-    colSel.invertColumnSelection(0, alignment.getWidth());
+    posProps.invertColumnSelection();
+    // colSel.invertColumnSelection(0, alignment.getWidth());
   }
 
   @Override
@@ -1641,7 +1629,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
   @Override
   public CigarArray getViewAsCigars(boolean selectedRegionOnly)
   {
-    return new CigarArray(alignment, colSel,
+    return new CigarArray(alignment, posProps.getColumnSelection(),
             (selectedRegionOnly ? selectionGroup : null));
   }
 
@@ -1656,8 +1644,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
   public jalview.datamodel.AlignmentView getAlignmentView(
           boolean selectedOnly, boolean markGroups)
   {
-    return new AlignmentView(alignment, colSel, selectionGroup,
-            colSel != null && colSel.hasHiddenColumns(), selectedOnly,
+    return new AlignmentView(alignment, posProps.getColumnSelection(),
+            selectionGroup, posProps.hasHiddenColumns(), selectedOnly,
             markGroups);
   }
 
@@ -1701,9 +1689,9 @@ public abstract class AlignmentViewport implements AlignViewportI,
     }
 
     selection = new String[iSize];
-    if (colSel != null && colSel.hasHiddenColumns())
+    if (posProps.hasHiddenColumns())
     {
-      selection = colSel.getVisibleSequenceStrings(start, end, seqs);
+      selection = posProps.getVisibleSequenceStrings(start, end, seqs);
     }
     else
     {
@@ -1719,49 +1707,52 @@ public abstract class AlignmentViewport implements AlignViewportI,
   @Override
   public List<int[]> getVisibleRegionBoundaries(int min, int max)
   {
-    ArrayList<int[]> regions = new ArrayList<int[]>();
-    int start = min;
-    int end = max;
-
-    do
-    {
-      if (colSel != null && colSel.hasHiddenColumns())
-      {
-        if (start == 0)
-        {
-          start = colSel.adjustForHiddenColumns(start);
-        }
+    return posProps.getVisibleRegionBoundaries(min, max);
+    /*    ArrayList<int[]> regions = new ArrayList<int[]>();
+        int start = min;
+        int end = max;
 
-        end = colSel.getHiddenBoundaryRight(start);
-        if (start == end)
-        {
-          end = max;
-        }
-        if (end > max)
+        do
         {
-          end = max;
-        }
-      }
+          if (colSel != null && colSel.hasHiddenColumns())
+          {
+            if (start == 0)
+            {
+              start = colSel.adjustForHiddenColumns(start);
+            }
+
+            end = colSel.getHiddenBoundaryRight(start);
+            if (start == end)
+            {
+              end = max;
+            }
+            if (end > max)
+            {
+              end = max;
+            }
+          }
 
-      regions.add(new int[] { start, end });
+          regions.add(new int[] { start, end });
 
-      if (colSel != null && colSel.hasHiddenColumns())
-      {
-        start = colSel.adjustForHiddenColumns(end);
-        start = colSel.getHiddenBoundaryLeft(start) + 1;
-      }
-    } while (end < max);
+          if (posProps.hasHiddenColumns())
+          {
+            start = colSel.adjustForHiddenColumns(end);
+            start = colSel.getHiddenBoundaryLeft(start) + 1;
+          }
+        } while (end < max);
 
-    int[][] startEnd = new int[regions.size()][2];
+        int[][] startEnd = new int[regions.size()][2];
 
-    return regions;
+        return regions;*/
   }
 
   @Override
   public List<AlignmentAnnotation> getVisibleAlignmentAnnotation(
           boolean selectedOnly)
   {
-    ArrayList<AlignmentAnnotation> ala = new ArrayList<AlignmentAnnotation>();
+    return posProps.getVisibleAlignmentAnnotation(selectedOnly,
+            selectionGroup);
+    /*ArrayList<AlignmentAnnotation> ala = new ArrayList<AlignmentAnnotation>();
     AlignmentAnnotation[] aa;
     if ((aa = alignment.getAlignmentAnnotation()) != null)
     {
@@ -1780,7 +1771,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
         ala.add(clone);
       }
     }
-    return ala;
+    return ala;*/
   }
 
   @Override
@@ -1840,7 +1831,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
       selectionGroup.setEndRes(alWidth - 1);
     }
 
-    resetAllColourSchemes();
+    updateAllColourSchemes();
     calculator.restartWorkers();
     // alignment.adjustSequenceAnnotations();
   }
@@ -1848,17 +1839,17 @@ public abstract class AlignmentViewport implements AlignViewportI,
   /**
    * reset scope and do calculations for all applied colourschemes on alignment
    */
-  void resetAllColourSchemes()
+  void updateAllColourSchemes()
   {
-    CollectionColourSchemeI cs = globalColourScheme;
-    if (cs != null)
+    ResidueShaderI rs = residueShading;
+    if (rs != null)
     {
-      cs.alignmentChanged(alignment, hiddenRepSequences);
+      rs.alignmentChanged(alignment, posProps.getHiddenRepSequences());
 
-      cs.setConsensus(hconsensus);
-      if (cs.conservationApplied())
+      rs.setConsensus(hconsensus);
+      if (rs.conservationApplied())
       {
-        cs.setConservation(Conservation.calculateConservation("All",
+        rs.setConservation(Conservation.calculateConservation("All",
                 alignment.getSequences(), 0, alignment.getWidth(), false,
                 getConsPercGaps(), false));
       }
@@ -1868,7 +1859,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
     {
       if (sg.cs != null)
       {
-        sg.cs.alignmentChanged(sg, hiddenRepSequences);
+        sg.cs.alignmentChanged(sg, posProps.getHiddenRepSequences());
       }
       sg.recalcConservation();
     }
@@ -2432,6 +2423,11 @@ public abstract class AlignmentViewport implements AlignViewportI,
   public void setViewStyle(ViewStyleI settingsForView)
   {
     viewStyle = new ViewStyle(settingsForView);
+    if (residueShading != null)
+    {
+      residueShading.setConservationApplied(settingsForView
+              .isConservationColourSelected());
+    }
   }
 
   @Override
@@ -2642,35 +2638,46 @@ public abstract class AlignmentViewport implements AlignViewportI,
     this.followHighlight = b;
   }
 
+  @Override
+  public ViewportPositionProps getPosProps()
+  {
+    return posProps;
+  }
+
+  @Override
   public int getStartRes()
   {
-    return startRes;
+    return posProps.getStartRes();
   }
 
   @Override
   public int getEndRes()
   {
-    return endRes;
+    return posProps.getEndRes();
   }
 
+  @Override
   public int getStartSeq()
   {
-    return startSeq;
+    return posProps.getStartSeq();
   }
 
   public void setStartRes(int res)
   {
-    this.startRes = res;
+    posProps.setStartRes(res);
+    // this.startRes = res;
   }
 
   public void setStartSeq(int seq)
   {
-    this.startSeq = seq;
+    posProps.setStartSeq(seq);
+    // this.startSeq = seq;
   }
 
   public void setEndRes(int res)
   {
-    if (res > alignment.getWidth() - 1)
+    posProps.setEndRes(res);
+    /*if (res > alignment.getWidth() - 1)
     {
       // log.System.out.println(" Corrected res from " + res + " to maximum " +
       // (alignment.getWidth()-1));
@@ -2680,12 +2687,13 @@ public abstract class AlignmentViewport implements AlignViewportI,
     {
       res = 0;
     }
-    this.endRes = res;
+    this.endRes = res;*/
   }
 
   public void setEndSeq(int seq)
   {
-    if (seq > alignment.getHeight())
+    posProps.setEndSeq(seq);
+    /*if (seq > alignment.getHeight())
     {
       seq = alignment.getHeight();
     }
@@ -2693,12 +2701,14 @@ public abstract class AlignmentViewport implements AlignViewportI,
     {
       seq = 0;
     }
-    this.endSeq = seq;
+    this.endSeq = seq;*/
   }
 
+  @Override
   public int getEndSeq()
   {
-    return endSeq;
+    return posProps.getEndSeq();
+    // return endSeq;
   }
 
   /**
@@ -2790,7 +2800,11 @@ public abstract class AlignmentViewport implements AlignViewportI,
    */
   public void expandColSelection(SequenceGroup sg, boolean wholewidth)
   {
-    int sgs, sge;
+    if (!this.hasSelectedColumns())
+    {
+      posProps.expandColSelection(sg, wholewidth);
+    }
+    /*int sgs, sge;
     if (sg != null && (sgs = sg.getStartRes()) >= 0
             && sg.getStartRes() <= (sge = sg.getEndRes())
             && !this.hasSelectedColumns())
@@ -2808,7 +2822,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
       {
         colSel.addElement(cspos);
       }
-    }
+    }*/
   }
 
   /**