From: kiramt Date: Thu, 8 Jun 2017 10:15:28 +0000 (+0100) Subject: JAL-2591 Refactor HiddenColumns to use ArrayList instead of Vector X-Git-Tag: Release_2_10_3b1~183^2~7 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=29c0f412ffb98c0b6d3d27714f2b6b032253f3bc;p=jalview.git JAL-2591 Refactor HiddenColumns to use ArrayList instead of Vector --- diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index e77ae54..8f28658 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -1924,8 +1924,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, if (viewport.hasHiddenColumns() && viewport.getSelectionGroup() != null) { - copiedHiddenColumns = viewport.getAlignment().getHiddenColumns() - .getHiddenColumnsCopy(); + copiedHiddenColumns = new Vector<>(viewport.getAlignment() + .getHiddenColumns().getHiddenColumnsCopy()); int hiddenOffset = viewport.getSelectionGroup().getStartRes(); for (int[] region : copiedHiddenColumns) { diff --git a/src/jalview/appletgui/AnnotationColumnChooser.java b/src/jalview/appletgui/AnnotationColumnChooser.java index bb67efc..2557c8d 100644 --- a/src/jalview/appletgui/AnnotationColumnChooser.java +++ b/src/jalview/appletgui/AnnotationColumnChooser.java @@ -300,7 +300,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements .getOldHiddenColumns(); if (oldHidden != null) { - ArrayList regions = oldHidden.getHiddenColumnsCopyAsList(); + ArrayList regions = oldHidden.getHiddenColumnsCopy(); for (int[] positions : regions) { av.hideColumns(positions[0], positions[1]); diff --git a/src/jalview/appletgui/AnnotationLabels.java b/src/jalview/appletgui/AnnotationLabels.java index 0971e56..3f7e523 100755 --- a/src/jalview/appletgui/AnnotationLabels.java +++ b/src/jalview/appletgui/AnnotationLabels.java @@ -50,6 +50,7 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.util.Arrays; import java.util.Collections; +import java.util.Vector; public class AnnotationLabels extends Panel implements ActionListener, MouseListener, MouseMotionListener @@ -837,8 +838,9 @@ public class AnnotationLabels extends Panel implements ActionListener, + sq.getSequenceAsString() + "\n"); if (av.hasHiddenColumns()) { - jalview.appletgui.AlignFrame.copiedHiddenColumns = av.getAlignment() - .getHiddenColumns().getHiddenColumnsCopy(); + jalview.appletgui.AlignFrame.copiedHiddenColumns = new Vector<>( + av.getAlignment().getHiddenColumns() + .getHiddenColumnsCopy()); } } diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index d4bf49a..da54ecf 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -570,7 +570,7 @@ public class SeqCanvas extends Panel implements ViewportListenerI if (av.hasHiddenColumns()) { HiddenColumns hidden = av.getAlignment().getHiddenColumns(); - for (int[] region : hidden.getHiddenColumnsCopyAsList()) + for (int[] region : hidden.getHiddenColumnsCopy()) { int hideStart = region[0]; int hideEnd = region[1]; diff --git a/src/jalview/datamodel/CigarArray.java b/src/jalview/datamodel/CigarArray.java index 31af5f8..febf6b4 100644 --- a/src/jalview/datamodel/CigarArray.java +++ b/src/jalview/datamodel/CigarArray.java @@ -90,7 +90,7 @@ public class CigarArray extends CigarBase { this(constructSeqCigarArray(alignment, selectionGroup)); constructFromAlignment(alignment, - hidden != null ? hidden.getHiddenColumnsCopyAsList() + hidden != null ? hidden.getHiddenColumnsCopy() : null, selectionGroup); } diff --git a/src/jalview/datamodel/HiddenColumns.java b/src/jalview/datamodel/HiddenColumns.java index b53fc8b..65ff9a5 100644 --- a/src/jalview/datamodel/HiddenColumns.java +++ b/src/jalview/datamodel/HiddenColumns.java @@ -38,10 +38,43 @@ public class HiddenColumns * list of hidden column [start, end] ranges; the list is maintained in * ascending start column order */ - private Vector hiddenColumns; + private ArrayList hiddenColumns; /** - * This Method is used to return all the HiddenColumn regions + * Constructor + */ + public HiddenColumns() + { + } + + /** + * Copy constructor + * + * @param copy + */ + public HiddenColumns(HiddenColumns copy) + { + try + { + + LOCK.readLock().lock(); + if (copy != null) + { + if (copy.hiddenColumns != null) + { + hiddenColumns = copy.copyHiddenRegionsToArrayList(); + } + } + } finally + { + LOCK.readLock().unlock(); + } + } + + /** + * This method is used to return all the HiddenColumn regions and is intended + * to remain private. External callers which need a copy of the regions can + * call getHiddenColumnsCopyAsList. * * @return empty list or List of hidden column intervals */ @@ -186,7 +219,7 @@ public class HiddenColumns { for (int i = 0; i < hiddenColumns.size(); i++) { - int[] region = hiddenColumns.elementAt(i); + int[] region = hiddenColumns.get(i); if (result >= region[0]) { result += region[1] - region[0] + 1; @@ -221,7 +254,7 @@ public class HiddenColumns int[] region; do { - region = hiddenColumns.elementAt(index++); + region = hiddenColumns.get(index++); if (hiddenColumn > region[1]) { result -= region[1] + 1 - region[0]; @@ -340,7 +373,7 @@ public class HiddenColumns { positions = new ArrayList<>(hiddenColumns.size()); - positions.add(hiddenColumns.elementAt(0)[0]); + positions.add(hiddenColumns.get(0)[0]); for (int i = 1; i < hiddenColumns.size(); ++i) { @@ -351,7 +384,7 @@ public class HiddenColumns int gaps = 0; do { - int[] region = hiddenColumns.elementAt(index); + int[] region = hiddenColumns.get(index); gaps += region[1] + 1 - region[0]; result = region[1] + 1; index++; @@ -392,7 +425,7 @@ public class HiddenColumns int index = 0; do { - int[] region = hiddenColumns.elementAt(index); + int[] region = hiddenColumns.get(index); if (alPos < region[0]) { return region[0]; @@ -428,7 +461,7 @@ public class HiddenColumns int index = hiddenColumns.size() - 1; do { - int[] region = hiddenColumns.elementAt(index); + int[] region = hiddenColumns.get(index); if (alPos > region[1]) { return region[1]; @@ -464,7 +497,7 @@ public class HiddenColumns int index = hiddenColumns.size() - 1; do { - int[] region = hiddenColumns.elementAt(index); + int[] region = hiddenColumns.get(index); if (pos > region[1]) { return index; @@ -511,7 +544,7 @@ public class HiddenColumns if (hiddenColumns == null) { - hiddenColumns = new Vector<>(); + hiddenColumns = new ArrayList<>(); } /* @@ -520,14 +553,14 @@ public class HiddenColumns */ for (int i = 0; i < hiddenColumns.size(); i++) { - int[] region = hiddenColumns.elementAt(i); + int[] region = hiddenColumns.get(i); if (end < region[0] - 1) { /* * insert discontiguous preceding range */ - hiddenColumns.insertElementAt(new int[] { start, end }, i); + hiddenColumns.add(i, new int[] { start, end }); return; } @@ -574,7 +607,7 @@ public class HiddenColumns /* * remaining case is that the new range follows everything else */ - hiddenColumns.addElement(new int[] { start, end }); + hiddenColumns.add(new int[] { start, end }); } finally { if (!alreadyLocked) @@ -608,56 +641,6 @@ public class HiddenColumns } } - /** - * ColumnSelection - */ - public HiddenColumns() - { - } - - /** - * Copy constructor - * - * @param copy - */ - public HiddenColumns(HiddenColumns copy) - { - try - { - - LOCK.readLock().lock(); - if (copy != null) - { - if (copy.hiddenColumns != null) - { - hiddenColumns = copy.copyHiddenRegions(); - } - } - } - finally - { - LOCK.readLock().unlock(); - } - } - - private Vector copyHiddenRegions() - { - Vector copy = new Vector<>(hiddenColumns.size()); - for (int i = 0, j = hiddenColumns.size(); i < j; i++) - { - int[] rh; - int[] cp; - rh = hiddenColumns.elementAt(i); - if (rh != null) - { - cp = new int[rh.length]; - System.arraycopy(rh, 0, cp, 0, rh.length); - copy.addElement(cp); - } - } - return copy; - } - private ArrayList copyHiddenRegionsToArrayList() { int size = 0; @@ -671,7 +654,7 @@ public class HiddenColumns { int[] rh; int[] cp; - rh = hiddenColumns.elementAt(i); + rh = hiddenColumns.get(i); if (rh != null) { cp = new int[rh.length]; @@ -682,26 +665,7 @@ public class HiddenColumns return copy; } - - /** - * Returns a copy of the vector of hidden regions, as a vector. Before using - * this method please consider if you really need access to the hidden regions - * - a new (or existing!) method on HiddenColumns might be more appropriate. - * - * @return hidden regions as vector of [start,end] pairs - */ - public Vector getHiddenColumnsCopy() - { - try - { - LOCK.readLock().lock(); - return copyHiddenRegions(); - } finally - { - LOCK.readLock().unlock(); - } - } - + /** * Returns a copy of the vector of hidden regions, as an ArrayList. Before * using this method please consider if you really need access to the hidden @@ -710,7 +674,7 @@ public class HiddenColumns * * @return hidden regions as an ArrayList of [start,end] pairs */ - public ArrayList getHiddenColumnsCopyAsList() + public ArrayList getHiddenColumnsCopy() { try { @@ -744,12 +708,12 @@ public class HiddenColumns int hSize = hiddenColumns.size(); for (int i = 0; i < hSize; i++) { - int[] region = hiddenColumns.elementAt(i); + int[] region = hiddenColumns.get(i); if (region[0] > start && start + change > region[1]) { deletedHiddenColumns.add(region); - hiddenColumns.removeElementAt(i); + hiddenColumns.remove(i); i--; hSize--; continue; @@ -796,7 +760,7 @@ public class HiddenColumns { for (int i = 0; i < hiddenColumns.size(); i++) { - int[] region = hiddenColumns.elementAt(i); + int[] region = hiddenColumns.get(i); if (region[0] >= start) { region[0] -= change; @@ -807,7 +771,7 @@ public class HiddenColumns } if (region[1] < region[0]) { - hiddenColumns.removeElementAt(i--); + hiddenColumns.remove(i--); } if (region[0] < 0) @@ -902,7 +866,7 @@ public class HiddenColumns { LOCK.readLock().lock(); int iSize = seqs.length; - String selections[] = new String[iSize]; + String[] selections = new String[iSize]; if (hiddenColumns != null && hiddenColumns.size() > 0) { for (int i = 0; i < iSize; i++) @@ -1247,7 +1211,7 @@ public class HiddenColumns { for (int i = 0; i < hiddenColumns.size(); i++) { - int[] region = hiddenColumns.elementAt(i); + int[] region = hiddenColumns.get(i); for (int j = region[0]; j < region[1] + 1; j++) { sel.addElement(j); @@ -1276,7 +1240,7 @@ public class HiddenColumns LOCK.writeLock().lock(); for (int i = 0; i < hiddenColumns.size(); i++) { - int[] region = hiddenColumns.elementAt(i); + int[] region = hiddenColumns.get(i); if (start == region[0]) { for (int j = region[0]; j < region[1] + 1; j++) @@ -1284,7 +1248,7 @@ public class HiddenColumns sel.addElement(j); } - hiddenColumns.removeElement(region); + hiddenColumns.remove(region); break; } } @@ -1307,16 +1271,16 @@ public class HiddenColumns * @param intervals * @return */ - private boolean pruneIntervalVector(final List shifts, - Vector intervals) + private boolean pruneIntervalList(final List shifts, + ArrayList intervals) { boolean pruned = false; int i = 0; int j = intervals.size() - 1; int s = 0; int t = shifts.size() - 1; - int hr[] = intervals.elementAt(i); - int sr[] = shifts.get(s); + int[] hr = intervals.get(i); + int[] sr = shifts.get(s); while (i <= j && s <= t) { boolean trailinghn = hr[1] >= sr[0]; @@ -1324,7 +1288,7 @@ public class HiddenColumns { if (i < j) { - hr = intervals.elementAt(++i); + hr = intervals.get(++i); } else { @@ -1352,12 +1316,12 @@ public class HiddenColumns { if (trailinghc) { // deleted hidden region. - intervals.removeElementAt(i); + intervals.remove(i); pruned = true; j--; if (i <= j) { - hr = intervals.elementAt(i); + hr = intervals.get(i); } continue; } @@ -1411,7 +1375,7 @@ public class HiddenColumns // delete any intervals intersecting. if (hiddenColumns != null) { - pruneIntervalVector(shifts, hiddenColumns); + pruneIntervalList(shifts, hiddenColumns); if (hiddenColumns != null && hiddenColumns.size() == 0) { hiddenColumns = null; diff --git a/src/jalview/datamodel/VisibleColsIterator.java b/src/jalview/datamodel/VisibleColsIterator.java index 5c78f96..a82de93 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.getHiddenColumnsCopyAsList(); + hidden = hiddenCols.getHiddenColumnsCopy(); lasthiddenregion = -1; if (hidden != null) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 2c7837f..fe84012 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -1886,7 +1886,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, int hiddenOffset = viewport.getSelectionGroup().getStartRes(); int hiddenCutoff = viewport.getSelectionGroup().getEndRes(); ArrayList hiddenRegions = viewport.getAlignment() - .getHiddenColumns().getHiddenColumnsCopyAsList(); + .getHiddenColumns().getHiddenColumnsCopy(); for (int[] region : hiddenRegions) { if (region[0] >= hiddenOffset && region[1] <= hiddenCutoff) diff --git a/src/jalview/gui/AnnotationColumnChooser.java b/src/jalview/gui/AnnotationColumnChooser.java index 311b9d5..bb475da 100644 --- a/src/jalview/gui/AnnotationColumnChooser.java +++ b/src/jalview/gui/AnnotationColumnChooser.java @@ -246,7 +246,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements .getOldHiddenColumns(); if (oldHidden != null) { - ArrayList regions = oldHidden.getHiddenColumnsCopyAsList(); + ArrayList regions = oldHidden.getHiddenColumnsCopy(); for (int[] positions : regions) { av.hideColumns(positions[0], positions[1]); diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 7741956..e16867a 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -969,7 +969,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, if (av.hasHiddenColumns()) { hiddenColumns = av.getAlignment().getHiddenColumns() - .getHiddenColumnsCopyAsList(); + .getHiddenColumnsCopy(); } Desktop.jalviewClipboard = new Object[] { seqs, ds, // what is the dataset diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index d18c9b3..45988fb 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -1422,7 +1422,7 @@ public class Jalview2XML else { ArrayList hiddenRegions = hidden - .getHiddenColumnsCopyAsList(); + .getHiddenColumnsCopy(); for (int[] region : hiddenRegions) { HiddenColumns hc = new HiddenColumns(); diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index c46e752..1625c52 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -668,7 +668,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI int blockEnd = endRes; for (int[] region : av.getAlignment().getHiddenColumns() - .getHiddenColumnsCopyAsList()) + .getHiddenColumnsCopy()) { int hideStart = region[0]; int hideEnd = region[1]; diff --git a/src/jalview/util/MappingUtils.java b/src/jalview/util/MappingUtils.java index 1fe55f3..b2ec120 100644 --- a/src/jalview/util/MappingUtils.java +++ b/src/jalview/util/MappingUtils.java @@ -539,7 +539,7 @@ public final class MappingUtils toSequences, fromGapChar); } - for (int[] hidden : hiddencols.getHiddenColumnsCopyAsList()) + for (int[] hidden : hiddencols.getHiddenColumnsCopy()) { mapHiddenColumns(hidden, codonFrames, newHidden, fromSequences, toSequences, fromGapChar); diff --git a/test/jalview/datamodel/ColumnSelectionTest.java b/test/jalview/datamodel/ColumnSelectionTest.java index b47285c..e99e952 100644 --- a/test/jalview/datamodel/ColumnSelectionTest.java +++ b/test/jalview/datamodel/ColumnSelectionTest.java @@ -132,7 +132,7 @@ public class ColumnSelectionTest // hide column 5 (and adjacent): cs.hideSelectedColumns(5, al.getHiddenColumns()); // 4,5,6 now hidden: - List hidden = al.getHiddenColumns().getHiddenColumnsCopyAsList(); + List hidden = al.getHiddenColumns().getHiddenColumnsCopy(); assertEquals(1, hidden.size()); assertEquals("[4, 6]", Arrays.toString(hidden.get(0))); // none now selected: @@ -145,7 +145,7 @@ public class ColumnSelectionTest cs.addElement(5); cs.addElement(6); cs.hideSelectedColumns(4, al.getHiddenColumns()); - hidden = al.getHiddenColumns().getHiddenColumnsCopyAsList(); + hidden = al.getHiddenColumns().getHiddenColumnsCopy(); assertEquals(1, hidden.size()); assertEquals("[4, 6]", Arrays.toString(hidden.get(0))); assertTrue(cs.getSelected().isEmpty()); @@ -157,7 +157,7 @@ public class ColumnSelectionTest cs.addElement(5); cs.addElement(6); cs.hideSelectedColumns(6, al.getHiddenColumns()); - hidden = al.getHiddenColumns().getHiddenColumnsCopyAsList(); + hidden = al.getHiddenColumns().getHiddenColumnsCopy(); assertEquals(1, hidden.size()); assertEquals("[4, 6]", Arrays.toString(hidden.get(0))); assertTrue(cs.getSelected().isEmpty()); @@ -168,7 +168,7 @@ public class ColumnSelectionTest cs.addElement(4); cs.addElement(6); cs.hideSelectedColumns(5, al.getHiddenColumns()); - hidden = al.getHiddenColumns().getHiddenColumnsCopyAsList(); + hidden = al.getHiddenColumns().getHiddenColumnsCopy(); assertEquals(1, hidden.size()); assertEquals("[4, 6]", Arrays.toString(hidden.get(0))); assertTrue(cs.getSelected().isEmpty()); @@ -196,7 +196,7 @@ public class ColumnSelectionTest cs.hideSelectedColumns(al); assertTrue(cs.getSelected().isEmpty()); - List hidden = cols.getHiddenColumnsCopyAsList(); + List hidden = cols.getHiddenColumnsCopy(); 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 13cb526..fbb354b 100644 --- a/test/jalview/datamodel/HiddenColumnsTest.java +++ b/test/jalview/datamodel/HiddenColumnsTest.java @@ -233,16 +233,16 @@ public class HiddenColumnsTest cs.hideColumns(10, 11); cs.hideColumns(5, 7); assertEquals("[5, 7]", - Arrays.toString(cs.getHiddenColumnsCopyAsList().get(0))); + Arrays.toString(cs.getHiddenColumnsCopy().get(0))); HiddenColumns cs2 = new HiddenColumns(cs); assertTrue(cs2.hasHiddenColumns()); - assertEquals(2, cs2.getHiddenColumnsCopyAsList().size()); + assertEquals(2, cs2.getHiddenColumnsCopy().size()); // hidden columns are held in column order assertEquals("[5, 7]", - Arrays.toString(cs2.getHiddenColumnsCopyAsList().get(0))); + Arrays.toString(cs2.getHiddenColumnsCopy().get(0))); assertEquals("[10, 11]", - Arrays.toString(cs2.getHiddenColumnsCopyAsList().get(1))); + Arrays.toString(cs2.getHiddenColumnsCopy().get(1))); } /** @@ -339,78 +339,78 @@ public class HiddenColumnsTest ColumnSelection colsel = new ColumnSelection(); HiddenColumns cs = al.getHiddenColumns(); colsel.hideSelectedColumns(5, al.getHiddenColumns()); - List hidden = cs.getHiddenColumnsCopyAsList(); + List hidden = cs.getHiddenColumnsCopy(); assertEquals(1, hidden.size()); assertEquals("[5, 5]", Arrays.toString(hidden.get(0))); colsel.hideSelectedColumns(3, al.getHiddenColumns()); - hidden = cs.getHiddenColumnsCopyAsList(); + hidden = cs.getHiddenColumnsCopy(); assertEquals(2, hidden.size()); // two hidden ranges, in order: - assertEquals(hidden.size(), cs.getHiddenColumnsCopyAsList().size()); + assertEquals(hidden.size(), cs.getHiddenColumnsCopy().size()); 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.getHiddenColumnsCopyAsList(); + hidden = cs.getHiddenColumnsCopy(); 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.getHiddenColumnsCopyAsList().isEmpty()); + assertTrue(cs.getHiddenColumnsCopy().isEmpty()); cs.hideColumns(3, 6); - hidden = cs.getHiddenColumnsCopyAsList(); + hidden = cs.getHiddenColumnsCopy(); int[] firstHiddenRange = hidden.get(0); assertEquals("[3, 6]", Arrays.toString(firstHiddenRange)); // adding a subrange of already hidden should do nothing cs.hideColumns(4, 5); - hidden = cs.getHiddenColumnsCopyAsList(); + hidden = cs.getHiddenColumnsCopy(); assertEquals(1, hidden.size()); assertEquals("[3, 6]", - Arrays.toString(cs.getHiddenColumnsCopyAsList().get(0))); + Arrays.toString(cs.getHiddenColumnsCopy().get(0))); cs.hideColumns(3, 5); - hidden = cs.getHiddenColumnsCopyAsList(); + hidden = cs.getHiddenColumnsCopy(); assertEquals(1, hidden.size()); assertEquals("[3, 6]", - Arrays.toString(cs.getHiddenColumnsCopyAsList().get(0))); + Arrays.toString(cs.getHiddenColumnsCopy().get(0))); cs.hideColumns(4, 6); - hidden = cs.getHiddenColumnsCopyAsList(); + hidden = cs.getHiddenColumnsCopy(); assertEquals(1, hidden.size()); assertEquals("[3, 6]", - Arrays.toString(cs.getHiddenColumnsCopyAsList().get(0))); + Arrays.toString(cs.getHiddenColumnsCopy().get(0))); cs.hideColumns(3, 6); - hidden = cs.getHiddenColumnsCopyAsList(); + hidden = cs.getHiddenColumnsCopy(); assertEquals(1, hidden.size()); assertEquals("[3, 6]", - Arrays.toString(cs.getHiddenColumnsCopyAsList().get(0))); + Arrays.toString(cs.getHiddenColumnsCopy().get(0))); cs.revealAllHiddenColumns(colsel); cs.hideColumns(2, 4); - hidden = cs.getHiddenColumnsCopyAsList(); + hidden = cs.getHiddenColumnsCopy(); assertEquals(1, hidden.size()); assertEquals("[2, 4]", Arrays.toString(hidden.get(0))); // extend contiguous with 2 positions overlap cs.hideColumns(3, 5); - hidden = cs.getHiddenColumnsCopyAsList(); + hidden = cs.getHiddenColumnsCopy(); assertEquals(1, hidden.size()); assertEquals("[2, 5]", Arrays.toString(hidden.get(0))); // extend contiguous with 1 position overlap cs.hideColumns(5, 6); - hidden = cs.getHiddenColumnsCopyAsList(); + hidden = cs.getHiddenColumnsCopy(); assertEquals(1, hidden.size()); assertEquals("[2, 6]", Arrays.toString(hidden.get(0))); // extend contiguous with overlap both ends: cs.hideColumns(1, 7); - hidden = cs.getHiddenColumnsCopyAsList(); + hidden = cs.getHiddenColumnsCopy(); assertEquals(1, hidden.size()); assertEquals("[1, 7]", Arrays.toString(hidden.get(0))); } @@ -428,7 +428,7 @@ public class HiddenColumnsTest colsel.addElement(10); cs.revealHiddenColumns(5, colsel); // hidden columns list now null but getter returns empty list: - assertTrue(cs.getHiddenColumnsCopyAsList().isEmpty()); + assertTrue(cs.getHiddenColumnsCopy().isEmpty()); // revealed columns are marked as selected (added to selection): assertEquals("[10, 5, 6, 7, 8]", colsel.getSelected().toString()); @@ -436,9 +436,9 @@ public class HiddenColumnsTest colsel = new ColumnSelection(); cs = new HiddenColumns(); cs.hideColumns(5, 8); - List hidden = cs.getHiddenColumnsCopyAsList(); + List hidden = cs.getHiddenColumnsCopy(); cs.revealHiddenColumns(6, colsel); - assertEquals(hidden.size(), cs.getHiddenColumnsCopyAsList().size()); + assertEquals(hidden.size(), cs.getHiddenColumnsCopy().size()); assertTrue(colsel.getSelected().isEmpty()); } @@ -457,7 +457,7 @@ public class HiddenColumnsTest * revealing hidden columns adds them (in order) to the (unordered) * selection list */ - assertTrue(cs.getHiddenColumnsCopyAsList().isEmpty()); + assertTrue(cs.getHiddenColumnsCopy().isEmpty()); assertEquals("[11, 1, 2, 3, 5, 6, 7, 8]", colsel.getSelected() .toString()); } @@ -493,13 +493,13 @@ public class HiddenColumnsTest HiddenColumns cs = new HiddenColumns(); cs.hideColumns(49, 59); cs.hideColumns(69, 79); - List hidden = cs.getHiddenColumnsCopyAsList(); + List hidden = cs.getHiddenColumnsCopy(); 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.getHiddenColumnsCopyAsList(); + hidden = cs.getHiddenColumnsCopy(); assertEquals(1, hidden.size()); assertEquals("[48, 80]", Arrays.toString(hidden.get(0))); @@ -512,7 +512,7 @@ public class HiddenColumnsTest cs.hideColumns(50, 60); // hiding 21-49 should merge to one range cs.hideColumns(21, 49); - hidden = cs.getHiddenColumnsCopyAsList(); + hidden = cs.getHiddenColumnsCopy(); assertEquals(1, hidden.size()); assertEquals("[10, 60]", Arrays.toString(hidden.get(0))); @@ -528,7 +528,7 @@ public class HiddenColumnsTest cs.hideColumns(60, 70); cs.hideColumns(15, 45); - hidden = cs.getHiddenColumnsCopyAsList(); + hidden = cs.getHiddenColumnsCopy(); assertEquals(2, hidden.size()); assertEquals("[10, 50]", Arrays.toString(hidden.get(0))); assertEquals("[60, 70]", Arrays.toString(hidden.get(1))); @@ -545,23 +545,23 @@ public class HiddenColumnsTest one.set(1); cs = new HiddenColumns(); cs.hideMarkedBits(one); - assertEquals(1, cs.getHiddenColumnsCopyAsList().size()); + assertEquals(1, cs.getHiddenColumnsCopy().size()); one.set(2); cs = new HiddenColumns(); cs.hideMarkedBits(one); - assertEquals(1, cs.getHiddenColumnsCopyAsList().size()); + assertEquals(1, cs.getHiddenColumnsCopy().size()); one.set(3); cs = new HiddenColumns(); cs.hideMarkedBits(one); - assertEquals(1, cs.getHiddenColumnsCopyAsList().size()); + assertEquals(1, cs.getHiddenColumnsCopy().size()); // split one.clear(2); cs = new HiddenColumns(); cs.hideMarkedBits(one); - assertEquals(2, cs.getHiddenColumnsCopyAsList().size()); + assertEquals(2, cs.getHiddenColumnsCopy().size()); assertEquals(0, cs.adjustForHiddenColumns(0)); assertEquals(2, cs.adjustForHiddenColumns(1)); @@ -572,7 +572,7 @@ public class HiddenColumnsTest cs = new HiddenColumns(); cs.hideMarkedBits(one); - assertEquals(1, cs.getHiddenColumnsCopyAsList().size()); + assertEquals(1, cs.getHiddenColumnsCopy().size()); assertEquals(0, cs.adjustForHiddenColumns(0)); assertEquals(1, cs.adjustForHiddenColumns(1)); diff --git a/test/jalview/gui/AlignFrameTest.java b/test/jalview/gui/AlignFrameTest.java index 721ffc8..67098ae 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() - .getHiddenColumnsCopyAsList() + .getHiddenColumnsCopy() .isEmpty()); assertFalse(alignFrame.hideFeatureColumns("exon", false)); assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty()); assertTrue(alignFrame.getViewport().getAlignment().getHiddenColumns() - .getHiddenColumnsCopyAsList() + .getHiddenColumnsCopy() .isEmpty()); /* @@ -101,7 +101,7 @@ public class AlignFrameTest assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty()); List hidden = alignFrame.getViewport().getAlignment() .getHiddenColumns() - .getHiddenColumnsCopyAsList(); + .getHiddenColumnsCopy(); assertTrue(hidden.isEmpty()); /* @@ -111,7 +111,7 @@ public class AlignFrameTest */ assertTrue(alignFrame.hideFeatureColumns("Turn", true)); hidden = alignFrame.getViewport().getAlignment().getHiddenColumns() - .getHiddenColumnsCopyAsList(); + .getHiddenColumnsCopy(); 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 6da6f5f..e046d94 100644 --- a/test/jalview/io/JSONFileTest.java +++ b/test/jalview/io/JSONFileTest.java @@ -195,7 +195,7 @@ public class JSONFileTest TEST_SEQ_HEIGHT = expectedSeqs.size(); TEST_GRP_HEIGHT = expectedGrps.size(); TEST_ANOT_HEIGHT = expectedAnnots.size(); - TEST_CS_HEIGHT = expectedColSel.getHiddenColumnsCopyAsList().size(); + TEST_CS_HEIGHT = expectedColSel.getHiddenColumnsCopy().size(); exportSettings = new AlignExportSettingI() { @@ -315,11 +315,11 @@ public class JSONFileTest { HiddenColumns cs = testJsonFile.getHiddenColumns(); Assert.assertNotNull(cs); - Assert.assertNotNull(cs.getHiddenColumnsCopyAsList()); - List hiddenCols = cs.getHiddenColumnsCopyAsList(); + Assert.assertNotNull(cs.getHiddenColumnsCopy()); + List hiddenCols = cs.getHiddenColumnsCopy(); Assert.assertEquals(hiddenCols.size(), TEST_CS_HEIGHT); Assert.assertEquals(hiddenCols.get(0), expectedColSel - .getHiddenColumnsCopyAsList().get(0), + .getHiddenColumnsCopy().get(0), "Mismatched hidden columns!"); } diff --git a/test/jalview/util/MappingUtilsTest.java b/test/jalview/util/MappingUtilsTest.java index c8b6034..d0ec3e8 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.getHiddenColumnsCopyAsList(); + List hidden = dnaHidden.getHiddenColumnsCopy(); 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.getHiddenColumnsCopyAsList(); + hidden = dnaHidden.getHiddenColumnsCopy(); 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.getHiddenColumnsCopyAsList().isEmpty()); + assertTrue(dnaHidden.getHiddenColumnsCopy().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.getHiddenColumnsCopyAsList(); + hidden = dnaHidden.getHiddenColumnsCopy(); 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.getHiddenColumnsCopyAsList(); + hidden = dnaHidden.getHiddenColumnsCopy(); assertEquals(2, hidden.size()); assertEquals("[0, 3]", Arrays.toString(hidden.get(0))); assertEquals("[5, 10]", Arrays.toString(hidden.get(1)));