package jalview.gui;
+import jalview.api.ViewStyleI;
+import jalview.datamodel.AlignmentI;
import jalview.jbgui.GAlignFrame;
import jalview.jbgui.GSplitFrame;
import jalview.structure.StructureSelectionManager;
+import jalview.viewmodel.AlignmentViewport;
import java.awt.Component;
import java.awt.Toolkit;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
+/**
+ * An internal frame on the desktop that hosts a horizontally split view of
+ * linked DNA and Protein alignments. Additional views can be created in linked
+ * pairs, expanded to separate split frames, or regathered into a single frame.
+ * <p>
+ * (Some) operations on each alignment are automatically mirrored on the other.
+ * These include mouseover (highlighting), sequence and column selection,
+ * sequence ordering and sorting, and grouping, colouring and sorting by tree.
+ *
+ * @author gmcarstairs
+ *
+ */
public class SplitFrame extends GSplitFrame
{
private static final long serialVersionUID = 1L;
{
setSize(AlignFrame.DEFAULT_WIDTH, Desktop.instance.getHeight() - 20);
+ adjustLayout();
+
addCloseFrameListener();
addKeyListener();
}
/**
+ * Do any tweaking and twerking of the layout wanted.
+ */
+ private void adjustLayout()
+ {
+ /*
+ * Ensure sequence ids are the same width for good alignment.
+ */
+ int w1 = ((AlignFrame) getTopFrame()).getViewport().getIdWidth();
+ int w2 = ((AlignFrame) getBottomFrame()).getViewport().getIdWidth();
+ int w3 = Math.max(w1, w2);
+ ((AlignFrame) getTopFrame()).getViewport().setIdWidth(w3);
+ ((AlignFrame) getBottomFrame()).getViewport().setIdWidth(w3);
+
+ /*
+ * Set the character width for protein to 3 times that for dna.
+ */
+ final AlignViewport topViewport = ((AlignFrame) getTopFrame()).viewport;
+ final AlignViewport bottomViewport = ((AlignFrame) getBottomFrame()).viewport;
+ final AlignmentI topAlignment = topViewport.getAlignment();
+ final AlignmentI bottomAlignment = bottomViewport.getAlignment();
+ AlignmentViewport cdna = topAlignment.isNucleotide() ? topViewport
+ : (bottomAlignment.isNucleotide() ? bottomViewport : null);
+ AlignmentViewport protein = !topAlignment.isNucleotide() ? topViewport
+ : (!bottomAlignment.isNucleotide() ? bottomViewport : null);
+ if (protein != null && cdna != null)
+ {
+ ViewStyleI vs = cdna.getViewStyle();
+ vs.setCharWidth(3 * vs.getCharWidth());
+ protein.setViewStyle(vs);
+ }
+ }
+
+ /**
* Add a listener to tidy up when the frame is closed.
*/
protected void addCloseFrameListener()