From 54adeabf66bf1b5f2ef56855d3ba940602a854eb Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 23 Jan 2015 14:10:20 +0000 Subject: [PATCH] JAL-969 drop the hiddenColumns flag in favour of checking current state of columnSelection --- src/jalview/gui/AlignViewport.java | 31 ++--------------------- src/jalview/viewmodel/AlignmentViewport.java | 35 +++++++++++--------------- 2 files changed, 17 insertions(+), 49 deletions(-) diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 4df9a62..a2ed7cd 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -195,16 +195,7 @@ public class AlignViewport extends AlignmentViewport implements setAlignment(al); if (hiddenColumns != null) { - this.colSel = hiddenColumns; - if (hiddenColumns.getHiddenColumns() != null - && hiddenColumns.getHiddenColumns().size() > 0) - { - hasHiddenColumns = true; - } - else - { - hasHiddenColumns = false; - } + colSel = hiddenColumns; } init(); } @@ -251,16 +242,7 @@ public class AlignViewport extends AlignmentViewport implements setAlignment(al); if (hiddenColumns != null) { - this.colSel = hiddenColumns; - if (hiddenColumns.getHiddenColumns() != null - && hiddenColumns.getHiddenColumns().size() > 0) - { - hasHiddenColumns = true; - } - else - { - hasHiddenColumns = false; - } + colSel = hiddenColumns; } init(); } @@ -1019,15 +1001,6 @@ public class AlignViewport extends AlignmentViewport implements } /** - * - * @return true if view has hidden columns - */ - public boolean hasHiddenColumns() - { - return hasHiddenColumns; - } - - /** * when set, view will scroll to show the highlighted position */ public boolean followHighlight = true; diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index a48c910..9cd9bfd 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -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 @@ -1113,8 +1108,7 @@ public abstract class AlignmentViewport implements AlignViewportI 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)); } @@ -1132,7 +1126,8 @@ public abstract class AlignmentViewport implements AlignViewportI boolean selectedOnly, boolean markGroups) { return new AlignmentView(alignment, colSel, selectionGroup, - hasHiddenColumns, selectedOnly, markGroups); + colSel != null && colSel.hasHiddenColumns(), selectedOnly, + markGroups); } @@ -1158,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); } @@ -1183,7 +1178,7 @@ public abstract class AlignmentViewport implements AlignViewportI do { - if (hasHiddenColumns) + if (colSel != null && colSel.hasHiddenColumns()) { if (start == 0) { @@ -1204,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; -- 1.7.10.2