3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertFalse;
5 import static org.junit.Assert.assertTrue;
7 import java.awt.BorderLayout;
8 import java.awt.Checkbox;
9 import java.awt.Component;
10 import java.awt.Container;
11 import java.awt.FlowLayout;
12 import java.awt.event.ItemEvent;
13 import java.io.IOException;
14 import java.util.List;
16 import javax.swing.JButton;
17 import javax.swing.JPanel;
19 import org.junit.Before;
20 import org.junit.Test;
22 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
23 import jalview.bin.Cache;
24 import jalview.datamodel.AlignmentAnnotation;
25 import jalview.datamodel.AlignmentI;
26 import jalview.datamodel.Annotation;
27 import jalview.datamodel.SequenceGroup;
28 import jalview.datamodel.SequenceI;
29 import jalview.io.AppletFormatAdapter;
30 import jalview.util.MessageManager;
33 * Unit tests for AnnotationChooser
38 public class AnnotationChooserTest
40 // 4 sequences x 13 positions
41 final static String TEST_DATA = ">FER_CAPAA Ferredoxin\n"
43 + ">FER_CAPAN Ferredoxin, chloroplast precursor\n"
45 + ">FER1_SOLLC Ferredoxin-1, chloroplast precursor\n"
46 + "TIETHKEEELTA-\n" + ">Q93XJ9_SOLTU Ferredoxin I precursor\n"
49 AnnotationChooser testee;
51 AlignmentPanel parentPanel;
56 public void setUp() throws IOException
58 Cache.applicationProperties.setProperty(Preferences.SORT_ANNOTATIONS,
59 SequenceAnnotationOrder.NONE.name());
60 final String True = Boolean.TRUE.toString();
61 Cache.applicationProperties.setProperty(
62 Preferences.SHOW_AUTOCALC_ABOVE, True);
63 Cache.applicationProperties.setProperty("SHOW_QUALITY", True);
64 Cache.applicationProperties.setProperty("SHOW_CONSERVATION", True);
65 Cache.applicationProperties.setProperty("SHOW_IDENTITY", True);
66 AlignmentI al = new jalview.io.FormatAdapter().readFile(TEST_DATA,
67 AppletFormatAdapter.PASTE, "FASTA");
68 af = new AlignFrame(al, 700, 500);
69 parentPanel = new AlignmentPanel(af, af.getViewport());
74 * Add 4 annotations, 3 of them sequence-specific.
77 * ann1 - for sequence 0 - label 'IUPRED'
78 * ann2 - not sequence related - label 'Beauty'
79 * ann3 - for sequence 3 - label 'JMol'
80 * ann4 - for sequence 2 - label 'IUPRED'
81 * ann5 - for sequence 1 - label 'JMol'
83 private void addAnnotations()
85 Annotation an = new Annotation(2f);
86 Annotation[] anns = new Annotation[]
88 AlignmentAnnotation ann0 = new AlignmentAnnotation("IUPRED", "", anns);
89 AlignmentAnnotation ann1 = new AlignmentAnnotation("Beauty", "", anns);
90 AlignmentAnnotation ann2 = new AlignmentAnnotation("JMol", "", anns);
91 AlignmentAnnotation ann3 = new AlignmentAnnotation("IUPRED", "", anns);
92 AlignmentAnnotation ann4 = new AlignmentAnnotation("JMol", "", anns);
93 SequenceI[] seqs = parentPanel.getAlignment().getSequencesArray();
94 ann0.setSequenceRef(seqs[0]);
95 ann2.setSequenceRef(seqs[3]);
96 ann3.setSequenceRef(seqs[2]);
97 ann4.setSequenceRef(seqs[1]);
98 parentPanel.getAlignment().addAnnotation(ann0);
99 parentPanel.getAlignment().addAnnotation(ann1);
100 parentPanel.getAlignment().addAnnotation(ann2);
101 parentPanel.getAlignment().addAnnotation(ann3);
102 parentPanel.getAlignment().addAnnotation(ann4);
106 * Test creation of panel with OK and Cancel buttons
109 public void testBuildActionButtonsPanel()
111 testee = new AnnotationChooser(parentPanel);
112 JPanel jp = testee.buildActionButtonsPanel();
113 assertTrue("Wrong layout", jp.getLayout() instanceof FlowLayout);
115 Component[] comps = jp.getComponents();
116 assertEquals("Not 2 action buttons", 2, comps.length);
118 final Component jb1 = comps[0];
119 final Component jb2 = comps[1];
121 assertEquals("Not 'OK' button", MessageManager.getString("action.ok"),
122 ((JButton) jb1).getText());
123 assertEquals("Wrong button font", JvSwingUtils.getLabelFont(),
126 assertEquals("Not 'Cancel' button",
127 MessageManager.getString("action.cancel"),
128 ((JButton) jb2).getText());
129 assertEquals("Wrong button font", JvSwingUtils.getLabelFont(),
134 * Test 'Apply to' has 3 radio buttons enabled, 'Selected Sequences' selected,
135 * when there is a current selection group.
138 public void testBuildApplyToOptionsPanel_withSelectionGroup()
140 selectSequences(0, 2, 3);
141 testee = new AnnotationChooser(parentPanel);
143 JPanel jp = testee.buildApplyToOptionsPanel();
144 Component[] comps = jp.getComponents();
145 assertEquals("Not 3 radio buttons", 3, comps.length);
147 final Checkbox cb1 = (Checkbox) comps[0];
148 final Checkbox cb2 = (Checkbox) comps[1];
149 final Checkbox cb3 = (Checkbox) comps[2];
151 assertTrue("Not enabled", cb1.isEnabled());
152 assertTrue("Not enabled", cb2.isEnabled());
153 assertTrue("Not enabled", cb3.isEnabled());
154 assertEquals("Option not selected", cb2, cb2.getCheckboxGroup()
155 .getSelectedCheckbox());
157 // check state variables match checkbox selection
158 assertTrue(testee.isApplyToSelectedSequences());
159 assertFalse(testee.isApplyToUnselectedSequences());
163 * Add a sequence group to the alignment with the specified sequences (base 0)
169 private void selectSequences(int... selected)
171 SequenceI[] seqs = parentPanel.getAlignment().getSequencesArray();
172 SequenceGroup sg = new SequenceGroup();
173 for (int i : selected)
175 sg.addSequence(seqs[i], false);
177 parentPanel.av.setSelectionGroup(sg);
181 * Test 'Apply to' has 1 radio button enabled, 'All Sequences' selected, when
182 * there is no current selection group.
185 public void testBuildApplyToOptionsPanel_noSelectionGroup()
187 testee = new AnnotationChooser(parentPanel);
188 JPanel jp = testee.buildApplyToOptionsPanel();
189 verifyApplyToOptionsPanel_noSelectionGroup(jp);
192 protected void verifyApplyToOptionsPanel_noSelectionGroup(JPanel jp)
194 assertTrue("Wrong layout", jp.getLayout() instanceof FlowLayout);
195 Component[] comps = jp.getComponents();
196 assertEquals("Not 3 radio buttons", 3, comps.length);
198 final Checkbox cb1 = (Checkbox) comps[0];
199 final Checkbox cb2 = (Checkbox) comps[1];
200 final Checkbox cb3 = (Checkbox) comps[2];
202 assertTrue("Not enabled", cb1.isEnabled());
203 assertFalse("Enabled", cb2.isEnabled());
204 assertFalse("Enabled", cb3.isEnabled());
205 assertEquals("Not selected", cb1, cb1.getCheckboxGroup()
206 .getSelectedCheckbox());
208 // check state variables match checkbox selection
209 assertTrue(testee.isApplyToSelectedSequences());
210 assertTrue(testee.isApplyToUnselectedSequences());
212 assertEquals("Wrong text",
213 MessageManager.getString("label.all_sequences"), cb1.getLabel());
214 assertEquals("Wrong text",
215 MessageManager.getString("label.selected_sequences"),
217 assertEquals("Wrong text",
218 MessageManager.getString("label.except_selected_sequences"),
223 * Test Show and Hide radio buttons created, with Hide initially selected.
226 public void testBuildShowHidePanel()
228 testee = new AnnotationChooser(parentPanel);
229 JPanel jp = testee.buildShowHidePanel();
230 verifyShowHidePanel(jp);
234 protected void verifyShowHidePanel(JPanel jp)
236 assertTrue("Wrong layout", jp.getLayout() instanceof FlowLayout);
237 Component[] comps = jp.getComponents();
238 assertEquals("Not 2 radio buttons", 2, comps.length);
240 final Checkbox cb1 = (Checkbox) comps[0];
241 final Checkbox cb2 = (Checkbox) comps[1];
243 assertTrue("Show not enabled", cb1.isEnabled());
244 assertTrue("Hide not enabled", cb2.isEnabled());
246 // Hide (button 2) selected; note this may change to none (null)
247 assertEquals("Not selected", cb2, cb2.getCheckboxGroup()
248 .getSelectedCheckbox());
250 assertTrue("Show is flagged", !testee.isShowSelected());
252 assertEquals("Wrong text",
253 MessageManager.getString("label.show_selected_annotations"),
255 assertEquals("Wrong text",
256 MessageManager.getString("label.hide_selected_annotations"),
261 * Test construction of panel containing two sub-panels
264 public void testBuildShowHideOptionsPanel()
266 testee = new AnnotationChooser(parentPanel);
267 JPanel jp = testee.buildShowHideOptionsPanel();
268 assertTrue("Wrong layout", jp.getLayout() instanceof BorderLayout);
269 Component[] comps = jp.getComponents();
270 assertEquals("Not 2 sub-panels", 2, comps.length);
272 verifyShowHidePanel((JPanel) comps[0]);
273 verifyApplyToOptionsPanel_noSelectionGroup((JPanel) comps[1]);
277 * Test that annotation types are (uniquely) identified.
281 public void testGetAnnotationTypes()
284 testee = new AnnotationChooser(parentPanel);
285 // selection group should make no difference to the result
286 // as all annotation types for the alignment are considered
288 List<String> types = AnnotationChooser.getAnnotationTypes(
289 parentPanel.getAlignment(), true);
290 assertEquals("Not two annotation types", 2, types.size());
291 assertTrue("IUPRED missing", types.contains("IUPRED"));
292 assertTrue("JMol missing", types.contains("JMol"));
294 types = AnnotationChooser.getAnnotationTypes(
295 parentPanel.getAlignment(), false);
296 assertEquals("Not six annotation types", 6, types.size());
297 assertTrue("IUPRED missing", types.contains("IUPRED"));
298 assertTrue("JMol missing", types.contains("JMol"));
299 assertTrue("Beauty missing", types.contains("Beauty"));
300 // These are added by viewmodel.AlignViewport.initAutoAnnotation():
301 assertTrue("Consensus missing", types.contains("Consensus"));
302 assertTrue("Quality missing", types.contains("Quality"));
303 assertTrue("Conservation missing", types.contains("Conservation"));
307 * Test result of selecting an annotation type, with 'Hide for all sequences'.
309 * We expect all annotations of that type to be set hidden. Other annotations
310 * should be left visible.
313 public void testSelectType_hideForAll()
315 selectSequences(1, 2);
316 testee = new AnnotationChooser(parentPanel);
317 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
318 setSelected(hideCheckbox, true);
320 final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee,
322 setSelected(allSequencesCheckbox, true);
324 AlignmentAnnotation[] anns = parentPanel.getAlignment()
325 .getAlignmentAnnotation();
327 assertTrue(anns[5].visible); // JMol for seq3
328 assertTrue(anns[7].visible); // JMol for seq1
330 setSelected(getTypeCheckbox("JMol"), true);
331 assertTrue(anns[0].visible); // Conservation
332 assertTrue(anns[1].visible); // Quality
333 assertTrue(anns[2].visible); // Consensus
334 assertTrue(anns[3].visible); // IUPred for seq0
335 assertTrue(anns[4].visible); // Beauty
336 assertFalse(anns[5].visible); // JMol for seq3 - not selected but hidden
337 assertTrue(anns[6].visible); // IUPRED for seq2
338 assertFalse(anns[7].visible); // JMol for seq1 - selected and hidden
342 * Test result of selecting an annotation type, with 'Hide for selected
345 * We expect the annotations of that type, linked to the sequence group, to be
346 * set hidden. Other annotations should be left visible.
349 public void testSelectType_hideForSelected()
351 selectSequences(1, 2);
352 testee = new AnnotationChooser(parentPanel);
353 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
354 setSelected(hideCheckbox, true);
357 * Don't set the 'selected sequences' radio button since this would trigger
358 * an update, including unselected sequences / annotation types
360 // setSelected(getSelectedSequencesCheckbox());
362 AlignmentAnnotation[] anns = parentPanel.getAlignment()
363 .getAlignmentAnnotation();
365 assertTrue(anns[7].visible); // JMol for seq1
367 setSelected(getTypeCheckbox("JMol"), true);
368 assertTrue(anns[0].visible); // Conservation
369 assertTrue(anns[1].visible); // Quality
370 assertTrue(anns[2].visible); // Consensus
371 assertTrue(anns[3].visible); // IUPred for seq0
372 assertTrue(anns[4].visible); // Beauty
373 assertTrue(anns[5].visible); // JMol for seq3 not in selection group
374 assertTrue(anns[6].visible); // IUPRED for seq2
375 assertFalse(anns[7].visible); // JMol for seq1 in selection group
379 * Test result of deselecting an annotation type, with 'Hide for all
382 * We expect all annotations of that type to be set visible. Other annotations
383 * should be left unchanged.
386 public void testDeselectType_hideForAll()
388 selectSequences(1, 2);
389 testee = new AnnotationChooser(parentPanel);
391 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
392 setSelected(hideCheckbox, true);
394 final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee,
396 setSelected(allSequencesCheckbox, true);
398 AlignmentAnnotation[] anns = parentPanel.getAlignment()
399 .getAlignmentAnnotation();
401 final Checkbox typeCheckbox = getTypeCheckbox("JMol");
403 // select JMol - all hidden
404 setSelected(typeCheckbox, true);
405 assertFalse(anns[5].visible); // JMol for seq3
406 assertFalse(anns[7].visible); // JMol for seq1
408 // deselect JMol - all unhidden
409 setSelected(typeCheckbox, false);
410 assertTrue(anns[0].visible); // Conservation
411 assertTrue(anns[1].visible); // Quality
412 assertTrue(anns[2].visible); // Consensus
413 assertTrue(anns[3].visible); // IUPred for seq0
414 assertTrue(anns[4].visible); // Beauty
415 assertTrue(anns[5].visible); // JMol for seq3
416 assertTrue(anns[6].visible); // IUPRED for seq2
417 assertTrue(anns[7].visible); // JMol for seq1
421 * Test result of deselecting an annotation type, with 'Hide for selected
424 * We expect the annotations of that type, linked to the sequence group, to be
425 * set visible. Other annotations should be left unchanged.
428 public void testDeselectType_hideForSelected()
430 selectSequences(1, 2);
431 testee = new AnnotationChooser(parentPanel);
432 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
433 setSelected(hideCheckbox, true);
436 * Don't set the 'selected sequences' radio button since this would trigger
437 * an update, including unselected sequences / annotation types
439 // setSelected(getSelectedSequencesCheckbox());
441 setSelected(getTypeCheckbox("JMol"), true);
442 setSelected(getTypeCheckbox("JMol"), false);
444 AlignmentAnnotation[] anns = parentPanel.getAlignment()
445 .getAlignmentAnnotation();
446 assertTrue(anns[0].visible); // Conservation
447 assertTrue(anns[1].visible); // Quality
448 assertTrue(anns[2].visible); // Consensus
449 assertTrue(anns[3].visible); // IUPred for seq0
450 assertTrue(anns[4].visible); // Beauty
451 assertTrue(anns[5].visible); // JMol for seq3 not in selection group
452 assertTrue(anns[6].visible); // IUPRED for seq2
453 assertTrue(anns[7].visible); // JMol for seq1 in selection group
457 * Test result of selecting an annotation type, with 'Show for all sequences'.
459 * We expect all annotations of that type to be set visible. Other annotations
460 * should be left unchanged
463 public void testSelectType_showForAll()
465 selectSequences(1, 2);
466 testee = new AnnotationChooser(parentPanel);
467 final Checkbox showCheckbox = (Checkbox) getComponent(testee, 1, 0, 0);
468 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
470 final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee,
473 AlignmentAnnotation[] anns = parentPanel.getAlignment()
474 .getAlignmentAnnotation();
476 // hide all JMol annotations
477 setSelected(allSequencesCheckbox, true);
478 setSelected(hideCheckbox, true);
479 setSelected(getTypeCheckbox("JMol"), true);
480 assertFalse(anns[5].visible); // JMol for seq3
481 assertFalse(anns[7].visible); // JMol for seq1
482 // ...now show them...
483 setSelected(showCheckbox, true);
484 assertTrue(anns[0].visible); // Conservation
485 assertTrue(anns[1].visible); // Quality
486 assertTrue(anns[2].visible); // Consensus
487 assertTrue(anns[3].visible); // IUPred for seq0
488 assertTrue(anns[4].visible); // Beauty
489 assertTrue(anns[5].visible); // JMol for seq3
490 assertTrue(anns[6].visible); // IUPRED for seq2
491 assertTrue(anns[7].visible); // JMol for seq1
495 * Test result of selecting an annotation type, with 'Show for selected
498 * We expect all annotations of that type, linked to the sequence group, to be
499 * set visible. Other annotations should be left unchanged
502 public void testSelectType_showForSelected()
504 selectSequences(1, 2);
505 testee = new AnnotationChooser(parentPanel);
506 final Checkbox showCheckbox = (Checkbox) getComponent(testee, 1, 0, 0);
507 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
509 final Checkbox selectedSequencesCheckbox = (Checkbox) getComponent(
512 AlignmentAnnotation[] anns = parentPanel.getAlignment()
513 .getAlignmentAnnotation();
515 // hide all JMol annotations in the selection region (== annotation 7)
516 setSelected(selectedSequencesCheckbox, true);
517 setSelected(hideCheckbox, true);
518 setSelected(getTypeCheckbox("JMol"), true);
519 assertTrue(anns[5].visible); // JMol for seq3
520 assertFalse(anns[7].visible); // JMol for seq1
521 // ...now show them...
522 setSelected(showCheckbox, true);
524 assertTrue(anns[0].visible); // Conservation
525 assertTrue(anns[1].visible); // Quality
526 assertTrue(anns[2].visible); // Consensus
527 assertTrue(anns[3].visible); // IUPred for seq0
528 assertTrue(anns[4].visible); // Beauty
529 assertTrue(anns[5].visible); // JMol for seq3
530 assertTrue(anns[6].visible); // IUPRED for seq2
531 assertTrue(anns[7].visible); // JMol for seq1
535 * Test result of deselecting an annotation type, with 'Show for all
538 * We expect all annotations of that type to be set hidden. Other annotations
539 * should be left unchanged.
542 public void testDeselectType_showForAll()
544 selectSequences(1, 2);
545 testee = new AnnotationChooser(parentPanel);
547 final Checkbox showCheckbox = (Checkbox) getComponent(testee, 1, 0, 0);
548 setSelected(showCheckbox, true);
550 final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee,
552 setSelected(allSequencesCheckbox, true);
554 AlignmentAnnotation[] anns = parentPanel.getAlignment()
555 .getAlignmentAnnotation();
557 final Checkbox typeCheckbox = getTypeCheckbox("JMol");
558 // select JMol - all shown
559 setSelected(typeCheckbox, true);
560 assertTrue(anns[5].visible); // JMol for seq3
561 assertTrue(anns[7].visible); // JMol for seq1
563 // deselect JMol - all hidden
564 setSelected(typeCheckbox, false);
565 assertTrue(anns[0].visible); // Conservation
566 assertTrue(anns[1].visible); // Quality
567 assertTrue(anns[2].visible); // Consensus
568 assertTrue(anns[3].visible); // IUPred for seq0
569 assertTrue(anns[4].visible); // Beauty
570 assertFalse(anns[5].visible); // JMol for seq3
571 assertTrue(anns[6].visible); // IUPRED for seq2
572 assertFalse(anns[7].visible); // JMol for seq1
576 * Test result of deselecting an annotation type, with 'Show for selected
579 * We expect the annotations of that type, linked to the sequence group, to be
580 * set hidden. Other annotations should be left unchanged.
583 public void testDeselectType_showForSelected()
585 selectSequences(1, 2);
586 testee = new AnnotationChooser(parentPanel);
587 final Checkbox showCheckbox = (Checkbox) getComponent(testee, 1, 0, 0);
588 setSelected(showCheckbox, true);
591 * Don't set the 'selected sequences' radio button since this would trigger
592 * an update, including unselected sequences / annotation types
594 // setSelected(getSelectedSequencesCheckbox());
596 AlignmentAnnotation[] anns = parentPanel.getAlignment()
597 .getAlignmentAnnotation();
599 // select JMol - should remain visible
600 setSelected(getTypeCheckbox("JMol"), true);
601 assertTrue(anns[5].visible); // JMol for seq3
602 assertTrue(anns[7].visible); // JMol for seq1
604 // deselect JMol - should be hidden for selected sequences only
605 setSelected(getTypeCheckbox("JMol"), false);
606 assertTrue(anns[0].visible); // Conservation
607 assertTrue(anns[1].visible); // Quality
608 assertTrue(anns[2].visible); // Consensus
609 assertTrue(anns[3].visible); // IUPred for seq0
610 assertTrue(anns[4].visible); // Beauty
611 assertTrue(anns[5].visible); // JMol for seq3 not in selection group
612 assertTrue(anns[6].visible); // IUPRED for seq2
613 assertFalse(anns[7].visible); // JMol for seq1 in selection group
617 * Helper method to drill down to a sub-component in a Container hierarchy.
625 public static Component getComponent(Container cont, int... positions)
627 Component comp = cont;
628 for (int i : positions)
630 comp = ((Container) comp).getComponent(i);
636 * Helper method to set or unset a checkbox and fire its action listener.
641 protected void setSelected(Checkbox cb, boolean select)
643 // TODO refactor to a test utility class
645 // have to manually fire the action listener
646 cb.getItemListeners()[0].itemStateChanged(new ItemEvent(cb,
647 ItemEvent.ITEM_STATE_CHANGED, cb, select ? ItemEvent.SELECTED
648 : ItemEvent.DESELECTED));
652 * Helper method to drill down to the 'Annotation type' checkbox with given
657 private Checkbox getTypeCheckbox(String forLabel)
659 Component[] cbs = ((JPanel) testee.getComponent(0)).getComponents();
660 for (Component comp : cbs)
662 final Checkbox cb = (Checkbox) comp;
663 if (cb.getLabel().equals(forLabel))
672 * Test isInActionScope for the case where the scope is selected sequences.
673 * Test cases include sequences in the selection group, and others not in the
677 public void testIsInActionScope_selectedScope()
679 // sequences 1 and 2 have annotations 4 and 3 respectively
680 selectSequences(1, 2);
681 testee = new AnnotationChooser(parentPanel);
683 final Checkbox selectedSequencesCheckbox = (Checkbox) getComponent(
685 setSelected(selectedSequencesCheckbox, true);
687 AlignmentAnnotation[] anns = parentPanel.getAlignment()
688 .getAlignmentAnnotation();
689 // remember 3 annotations to skip (Conservation/Quality/Consensus)
690 assertFalse(testee.isInActionScope(anns[3]));
691 assertFalse(testee.isInActionScope(anns[4]));
692 assertFalse(testee.isInActionScope(anns[5]));
693 assertTrue(testee.isInActionScope(anns[6]));
694 assertTrue(testee.isInActionScope(anns[7]));
698 * Test isInActionScope for the case where the scope is unselected sequences.
699 * Test cases include sequences in the selection group, and others not in the
703 public void testIsInActionScope_unselectedScope()
705 // sequences 1 and 2 have annotations 4 and 3 respectively
706 selectSequences(1, 2);
707 testee = new AnnotationChooser(parentPanel);
709 final Checkbox unselectedSequencesCheckbox = (Checkbox) getComponent(
711 setSelected(unselectedSequencesCheckbox, true);
713 AlignmentAnnotation[] anns = parentPanel.getAlignment()
714 .getAlignmentAnnotation();
715 // remember 3 annotations to skip (Conservation/Quality/Consensus)
716 assertTrue(testee.isInActionScope(anns[3]));
717 assertTrue(testee.isInActionScope(anns[4]));
718 assertTrue(testee.isInActionScope(anns[5]));
719 assertFalse(testee.isInActionScope(anns[6]));
720 assertFalse(testee.isInActionScope(anns[7]));
724 * Test that the reset method restores previous visibility flags.
727 public void testResetOriginalState()
729 testee = new AnnotationChooser(parentPanel);
731 AlignmentAnnotation[] anns = parentPanel.getAlignment()
732 .getAlignmentAnnotation();
734 for (int i = 0; i < anns.length; i++)
736 assertTrue(i + "'th sequence not visible", anns[i].visible);
739 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
740 setSelected(hideCheckbox, true);
742 final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee,
744 setSelected(allSequencesCheckbox, true);
746 setSelected(getTypeCheckbox("JMol"), true);
747 setSelected(getTypeCheckbox("IUPRED"), true);
749 assertTrue(anns[0].visible); // Conservation
750 assertTrue(anns[1].visible); // Quality
751 assertTrue(anns[2].visible); // Consensus
752 assertFalse(anns[3].visible); // IUPRED
753 assertTrue(anns[4].visible); // Beauty (not seq-related)
754 assertFalse(anns[5].visible); // JMol
755 assertFalse(anns[6].visible); // IUPRED
756 assertFalse(anns[7].visible); // JMol
758 // reset - should all be visible
759 testee.resetOriginalState();
760 for (int i = 0; i < anns.length; i++)
762 assertTrue(i + "'th sequence not visible", anns[i].visible);