JAL-969 drop the hiddenColumns flag in favour of checking current state of columnSele...
[jalview.git] / src / jalview / viewmodel / AlignmentViewport.java
index daea70d..9cd9bfd 100644 (file)
@@ -637,10 +637,6 @@ public abstract class AlignmentViewport implements AlignViewportI
   public void setHiddenColumns(ColumnSelection colsel)
   {
     this.colSel = colsel;
-    if (colSel.getHiddenColumns() != null)
-    {
-      hasHiddenColumns = true;
-    }
   }
 
   @Override
@@ -676,11 +672,17 @@ public abstract class AlignmentViewport implements AlignViewportI
     this.hiddenRepSequences = hiddenRepSequences;
   }
 
-  protected boolean hasHiddenColumns = false;
+  @Override
+  public boolean hasHiddenColumns()
+  {
+    return colSel != null && colSel.hasHiddenColumns();
+  }
 
   public void updateHiddenColumns()
   {
-    hasHiddenColumns = colSel.hasHiddenColumns();
+    // this method doesn't really do anything now. But - it could, since a
+    // column Selection could be in the process of modification
+    // hasHiddenColumns = colSel.hasHiddenColumns();
   }
 
   protected boolean hasHiddenRows = false;
@@ -864,7 +866,6 @@ public abstract class AlignmentViewport implements AlignViewportI
     colSel.hideSelectedColumns();
     setSelectionGroup(null);
 
-    hasHiddenColumns = true;
   }
 
   public void hideColumns(int start, int end)
@@ -877,23 +878,17 @@ public abstract class AlignmentViewport implements AlignViewportI
     {
       colSel.hideColumns(start, end);
     }
-
-    hasHiddenColumns = true;
   }
 
   public void showColumn(int col)
   {
     colSel.revealHiddenColumns(col);
-    if (colSel.getHiddenColumns() == null)
-    {
-      hasHiddenColumns = false;
-    }
+
   }
 
   public void showAllHiddenColumns()
   {
     colSel.revealAllHiddenColumns();
-    hasHiddenColumns = false;
   }
 
   // common hide/show seq stuff
@@ -1046,32 +1041,24 @@ public abstract class AlignmentViewport implements AlignViewportI
             : hiddenRepSequences.get(seq));
   }
 
+  @Override
   public int adjustForHiddenSeqs(int alignmentIndex)
   {
     return alignment.getHiddenSequences().adjustForHiddenSeqs(
             alignmentIndex);
   }
 
-  // Selection manipulation
-  /**
-   * broadcast selection to any interested parties
-   */
+  @Override
   public abstract void sendSelection();
 
+  @Override
   public void invertColumnSelection()
   {
     colSel.invertColumnSelection(0, alignment.getWidth());
   }
 
-  /**
-   * This method returns an array of new SequenceI objects derived from the
-   * whole alignment or just the current selection with start and end points
-   * adjusted
-   * 
-   * @note if you need references to the actual SequenceI objects in the
-   *       alignment or currently selected then use getSequenceSelection()
-   * @return selection as new sequenceI objects
-   */
+
+  @Override
   public SequenceI[] getSelectionAsNewSequence()
   {
     SequenceI[] sequences;
@@ -1100,12 +1087,7 @@ public abstract class AlignmentViewport implements AlignViewportI
     return sequences;
   }
 
-  /**
-   * get the currently selected sequence objects or all the sequences in the
-   * alignment.
-   * 
-   * @return array of references to sequence objects
-   */
+
   @Override
   public SequenceI[] getSequenceSelection()
   {
@@ -1121,31 +1103,16 @@ public abstract class AlignmentViewport implements AlignViewportI
     return sequences;
   }
 
-  /**
-   * This method returns the visible alignment as text, as seen on the GUI, ie
-   * if columns are hidden they will not be returned in the result. Use this for
-   * calculating trees, PCA, redundancy etc on views which contain hidden
-   * columns.
-   * 
-   * @return String[]
-   */
+
   @Override
   public jalview.datamodel.CigarArray getViewAsCigars(
           boolean selectedRegionOnly)
   {
-    return new jalview.datamodel.CigarArray(alignment,
-            (hasHiddenColumns ? colSel : null),
+    return new jalview.datamodel.CigarArray(alignment, colSel,
             (selectedRegionOnly ? selectionGroup : null));
   }
 
-  /**
-   * return a compact representation of the current alignment selection to pass
-   * to an analysis function
-   * 
-   * @param selectedOnly
-   *          boolean true to just return the selected view
-   * @return AlignmentView
-   */
+
   @Override
   public jalview.datamodel.AlignmentView getAlignmentView(
           boolean selectedOnly)
@@ -1153,34 +1120,17 @@ public abstract class AlignmentViewport implements AlignViewportI
     return getAlignmentView(selectedOnly, false);
   }
 
-  /**
-   * return a compact representation of the current alignment selection to pass
-   * to an analysis function
-   * 
-   * @param selectedOnly
-   *          boolean true to just return the selected view
-   * @param markGroups
-   *          boolean true to annotate the alignment view with groups on the
-   *          alignment (and intersecting with selected region if selectedOnly
-   *          is true)
-   * @return AlignmentView
-   */
+
   @Override
   public jalview.datamodel.AlignmentView getAlignmentView(
           boolean selectedOnly, boolean markGroups)
   {
     return new AlignmentView(alignment, colSel, selectionGroup,
-            hasHiddenColumns, selectedOnly, markGroups);
+            colSel != null && colSel.hasHiddenColumns(), selectedOnly,
+            markGroups);
   }
 
-  /**
-   * This method returns the visible alignment as text, as seen on the GUI, ie
-   * if columns are hidden they will not be returned in the result. Use this for
-   * calculating trees, PCA, redundancy etc on views which contain hidden
-   * columns.
-   * 
-   * @return String[]
-   */
+
   @Override
   public String[] getViewAsString(boolean selectedRegionOnly)
   {
@@ -1203,7 +1153,7 @@ public abstract class AlignmentViewport implements AlignViewportI
     }
 
     selection = new String[iSize];
-    if (hasHiddenColumns)
+    if (colSel != null && colSel.hasHiddenColumns())
     {
       selection = colSel.getVisibleSequenceStrings(start, end, seqs);
     }
@@ -1218,15 +1168,8 @@ public abstract class AlignmentViewport implements AlignViewportI
     return selection;
   }
 
-  /**
-   * return visible region boundaries within given column range
-   * 
-   * @param min
-   *          first column (inclusive, from 0)
-   * @param max
-   *          last column (exclusive)
-   * @return int[][] range of {start,end} visible positions
-   */
+
+  @Override
   public int[][] getVisibleRegionBoundaries(int min, int max)
   {
     Vector regions = new Vector();
@@ -1235,7 +1178,7 @@ public abstract class AlignmentViewport implements AlignViewportI
 
     do
     {
-      if (hasHiddenColumns)
+      if (colSel != null && colSel.hasHiddenColumns())
       {
         if (start == 0)
         {
@@ -1256,7 +1199,7 @@ public abstract class AlignmentViewport implements AlignViewportI
       regions.addElement(new int[]
       { start, end });
 
-      if (hasHiddenColumns)
+      if (colSel != null && colSel.hasHiddenColumns())
       {
         start = colSel.adjustForHiddenColumns(end);
         start = colSel.getHiddenBoundaryLeft(start) + 1;
@@ -1293,18 +1236,15 @@ public abstract class AlignmentViewport implements AlignViewportI
     return ala;
   }
 
-  /**
-   * @return the padGaps
-   */
+
+  @Override
   public boolean isPadGaps()
   {
     return padGaps;
   }
 
-  /**
-   * @param padGaps
-   *          the padGaps to set
-   */
+
+  @Override
   public void setPadGaps(boolean padGaps)
   {
     this.padGaps = padGaps;
@@ -1316,6 +1256,7 @@ public abstract class AlignmentViewport implements AlignViewportI
    * 
    * @param ap
    */
+  @Override
   public void alignmentChanged(AlignmentViewPanel ap)
   {
     if (isPadGaps())
@@ -1477,6 +1418,7 @@ public abstract class AlignmentViewport implements AlignViewportI
    * 
    * @see jalview.api.AlignViewportI#calcPanelHeight()
    */
+  @Override
   public int calcPanelHeight()
   {
     // setHeight of panels
@@ -1617,11 +1559,13 @@ public abstract class AlignmentViewport implements AlignViewportI
    */
   private boolean colourByReferenceSeq=false;
 
+  @Override
   public boolean isDisplayReferenceSeq()
   {
     return alignment.hasSeqrep() && displayReferenceSeq;
   }
 
+  @Override
   public void setDisplayReferenceSeq(boolean displayReferenceSeq)
   {
     this.displayReferenceSeq = displayReferenceSeq;
@@ -1703,11 +1647,13 @@ public abstract class AlignmentViewport implements AlignViewportI
     return featuresDisplayed;
   }
 
+  @Override
   public void setFeaturesDisplayed(FeaturesDisplayedI featuresDisplayedI)
   {
     featuresDisplayed = featuresDisplayedI;
   }
 
+  @Override
   public boolean areFeaturesDisplayed()
   {
     return featuresDisplayed != null && featuresDisplayed.getRegisterdFeaturesCount()>0;
@@ -1737,11 +1683,13 @@ public abstract class AlignmentViewport implements AlignViewportI
 
   boolean showSeqFeaturesHeight;
 
+  @Override
   public void setShowSequenceFeaturesHeight(boolean selected)
   {
     showSeqFeaturesHeight = selected;
   }
 
+  @Override
   public boolean isShowSequenceFeaturesHeight()
   {
     return showSeqFeaturesHeight;