2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import static jalview.util.UrlConstants.DB_ACCESSION;
24 import static jalview.util.UrlConstants.SEQUENCE_ID;
25 import static org.testng.AssertJUnit.assertEquals;
26 import static org.testng.AssertJUnit.assertFalse;
27 import static org.testng.AssertJUnit.assertTrue;
29 import jalview.bin.Cache;
30 import jalview.datamodel.AlignmentAnnotation;
31 import jalview.datamodel.AlignmentI;
32 import jalview.datamodel.Annotation;
33 import jalview.datamodel.ColumnSelection;
34 import jalview.datamodel.DBRefEntry;
35 import jalview.datamodel.DBRefSource;
36 import jalview.datamodel.HiddenColumns;
37 import jalview.datamodel.Sequence;
38 import jalview.datamodel.SequenceFeature;
39 import jalview.datamodel.SequenceGroup;
40 import jalview.datamodel.SequenceI;
41 import jalview.io.DataSourceType;
42 import jalview.io.FileFormat;
43 import jalview.io.FormatAdapter;
44 import jalview.urls.api.UrlProviderFactoryI;
45 import jalview.urls.desktop.DesktopUrlProviderFactory;
46 import jalview.util.MessageManager;
47 import jalview.util.UrlConstants;
49 import java.awt.Component;
50 import java.io.IOException;
51 import java.util.ArrayList;
52 import java.util.Collections;
53 import java.util.Iterator;
54 import java.util.List;
56 import javax.swing.JMenu;
57 import javax.swing.JMenuItem;
58 import javax.swing.JPopupMenu;
59 import javax.swing.JSeparator;
61 import org.testng.annotations.BeforeClass;
62 import org.testng.annotations.BeforeMethod;
63 import org.testng.annotations.Test;
65 public class PopupMenuTest
68 @BeforeClass(alwaysRun = true)
69 public void setUpJvOptionPane()
71 JvOptionPane.setInteractiveMode(false);
72 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
75 // 4 sequences x 13 positions
76 final static String TEST_DATA = ">FER_CAPAA Ferredoxin\n"
78 + ">FER_CAPAN Ferredoxin, chloroplast precursor\n"
80 + ">FER1_SOLLC Ferredoxin-1, chloroplast precursor\n"
81 + "TIETHKEEELTA-\n" + ">Q93XJ9_SOLTU Ferredoxin I precursor\n"
86 AlignmentPanel parentPanel;
88 PopupMenu testee = null;
90 @BeforeMethod(alwaysRun = true)
91 public void setUp() throws IOException
93 Cache.loadProperties("test/jalview/io/testProps.jvprops");
94 String inMenuString = ("EMBL-EBI Search | http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$"
98 + "UNIPROT | http://www.uniprot.org/uniprot/$" + DB_ACCESSION + "$")
100 + ("INTERPRO | http://www.ebi.ac.uk/interpro/entry/$"
101 + DB_ACCESSION + "$")
104 // Gene3D entry tests for case (in)sensitivity
105 ("Gene3D | http://gene3d.biochem.ucl.ac.uk/Gene3D/search?sterm=$"
106 + DB_ACCESSION + "$&mode=protein");
108 UrlProviderFactoryI factory = new DesktopUrlProviderFactory(
109 UrlConstants.DEFAULT_LABEL, inMenuString, "");
110 Preferences.sequenceUrlLinks = factory.createUrlProvider();
112 alignment = new FormatAdapter().readFile(TEST_DATA,
113 DataSourceType.PASTE, FileFormat.Fasta);
114 AlignFrame af = new AlignFrame(alignment, 700, 500);
115 parentPanel = new AlignmentPanel(af, af.getViewport());
116 testee = new PopupMenu(parentPanel, null, null);
118 for (SequenceI seq : alignment.getSequences())
120 final AlignmentAnnotation annotation = new AlignmentAnnotation(
121 "label" + i, "desc" + i, i);
122 annotation.setCalcId("calcId" + i);
123 seq.addAlignmentAnnotation(annotation);
124 annotation.setSequenceRef(seq);
128 @Test(groups = { "Functional" })
129 public void testConfigureReferenceAnnotationsMenu_noSequenceSelected()
131 JMenuItem menu = new JMenuItem();
132 List<SequenceI> seqs = new ArrayList<>();
133 testee.configureReferenceAnnotationsMenu(menu, seqs);
134 assertFalse(menu.isEnabled());
136 menu.setEnabled(true);
137 testee.configureReferenceAnnotationsMenu(menu, null);
138 assertFalse(menu.isEnabled());
142 * Test building the 'add reference annotations' menu for the case where there
143 * are no reference annotations to add to the alignment. The menu item should
146 @Test(groups = { "Functional" })
147 public void testConfigureReferenceAnnotationsMenu_noReferenceAnnotations()
149 JMenuItem menu = new JMenuItem();
152 * Initial state is that sequences have annotations, and have dataset
153 * sequences, but the dataset sequences have no annotations. Hence nothing
156 List<SequenceI> seqs = parentPanel.getAlignment().getSequences();
158 testee.configureReferenceAnnotationsMenu(menu, seqs);
159 assertFalse(menu.isEnabled());
163 * Test building the 'add reference annotations' menu for the case where all
164 * reference annotations are already on the alignment. The menu item should be
167 @Test(groups = { "Functional" })
168 public void testConfigureReferenceAnnotationsMenu_alreadyAdded()
170 JMenuItem menu = new JMenuItem();
171 List<SequenceI> seqs = parentPanel.getAlignment().getSequences();
173 // make up new annotations and add to dataset sequences, sequences and
175 attachReferenceAnnotations(seqs, true, true);
177 testee.configureReferenceAnnotationsMenu(menu, seqs);
178 assertFalse(menu.isEnabled());
182 * Test building the 'add reference annotations' menu for the case where
183 * several reference annotations are on the dataset but not on the sequences.
184 * The menu item should be enabled, and acquire a tooltip which lists the
185 * annotation sources (calcIds) and type (labels).
187 @Test(groups = { "Functional" })
188 public void testConfigureReferenceAnnotationsMenu()
190 JMenuItem menu = new JMenuItem();
191 List<SequenceI> seqs = parentPanel.getAlignment().getSequences();
193 // make up new annotations and add to dataset sequences
194 attachReferenceAnnotations(seqs, false, false);
196 testee.configureReferenceAnnotationsMenu(menu, seqs);
197 assertTrue(menu.isEnabled());
198 String s = MessageManager.getString("label.add_annotations_for");
199 // String expected = "<html><style> p.ttip {width: 350; text-align: justify;
200 // word-wrap: break-word;}</style><p class=\"ttip\">"
201 // + s + "<br/>Jmol/secondary structure<br/>PDB/Temp</p></html>";
202 String expected = JvSwingUtils.HTML_PREFIX + s
203 + "<br/>Jmol/secondary structure<br/>PDB/Temp</div></html>";
204 assertEquals(expected, menu.getToolTipText());
208 * Test building the 'add reference annotations' menu for the case where
209 * several reference annotations are on the dataset and the sequences but not
210 * on the alignment. The menu item should be enabled, and acquire a tooltip
211 * which lists the annotation sources (calcIds) and type (labels).
213 @Test(groups = { "Functional" })
214 public void testConfigureReferenceAnnotationsMenu_notOnAlignment()
216 JMenuItem menu = new JMenuItem();
217 List<SequenceI> seqs = parentPanel.getAlignment().getSequences();
219 // make up new annotations and add to dataset sequences and sequences
220 attachReferenceAnnotations(seqs, true, false);
222 testee.configureReferenceAnnotationsMenu(menu, seqs);
223 assertTrue(menu.isEnabled());
224 String s = MessageManager.getString("label.add_annotations_for");
225 // String expected = "<html><style> p.ttip {width: 350; text-align: justify;
226 // word-wrap: break-word;}</style><p class=\"ttip\">"
227 // + s + "<br/>Jmol/secondary structure<br/>PDB/Temp</p></html>";
228 String expected = JvSwingUtils.HTML_PREFIX
229 + "Add annotations for<br/>Jmol/secondary structure<br/>PDB/Temp</div></html>";
230 assertEquals(expected, menu.getToolTipText());
234 * Generate annotations and add to dataset sequences and (optionally)
235 * sequences and/or alignment
238 * @param addToSequence
239 * @param addToAlignment
241 private void attachReferenceAnnotations(List<SequenceI> seqs,
242 boolean addToSequence, boolean addToAlignment)
244 // PDB.secondary structure on Sequence0
245 AlignmentAnnotation annotation = new AlignmentAnnotation(
246 "secondary structure", "", 0);
247 annotation.setCalcId("PDB");
248 seqs.get(0).getDatasetSequence().addAlignmentAnnotation(annotation);
251 seqs.get(0).addAlignmentAnnotation(annotation);
255 this.alignment.addAnnotation(annotation);
258 // PDB.Temp on Sequence1
259 annotation = new AlignmentAnnotation("Temp", "", 0);
260 annotation.setCalcId("PDB");
261 seqs.get(1).getDatasetSequence().addAlignmentAnnotation(annotation);
264 seqs.get(1).addAlignmentAnnotation(annotation);
268 this.alignment.addAnnotation(annotation);
271 // JMOL.secondary structure on Sequence0
272 annotation = new AlignmentAnnotation("secondary structure", "", 0);
273 annotation.setCalcId("Jmol");
274 seqs.get(0).getDatasetSequence().addAlignmentAnnotation(annotation);
277 seqs.get(0).addAlignmentAnnotation(annotation);
281 this.alignment.addAnnotation(annotation);
286 * Test building the 'add reference annotations' menu for the case where there
287 * are two alignment views:
289 * <li>in one view, reference annotations have been added (are on the
290 * datasets, sequences and alignment)</li>
291 * <li>in the current view, reference annotations are on the dataset and
292 * sequence, but not the alignment</li>
294 * The menu item should be enabled, and acquire a tooltip which lists the
295 * annotation sources (calcIds) and type (labels).
297 @Test(groups = { "Functional" })
298 public void testConfigureReferenceAnnotationsMenu_twoViews()
303 * Test for building menu options including 'show' and 'hide' annotation
306 @Test(groups = { "Functional" })
307 public void testBuildAnnotationTypesMenus()
309 JMenu showMenu = new JMenu();
310 JMenu hideMenu = new JMenu();
311 List<SequenceI> seqs = parentPanel.getAlignment().getSequences();
313 // make up new annotations and add to sequences and to the alignment
315 // PDB.secondary structure on Sequence0
316 AlignmentAnnotation annotation = new AlignmentAnnotation(
317 "secondary structure", "", new Annotation[] {});
318 annotation.setCalcId("PDB");
319 annotation.visible = true;
320 seqs.get(0).addAlignmentAnnotation(annotation);
321 parentPanel.getAlignment().addAnnotation(annotation);
323 // JMOL.secondary structure on Sequence0 - hidden
324 annotation = new AlignmentAnnotation("secondary structure", "",
325 new Annotation[] {});
326 annotation.setCalcId("JMOL");
327 annotation.visible = false;
328 seqs.get(0).addAlignmentAnnotation(annotation);
329 parentPanel.getAlignment().addAnnotation(annotation);
331 // Jpred.SSP on Sequence0 - hidden
332 annotation = new AlignmentAnnotation("SSP", "", new Annotation[] {});
333 annotation.setCalcId("JPred");
334 annotation.visible = false;
335 seqs.get(0).addAlignmentAnnotation(annotation);
336 parentPanel.getAlignment().addAnnotation(annotation);
338 // PDB.Temp on Sequence1
339 annotation = new AlignmentAnnotation("Temp", "", new Annotation[] {});
340 annotation.setCalcId("PDB");
341 annotation.visible = true;
342 seqs.get(1).addAlignmentAnnotation(annotation);
343 parentPanel.getAlignment().addAnnotation(annotation);
346 * Expect menu options to show "secondary structure" and "SSP", and to hide
347 * "secondary structure" and "Temp". Tooltip should be calcId.
349 testee.buildAnnotationTypesMenus(showMenu, hideMenu, seqs);
351 assertTrue(showMenu.isEnabled());
352 assertTrue(hideMenu.isEnabled());
354 Component[] showOptions = showMenu.getMenuComponents();
355 Component[] hideOptions = hideMenu.getMenuComponents();
357 assertEquals(4, showOptions.length); // includes 'All' and separator
358 assertEquals(4, hideOptions.length);
359 String all = MessageManager.getString("label.all");
360 assertEquals(all, ((JMenuItem) showOptions[0]).getText());
361 assertTrue(showOptions[1] instanceof JPopupMenu.Separator);
362 assertEquals(JSeparator.HORIZONTAL,
363 ((JSeparator) showOptions[1]).getOrientation());
364 assertEquals("secondary structure",
365 ((JMenuItem) showOptions[2]).getText());
366 assertEquals("JMOL", ((JMenuItem) showOptions[2]).getToolTipText());
367 assertEquals("SSP", ((JMenuItem) showOptions[3]).getText());
368 assertEquals("JPred", ((JMenuItem) showOptions[3]).getToolTipText());
370 assertEquals(all, ((JMenuItem) hideOptions[0]).getText());
371 assertTrue(hideOptions[1] instanceof JPopupMenu.Separator);
372 assertEquals(JSeparator.HORIZONTAL,
373 ((JSeparator) hideOptions[1]).getOrientation());
374 assertEquals("secondary structure",
375 ((JMenuItem) hideOptions[2]).getText());
376 assertEquals("PDB", ((JMenuItem) hideOptions[2]).getToolTipText());
377 assertEquals("Temp", ((JMenuItem) hideOptions[3]).getText());
378 assertEquals("PDB", ((JMenuItem) hideOptions[3]).getToolTipText());
382 * Test for building menu options with only 'hide' annotation types enabled.
384 @Test(groups = { "Functional" })
385 public void testBuildAnnotationTypesMenus_showDisabled()
387 JMenu showMenu = new JMenu();
388 JMenu hideMenu = new JMenu();
389 List<SequenceI> seqs = parentPanel.getAlignment().getSequences();
391 // make up new annotations and add to sequences and to the alignment
393 // PDB.secondary structure on Sequence0
394 AlignmentAnnotation annotation = new AlignmentAnnotation(
395 "secondary structure", "", new Annotation[] {});
396 annotation.setCalcId("PDB");
397 annotation.visible = true;
398 seqs.get(0).addAlignmentAnnotation(annotation);
399 parentPanel.getAlignment().addAnnotation(annotation);
401 // PDB.Temp on Sequence1
402 annotation = new AlignmentAnnotation("Temp", "", new Annotation[] {});
403 annotation.setCalcId("PDB");
404 annotation.visible = true;
405 seqs.get(1).addAlignmentAnnotation(annotation);
406 parentPanel.getAlignment().addAnnotation(annotation);
409 * Expect menu options to hide "secondary structure" and "Temp". Tooltip
410 * should be calcId. 'Show' menu should be disabled.
412 testee.buildAnnotationTypesMenus(showMenu, hideMenu, seqs);
414 assertFalse(showMenu.isEnabled());
415 assertTrue(hideMenu.isEnabled());
417 Component[] showOptions = showMenu.getMenuComponents();
418 Component[] hideOptions = hideMenu.getMenuComponents();
420 assertEquals(2, showOptions.length); // includes 'All' and separator
421 assertEquals(4, hideOptions.length);
422 String all = MessageManager.getString("label.all");
423 assertEquals(all, ((JMenuItem) showOptions[0]).getText());
424 assertTrue(showOptions[1] instanceof JPopupMenu.Separator);
425 assertEquals(JSeparator.HORIZONTAL,
426 ((JSeparator) showOptions[1]).getOrientation());
428 assertEquals(all, ((JMenuItem) hideOptions[0]).getText());
429 assertTrue(hideOptions[1] instanceof JPopupMenu.Separator);
430 assertEquals(JSeparator.HORIZONTAL,
431 ((JSeparator) hideOptions[1]).getOrientation());
432 assertEquals("secondary structure",
433 ((JMenuItem) hideOptions[2]).getText());
434 assertEquals("PDB", ((JMenuItem) hideOptions[2]).getToolTipText());
435 assertEquals("Temp", ((JMenuItem) hideOptions[3]).getText());
436 assertEquals("PDB", ((JMenuItem) hideOptions[3]).getToolTipText());
440 * Test for building menu options with only 'show' annotation types enabled.
442 @Test(groups = { "Functional" })
443 public void testBuildAnnotationTypesMenus_hideDisabled()
445 JMenu showMenu = new JMenu();
446 JMenu hideMenu = new JMenu();
447 List<SequenceI> seqs = parentPanel.getAlignment().getSequences();
449 // make up new annotations and add to sequences and to the alignment
451 // PDB.secondary structure on Sequence0
452 AlignmentAnnotation annotation = new AlignmentAnnotation(
453 "secondary structure", "", new Annotation[] {});
454 annotation.setCalcId("PDB");
455 annotation.visible = false;
456 seqs.get(0).addAlignmentAnnotation(annotation);
457 parentPanel.getAlignment().addAnnotation(annotation);
459 // PDB.Temp on Sequence1
460 annotation = new AlignmentAnnotation("Temp", "", new Annotation[] {});
461 annotation.setCalcId("PDB2");
462 annotation.visible = false;
463 seqs.get(1).addAlignmentAnnotation(annotation);
464 parentPanel.getAlignment().addAnnotation(annotation);
467 * Expect menu options to show "secondary structure" and "Temp". Tooltip
468 * should be calcId. 'hide' menu should be disabled.
470 testee.buildAnnotationTypesMenus(showMenu, hideMenu, seqs);
472 assertTrue(showMenu.isEnabled());
473 assertFalse(hideMenu.isEnabled());
475 Component[] showOptions = showMenu.getMenuComponents();
476 Component[] hideOptions = hideMenu.getMenuComponents();
478 assertEquals(4, showOptions.length); // includes 'All' and separator
479 assertEquals(2, hideOptions.length);
480 String all = MessageManager.getString("label.all");
481 assertEquals(all, ((JMenuItem) showOptions[0]).getText());
482 assertTrue(showOptions[1] instanceof JPopupMenu.Separator);
483 assertEquals(JSeparator.HORIZONTAL,
484 ((JSeparator) showOptions[1]).getOrientation());
485 assertEquals("secondary structure",
486 ((JMenuItem) showOptions[2]).getText());
487 assertEquals("PDB", ((JMenuItem) showOptions[2]).getToolTipText());
488 assertEquals("Temp", ((JMenuItem) showOptions[3]).getText());
489 assertEquals("PDB2", ((JMenuItem) showOptions[3]).getToolTipText());
491 assertEquals(all, ((JMenuItem) hideOptions[0]).getText());
492 assertTrue(hideOptions[1] instanceof JPopupMenu.Separator);
493 assertEquals(JSeparator.HORIZONTAL,
494 ((JSeparator) hideOptions[1]).getOrientation());
498 * Test for adding sequence id, dbref and feature links
500 @Test(groups = { "Functional" })
501 public void testBuildLinkMenu()
503 List<SequenceI> seqs = parentPanel.getAlignment().getSequences();
504 final SequenceI seq0 = seqs.get(0);
505 final SequenceI seq1 = seqs.get(1);
506 final List<SequenceFeature> noFeatures = Collections
507 .<SequenceFeature> emptyList();
508 final String linkText = MessageManager.getString("action.link");
510 seq0.addDBRef(new DBRefEntry(DBRefSource.UNIPROT, "1", "P83527"));
511 seq0.addDBRef(new DBRefEntry("INTERPRO", "1", "IPR001041"));
512 seq0.addDBRef(new DBRefEntry("INTERPRO", "1", "IPR012675"));
513 seq0.addDBRef(new DBRefEntry("INTERPRO", "1", "IPR006058"));
514 seq1.addDBRef(new DBRefEntry(DBRefSource.UNIPROT, "1", "Q9ZTS2"));
515 seq1.addDBRef(new DBRefEntry("GENE3D", "1", "3.10.20.30"));
518 * check the Link Menu for the first sequence
520 JMenu linkMenu = PopupMenu.buildLinkMenu(seq0, noFeatures);
521 assertEquals(linkText, linkMenu.getText());
522 Component[] linkItems = linkMenu.getMenuComponents();
525 * menu items are ordered: SEQUENCE_ID search first, then dbrefs in order
526 * of database name (and within that by order of dbref addition)
528 assertEquals(5, linkItems.length);
529 assertEquals("EMBL-EBI Search", ((JMenuItem) linkItems[0]).getText());
530 assertEquals("INTERPRO|IPR001041",
531 ((JMenuItem) linkItems[1]).getText());
532 assertEquals("INTERPRO|IPR012675",
533 ((JMenuItem) linkItems[2]).getText());
534 assertEquals("INTERPRO|IPR006058",
535 ((JMenuItem) linkItems[3]).getText());
536 assertEquals("UNIPROT|P83527", ((JMenuItem) linkItems[4]).getText());
539 * check the Link Menu for the second sequence
540 * note dbref GENE3D is matched to link Gene3D, the latter is displayed
542 linkMenu = PopupMenu.buildLinkMenu(seq1, noFeatures);
543 assertEquals(linkText, linkMenu.getText());
544 linkItems = linkMenu.getMenuComponents();
545 assertEquals(3, linkItems.length);
546 assertEquals("EMBL-EBI Search", ((JMenuItem) linkItems[0]).getText());
547 assertEquals("Gene3D|3.10.20.30", ((JMenuItem) linkItems[1]).getText());
548 assertEquals("UNIPROT|Q9ZTS2", ((JMenuItem) linkItems[2]).getText());
551 * if there are no valid links the Links submenu is still shown, but
552 * reduced to the EMBL-EBI lookup only (inserted by
553 * CustomUrlProvider.choosePrimaryUrl())
555 String unmatched = "NOMATCH|http://www.uniprot.org/uniprot/$"
556 + DB_ACCESSION + "$";
557 UrlProviderFactoryI factory = new DesktopUrlProviderFactory(null,
559 Preferences.sequenceUrlLinks = factory.createUrlProvider();
561 linkMenu = PopupMenu.buildLinkMenu(seq1, noFeatures);
562 assertEquals(linkText, linkMenu.getText());
563 linkItems = linkMenu.getMenuComponents();
564 assertEquals(1, linkItems.length);
565 assertEquals("EMBL-EBI Search", ((JMenuItem) linkItems[0]).getText());
568 @Test(groups = { "Functional" })
569 public void testHideInsertions()
571 // get sequences from the alignment
572 List<SequenceI> seqs = parentPanel.getAlignment().getSequences();
574 // add our own seqs to avoid problems with changes to existing sequences
575 // (gap at end of sequences varies depending on how tests are run!)
576 Sequence seqGap1 = new Sequence("GappySeq",
577 "AAAA----AA-AAAAAAA---AAA-----------AAAAAAAAAA--");
578 seqGap1.createDatasetSequence();
580 Sequence seqGap2 = new Sequence("LessGappySeq",
581 "AAAAAA-AAAAA---AAA--AAAAA--AAAAAAA-AAAAAA");
582 seqGap2.createDatasetSequence();
584 Sequence seqGap3 = new Sequence("AnotherGapSeq",
585 "AAAAAA-AAAAAA--AAAAAA-AAAAAAAAAAA---AAAAAAAA");
586 seqGap3.createDatasetSequence();
588 Sequence seqGap4 = new Sequence("NoGaps",
589 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
590 seqGap4.createDatasetSequence();
593 ColumnSelection sel = new ColumnSelection();
594 parentPanel.av.getAlignment().getHiddenColumns()
595 .revealAllHiddenColumns(sel);
597 // get the Popup Menu for 7th sequence - no insertions
598 testee = new PopupMenu(parentPanel, seqs.get(7), null);
599 testee.hideInsertions_actionPerformed(null);
601 HiddenColumns hidden = parentPanel.av.getAlignment().getHiddenColumns();
602 Iterator<int[]> it = hidden.iterator();
603 assertFalse(it.hasNext());
605 // get the Popup Menu for GappySeq - this time we have insertions
606 testee = new PopupMenu(parentPanel, seqs.get(4), null);
607 testee.hideInsertions_actionPerformed(null);
608 hidden = parentPanel.av.getAlignment().getHiddenColumns();
609 it = hidden.iterator();
611 assertTrue(it.hasNext());
612 int[] region = it.next();
613 assertEquals(region[0], 4);
614 assertEquals(region[1], 7);
616 assertTrue(it.hasNext());
618 assertEquals(region[0], 10);
619 assertEquals(region[1], 10);
621 assertTrue(it.hasNext());
623 assertEquals(region[0], 18);
624 assertEquals(region[1], 20);
626 assertTrue(it.hasNext());
628 assertEquals(region[0], 24);
629 assertEquals(region[1], 34);
631 assertTrue(it.hasNext());
633 assertEquals(region[0], 45);
634 assertEquals(region[1], 46);
636 assertFalse(it.hasNext());
638 sel = new ColumnSelection();
639 hidden.revealAllHiddenColumns(sel);
641 // make a sequence group and hide insertions within the group
642 SequenceGroup sg = new SequenceGroup();
645 sg.addSequence(seqGap2, false);
646 sg.addSequence(seqGap3, false);
647 parentPanel.av.setSelectionGroup(sg);
649 // hide columns outside and within selection
650 // only hidden columns outside the collection will be retained (unless also
651 // gaps in the selection)
652 hidden.hideColumns(1, 10);
653 hidden.hideColumns(31, 40);
655 // get the Popup Menu for LessGappySeq in the sequence group
656 testee = new PopupMenu(parentPanel, seqs.get(5), null);
657 testee.hideInsertions_actionPerformed(null);
658 hidden = parentPanel.av.getAlignment().getHiddenColumns();
659 it = hidden.iterator();
661 assertTrue(it.hasNext());
663 assertEquals(region[0], 1);
664 assertEquals(region[1], 7);
666 assertTrue(it.hasNext());
668 assertEquals(region[0], 13);
669 assertEquals(region[1], 14);
671 assertTrue(it.hasNext());
673 assertEquals(region[0], 34);
674 assertEquals(region[1], 34);