From 14985603cea28569e295ddabb219da8034f1c7b2 Mon Sep 17 00:00:00 2001 From: kiramt Date: Tue, 25 Apr 2017 12:15:50 +0100 Subject: [PATCH] JAL-2388 Working hidden regions hide/show in desktop --- resources/lang/Messages.properties | 2 +- resources/lang/Messages_es.properties | 2 +- src/jalview/appletgui/AlignFrame.java | 2 +- src/jalview/appletgui/AnnotationColumnChooser.java | 6 +- src/jalview/appletgui/AnnotationLabels.java | 2 +- src/jalview/appletgui/OverviewPanel.java | 18 +++--- src/jalview/appletgui/ScalePanel.java | 4 +- src/jalview/appletgui/SeqCanvas.java | 4 +- src/jalview/appletgui/SeqPanel.java | 2 +- src/jalview/datamodel/CigarArray.java | 2 +- src/jalview/datamodel/HiddenColumns.java | 33 ++++++++-- src/jalview/datamodel/VisibleColsIterator.java | 2 +- src/jalview/datamodel/VisibleRowsCollection.java | 2 +- src/jalview/datamodel/VisibleRowsIterator.java | 6 +- src/jalview/gui/AlignFrame.java | 4 +- src/jalview/gui/AnnotationColumnChooser.java | 6 +- src/jalview/gui/AnnotationLabels.java | 4 +- src/jalview/gui/Jalview2XML.java | 6 +- src/jalview/gui/OverviewCanvas.java | 9 +-- src/jalview/gui/OverviewPanel.java | 11 ++-- src/jalview/gui/ScalePanel.java | 8 +-- src/jalview/gui/SeqCanvas.java | 4 +- src/jalview/gui/SeqPanel.java | 2 +- src/jalview/io/AnnotationFile.java | 2 +- src/jalview/io/JSONFile.java | 2 +- src/jalview/util/MappingUtils.java | 2 +- src/jalview/viewmodel/OverviewDimensions.java | 25 ++++---- .../viewmodel/OverviewDimensionsAllVisible.java | 49 +++++++------- .../viewmodel/OverviewDimensionsWithHidden.java | 48 +++++++------- src/jalview/viewmodel/ViewportRanges.java | 3 +- test/jalview/datamodel/ColumnSelectionTest.java | 10 +-- test/jalview/datamodel/HiddenColumnsTest.java | 67 +++++++++++++------- test/jalview/gui/AlignFrameTest.java | 8 +-- test/jalview/io/JSONFileTest.java | 8 +-- test/jalview/util/MappingUtilsTest.java | 10 +-- test/jalview/viewmodel/OverviewDimensionsTest.java | 46 ++++++-------- 36 files changed, 230 insertions(+), 191 deletions(-) diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index b93acdc..6b6577f 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1297,4 +1297,4 @@ warn.name_cannot_be_duplicate = User-defined URL names must be unique and cannot label.invalid_name = Invalid Name ! label.output_seq_details = Output Sequence Details to list all database references label.urllinks = Links -label.togglehidden = Toggle hidden columns on/off \ No newline at end of file +label.togglehidden = Toggle hidden regions on/off \ No newline at end of file diff --git a/resources/lang/Messages_es.properties b/resources/lang/Messages_es.properties index 8e40552..bd14d2d 100644 --- a/resources/lang/Messages_es.properties +++ b/resources/lang/Messages_es.properties @@ -1298,4 +1298,4 @@ warn.name_cannot_be_duplicate = Los nombres URL definidos por el usuario deben s label.invalid_name = Nombre inválido ! label.output_seq_details = Seleccionar Detalles de la secuencia para ver todas label.urllinks = Enlaces -label.togglehidden = Toggle hidden columns on/off \ No newline at end of file +label.togglehidden = Toggle hidden regions on/off \ No newline at end of file diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 681c777..e2abbe4 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -1926,7 +1926,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, copiedHiddenColumns = new Vector(); int hiddenOffset = viewport.getSelectionGroup().getStartRes(); for (int[] region : viewport.getAlignment().getHiddenColumns() - .getListOfCols()) + .getHiddenRegions()) { copiedHiddenColumns.addElement(new int[] { region[0] - hiddenOffset, region[1] - hiddenOffset }); diff --git a/src/jalview/appletgui/AnnotationColumnChooser.java b/src/jalview/appletgui/AnnotationColumnChooser.java index 7efb490..852512d 100644 --- a/src/jalview/appletgui/AnnotationColumnChooser.java +++ b/src/jalview/appletgui/AnnotationColumnChooser.java @@ -291,10 +291,10 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements HiddenColumns oldHidden = av .getAnnotationColumnSelectionState() .getOldHiddenColumns(); - if (oldHidden != null && oldHidden.getListOfCols() != null - && !oldHidden.getListOfCols().isEmpty()) + if (oldHidden != null && oldHidden.getHiddenRegions() != null + && !oldHidden.getHiddenRegions().isEmpty()) { - for (Iterator itr = oldHidden.getListOfCols() + for (Iterator itr = oldHidden.getHiddenRegions() .iterator(); itr.hasNext();) { int positions[] = itr.next(); diff --git a/src/jalview/appletgui/AnnotationLabels.java b/src/jalview/appletgui/AnnotationLabels.java index 9444a76..307301d 100755 --- a/src/jalview/appletgui/AnnotationLabels.java +++ b/src/jalview/appletgui/AnnotationLabels.java @@ -840,7 +840,7 @@ public class AnnotationLabels extends Panel implements ActionListener, { jalview.appletgui.AlignFrame.copiedHiddenColumns = new Vector(); for (int[] region : av.getAlignment().getHiddenColumns() - .getListOfCols()) + .getHiddenRegions()) { jalview.appletgui.AlignFrame.copiedHiddenColumns .addElement(new int[] { region[0], region[1] }); diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index f339014..5a13c26 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -121,8 +121,7 @@ public class OverviewPanel extends Panel implements Runnable, private void mouseAction(MouseEvent evt) { od.updateViewportFromMouse(evt.getX(), evt.getY(), av.getAlignment() - .getHiddenSequences(), av.getAlignment().getHiddenColumns(), av - .getRanges()); + .getHiddenSequences(), av.getAlignment().getHiddenColumns()); ap.setScrollValues(od.getScrollCol(), od.getScrollRow()); ap.paintAlignment(false); } @@ -139,13 +138,16 @@ public class OverviewPanel extends Panel implements Runnable, } setSize(new Dimension(od.getWidth(), od.getHeight())); - if (updateRunning) + synchronized (this) { - oviewCanvas.restartDraw(); - return; - } + if (updateRunning) + { + oviewCanvas.restartDraw(); + return; + } - updateRunning = true; + updateRunning = true; + } Thread thread = new Thread(this); thread.start(); repaint(); @@ -170,7 +172,7 @@ public class OverviewPanel extends Panel implements Runnable, { od.setBoxPosition(av.getAlignment() .getHiddenSequences(), av - .getAlignment().getHiddenColumns(), av.getRanges()); + .getAlignment().getHiddenColumns()); repaint(); } } diff --git a/src/jalview/appletgui/ScalePanel.java b/src/jalview/appletgui/ScalePanel.java index e0ec011..22b4e3a 100755 --- a/src/jalview/appletgui/ScalePanel.java +++ b/src/jalview/appletgui/ScalePanel.java @@ -335,7 +335,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, reveal = null; for (int[] region : av.getAlignment().getHiddenColumns() - .getListOfCols()) + .getHiddenRegions()) { if (res + 1 == region[0] || res - 1 == region[1]) { @@ -447,7 +447,7 @@ public class ScalePanel extends Panel implements MouseMotionListener, if (av.getShowHiddenMarkers()) { int widthx = 1 + endx - startx; - for (int i = 0; i < hidden.getListOfCols().size(); i++) + for (int i = 0; i < hidden.getHiddenRegions().size(); i++) { res = hidden.findHiddenRegionPosition(i) - startx; diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index ae879b5..39382c5 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -483,7 +483,7 @@ public class SeqCanvas extends Panel HiddenColumns hidden = av.getAlignment().getHiddenColumns(); g.setColor(Color.blue); int res; - for (int i = 0; i < hidden.getListOfCols() + for (int i = 0; i < hidden.getHiddenRegions() .size(); i++) { res = hidden.findHiddenRegionPosition(i) @@ -566,7 +566,7 @@ public class SeqCanvas extends Panel if (av.hasHiddenColumns()) { HiddenColumns hidden = av.getAlignment().getHiddenColumns(); - for (int[] region : hidden.getListOfCols()) + for (int[] region : hidden.getHiddenRegions()) { int hideStart = region[0]; int hideEnd = region[1]; diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index ceae253..16aa628 100644 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -1886,7 +1886,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, if (copycolsel && av.hasHiddenColumns() && (av.getColumnSelection() == null || av.getAlignment() - .getHiddenColumns().getListOfCols() == null)) + .getHiddenColumns().getHiddenRegions() == null)) { System.err.println("Bad things"); } diff --git a/src/jalview/datamodel/CigarArray.java b/src/jalview/datamodel/CigarArray.java index a48a178..aab82a1 100644 --- a/src/jalview/datamodel/CigarArray.java +++ b/src/jalview/datamodel/CigarArray.java @@ -92,7 +92,7 @@ public class CigarArray extends CigarBase { this(constructSeqCigarArray(alignment, selectionGroup)); constructFromAlignment(alignment, - hidden != null ? hidden.getListOfCols() + hidden != null ? hidden.getHiddenRegions() : null, selectionGroup); } diff --git a/src/jalview/datamodel/HiddenColumns.java b/src/jalview/datamodel/HiddenColumns.java index 0b7e246..f6102d4 100644 --- a/src/jalview/datamodel/HiddenColumns.java +++ b/src/jalview/datamodel/HiddenColumns.java @@ -20,12 +20,35 @@ public class HiddenColumns * * @return empty list or List of hidden column intervals */ - public List getListOfCols() + public List getHiddenRegions() { return hiddenColumns == null ? Collections. emptyList() : hiddenColumns; } + /** + * Find the number of hidden columns + * + * @return number of hidden columns + */ + public int getSize() + { + int size = 0; + if (hasHidden()) + { + for (int[] range : hiddenColumns) + { + size += range[1] - range[0] + 1; + } + } + return size; + } + + /** + * Answers if there are any hidden columns + * + * @return true if there are hidden columns + */ public boolean hasHidden() { return (hiddenColumns != null) && (!hiddenColumns.isEmpty()); @@ -543,7 +566,7 @@ public class HiddenColumns if (hiddenColumns != null && hiddenColumns.size() > 0) { List visiblecontigs = new ArrayList(); - List regions = getListOfCols(); + List regions = getHiddenRegions(); int vstart = start; int[] region; @@ -597,7 +620,7 @@ public class HiddenColumns for (i = 0; i < iSize; i++) { StringBuffer visibleSeq = new StringBuffer(); - List regions = getListOfCols(); + List regions = getHiddenRegions(); int blockStart = start, blockEnd = end; int[] region; @@ -670,7 +693,7 @@ public class HiddenColumns // Simply walk along the sequence whilst watching for hidden column // boundaries - List regions = getListOfCols(); + List regions = getHiddenRegions(); int spos = fpos, lastvispos = -1, rcount = 0, hideStart = seq .getLength(), hideEnd = -1; int visPrev = 0, visNext = 0, firstP = -1, lastP = -1; @@ -764,7 +787,7 @@ public class HiddenColumns // then mangle the alignmentAnnotation annotation array Vector annels = new Vector(); Annotation[] els = null; - List regions = getListOfCols(); + List regions = getHiddenRegions(); int blockStart = start, blockEnd = end; int[] region; int hideStart, hideEnd, w = 0; diff --git a/src/jalview/datamodel/VisibleColsIterator.java b/src/jalview/datamodel/VisibleColsIterator.java index 2ab61ff..70de1e3 100644 --- a/src/jalview/datamodel/VisibleColsIterator.java +++ b/src/jalview/datamodel/VisibleColsIterator.java @@ -48,7 +48,7 @@ public class VisibleColsIterator implements Iterator last = lastcol; current = firstcol; next = firstcol; - hidden = hiddenCols.getListOfCols(); + hidden = hiddenCols.getHiddenRegions(); lasthiddenregion = -1; if (hidden != null) diff --git a/src/jalview/datamodel/VisibleRowsCollection.java b/src/jalview/datamodel/VisibleRowsCollection.java index 98153f9..ce8e8da 100644 --- a/src/jalview/datamodel/VisibleRowsCollection.java +++ b/src/jalview/datamodel/VisibleRowsCollection.java @@ -54,7 +54,7 @@ public class VisibleRowsCollection implements AlignmentRowsCollectionI @Override public SequenceI getSequence(int seq) { - return alignment.getSequenceAt(seq); + return alignment.getSequenceAtAbsoluteIndex(seq); } } diff --git a/src/jalview/datamodel/VisibleRowsIterator.java b/src/jalview/datamodel/VisibleRowsIterator.java index 0259fd3..a9c782d 100644 --- a/src/jalview/datamodel/VisibleRowsIterator.java +++ b/src/jalview/datamodel/VisibleRowsIterator.java @@ -57,12 +57,12 @@ public class VisibleRowsIterator implements Iterator current = firstrow; last = lastrow; hidden = al.getHiddenSequences(); - while (hidden.isHidden(last) && last > current) + while (last > current && hidden.isHidden(last)) { last--; } current = firstrow; - while (hidden.isHidden(current) && current < last) + while (current < last && hidden.isHidden(current)) { current++; } @@ -86,7 +86,7 @@ public class VisibleRowsIterator implements Iterator do { next++; - } while (hidden.isHidden(next) && next <= last); + } while (next <= last && hidden.isHidden(next)); return current; } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 9cb9804..195dd67 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -1316,7 +1316,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, alignmentStartEnd = alignmentToExport .getVisibleStartAndEndIndex(viewport.getAlignment() .getHiddenColumns() - .getListOfCols()); + .getHiddenRegions()); AlignmentExportData ed = new AlignmentExportData(alignmentToExport, omitHidden, alignmentStartEnd, settings); return ed; @@ -1881,7 +1881,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, int hiddenOffset = viewport.getSelectionGroup().getStartRes(), hiddenCutoff = viewport .getSelectionGroup().getEndRes(); for (int[] region : viewport.getAlignment().getHiddenColumns() - .getListOfCols()) + .getHiddenRegions()) { if (region[0] >= hiddenOffset && region[1] <= hiddenCutoff) { diff --git a/src/jalview/gui/AnnotationColumnChooser.java b/src/jalview/gui/AnnotationColumnChooser.java index fa63e0d..6cf359b 100644 --- a/src/jalview/gui/AnnotationColumnChooser.java +++ b/src/jalview/gui/AnnotationColumnChooser.java @@ -233,10 +233,10 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements HiddenColumns oldHidden = av .getAnnotationColumnSelectionState() .getOldHiddenColumns(); - if (oldHidden != null && oldHidden.getListOfCols() != null - && !oldHidden.getListOfCols().isEmpty()) + if (oldHidden != null && oldHidden.getHiddenRegions() != null + && !oldHidden.getHiddenRegions().isEmpty()) { - for (Iterator itr = oldHidden.getListOfCols() + for (Iterator itr = oldHidden.getHiddenRegions() .iterator(); itr.hasNext();) { int positions[] = itr.next(); diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 3e4ec98..8ca1a4e 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -954,7 +954,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, int[] alignmentStartEnd = new int[] { 0, ds.getWidth() - 1 }; List hiddenCols = av.getAlignment().getHiddenColumns() - .getListOfCols(); + .getHiddenRegions(); if (hiddenCols != null) { alignmentStartEnd = av.getAlignment().getVisibleStartAndEndIndex( @@ -971,7 +971,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, { hiddenColumns = new ArrayList(); for (int[] region : av.getAlignment().getHiddenColumns() - .getListOfCols()) + .getHiddenRegions()) { hiddenColumns.add(new int[] { region[0], region[1] }); } diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 962dc0d..0435bd4 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -1415,16 +1415,16 @@ public class Jalview2XML { jalview.datamodel.HiddenColumns hidden = av.getAlignment() .getHiddenColumns(); - if (hidden == null || hidden.getListOfCols() == null) + if (hidden == null || hidden.getHiddenRegions() == null) { warn("REPORT BUG: avoided null columnselection bug (DMAM reported). Please contact Jim about this."); } else { - for (int c = 0; c < hidden.getListOfCols() + for (int c = 0; c < hidden.getHiddenRegions() .size(); c++) { - int[] region = hidden.getListOfCols() + int[] region = hidden.getHiddenRegions() .get(c); HiddenColumns hc = new HiddenColumns(); hc.setStart(region[0]); diff --git a/src/jalview/gui/OverviewCanvas.java b/src/jalview/gui/OverviewCanvas.java index e475c2c..90181f8 100644 --- a/src/jalview/gui/OverviewCanvas.java +++ b/src/jalview/gui/OverviewCanvas.java @@ -124,10 +124,8 @@ public class OverviewCanvas extends JComponent setPreferredSize(new Dimension(od.getWidth(), od.getHeight())); OverviewRenderer or = new OverviewRenderer(sr, finder, od); - miniMe = or.draw(od.getRows(av.getRanges(), av.getAlignment()), - od - .getColumns(av.getRanges(), av.getAlignment() - .getHiddenColumns())); + miniMe = or.draw(od.getRows(av.getAlignment()), + od.getColumns(av.getAlignment().getHiddenColumns())); Graphics mg = miniMe.getGraphics(); @@ -136,8 +134,7 @@ public class OverviewCanvas extends JComponent mg.translate(0, od.getSequencesHeight()); or.drawGraph(mg, av.getAlignmentConservationAnnotation(), av.getCharWidth(), od.getGraphHeight(), - od.getColumns( - av.getRanges(), av.getAlignment().getHiddenColumns())); + od.getColumns(av.getAlignment().getHiddenColumns())); mg.translate(0, -od.getSequencesHeight()); } System.gc(); diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index 408eca6..ac385c3 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -102,7 +102,7 @@ public class OverviewPanel extends JPanel implements Runnable { od.updateViewportFromMouse(evt.getX(), evt.getY(), av .getAlignment().getHiddenSequences(), av.getAlignment() - .getHiddenColumns(), av.getRanges()); + .getHiddenColumns()); ap.setScrollValues(od.getScrollCol(), od.getScrollRow()); } } @@ -124,7 +124,7 @@ public class OverviewPanel extends JPanel implements Runnable { od.updateViewportFromMouse(evt.getX(), evt.getY(), av .getAlignment().getHiddenSequences(), av.getAlignment() - .getHiddenColumns(), av.getRanges()); + .getHiddenColumns()); ap.setScrollValues(od.getScrollCol(), od.getScrollRow()); } } @@ -198,7 +198,7 @@ public class OverviewPanel extends JPanel implements Runnable od.setWidth(getWidth()); od.setHeight(getHeight()); } - + setPreferredSize(new Dimension(od.getWidth(), od.getHeight())); if (oviewCanvas.restartDraw()) @@ -229,9 +229,8 @@ public class OverviewPanel extends JPanel implements Runnable */ public void setBoxPosition() { - od.setBoxPosition(av.getAlignment() -.getHiddenSequences(), av - .getAlignment().getHiddenColumns(), av.getRanges()); + od.setBoxPosition(av.getAlignment().getHiddenSequences(), av + .getAlignment().getHiddenColumns()); repaint(); } } diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index bc59f91..90f7cd2 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -399,10 +399,10 @@ public class ScalePanel extends JPanel implements MouseMotionListener, res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(res); - if (av.getAlignment().getHiddenColumns().getListOfCols() != null) + if (av.getAlignment().getHiddenColumns().getHiddenRegions() != null) { for (int[] region : av.getAlignment().getHiddenColumns() - .getListOfCols()) + .getHiddenRegions()) { if (res + 1 == region[0] || res - 1 == region[1]) { @@ -495,9 +495,9 @@ public class ScalePanel extends JPanel implements MouseMotionListener, gg.setColor(Color.blue); int res; - if (av.getShowHiddenMarkers() && hidden.getListOfCols() != null) + if (av.getShowHiddenMarkers() && hidden.getHiddenRegions() != null) { - for (int i = 0; i < hidden.getListOfCols() + for (int i = 0; i < hidden.getHiddenRegions() .size(); i++) { res = hidden.findHiddenRegionPosition(i) diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 3725445..c2a2ccb 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -560,7 +560,7 @@ public class SeqCanvas extends JComponent g.setColor(Color.blue); int res; HiddenColumns hidden = av.getAlignment().getHiddenColumns(); - for (int i = 0; i < hidden.getListOfCols().size(); i++) + for (int i = 0; i < hidden.getHiddenRegions().size(); i++) { res = hidden.findHiddenRegionPosition(i) - startRes; @@ -660,7 +660,7 @@ public class SeqCanvas extends JComponent else { List regions = av.getAlignment().getHiddenColumns() - .getListOfCols(); + .getHiddenRegions(); int screenY = 0; int blockStart = startRes; diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 063ab7d..d18ecf7 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -2054,7 +2054,7 @@ public class SeqPanel extends JPanel implements MouseListener, if (copycolsel && av.hasHiddenColumns() && (av.getAlignment().getHiddenColumns() == null || av - .getAlignment().getHiddenColumns().getListOfCols() == null)) + .getAlignment().getHiddenColumns().getHiddenRegions() == null)) { System.err.println("Bad things"); } diff --git a/src/jalview/io/AnnotationFile.java b/src/jalview/io/AnnotationFile.java index 31aeffa..5c5fa8f 100755 --- a/src/jalview/io/AnnotationFile.java +++ b/src/jalview/io/AnnotationFile.java @@ -172,7 +172,7 @@ public class AnnotationFile if (cs != null && cs.hasHiddenColumns()) { text.append("VIEW_HIDECOLS\t"); - List hc = cs.getListOfCols(); + List hc = cs.getHiddenRegions(); boolean comma = false; for (int[] r : hc) { diff --git a/src/jalview/io/JSONFile.java b/src/jalview/io/JSONFile.java index e89dcfb..8dbede6 100644 --- a/src/jalview/io/JSONFile.java +++ b/src/jalview/io/JSONFile.java @@ -280,7 +280,7 @@ public class JSONFile extends AlignFile implements ComplexAlignFile { List hiddenCols = getViewport().getAlignment() .getHiddenColumns() - .getListOfCols(); + .getHiddenRegions(); StringBuilder hiddenColsBuilder = new StringBuilder(); for (int[] range : hiddenCols) { diff --git a/src/jalview/util/MappingUtils.java b/src/jalview/util/MappingUtils.java index 33c43d3..926ccc7 100644 --- a/src/jalview/util/MappingUtils.java +++ b/src/jalview/util/MappingUtils.java @@ -540,7 +540,7 @@ public final class MappingUtils toSequences, fromGapChar); } - for (int[] hidden : hiddencols.getListOfCols()) + for (int[] hidden : hiddencols.getHiddenRegions()) { mapHiddenColumns(hidden, codonFrames, newHidden, fromSequences, toSequences, fromGapChar); diff --git a/src/jalview/viewmodel/OverviewDimensions.java b/src/jalview/viewmodel/OverviewDimensions.java index 6f4a4e0..eb4a6e6 100644 --- a/src/jalview/viewmodel/OverviewDimensions.java +++ b/src/jalview/viewmodel/OverviewDimensions.java @@ -149,11 +149,13 @@ public abstract class OverviewDimensions public float getPixelsPerCol() { + resetAlignmentDims(); return (float) width / alwidth; } public float getPixelsPerSeq() { + resetAlignmentDims(); return (float) sequencesHeight / alheight; } @@ -178,12 +180,9 @@ public abstract class OverviewDimensions * the alignment's hidden sequences * @param hiddenCols * the alignment's hidden columns - * @param ranges - * the alignment's width and height ranges */ public abstract void updateViewportFromMouse(int mousex, int mousey, - HiddenSequences hiddenSeqs, HiddenColumns hiddenCols, - ViewportRanges ranges); + HiddenSequences hiddenSeqs, HiddenColumns hiddenCols); /** * Set the overview panel's box position to match the viewport @@ -192,33 +191,31 @@ public abstract class OverviewDimensions * the alignment's hidden sequences * @param hiddenCols * the alignment's hidden columns - * @param ranges - * the alignment's width and height ranges */ public abstract void setBoxPosition(HiddenSequences hiddenSeqs, - HiddenColumns hiddenCols, ViewportRanges ranges); + HiddenColumns hiddenCols); /** * Get the collection of columns used by this overview dimensions object * - * @param ranges - * the alignment's width and height ranges * @param hiddenCols * the alignment's hidden columns * @return a column collection */ public abstract AlignmentColsCollectionI getColumns( - ViewportRanges ranges, HiddenColumns hiddenCols); + HiddenColumns hiddenCols); /** * Get the collection of rows used by this overview dimensions object * - * @param ranges - * the alignment's width and height ranges * @param al * the alignment * @return a row collection */ - public abstract AlignmentRowsCollectionI getRows( - ViewportRanges ranges, AlignmentI al); + public abstract AlignmentRowsCollectionI getRows(AlignmentI al); + + /** + * Updates overview dimensions to account for current alignment dimensions + */ + protected abstract void resetAlignmentDims(); } \ No newline at end of file diff --git a/src/jalview/viewmodel/OverviewDimensionsAllVisible.java b/src/jalview/viewmodel/OverviewDimensionsAllVisible.java index 94d2899..d963876 100644 --- a/src/jalview/viewmodel/OverviewDimensionsAllVisible.java +++ b/src/jalview/viewmodel/OverviewDimensionsAllVisible.java @@ -10,26 +10,25 @@ import jalview.datamodel.VisibleRowsCollection; public class OverviewDimensionsAllVisible extends OverviewDimensions { + private ViewportRanges alRanges; + public OverviewDimensionsAllVisible(ViewportRanges ranges, boolean showAnnotationPanel) { super(ranges, showAnnotationPanel); - - alwidth = ranges.getVisibleAlignmentWidth(); - alheight = ranges.getVisibleAlignmentHeight(); + alRanges = ranges; + resetAlignmentDims(); } @Override public void updateViewportFromMouse(int mousex, int mousey, - HiddenSequences hiddenSeqs, HiddenColumns hiddenCols, - ViewportRanges ranges) + HiddenSequences hiddenSeqs, HiddenColumns hiddenCols) { + resetAlignmentDims(); + int x = mousex; int y = mousey; - alwidth = ranges.getVisibleAlignmentWidth(); - alheight = ranges.getVisibleAlignmentHeight(); - if (x < 0) { x = 0; @@ -52,7 +51,7 @@ public class OverviewDimensionsAllVisible extends OverviewDimensions int xAsRes = Math.round((float) x * alwidth / width); // get viewport width in residues - int vpwidth = ranges.getEndRes() - ranges.getStartRes() + 1; + int vpwidth = alRanges.getEndRes() - alRanges.getStartRes() + 1; if (xAsRes + vpwidth > alwidth) { @@ -79,7 +78,7 @@ public class OverviewDimensionsAllVisible extends OverviewDimensions // get viewport height in sequences // add 1 because height includes both endSeq and startSeq - int vpheight = ranges.getEndSeq() - ranges.getStartSeq() + 1; + int vpheight = alRanges.getEndSeq() - alRanges.getStartSeq() + 1; if (yAsSeq + vpheight > alheight) { @@ -102,18 +101,17 @@ public class OverviewDimensionsAllVisible extends OverviewDimensions @Override public void setBoxPosition(HiddenSequences hiddenSeqs, - HiddenColumns hiddenCols, ViewportRanges ranges) + HiddenColumns hiddenCols) { - alwidth = ranges.getVisibleAlignmentWidth(); - alheight = ranges.getVisibleAlignmentHeight(); + resetAlignmentDims(); // work with visible values of startRes and endRes - int startRes = ranges.getStartRes(); - int endRes = ranges.getEndRes(); + int startRes = alRanges.getStartRes(); + int endRes = alRanges.getEndRes(); // work with visible values of startSeq and endSeq - int startSeq = ranges.getStartSeq(); - int endSeq = ranges.getEndSeq(); + int startSeq = alRanges.getStartSeq(); + int endSeq = alRanges.getEndSeq(); // boxX, boxY is the x,y location equivalent to startRes, startSeq boxX = Math.round((float) startRes * width / alwidth); @@ -131,18 +129,23 @@ public class OverviewDimensionsAllVisible extends OverviewDimensions } @Override - public AlignmentColsCollectionI getColumns(ViewportRanges ranges, - HiddenColumns hiddenCols) + public AlignmentColsCollectionI getColumns(HiddenColumns hiddenCols) { return new VisibleColsCollection(0, - ranges.getVisibleAlignmentWidth() - 1, hiddenCols); + alRanges.getAbsoluteAlignmentWidth() - 1, hiddenCols); } @Override - public AlignmentRowsCollectionI getRows(ViewportRanges ranges, - AlignmentI al) + public AlignmentRowsCollectionI getRows(AlignmentI al) { return new VisibleRowsCollection(0, - ranges.getVisibleAlignmentHeight() - 1, al); + alRanges.getAbsoluteAlignmentHeight() - 1, al); + } + + @Override + protected void resetAlignmentDims() + { + alwidth = alRanges.getVisibleAlignmentWidth(); + alheight = alRanges.getVisibleAlignmentHeight(); } } diff --git a/src/jalview/viewmodel/OverviewDimensionsWithHidden.java b/src/jalview/viewmodel/OverviewDimensionsWithHidden.java index 6043755..e718d5a 100644 --- a/src/jalview/viewmodel/OverviewDimensionsWithHidden.java +++ b/src/jalview/viewmodel/OverviewDimensionsWithHidden.java @@ -30,6 +30,8 @@ import jalview.datamodel.HiddenSequences; public class OverviewDimensionsWithHidden extends OverviewDimensions { + private ViewportRanges alRanges; + /** * Create an OverviewDimensions object * @@ -42,9 +44,8 @@ public class OverviewDimensionsWithHidden extends OverviewDimensions boolean showAnnotationPanel) { super(ranges, showAnnotationPanel); - - alwidth = ranges.getAbsoluteAlignmentWidth(); - alheight = ranges.getAbsoluteAlignmentHeight(); + alRanges = ranges; + resetAlignmentDims(); } /** @@ -63,14 +64,12 @@ public class OverviewDimensionsWithHidden extends OverviewDimensions */ @Override public void updateViewportFromMouse(int mousex, int mousey, - HiddenSequences hiddenSeqs, HiddenColumns hiddenCols, - ViewportRanges ranges) + HiddenSequences hiddenSeqs, HiddenColumns hiddenCols) { int x = mousex; int y = mousey; - alwidth = ranges.getAbsoluteAlignmentWidth(); - alheight = ranges.getAbsoluteAlignmentHeight(); + resetAlignmentDims(); if (x < 0) { @@ -94,7 +93,7 @@ public class OverviewDimensionsWithHidden extends OverviewDimensions int xAsRes = Math.round((float) x * alwidth / width); // get viewport width in residues - int vpwidth = ranges.getEndRes() - ranges.getStartRes() + 1; + int vpwidth = alRanges.getEndRes() - alRanges.getStartRes() + 1; // get where x should be when accounting for hidden cols // if x is in a hidden col region, shift to left - but we still need @@ -129,7 +128,7 @@ public class OverviewDimensionsWithHidden extends OverviewDimensions // get viewport height in sequences // add 1 because height includes both endSeq and startSeq - int vpheight = ranges.getEndSeq() - ranges.getStartSeq() + 1; + int vpheight = alRanges.getEndSeq() - alRanges.getStartSeq() + 1; // get where y should be when accounting for hidden rows // if y is in a hidden row region, shift up - but we still need absolute @@ -174,18 +173,18 @@ public class OverviewDimensionsWithHidden extends OverviewDimensions */ @Override public void setBoxPosition(HiddenSequences hiddenSeqs, - HiddenColumns hiddenCols, ViewportRanges ranges) + HiddenColumns hiddenCols) { - alwidth = ranges.getAbsoluteAlignmentWidth(); - alheight = ranges.getAbsoluteAlignmentHeight(); + resetAlignmentDims(); // work with absolute values of startRes and endRes - int startRes = hiddenCols.adjustForHiddenColumns(ranges.getStartRes()); - int endRes = hiddenCols.adjustForHiddenColumns(ranges.getEndRes()); + int startRes = hiddenCols + .adjustForHiddenColumns(alRanges.getStartRes()); + int endRes = hiddenCols.adjustForHiddenColumns(alRanges.getEndRes()); // work with absolute values of startSeq and endSeq - int startSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getStartSeq()); - int endSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getEndSeq()); + int startSeq = hiddenSeqs.adjustForHiddenSeqs(alRanges.getStartSeq()); + int endSeq = hiddenSeqs.adjustForHiddenSeqs(alRanges.getEndSeq()); // boxX, boxY is the x,y location equivalent to startRes, startSeq boxX = Math.round((float) startRes * width / alwidth); @@ -203,20 +202,25 @@ public class OverviewDimensionsWithHidden extends OverviewDimensions } @Override - public AlignmentColsCollectionI getColumns(ViewportRanges ranges, - HiddenColumns hiddenCols) + public AlignmentColsCollectionI getColumns(HiddenColumns hiddenCols) { return new AllColsCollection(0, - ranges.getAbsoluteAlignmentWidth() - 1, + alRanges.getAbsoluteAlignmentWidth() - 1, hiddenCols); } @Override - public AlignmentRowsCollectionI getRows(ViewportRanges ranges, - AlignmentI al) + public AlignmentRowsCollectionI getRows(AlignmentI al) { return new AllRowsCollection(0, - ranges.getAbsoluteAlignmentHeight() - 1, + alRanges.getAbsoluteAlignmentHeight() - 1, al); } + + @Override + protected void resetAlignmentDims() + { + alwidth = alRanges.getAbsoluteAlignmentWidth(); + alheight = alRanges.getAbsoluteAlignmentHeight(); + } } diff --git a/src/jalview/viewmodel/ViewportRanges.java b/src/jalview/viewmodel/ViewportRanges.java index 18703b4..fc163e0 100644 --- a/src/jalview/viewmodel/ViewportRanges.java +++ b/src/jalview/viewmodel/ViewportRanges.java @@ -83,8 +83,7 @@ public class ViewportRanges extends ViewportProperties */ public int getVisibleAlignmentWidth() { - // TODO need access to hidden columns here - return al.getWidth(); // - hidden columns + return al.getWidth() - al.getHiddenColumns().getSize(); } /** diff --git a/test/jalview/datamodel/ColumnSelectionTest.java b/test/jalview/datamodel/ColumnSelectionTest.java index e5f2daa..d69c495 100644 --- a/test/jalview/datamodel/ColumnSelectionTest.java +++ b/test/jalview/datamodel/ColumnSelectionTest.java @@ -108,7 +108,7 @@ public class ColumnSelectionTest // hide column 5 (and adjacent): cs.hideSelectedColumns(5, al.getHiddenColumns()); // 4,5,6 now hidden: - List hidden = al.getHiddenColumns().getListOfCols(); + List hidden = al.getHiddenColumns().getHiddenRegions(); assertEquals(1, hidden.size()); assertEquals("[4, 6]", Arrays.toString(hidden.get(0))); // none now selected: @@ -121,7 +121,7 @@ public class ColumnSelectionTest cs.addElement(5); cs.addElement(6); cs.hideSelectedColumns(4, al.getHiddenColumns()); - hidden = al.getHiddenColumns().getListOfCols(); + hidden = al.getHiddenColumns().getHiddenRegions(); assertEquals(1, hidden.size()); assertEquals("[4, 6]", Arrays.toString(hidden.get(0))); assertTrue(cs.getSelected().isEmpty()); @@ -133,7 +133,7 @@ public class ColumnSelectionTest cs.addElement(5); cs.addElement(6); cs.hideSelectedColumns(6, al.getHiddenColumns()); - hidden = al.getHiddenColumns().getListOfCols(); + hidden = al.getHiddenColumns().getHiddenRegions(); assertEquals(1, hidden.size()); assertEquals("[4, 6]", Arrays.toString(hidden.get(0))); assertTrue(cs.getSelected().isEmpty()); @@ -144,7 +144,7 @@ public class ColumnSelectionTest cs.addElement(4); cs.addElement(6); cs.hideSelectedColumns(5, al.getHiddenColumns()); - hidden = al.getHiddenColumns().getListOfCols(); + hidden = al.getHiddenColumns().getHiddenRegions(); assertEquals(1, hidden.size()); assertEquals("[4, 6]", Arrays.toString(hidden.get(0))); assertTrue(cs.getSelected().isEmpty()); @@ -172,7 +172,7 @@ public class ColumnSelectionTest cs.hideSelectedColumns(al); assertTrue(cs.getSelected().isEmpty()); - List hidden = cols.getListOfCols(); + List hidden = cols.getHiddenRegions(); assertEquals(4, hidden.size()); assertEquals("[2, 4]", Arrays.toString(hidden.get(0))); assertEquals("[7, 9]", Arrays.toString(hidden.get(1))); diff --git a/test/jalview/datamodel/HiddenColumnsTest.java b/test/jalview/datamodel/HiddenColumnsTest.java index 5eaecd3..b767cf7 100644 --- a/test/jalview/datamodel/HiddenColumnsTest.java +++ b/test/jalview/datamodel/HiddenColumnsTest.java @@ -45,6 +45,29 @@ public class HiddenColumnsTest } /** + * Test the method which counts the number of hidden columns + */ + @Test(groups = { "Functional" }) + public void testGetSize() + { + HiddenColumns hidden = new HiddenColumns(); + assertEquals(0, hidden.getSize()); + + hidden.hideColumns(3, 5); + assertEquals(3, hidden.getSize()); + + hidden.hideColumns(8, 8); + assertEquals(4, hidden.getSize()); + + hidden.hideColumns(9, 14); + assertEquals(10, hidden.getSize()); + + ColumnSelection cs = new ColumnSelection(); + hidden.revealAllHiddenColumns(cs); + assertEquals(0, hidden.getSize()); + } + + /** * Test the method that finds the visible column position of an alignment * column, allowing for hidden columns. */ @@ -207,14 +230,14 @@ public class HiddenColumnsTest HiddenColumns cs = new HiddenColumns(); cs.hideColumns(10, 11); cs.hideColumns(5, 7); - assertEquals("[5, 7]", Arrays.toString(cs.getListOfCols().get(0))); + assertEquals("[5, 7]", Arrays.toString(cs.getHiddenRegions().get(0))); HiddenColumns cs2 = new HiddenColumns(cs); assertTrue(cs2.hasHiddenColumns()); - assertEquals(2, cs2.getListOfCols().size()); + assertEquals(2, cs2.getHiddenRegions().size()); // hidden columns are held in column order - assertEquals("[5, 7]", Arrays.toString(cs2.getListOfCols().get(0))); - assertEquals("[10, 11]", Arrays.toString(cs2.getListOfCols().get(1))); + assertEquals("[5, 7]", Arrays.toString(cs2.getHiddenRegions().get(0))); + assertEquals("[10, 11]", Arrays.toString(cs2.getHiddenRegions().get(1))); } /** @@ -311,51 +334,51 @@ public class HiddenColumnsTest ColumnSelection colsel = new ColumnSelection(); HiddenColumns cs = al.getHiddenColumns(); colsel.hideSelectedColumns(5, al.getHiddenColumns()); - List hidden = cs.getListOfCols(); + List hidden = cs.getHiddenRegions(); assertEquals(1, hidden.size()); assertEquals("[5, 5]", Arrays.toString(hidden.get(0))); colsel.hideSelectedColumns(3, al.getHiddenColumns()); assertEquals(2, hidden.size()); // two hidden ranges, in order: - assertSame(hidden, cs.getListOfCols()); + assertSame(hidden, cs.getHiddenRegions()); assertEquals("[3, 3]", Arrays.toString(hidden.get(0))); assertEquals("[5, 5]", Arrays.toString(hidden.get(1))); // hiding column 4 expands [3, 3] to [3, 4] // and merges to [5, 5] to make [3, 5] colsel.hideSelectedColumns(4, al.getHiddenColumns()); - hidden = cs.getListOfCols(); + hidden = cs.getHiddenRegions(); assertEquals(1, hidden.size()); assertEquals("[3, 5]", Arrays.toString(hidden.get(0))); // clear hidden columns (note they are added to selected) cs.revealAllHiddenColumns(colsel); // it is now actually null but getter returns an empty list - assertTrue(cs.getListOfCols().isEmpty()); + assertTrue(cs.getHiddenRegions().isEmpty()); cs.hideColumns(3, 6); - hidden = cs.getListOfCols(); + hidden = cs.getHiddenRegions(); int[] firstHiddenRange = hidden.get(0); assertEquals("[3, 6]", Arrays.toString(firstHiddenRange)); // adding a subrange of already hidden should do nothing cs.hideColumns(4, 5); assertEquals(1, hidden.size()); - assertSame(firstHiddenRange, cs.getListOfCols().get(0)); + assertSame(firstHiddenRange, cs.getHiddenRegions().get(0)); cs.hideColumns(3, 5); assertEquals(1, hidden.size()); - assertSame(firstHiddenRange, cs.getListOfCols().get(0)); + assertSame(firstHiddenRange, cs.getHiddenRegions().get(0)); cs.hideColumns(4, 6); assertEquals(1, hidden.size()); - assertSame(firstHiddenRange, cs.getListOfCols().get(0)); + assertSame(firstHiddenRange, cs.getHiddenRegions().get(0)); cs.hideColumns(3, 6); assertEquals(1, hidden.size()); - assertSame(firstHiddenRange, cs.getListOfCols().get(0)); + assertSame(firstHiddenRange, cs.getHiddenRegions().get(0)); cs.revealAllHiddenColumns(colsel); cs.hideColumns(2, 4); - hidden = cs.getListOfCols(); + hidden = cs.getHiddenRegions(); assertEquals(1, hidden.size()); assertEquals("[2, 4]", Arrays.toString(hidden.get(0))); @@ -388,7 +411,7 @@ public class HiddenColumnsTest colsel.addElement(10); cs.revealHiddenColumns(5, colsel); // hidden columns list now null but getter returns empty list: - assertTrue(cs.getListOfCols().isEmpty()); + assertTrue(cs.getHiddenRegions().isEmpty()); // revealed columns are marked as selected (added to selection): assertEquals("[10, 5, 6, 7, 8]", colsel.getSelected().toString()); @@ -396,9 +419,9 @@ public class HiddenColumnsTest colsel = new ColumnSelection(); cs = new HiddenColumns(); cs.hideColumns(5, 8); - List hidden = cs.getListOfCols(); + List hidden = cs.getHiddenRegions(); cs.revealHiddenColumns(6, colsel); - assertSame(hidden, cs.getListOfCols()); + assertSame(hidden, cs.getHiddenRegions()); assertTrue(colsel.getSelected().isEmpty()); } @@ -417,7 +440,7 @@ public class HiddenColumnsTest * revealing hidden columns adds them (in order) to the (unordered) * selection list */ - assertTrue(cs.getListOfCols().isEmpty()); + assertTrue(cs.getHiddenRegions().isEmpty()); assertEquals("[11, 1, 2, 3, 5, 6, 7, 8]", colsel.getSelected() .toString()); } @@ -453,13 +476,13 @@ public class HiddenColumnsTest HiddenColumns cs = new HiddenColumns(); cs.hideColumns(49, 59); cs.hideColumns(69, 79); - List hidden = cs.getListOfCols(); + List hidden = cs.getHiddenRegions(); assertEquals(2, hidden.size()); assertEquals("[49, 59]", Arrays.toString(hidden.get(0))); assertEquals("[69, 79]", Arrays.toString(hidden.get(1))); cs.hideColumns(48, 80); - hidden = cs.getListOfCols(); + hidden = cs.getHiddenRegions(); assertEquals(1, hidden.size()); assertEquals("[48, 80]", Arrays.toString(hidden.get(0))); @@ -472,7 +495,7 @@ public class HiddenColumnsTest cs.hideColumns(50, 60); // hiding 21-49 should merge to one range cs.hideColumns(21, 49); - hidden = cs.getListOfCols(); + hidden = cs.getHiddenRegions(); assertEquals(1, hidden.size()); assertEquals("[10, 60]", Arrays.toString(hidden.get(0))); @@ -488,7 +511,7 @@ public class HiddenColumnsTest cs.hideColumns(60, 70); cs.hideColumns(15, 45); - hidden = cs.getListOfCols(); + hidden = cs.getHiddenRegions(); assertEquals(2, hidden.size()); assertEquals("[10, 50]", Arrays.toString(hidden.get(0))); assertEquals("[60, 70]", Arrays.toString(hidden.get(1))); diff --git a/test/jalview/gui/AlignFrameTest.java b/test/jalview/gui/AlignFrameTest.java index bd6b68f..fed5992 100644 --- a/test/jalview/gui/AlignFrameTest.java +++ b/test/jalview/gui/AlignFrameTest.java @@ -86,12 +86,12 @@ public class AlignFrameTest assertFalse(alignFrame.hideFeatureColumns("exon", true)); assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty()); assertTrue(alignFrame.getViewport().getAlignment().getHiddenColumns() - .getListOfCols() + .getHiddenRegions() .isEmpty()); assertFalse(alignFrame.hideFeatureColumns("exon", false)); assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty()); assertTrue(alignFrame.getViewport().getAlignment().getHiddenColumns() - .getListOfCols() + .getHiddenRegions() .isEmpty()); /* @@ -101,7 +101,7 @@ public class AlignFrameTest assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty()); List hidden = alignFrame.getViewport().getAlignment() .getHiddenColumns() - .getListOfCols(); + .getHiddenRegions(); assertTrue(hidden.isEmpty()); /* @@ -111,7 +111,7 @@ public class AlignFrameTest */ assertTrue(alignFrame.hideFeatureColumns("Turn", true)); hidden = alignFrame.getViewport().getAlignment().getHiddenColumns() - .getListOfCols(); + .getHiddenRegions(); assertEquals(hidden.size(), 2); assertEquals(hidden.get(0)[0], 1); assertEquals(hidden.get(0)[1], 3); diff --git a/test/jalview/io/JSONFileTest.java b/test/jalview/io/JSONFileTest.java index 957343b..1917097 100644 --- a/test/jalview/io/JSONFileTest.java +++ b/test/jalview/io/JSONFileTest.java @@ -191,7 +191,7 @@ public class JSONFileTest TEST_SEQ_HEIGHT = expectedSeqs.size(); TEST_GRP_HEIGHT = expectedGrps.size(); TEST_ANOT_HEIGHT = expectedAnnots.size(); - TEST_CS_HEIGHT = expectedColSel.getListOfCols().size(); + TEST_CS_HEIGHT = expectedColSel.getHiddenRegions().size(); AlignExportSettingI exportSettings = new AlignExportSettingI() { @@ -311,11 +311,11 @@ public class JSONFileTest { HiddenColumns cs = testJsonFile.getHiddenColumns(); Assert.assertNotNull(cs); - Assert.assertNotNull(cs.getListOfCols()); - List hiddenCols = cs.getListOfCols(); + Assert.assertNotNull(cs.getHiddenRegions()); + List hiddenCols = cs.getHiddenRegions(); Assert.assertEquals(hiddenCols.size(), TEST_CS_HEIGHT); Assert.assertEquals(hiddenCols.get(0), expectedColSel - .getListOfCols().get(0), + .getHiddenRegions().get(0), "Mismatched hidden columns!"); } diff --git a/test/jalview/util/MappingUtilsTest.java b/test/jalview/util/MappingUtilsTest.java index bd97ad8..19c8438 100644 --- a/test/jalview/util/MappingUtilsTest.java +++ b/test/jalview/util/MappingUtilsTest.java @@ -913,7 +913,7 @@ public class MappingUtilsTest MappingUtils.mapColumnSelection(proteinSelection, hiddenCols, proteinView, dnaView, dnaSelection, dnaHidden); assertEquals("[]", dnaSelection.getSelected().toString()); - List hidden = dnaHidden.getListOfCols(); + List hidden = dnaHidden.getHiddenRegions(); assertEquals(1, hidden.size()); assertEquals("[0, 4]", Arrays.toString(hidden.get(0))); @@ -930,7 +930,7 @@ public class MappingUtilsTest proteinSelection.hideSelectedColumns(1, hiddenCols); MappingUtils.mapColumnSelection(proteinSelection, hiddenCols, proteinView, dnaView, dnaSelection, dnaHidden); - hidden = dnaHidden.getListOfCols(); + hidden = dnaHidden.getHiddenRegions(); assertEquals(1, hidden.size()); assertEquals("[0, 3]", Arrays.toString(hidden.get(0))); @@ -944,7 +944,7 @@ public class MappingUtilsTest proteinSelection.hideSelectedColumns(2, hiddenCols); MappingUtils.mapColumnSelection(proteinSelection, hiddenCols, proteinView, dnaView, dnaSelection, dnaHidden); - assertTrue(dnaHidden.getListOfCols().isEmpty()); + assertTrue(dnaHidden.getHiddenRegions().isEmpty()); /* * Column 3 in protein picks up Seq1/P, Seq2/Q, Seq3/S which map to columns @@ -959,7 +959,7 @@ public class MappingUtilsTest MappingUtils.mapColumnSelection(proteinSelection, hiddenCols, proteinView, dnaView, dnaSelection, dnaHidden); assertEquals("[0, 1, 2, 3]", dnaSelection.getSelected().toString()); - hidden = dnaHidden.getListOfCols(); + hidden = dnaHidden.getHiddenRegions(); assertEquals(1, hidden.size()); assertEquals("[5, 10]", Arrays.toString(hidden.get(0))); @@ -974,7 +974,7 @@ public class MappingUtilsTest proteinSelection.hideSelectedColumns(3, hiddenCols); MappingUtils.mapColumnSelection(proteinSelection, hiddenCols, proteinView, dnaView, dnaSelection, dnaHidden); - hidden = dnaHidden.getListOfCols(); + hidden = dnaHidden.getHiddenRegions(); assertEquals(2, hidden.size()); assertEquals("[0, 3]", Arrays.toString(hidden.get(0))); assertEquals("[5, 10]", Arrays.toString(hidden.get(1))); diff --git a/test/jalview/viewmodel/OverviewDimensionsTest.java b/test/jalview/viewmodel/OverviewDimensionsTest.java index 5ecac03..e5a8c86 100644 --- a/test/jalview/viewmodel/OverviewDimensionsTest.java +++ b/test/jalview/viewmodel/OverviewDimensionsTest.java @@ -90,7 +90,7 @@ public class OverviewDimensionsTest od = new OverviewDimensionsWithHidden(vpranges, true); // Initial box sizing - default path through code - od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges); + od.setBoxPosition(al.getHiddenSequences(), hiddenCols); mouseClick(od, 0, 0); moveViewport(0, 0); @@ -199,8 +199,7 @@ public class OverviewDimensionsTest @Test(groups = { "Functional" }) public void testSetBoxFromMouseClick() { - od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols, - vpranges); + od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); @@ -298,8 +297,7 @@ public class OverviewDimensionsTest @Test(groups = { "Functional" }) public void testFromMouseWithHiddenColsAtStart() { - od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols, - vpranges); + od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); @@ -311,7 +309,7 @@ public class OverviewDimensionsTest int lastHiddenCol = 30; hiddenCols.hideColumns(0, lastHiddenCol); - od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges); + od.setBoxPosition(al.getHiddenSequences(), hiddenCols); assertEquals(od.getBoxX(), Math.round((float) (lastHiddenCol + 1) * od.getWidth() / alwidth)); @@ -363,8 +361,7 @@ public class OverviewDimensionsTest @Test(groups = { "Functional" }) public void testFromMouseWithHiddenColsInMiddle() { - od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols, - vpranges); + od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); @@ -376,7 +373,7 @@ public class OverviewDimensionsTest int lastHidden = 73; hiddenCols.hideColumns(firstHidden, lastHidden); - od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges); + od.setBoxPosition(al.getHiddenSequences(), hiddenCols); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); @@ -465,8 +462,7 @@ public class OverviewDimensionsTest @Test(groups = { "Functional" }) public void testFromMouseWithHiddenColsAtEnd() { - od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols, - vpranges); + od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); @@ -477,7 +473,7 @@ public class OverviewDimensionsTest int firstHidden = 140; int lastHidden = 164; hiddenCols.hideColumns(firstHidden, lastHidden); - od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges); + od.setBoxPosition(al.getHiddenSequences(), hiddenCols); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); @@ -792,8 +788,7 @@ public class OverviewDimensionsTest @Test(groups = { "Functional" }) public void testFromMouseWithHiddenRowsAtStart() { - od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols, - vpranges); + od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxHeight(), boxHeight); @@ -806,7 +801,7 @@ public class OverviewDimensionsTest int lastHiddenRow = 30; hideSequences(0, lastHiddenRow); - od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges); + od.setBoxPosition(al.getHiddenSequences(), hiddenCols); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), Math.round((float) (lastHiddenRow + 1) @@ -839,8 +834,7 @@ public class OverviewDimensionsTest @Test(groups = { "Functional" }) public void testFromMouseWithHiddenRowsInMiddle() { - od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols, - vpranges); + od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); @@ -855,7 +849,7 @@ public class OverviewDimensionsTest int lastHiddenRow = 54; hideSequences(firstHiddenRow, lastHiddenRow); - od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges); + od.setBoxPosition(al.getHiddenSequences(), hiddenCols); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); @@ -898,8 +892,7 @@ public class OverviewDimensionsTest @Test(groups = { "Functional" }) public void testFromMouseWithHiddenRowsAtEnd() { - od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols, - vpranges); + od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); @@ -913,7 +906,7 @@ public class OverviewDimensionsTest int lastHidden = 524; hideSequences(firstHidden, lastHidden); - od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges); + od.setBoxPosition(al.getHiddenSequences(), hiddenCols); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); @@ -962,7 +955,7 @@ public class OverviewDimensionsTest { vpranges.setStartRes(startRes); vpranges.setEndRes(startRes + viewWidth - 1); - od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges); + od.setBoxPosition(al.getHiddenSequences(), hiddenCols); } /* @@ -972,7 +965,7 @@ public class OverviewDimensionsTest { vpranges.setStartSeq(startSeq); vpranges.setEndSeq(startSeq + viewHeight - 1); - od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges); + od.setBoxPosition(al.getHiddenSequences(), hiddenCols); } /* @@ -984,7 +977,7 @@ public class OverviewDimensionsTest vpranges.setEndRes(startRes + viewWidth - 1); vpranges.setStartSeq(startSeq); vpranges.setEndSeq(startSeq + viewHeight - 1); - od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges); + od.setBoxPosition(al.getHiddenSequences(), hiddenCols); } /* @@ -992,8 +985,7 @@ public class OverviewDimensionsTest */ private void mouseClick(OverviewDimensionsWithHidden od, int x, int y) { - od.updateViewportFromMouse(x, y, al.getHiddenSequences(), hiddenCols, - vpranges); + od.updateViewportFromMouse(x, y, al.getHiddenSequences(), hiddenCols); // updates require an OverviewPanel to exist which it doesn't here // so call setBoxPosition() as it would be called by the AlignmentPanel @@ -1003,7 +995,7 @@ public class OverviewDimensionsTest vpranges.setEndRes(od.getScrollCol() + viewWidth - 1); vpranges.setStartSeq(od.getScrollRow()); vpranges.setEndSeq(od.getScrollRow() + viewHeight - 1); - od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges); + od.setBoxPosition(al.getHiddenSequences(), hiddenCols); } /* -- 1.7.10.2