AlignedCodonFrame getMapping(SequenceI mapFrom, SequenceI mapTo);
/**
- * Set the hidden columns collection on the alignment
+ * Set the hidden columns collection on the alignment. Answers true if the
+ * hidden column selection changed, else false.
*
* @param cols
+ * @return
*/
- public void setHiddenColumns(HiddenColumns cols);
+ public boolean setHiddenColumns(HiddenColumns cols);
/**
* Set the first sequence as representative and hide its insertions. Typically
HiddenColumns hs = new HiddenColumns();
MappingUtils.mapColumnSelection(colsel, hidden, sourceAv, av, cs, hs);
av.setColumnSelection(cs);
- av.getAlignment().setHiddenColumns(hs);
+ boolean hiddenChanged = av.getAlignment().setHiddenColumns(hs);
// lastly, update any dependent dialogs
if (ap.getCalculationDialog() != null)
ap.getCalculationDialog().validateCalcTypes();
}
- PaintRefresher.Refresh(this, av.getSequenceSetId());
+ /*
+ * repaint alignment, and also Overview or Structure
+ * if hidden column selection has changed
+ */
+ ap.paintAlignment(hiddenChanged, hiddenChanged);
return true;
}
assertEquals(".JKLMNO", seq2.getSequenceAsString());
assertEquals(".PQR...", seq3.getSequenceAsString());
}
+
+ /**
+ * Test for setHiddenColumns, to check it returns true if the hidden columns
+ * have changed, else false
+ */
+ @Test(groups = { "Functional" })
+ public void testSetHiddenColumns()
+ {
+ AlignmentI al = new Alignment(new SequenceI[] {});
+ assertFalse(al.getHiddenColumns().hasHiddenColumns());
+
+ HiddenColumns hc = new HiddenColumns();
+ assertFalse(al.setHiddenColumns(hc)); // no change
+ assertSame(hc, al.getHiddenColumns());
+
+ hc.hideColumns(2, 4);
+ assertTrue(al.getHiddenColumns().hasHiddenColumns());
+
+ /*
+ * set a different object but with the same columns hidden
+ */
+ HiddenColumns hc2 = new HiddenColumns();
+ hc2.hideColumns(2, 4);
+ assertFalse(al.setHiddenColumns(hc2)); // no change
+ assertSame(hc2, al.getHiddenColumns());
+
+ assertTrue(al.setHiddenColumns(null));
+ assertNull(al.getHiddenColumns());
+ assertTrue(al.setHiddenColumns(hc));
+ assertSame(hc, al.getHiddenColumns());
+
+ al.getHiddenColumns().hideColumns(10, 12);
+ hc2.hideColumns(10, 12);
+ assertFalse(al.setHiddenColumns(hc2)); // no change
+
+ /*
+ * hide columns 15-16 then 17-18 in hc
+ * hide columns 15-18 in hc2
+ * these are not now 'equal' objects even though they
+ * represent the same set of columns
+ */
+ assertSame(hc2, al.getHiddenColumns());
+ hc.hideColumns(15, 16);
+ hc.hideColumns(17, 18);
+ hc2.hideColumns(15, 18);
+ assertFalse(hc.equals(hc2));
+ assertTrue(al.setHiddenColumns(hc)); // 'changed'
+ }
}