if (av.hasHiddenColumns())
{
HiddenColumns hidden = av.getAlignment().getHiddenColumns();
- for (int[] region : hidden)
+ for (int[] region : hidden.getHiddenColumnsCopyAsList())
{
int hideStart = region[0];
int hideEnd = region[1];
{
this(constructSeqCigarArray(alignment, selectionGroup));
constructFromAlignment(alignment,
- hidden != null ? hidden.getHiddenRegions()
+ hidden != null ? hidden.getHiddenColumnsCopyAsList()
: null, selectionGroup);
}
*
* @return empty list or List of hidden column intervals
*/
- public List<int[]> getHiddenRegions()
+ private List<int[]> getHiddenRegions()
{
return hiddenColumns == null ? Collections.<int[]> emptyList()
: hiddenColumns;
private ArrayList<int[]> copyHiddenRegionsToArrayList()
{
- ArrayList<int[]> copy = new ArrayList<>(hiddenColumns.size());
- for (int i = 0, j = hiddenColumns.size(); i < j; i++)
+ int size = 0;
+ if (hiddenColumns != null)
+ {
+ size = hiddenColumns.size();
+ }
+ ArrayList<int[]> copy = new ArrayList<>(size);
+
+ for (int i = 0, j = size; i < j; i++)
{
int[] rh;
int[] cp;
copy.add(cp);
}
}
+
return copy;
}
last = lastcol;
current = firstcol;
next = firstcol;
- hidden = hiddenCols.getHiddenRegions();
+ hidden = hiddenCols.getHiddenColumnsCopyAsList();
lasthiddenregion = -1;
if (hidden != null)
int blockStart = startRes;
int blockEnd = endRes;
- for (int[] region : av.getAlignment().getHiddenColumns())
+ for (int[] region : av.getAlignment().getHiddenColumns()
+ .getHiddenColumnsCopyAsList())
{
int hideStart = region[0];
int hideEnd = region[1];
AlignViewportI protein = targetIsNucleotide ? mapFrom : mapTo;
List<AlignedCodonFrame> codonFrames = protein.getAlignment()
.getCodonFrames();
- // ColumnSelection mappedColumns = new ColumnSelection();
if (colsel == null)
{
toSequences, fromGapChar);
}
- for (int[] hidden : hiddencols)
+ for (int[] hidden : hiddencols.getHiddenColumnsCopyAsList())
{
mapHiddenColumns(hidden, codonFrames, newHidden, fromSequences,
toSequences, fromGapChar);
// hide column 5 (and adjacent):
cs.hideSelectedColumns(5, al.getHiddenColumns());
// 4,5,6 now hidden:
- List<int[]> hidden = al.getHiddenColumns().getHiddenRegions();
+ List<int[]> hidden = al.getHiddenColumns().getHiddenColumnsCopyAsList();
assertEquals(1, hidden.size());
assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
// none now selected:
cs.addElement(5);
cs.addElement(6);
cs.hideSelectedColumns(4, al.getHiddenColumns());
- hidden = al.getHiddenColumns().getHiddenRegions();
+ hidden = al.getHiddenColumns().getHiddenColumnsCopyAsList();
assertEquals(1, hidden.size());
assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
assertTrue(cs.getSelected().isEmpty());
cs.addElement(5);
cs.addElement(6);
cs.hideSelectedColumns(6, al.getHiddenColumns());
- hidden = al.getHiddenColumns().getHiddenRegions();
+ hidden = al.getHiddenColumns().getHiddenColumnsCopyAsList();
assertEquals(1, hidden.size());
assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
assertTrue(cs.getSelected().isEmpty());
cs.addElement(4);
cs.addElement(6);
cs.hideSelectedColumns(5, al.getHiddenColumns());
- hidden = al.getHiddenColumns().getHiddenRegions();
+ hidden = al.getHiddenColumns().getHiddenColumnsCopyAsList();
assertEquals(1, hidden.size());
assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
assertTrue(cs.getSelected().isEmpty());
cs.hideSelectedColumns(al);
assertTrue(cs.getSelected().isEmpty());
- List<int[]> hidden = cols.getHiddenRegions();
+ List<int[]> hidden = cols.getHiddenColumnsCopyAsList();
assertEquals(4, hidden.size());
assertEquals("[2, 4]", Arrays.toString(hidden.get(0)));
assertEquals("[7, 9]", Arrays.toString(hidden.get(1)));
import static org.testng.Assert.assertNull;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
import jalview.analysis.AlignmentGenerator;
HiddenColumns cs = new HiddenColumns();
cs.hideColumns(10, 11);
cs.hideColumns(5, 7);
- assertEquals("[5, 7]", Arrays.toString(cs.getHiddenRegions().get(0)));
+ assertEquals("[5, 7]",
+ Arrays.toString(cs.getHiddenColumnsCopyAsList().get(0)));
HiddenColumns cs2 = new HiddenColumns(cs);
assertTrue(cs2.hasHiddenColumns());
- assertEquals(2, cs2.getHiddenRegions().size());
+ assertEquals(2, cs2.getHiddenColumnsCopyAsList().size());
// hidden columns are held in column order
- assertEquals("[5, 7]", Arrays.toString(cs2.getHiddenRegions().get(0)));
- assertEquals("[10, 11]", Arrays.toString(cs2.getHiddenRegions().get(1)));
+ assertEquals("[5, 7]",
+ Arrays.toString(cs2.getHiddenColumnsCopyAsList().get(0)));
+ assertEquals("[10, 11]",
+ Arrays.toString(cs2.getHiddenColumnsCopyAsList().get(1)));
}
/**
ColumnSelection colsel = new ColumnSelection();
HiddenColumns cs = al.getHiddenColumns();
colsel.hideSelectedColumns(5, al.getHiddenColumns());
- List<int[]> hidden = cs.getHiddenRegions();
+ List<int[]> hidden = cs.getHiddenColumnsCopyAsList();
assertEquals(1, hidden.size());
assertEquals("[5, 5]", Arrays.toString(hidden.get(0)));
colsel.hideSelectedColumns(3, al.getHiddenColumns());
+ hidden = cs.getHiddenColumnsCopyAsList();
assertEquals(2, hidden.size());
// two hidden ranges, in order:
- assertSame(hidden, cs.getHiddenRegions());
+ assertEquals(hidden.size(), cs.getHiddenColumnsCopyAsList().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.getHiddenRegions();
+ hidden = cs.getHiddenColumnsCopyAsList();
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.getHiddenRegions().isEmpty());
+ assertTrue(cs.getHiddenColumnsCopyAsList().isEmpty());
cs.hideColumns(3, 6);
- hidden = cs.getHiddenRegions();
+ hidden = cs.getHiddenColumnsCopyAsList();
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();
assertEquals(1, hidden.size());
- assertSame(firstHiddenRange, cs.getHiddenRegions().get(0));
+ assertEquals("[3, 6]",
+ Arrays.toString(cs.getHiddenColumnsCopyAsList().get(0)));
cs.hideColumns(3, 5);
+ hidden = cs.getHiddenColumnsCopyAsList();
assertEquals(1, hidden.size());
- assertSame(firstHiddenRange, cs.getHiddenRegions().get(0));
+ assertEquals("[3, 6]",
+ Arrays.toString(cs.getHiddenColumnsCopyAsList().get(0)));
cs.hideColumns(4, 6);
+ hidden = cs.getHiddenColumnsCopyAsList();
assertEquals(1, hidden.size());
- assertSame(firstHiddenRange, cs.getHiddenRegions().get(0));
+ assertEquals("[3, 6]",
+ Arrays.toString(cs.getHiddenColumnsCopyAsList().get(0)));
cs.hideColumns(3, 6);
+ hidden = cs.getHiddenColumnsCopyAsList();
assertEquals(1, hidden.size());
- assertSame(firstHiddenRange, cs.getHiddenRegions().get(0));
+ assertEquals("[3, 6]",
+ Arrays.toString(cs.getHiddenColumnsCopyAsList().get(0)));
cs.revealAllHiddenColumns(colsel);
cs.hideColumns(2, 4);
- hidden = cs.getHiddenRegions();
+ hidden = cs.getHiddenColumnsCopyAsList();
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();
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();
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();
assertEquals(1, hidden.size());
assertEquals("[1, 7]", Arrays.toString(hidden.get(0)));
}
colsel.addElement(10);
cs.revealHiddenColumns(5, colsel);
// hidden columns list now null but getter returns empty list:
- assertTrue(cs.getHiddenRegions().isEmpty());
+ assertTrue(cs.getHiddenColumnsCopyAsList().isEmpty());
// revealed columns are marked as selected (added to selection):
assertEquals("[10, 5, 6, 7, 8]", colsel.getSelected().toString());
colsel = new ColumnSelection();
cs = new HiddenColumns();
cs.hideColumns(5, 8);
- List<int[]> hidden = cs.getHiddenRegions();
+ List<int[]> hidden = cs.getHiddenColumnsCopyAsList();
cs.revealHiddenColumns(6, colsel);
- assertSame(hidden, cs.getHiddenRegions());
+ assertEquals(hidden.size(), cs.getHiddenColumnsCopyAsList().size());
assertTrue(colsel.getSelected().isEmpty());
}
* revealing hidden columns adds them (in order) to the (unordered)
* selection list
*/
- assertTrue(cs.getHiddenRegions().isEmpty());
+ assertTrue(cs.getHiddenColumnsCopyAsList().isEmpty());
assertEquals("[11, 1, 2, 3, 5, 6, 7, 8]", colsel.getSelected()
.toString());
}
HiddenColumns cs = new HiddenColumns();
cs.hideColumns(49, 59);
cs.hideColumns(69, 79);
- List<int[]> hidden = cs.getHiddenRegions();
+ List<int[]> hidden = cs.getHiddenColumnsCopyAsList();
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.getHiddenRegions();
+ hidden = cs.getHiddenColumnsCopyAsList();
assertEquals(1, hidden.size());
assertEquals("[48, 80]", Arrays.toString(hidden.get(0)));
cs.hideColumns(50, 60);
// hiding 21-49 should merge to one range
cs.hideColumns(21, 49);
- hidden = cs.getHiddenRegions();
+ hidden = cs.getHiddenColumnsCopyAsList();
assertEquals(1, hidden.size());
assertEquals("[10, 60]", Arrays.toString(hidden.get(0)));
cs.hideColumns(60, 70);
cs.hideColumns(15, 45);
- hidden = cs.getHiddenRegions();
+ hidden = cs.getHiddenColumnsCopyAsList();
assertEquals(2, hidden.size());
assertEquals("[10, 50]", Arrays.toString(hidden.get(0)));
assertEquals("[60, 70]", Arrays.toString(hidden.get(1)));
one.set(1);
cs = new HiddenColumns();
cs.hideMarkedBits(one);
- assertEquals(1, cs.getHiddenRegions().size());
+ assertEquals(1, cs.getHiddenColumnsCopyAsList().size());
one.set(2);
cs = new HiddenColumns();
cs.hideMarkedBits(one);
- assertEquals(1, cs.getHiddenRegions().size());
+ assertEquals(1, cs.getHiddenColumnsCopyAsList().size());
one.set(3);
cs = new HiddenColumns();
cs.hideMarkedBits(one);
- assertEquals(1, cs.getHiddenRegions().size());
+ assertEquals(1, cs.getHiddenColumnsCopyAsList().size());
// split
one.clear(2);
cs = new HiddenColumns();
cs.hideMarkedBits(one);
- assertEquals(2, cs.getHiddenRegions().size());
+ assertEquals(2, cs.getHiddenColumnsCopyAsList().size());
assertEquals(0, cs.adjustForHiddenColumns(0));
assertEquals(2, cs.adjustForHiddenColumns(1));
cs = new HiddenColumns();
cs.hideMarkedBits(one);
- assertEquals(1, cs.getHiddenRegions().size());
+ assertEquals(1, cs.getHiddenColumnsCopyAsList().size());
assertEquals(0, cs.adjustForHiddenColumns(0));
assertEquals(1, cs.adjustForHiddenColumns(1));
assertFalse(alignFrame.hideFeatureColumns("exon", true));
assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
assertTrue(alignFrame.getViewport().getAlignment().getHiddenColumns()
- .getHiddenRegions()
+ .getHiddenColumnsCopyAsList()
.isEmpty());
assertFalse(alignFrame.hideFeatureColumns("exon", false));
assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
assertTrue(alignFrame.getViewport().getAlignment().getHiddenColumns()
- .getHiddenRegions()
+ .getHiddenColumnsCopyAsList()
.isEmpty());
/*
assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
List<int[]> hidden = alignFrame.getViewport().getAlignment()
.getHiddenColumns()
- .getHiddenRegions();
+ .getHiddenColumnsCopyAsList();
assertTrue(hidden.isEmpty());
/*
*/
assertTrue(alignFrame.hideFeatureColumns("Turn", true));
hidden = alignFrame.getViewport().getAlignment().getHiddenColumns()
- .getHiddenRegions();
+ .getHiddenColumnsCopyAsList();
assertEquals(hidden.size(), 2);
assertEquals(hidden.get(0)[0], 1);
assertEquals(hidden.get(0)[1], 3);
private Alignment alignment;
- private HashMap<String, SequenceI> expectedSeqs = new HashMap<String, SequenceI>();
+ private HashMap<String, SequenceI> expectedSeqs = new HashMap<>();
- private HashMap<String, AlignmentAnnotation> expectedAnnots = new HashMap<String, AlignmentAnnotation>();
+ private HashMap<String, AlignmentAnnotation> expectedAnnots = new HashMap<>();
- private HashMap<String, SequenceGroup> expectedGrps = new HashMap<String, SequenceGroup>();
+ private HashMap<String, SequenceGroup> expectedGrps = new HashMap<>();
private HiddenColumns expectedColSel = new HiddenColumns();
}
// create and add a sequence group
- List<SequenceI> grpSeqs = new ArrayList<SequenceI>();
+ List<SequenceI> grpSeqs = new ArrayList<>();
grpSeqs.add(seqs[1]);
grpSeqs.add(seqs[2]);
grpSeqs.add(seqs[3]);
TEST_SEQ_HEIGHT = expectedSeqs.size();
TEST_GRP_HEIGHT = expectedGrps.size();
TEST_ANOT_HEIGHT = expectedAnnots.size();
- TEST_CS_HEIGHT = expectedColSel.getHiddenRegions().size();
+ TEST_CS_HEIGHT = expectedColSel.getHiddenColumnsCopyAsList().size();
exportSettings = new AlignExportSettingI()
{
{
HiddenColumns cs = testJsonFile.getHiddenColumns();
Assert.assertNotNull(cs);
- Assert.assertNotNull(cs.getHiddenRegions());
- List<int[]> hiddenCols = cs.getHiddenRegions();
+ Assert.assertNotNull(cs.getHiddenColumnsCopyAsList());
+ List<int[]> hiddenCols = cs.getHiddenColumnsCopyAsList();
Assert.assertEquals(hiddenCols.size(), TEST_CS_HEIGHT);
Assert.assertEquals(hiddenCols.get(0), expectedColSel
- .getHiddenRegions().get(0),
+ .getHiddenColumnsCopyAsList().get(0),
"Mismatched hidden columns!");
}
AlignedCodonFrame acf3 = new AlignedCodonFrame();
acf3.addMap(seq3.getDatasetSequence(), seq1.getDatasetSequence(), map);
- List<AlignedCodonFrame> mappings = new ArrayList<AlignedCodonFrame>();
+ List<AlignedCodonFrame> mappings = new ArrayList<>();
mappings.add(acf1);
mappings.add(acf2);
mappings.add(acf3);
AlignedCodonFrame acf4 = new AlignedCodonFrame();
acf4.addMap(seq3.getDatasetSequence(), seq4.getDatasetSequence(), map);
- List<AlignedCodonFrame> mappings = new ArrayList<AlignedCodonFrame>();
+ List<AlignedCodonFrame> mappings = new ArrayList<>();
mappings.add(acf1);
mappings.add(acf2);
mappings.add(acf3);
AlignedCodonFrame acf = new AlignedCodonFrame();
MapList map = new MapList(new int[] { 8, 16 }, new int[] { 5, 7 }, 3, 1);
acf.addMap(dna.getDatasetSequence(), protein.getDatasetSequence(), map);
- List<AlignedCodonFrame> mappings = new ArrayList<AlignedCodonFrame>();
+ List<AlignedCodonFrame> mappings = new ArrayList<>();
mappings.add(acf);
AlignmentI prot = new Alignment(new SequenceI[] { protein });
MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
proteinView, dnaView, dnaSelection, dnaHidden);
assertEquals("[]", dnaSelection.getSelected().toString());
- List<int[]> hidden = dnaHidden.getHiddenRegions();
+ List<int[]> hidden = dnaHidden.getHiddenColumnsCopyAsList();
assertEquals(1, hidden.size());
assertEquals("[0, 4]", Arrays.toString(hidden.get(0)));
proteinSelection.hideSelectedColumns(1, hiddenCols);
MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
proteinView, dnaView, dnaSelection, dnaHidden);
- hidden = dnaHidden.getHiddenRegions();
+ hidden = dnaHidden.getHiddenColumnsCopyAsList();
assertEquals(1, hidden.size());
assertEquals("[0, 3]", Arrays.toString(hidden.get(0)));
proteinSelection.hideSelectedColumns(2, hiddenCols);
MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
proteinView, dnaView, dnaSelection, dnaHidden);
- assertTrue(dnaHidden.getHiddenRegions().isEmpty());
+ assertTrue(dnaHidden.getHiddenColumnsCopyAsList().isEmpty());
/*
* 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.getHiddenRegions();
+ hidden = dnaHidden.getHiddenColumnsCopyAsList();
assertEquals(1, hidden.size());
assertEquals("[5, 10]", Arrays.toString(hidden.get(0)));
proteinSelection.hideSelectedColumns(3, hiddenCols);
MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
proteinView, dnaView, dnaSelection, dnaHidden);
- hidden = dnaHidden.getHiddenRegions();
+ hidden = dnaHidden.getHiddenColumnsCopyAsList();
assertEquals(2, hidden.size());
assertEquals("[0, 3]", Arrays.toString(hidden.get(0)));
assertEquals("[5, 10]", Arrays.toString(hidden.get(1)));
/*
* [start, end] ranges
*/
- List<int[]> ranges = new ArrayList<int[]>();
+ List<int[]> ranges = new ArrayList<>();
assertEquals(0, MappingUtils.getLength(ranges));
ranges.add(new int[] { 1, 1 });
assertEquals(1, MappingUtils.getLength(ranges));
public void testContains()
{
assertFalse(MappingUtils.contains(null, 1));
- List<int[]> ranges = new ArrayList<int[]>();
+ List<int[]> ranges = new ArrayList<>();
assertFalse(MappingUtils.contains(ranges, 1));
ranges.add(new int[] { 1, 4 });