return blockStart;
}
-
- @Benchmark
- @BenchmarkMode({Mode.Throughput})
- public int benchHiddenColsCopy(HiddenColsAndStartState tstate)
- {
- int startx = tstate.visibleColumn;
- int blockEnd;
- int blockStart = startx;
- int screenY = 0;
- for (int[] region : tstate.h.getHiddenColumnsCopy())
- {
- int hideStart = region[0];
- int hideEnd = region[1];
-
- if (hideStart <= blockStart)
- {
- blockStart += (hideEnd - hideStart) + 1;
- continue;
- }
-
- //do something
- Blackhole.consumeCPU(5);
- blockEnd = Math.min(hideStart - 1, blockStart + 60 - screenY);
-
- screenY += blockEnd - blockStart + 1;
- blockStart = hideEnd + 1;
-
- if (screenY > 60)
- {
- //done
- break;
- }
- }
- return blockStart;
- }
-
-
@Benchmark
@BenchmarkMode({Mode.Throughput})
public int benchLoop1(HiddenColsAndStartState tstate)
@Benchmark
@BenchmarkMode({Mode.Throughput})
- public ArrayList<int[]> benchGetHiddenColumnsCopy(HiddenColsAndStartState tstate)
- {
- return tstate.h.getHiddenColumnsCopy();
- }
-
-
- @Benchmark
- @BenchmarkMode({Mode.Throughput})
public int benchGetSize(HiddenColsAndStartState tstate)
{
return tstate.h.getSize();
}
}
+ /**
+ * Get the number of distinct hidden regions
+ *
+ * @return number of regions
+ */
+ public int getNumberOfRegions()
+ {
+ try
+ {
+ LOCK.readLock().lock();
+ int num = 0;
+ if (hasHiddenColumns())
+ {
+ num = hiddenColumns.size();
+ }
+ return num;
+ } finally
+ {
+ LOCK.readLock().unlock();
+ }
+ }
+
@Override
public boolean equals(Object obj)
{
// but where each hidden column region is shifted backwards by the number of
// preceding visible gaps
// update hidden columns at the same time
- ArrayList<int[]> regions = getHiddenColumnsCopy();
+ Iterator<int[]> regions = iterator();
ArrayList<int[]> newhidden = new ArrayList<>();
int numGapsBefore = 0;
int gapPosition = 0;
- for (int[] region : regions)
+ while (regions.hasNext())
{
// get region coordinates accounting for gaps
// we can rely on gaps not being *in* hidden regions because we already
// removed those
+ int[] region = regions.next();
while (gapPosition < region[0])
{
gapPosition++;
{
if (hiddenColumns != null)
{
- return new BoundedHiddenColsIterator(0, hiddenColumns.size(), true);
+ int last = hiddenColumns.get(hiddenColumns.size() - 1)[1];
+ return new BoundedHiddenColsIterator(0, last, true);
}
else
{
* lower bound to iterate from
* @param upperBound
* upper bound to iterate to
- * @param opt
- * Option.OVERLAP: regions which overlap [lowerBound,upperBound]
- * are included Option.START: regions which start in
- * [lowerBound,upperBound] are included
- * @param useAbsolutePos
- * have bounds and return values with reference to absolute indices
- * (if false, use indices for visible columns)
* @param useCopyCols
* whether to make a local copy of hiddenColumns for iteration (set
* to true if calling from outwith the HiddenColumns class)
toSequences, fromGapChar);
}
- for (int[] hidden : hiddencols.getHiddenColumnsCopy())
+ Iterator<int[]> regions = hiddencols.iterator();
+ while (regions.hasNext())
{
- mapHiddenColumns(hidden, codonFrames, newHidden, fromSequences,
+ mapHiddenColumns(regions.next(), codonFrames, newHidden,
+ fromSequences,
toSequences, fromGapChar);
}
return; // mappedColumns;
import java.util.BitSet;
import java.util.Collections;
import java.util.ConcurrentModificationException;
+import java.util.Iterator;
import java.util.List;
import org.testng.annotations.BeforeClass;
// hide column 5 (and adjacent):
cs.hideSelectedColumns(5, al.getHiddenColumns());
// 4,5,6 now hidden:
- List<int[]> hidden = al.getHiddenColumns().getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
+ Iterator<int[]> regions = al.getHiddenColumns().iterator();
+ assertEquals(1, al.getHiddenColumns().getNumberOfRegions());
+ assertEquals("[4, 6]", Arrays.toString(regions.next()));
// none now selected:
assertTrue(cs.getSelected().isEmpty());
cs.addElement(5);
cs.addElement(6);
cs.hideSelectedColumns(4, al.getHiddenColumns());
- hidden = al.getHiddenColumns().getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
+ regions = al.getHiddenColumns().iterator();
+ assertEquals(1, al.getHiddenColumns().getNumberOfRegions());
+ assertEquals("[4, 6]", Arrays.toString(regions.next()));
assertTrue(cs.getSelected().isEmpty());
// repeat, hiding column (4, 5 and) 6
cs.addElement(5);
cs.addElement(6);
cs.hideSelectedColumns(6, al.getHiddenColumns());
- hidden = al.getHiddenColumns().getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
+ regions = al.getHiddenColumns().iterator();
+ assertEquals(1, al.getHiddenColumns().getNumberOfRegions());
+ assertEquals("[4, 6]", Arrays.toString(regions.next()));
assertTrue(cs.getSelected().isEmpty());
// repeat, with _only_ adjacent columns selected
cs.addElement(4);
cs.addElement(6);
cs.hideSelectedColumns(5, al.getHiddenColumns());
- hidden = al.getHiddenColumns().getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
+ regions = al.getHiddenColumns().iterator();
+ assertEquals(1, al.getHiddenColumns().getNumberOfRegions());
+ assertEquals("[4, 6]", Arrays.toString(regions.next()));
assertTrue(cs.getSelected().isEmpty());
}
cs.hideSelectedColumns(al);
assertTrue(cs.getSelected().isEmpty());
- List<int[]> hidden = cols.getHiddenColumnsCopy();
- assertEquals(4, hidden.size());
- assertEquals("[2, 4]", Arrays.toString(hidden.get(0)));
- assertEquals("[7, 9]", Arrays.toString(hidden.get(1)));
- assertEquals("[15, 18]", Arrays.toString(hidden.get(2)));
- assertEquals("[20, 22]", Arrays.toString(hidden.get(3)));
+ Iterator<int[]> regions = cols.iterator();
+ assertEquals(4, cols.getNumberOfRegions());
+ assertEquals("[2, 4]", Arrays.toString(regions.next()));
+ assertEquals("[7, 9]", Arrays.toString(regions.next()));
+ assertEquals("[15, 18]", Arrays.toString(regions.next()));
+ assertEquals("[20, 22]", Arrays.toString(regions.next()));
}
/**
import jalview.gui.JvOptionPane;
import jalview.util.Comparison;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Iterator;
HiddenColumns cs = new HiddenColumns();
cs.hideColumns(10, 11);
cs.hideColumns(5, 7);
+ Iterator<int[]> regions = cs.iterator();
assertEquals("[5, 7]",
- Arrays.toString(cs.getHiddenColumnsCopy().get(0)));
+ Arrays.toString(regions.next()));
HiddenColumns cs2 = new HiddenColumns(cs);
+ regions = cs2.iterator();
assertTrue(cs2.hasHiddenColumns());
- assertEquals(2, cs2.getHiddenColumnsCopy().size());
+ assertEquals(2, cs2.getNumberOfRegions());
// hidden columns are held in column order
assertEquals("[5, 7]",
- Arrays.toString(cs2.getHiddenColumnsCopy().get(0)));
+ Arrays.toString(regions.next()));
assertEquals("[10, 11]",
- Arrays.toString(cs2.getHiddenColumnsCopy().get(1)));
+ Arrays.toString(regions.next()));
}
@Test(groups = "Functional")
HiddenColumns cs2 = new HiddenColumns(cs, 3, 9, 1);
assertTrue(cs2.hasHiddenColumns());
+ Iterator<int[]> regions = cs2.iterator();
// only [5,7] returned, offset by 1
assertEquals("[4, 6]",
- Arrays.toString(cs2.getHiddenColumnsCopy().get(0)));
+ Arrays.toString(regions.next()));
assertEquals(3, cs2.getSize());
cs2 = new HiddenColumns(cs, 8, 15, 4);
+ regions = cs2.iterator();
assertTrue(cs2.hasHiddenColumns());
// only [10,11] returned, offset by 4
assertEquals("[6, 7]",
- Arrays.toString(cs2.getHiddenColumnsCopy().get(0)));
+ Arrays.toString(regions.next()));
assertEquals(2, cs2.getSize());
cs2 = new HiddenColumns(cs, 6, 10, 4);
ColumnSelection colsel = new ColumnSelection();
HiddenColumns cs = al.getHiddenColumns();
colsel.hideSelectedColumns(5, al.getHiddenColumns());
- List<int[]> hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[5, 5]", Arrays.toString(hidden.get(0)));
+ Iterator<int[]> regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals("[5, 5]", Arrays.toString(regions.next()));
colsel.hideSelectedColumns(3, al.getHiddenColumns());
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(2, hidden.size());
+ regions = cs.iterator();
+ assertEquals(2, cs.getNumberOfRegions());
// two hidden ranges, in order:
- assertEquals(hidden.size(), cs.getHiddenColumnsCopy().size());
- assertEquals("[3, 3]", Arrays.toString(hidden.get(0)));
- assertEquals("[5, 5]", Arrays.toString(hidden.get(1)));
+ assertEquals("[3, 3]", Arrays.toString(regions.next()));
+ assertEquals("[5, 5]", Arrays.toString(regions.next()));
// 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.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[3, 5]", Arrays.toString(hidden.get(0)));
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals("[3, 5]", Arrays.toString(regions.next()));
// 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.getHiddenColumnsCopy().isEmpty());
+ assertEquals(0, cs.getNumberOfRegions());
cs.hideColumns(3, 6);
- hidden = cs.getHiddenColumnsCopy();
- int[] firstHiddenRange = hidden.get(0);
+ regions = cs.iterator();
+ int[] firstHiddenRange = regions.next();
assertEquals("[3, 6]", Arrays.toString(firstHiddenRange));
// adding a subrange of already hidden should do nothing
cs.hideColumns(4, 5);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
assertEquals("[3, 6]",
- Arrays.toString(cs.getHiddenColumnsCopy().get(0)));
+ Arrays.toString(regions.next()));
cs.hideColumns(3, 5);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
assertEquals("[3, 6]",
- Arrays.toString(cs.getHiddenColumnsCopy().get(0)));
+ Arrays.toString(regions.next()));
cs.hideColumns(4, 6);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
assertEquals("[3, 6]",
- Arrays.toString(cs.getHiddenColumnsCopy().get(0)));
+ Arrays.toString(regions.next()));
cs.hideColumns(3, 6);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
assertEquals("[3, 6]",
- Arrays.toString(cs.getHiddenColumnsCopy().get(0)));
+ Arrays.toString(regions.next()));
cs.revealAllHiddenColumns(colsel);
cs.hideColumns(2, 4);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[2, 4]", Arrays.toString(hidden.get(0)));
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals("[2, 4]", Arrays.toString(regions.next()));
// extend contiguous with 2 positions overlap
cs.hideColumns(3, 5);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[2, 5]", Arrays.toString(hidden.get(0)));
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals("[2, 5]", Arrays.toString(regions.next()));
// extend contiguous with 1 position overlap
cs.hideColumns(5, 6);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[2, 6]", Arrays.toString(hidden.get(0)));
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals("[2, 6]", Arrays.toString(regions.next()));
// extend contiguous with overlap both ends:
cs.hideColumns(1, 7);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[1, 7]", Arrays.toString(hidden.get(0)));
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals("[1, 7]", Arrays.toString(regions.next()));
}
/**
HiddenColumns cs = new HiddenColumns();
cs.hideColumns(49, 59);
cs.hideColumns(69, 79);
- List<int[]> hidden = cs.getHiddenColumnsCopy();
- assertEquals(2, hidden.size());
- assertEquals("[49, 59]", Arrays.toString(hidden.get(0)));
- assertEquals("[69, 79]", Arrays.toString(hidden.get(1)));
+ Iterator<int[]> regions = cs.iterator();
+ assertEquals(2, cs.getNumberOfRegions());
+ assertEquals("[49, 59]", Arrays.toString(regions.next()));
+ assertEquals("[69, 79]", Arrays.toString(regions.next()));
cs.hideColumns(48, 80);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[48, 80]", Arrays.toString(hidden.get(0)));
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals("[48, 80]", Arrays.toString(regions.next()));
/*
* another...joining hidden ranges
cs.hideColumns(50, 60);
// hiding 21-49 should merge to one range
cs.hideColumns(21, 49);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[10, 60]", Arrays.toString(hidden.get(0)));
+ regions = cs.iterator();
+ assertEquals(1, cs.getNumberOfRegions());
+ assertEquals("[10, 60]", Arrays.toString(regions.next()));
/*
* another...left overlap, subsumption, right overlap,
cs.hideColumns(60, 70);
cs.hideColumns(15, 45);
- hidden = cs.getHiddenColumnsCopy();
- assertEquals(2, hidden.size());
- assertEquals("[10, 50]", Arrays.toString(hidden.get(0)));
- assertEquals("[60, 70]", Arrays.toString(hidden.get(1)));
+ regions = cs.iterator();
+ assertEquals(2, cs.getNumberOfRegions());
+ assertEquals("[10, 50]", Arrays.toString(regions.next()));
+ assertEquals("[60, 70]", Arrays.toString(regions.next()));
}
@Test(groups = { "Functional" })
one.set(1);
cs = new HiddenColumns();
cs.hideMarkedBits(one);
- assertEquals(1, cs.getHiddenColumnsCopy().size());
+ assertEquals(1, cs.getNumberOfRegions());
one.set(2);
cs = new HiddenColumns();
cs.hideMarkedBits(one);
- assertEquals(1, cs.getHiddenColumnsCopy().size());
+ assertEquals(1, cs.getNumberOfRegions());
one.set(3);
cs = new HiddenColumns();
cs.hideMarkedBits(one);
- assertEquals(1, cs.getHiddenColumnsCopy().size());
+ assertEquals(1, cs.getNumberOfRegions());
// split
one.clear(2);
cs = new HiddenColumns();
cs.hideMarkedBits(one);
- assertEquals(2, cs.getHiddenColumnsCopy().size());
+ assertEquals(2, cs.getNumberOfRegions());
assertEquals(0, cs.adjustForHiddenColumns(0));
assertEquals(2, cs.adjustForHiddenColumns(1));
cs = new HiddenColumns();
cs.hideMarkedBits(one);
- assertEquals(1, cs.getHiddenColumnsCopy().size());
+ assertEquals(1, cs.getNumberOfRegions());
assertEquals(0, cs.adjustForHiddenColumns(0));
assertEquals(1, cs.adjustForHiddenColumns(1));
}
@Test(groups = "Functional")
- public void testGetHiddenColumnsCopy()
+ public void testIterator()
{
HiddenColumns h = new HiddenColumns();
- ArrayList<int[]> result = h.getHiddenColumnsCopy();
- assertTrue(result.isEmpty());
+ Iterator<int[]> result = h.iterator();
+ assertFalse(result.hasNext());
h.hideColumns(5, 10);
- result = h.getHiddenColumnsCopy();
- assertEquals(1, result.size());
- assertEquals(5, result.get(0)[0]);
- assertEquals(10, result.get(0)[1]);
+ result = h.iterator();
+ int[] next = result.next();
+ assertEquals(5, next[0]);
+ assertEquals(10, next[1]);
+ assertFalse(result.hasNext());
h.hideColumns(22, 23);
- result = h.getHiddenColumnsCopy();
- assertEquals(2, result.size());
- assertEquals(5, result.get(0)[0]);
- assertEquals(10, result.get(0)[1]);
- assertEquals(22, result.get(1)[0]);
- assertEquals(23, result.get(1)[1]);
+ result = h.iterator();
+ next = result.next();
+ assertEquals(5, next[0]);
+ assertEquals(10, next[1]);
+ next = result.next();
+ assertEquals(22, next[0]);
+ assertEquals(23, next[1]);
+ assertFalse(result.hasNext());
// test for only one hidden region at start of alignment
ColumnSelection sel = new ColumnSelection();
h.revealAllHiddenColumns(sel);
h.hideColumns(0, 1);
- result = h.getHiddenColumnsCopy();
- assertEquals(1, result.size());
- assertEquals(0, result.get(0)[0]);
- assertEquals(1, result.get(0)[1]);
+ result = h.iterator();
+ next = result.next();
+ assertEquals(0, next[0]);
+ assertEquals(1, next[1]);
+ assertFalse(result.hasNext());
}
@Test(groups = "Functional")
import jalview.util.MessageManager;
import java.awt.Color;
-import java.util.List;
+import java.util.Iterator;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
*/
assertFalse(alignFrame.hideFeatureColumns("exon", true));
assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
- assertTrue(alignFrame.getViewport().getAlignment().getHiddenColumns()
- .getHiddenColumnsCopy()
- .isEmpty());
+ assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
+ .getNumberOfRegions(), 0);
assertFalse(alignFrame.hideFeatureColumns("exon", false));
assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
- assertTrue(alignFrame.getViewport().getAlignment().getHiddenColumns()
- .getHiddenColumnsCopy()
- .isEmpty());
+ assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
+ .getNumberOfRegions(), 0);
/*
* hiding a feature in all columns does nothing
*/
assertFalse(alignFrame.hideFeatureColumns("Metal", true));
assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
- List<int[]> hidden = alignFrame.getViewport().getAlignment()
- .getHiddenColumns()
- .getHiddenColumnsCopy();
- assertTrue(hidden.isEmpty());
+ assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
+ .getNumberOfRegions(), 0);
/*
* hide a feature present in some columns
* [1-3], [6-8] base zero
*/
assertTrue(alignFrame.hideFeatureColumns("Turn", true));
- hidden = alignFrame.getViewport().getAlignment().getHiddenColumns()
- .getHiddenColumnsCopy();
- assertEquals(hidden.size(), 2);
- assertEquals(hidden.get(0)[0], 1);
- assertEquals(hidden.get(0)[1], 3);
- assertEquals(hidden.get(1)[0], 6);
- assertEquals(hidden.get(1)[1], 8);
+ Iterator<int[]> regions = alignFrame.getViewport().getAlignment()
+ .getHiddenColumns().iterator();
+ assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
+ .getNumberOfRegions(), 2);
+ int[] next = regions.next();
+ assertEquals(next[0], 1);
+ assertEquals(next[1], 3);
+ next = regions.next();
+ assertEquals(next[0], 6);
+ assertEquals(next[1], 8);
}
@BeforeClass(alwaysRun = true)
import jalview.io.FormatAdapter;
import java.io.IOException;
-import java.util.List;
+import java.util.Iterator;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
HiddenColumns currentHidden = af.getViewport().getAlignment()
.getHiddenColumns();
- List<int[]> regions = currentHidden.getHiddenColumnsCopy();
- assertEquals(regions.get(0)[0], 0);
- assertEquals(regions.get(0)[1], 3);
- assertEquals(regions.get(1)[0], 22);
- assertEquals(regions.get(1)[1], 25);
+ Iterator<int[]> regions = currentHidden.iterator();
+ int[] next = regions.next();
+ assertEquals(0, next[0]);
+ assertEquals(3, next[1]);
+ next = regions.next();
+ assertEquals(22, next[0]);
+ assertEquals(25, next[1]);
// now reset hidden columns
acc.reset();
currentHidden = af.getViewport().getAlignment().getHiddenColumns();
- regions = currentHidden.getHiddenColumnsCopy();
- assertEquals(regions.get(0)[0], 10);
- assertEquals(regions.get(0)[1], 20);
+ regions = currentHidden.iterator();
+ next = regions.next();
+ assertEquals(10, next[0]);
+ assertEquals(20, next[1]);
// check works with empty hidden columns as old columns
oldhidden = new HiddenColumns();
acc.reset();
currentHidden = af.getViewport().getAlignment().getHiddenColumns();
- regions = currentHidden.getHiddenColumnsCopy();
- assertEquals(regions.get(0)[0], 10);
- assertEquals(regions.get(0)[1], 20);
+ regions = currentHidden.iterator();
+ next = regions.next();
+ assertEquals(10, next[0]);
+ assertEquals(20, next[1]);
}
}
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
TEST_SEQ_HEIGHT = expectedSeqs.size();
TEST_GRP_HEIGHT = expectedGrps.size();
TEST_ANOT_HEIGHT = expectedAnnots.size();
- TEST_CS_HEIGHT = expectedColSel.getHiddenColumnsCopy().size();
+ TEST_CS_HEIGHT = expectedColSel.getNumberOfRegions();
exportSettings = new AlignExportSettingI()
{
{
HiddenColumns cs = testJsonFile.getHiddenColumns();
Assert.assertNotNull(cs);
- Assert.assertNotNull(cs.getHiddenColumnsCopy());
- List<int[]> hiddenCols = cs.getHiddenColumnsCopy();
- Assert.assertEquals(hiddenCols.size(), TEST_CS_HEIGHT);
- Assert.assertEquals(hiddenCols.get(0), expectedColSel
- .getHiddenColumnsCopy().get(0),
+
+ Iterator<int[]> it = cs.iterator();
+ Iterator<int[]> colselit = expectedColSel.iterator();
+ Assert.assertTrue(it.hasNext());
+ Assert.assertEquals(cs.getNumberOfRegions(), TEST_CS_HEIGHT);
+ Assert.assertEquals(it.next(), colselit.next(),
"Mismatched hidden columns!");
}
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Iterator;
import java.util.List;
import org.testng.annotations.BeforeClass;
MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
proteinView, dnaView, dnaSelection, dnaHidden);
assertEquals("[]", dnaSelection.getSelected().toString());
- List<int[]> hidden = dnaHidden.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[0, 4]", Arrays.toString(hidden.get(0)));
+ Iterator<int[]> regions = dnaHidden.iterator();
+ assertEquals(1, dnaHidden.getNumberOfRegions());
+ assertEquals("[0, 4]", Arrays.toString(regions.next()));
/*
* Column 1 in protein picks up Seq1/K which maps to cols 0-3 in dna
proteinSelection.hideSelectedColumns(1, hiddenCols);
MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
proteinView, dnaView, dnaSelection, dnaHidden);
- hidden = dnaHidden.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[0, 3]", Arrays.toString(hidden.get(0)));
+ regions = dnaHidden.iterator();
+ assertEquals(1, dnaHidden.getNumberOfRegions());
+ assertEquals("[0, 3]", Arrays.toString(regions.next()));
/*
* Column 2 in protein picks up gaps only - no mapping
proteinSelection.hideSelectedColumns(2, hiddenCols);
MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
proteinView, dnaView, dnaSelection, dnaHidden);
- assertTrue(dnaHidden.getHiddenColumnsCopy().isEmpty());
+ assertEquals(0, dnaHidden.getNumberOfRegions());
/*
* Column 3 in protein picks up Seq1/P, Seq2/Q, Seq3/S which map to columns
MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
proteinView, dnaView, dnaSelection, dnaHidden);
assertEquals("[0, 1, 2, 3]", dnaSelection.getSelected().toString());
- hidden = dnaHidden.getHiddenColumnsCopy();
- assertEquals(1, hidden.size());
- assertEquals("[5, 10]", Arrays.toString(hidden.get(0)));
+ regions = dnaHidden.iterator();
+ assertEquals(1, dnaHidden.getNumberOfRegions());
+ assertEquals("[5, 10]", Arrays.toString(regions.next()));
/*
* Combine hiding columns 1 and 3 to get discontiguous hidden columns
proteinSelection.hideSelectedColumns(3, hiddenCols);
MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
proteinView, dnaView, dnaSelection, dnaHidden);
- hidden = dnaHidden.getHiddenColumnsCopy();
- assertEquals(2, hidden.size());
- assertEquals("[0, 3]", Arrays.toString(hidden.get(0)));
- assertEquals("[5, 10]", Arrays.toString(hidden.get(1)));
+ regions = dnaHidden.iterator();
+ assertEquals(2, dnaHidden.getNumberOfRegions());
+ assertEquals("[0, 3]", Arrays.toString(regions.next()));
+ assertEquals("[5, 10]", Arrays.toString(regions.next()));
}
@Test(groups = { "Functional" })