+ /**
+ * Helper method to open a new SplitFrame holding linked dna and protein
+ * alignments.
+ *
+ * @param newAlignFrame
+ * containing a new alignment to be shown
+ * @param existingAlignment
+ * an existing alignment to be copied for display in the split frame
+ * @return the protein alignment in the split frame
+ */
+ protected AlignmentI openSplitFrame(AlignFrame newAlignFrame,
+ AlignmentI existingAlignment)
+ {
+ // TODO: move this to a factory/controller method ?
+ /*
+ * Open in split pane. DNA sequence above, protein below.
+ */
+ AlignFrame copyMe = new AlignFrame(existingAlignment,
+ AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
+ copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
+
+ AlignmentI al = newAlignFrame.viewport.getAlignment();
+ final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
+ : newAlignFrame;
+ final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame
+ : copyMe;
+ AlignmentI protein = proteinFrame.viewport.getAlignment();
+
+ cdnaFrame.setVisible(true);
+ proteinFrame.setVisible(true);
+ String linkedTitle = MessageManager
+ .getString("label.linked_view_title");
+ JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
+ Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
+
+ /*
+ * Set the frames to listen for each other's edit and sort commands.
+ */
+ final StructureSelectionManager ssm = StructureSelectionManager
+ .getStructureSelectionManager(Desktop.instance);
+ ssm.addCommandListener(cdnaFrame.getViewport());
+ ssm.addCommandListener(proteinFrame.getViewport());
+
+ /*
+ * 'Coding complement' (dna/protein) views will mirror each others' edits,
+ * selections, sorting etc as decided from time to time by the relevant
+ * authorities.
+ */
+ proteinFrame.getViewport().setCodingComplement(cdnaFrame.getViewport());
+ return protein;
+ }
+