package jalview.appletgui;
+import jalview.analysis.AlignmentUtils;
+import jalview.analysis.AlignmentUtils.MappingResult;
+import jalview.api.ViewStyleI;
import jalview.bin.JalviewLite;
+import jalview.datamodel.AlignmentI;
+import jalview.structure.StructureSelectionManager;
import java.awt.BorderLayout;
import java.awt.GridLayout;
addAlignFrameComponents(topFrame, topPanel);
addAlignFrameComponents(bottomFrame, bottomPanel);
+
+ /*
+ * Try to make and add dna/protein sequence mappings
+ */
+ final AlignViewport topViewport = topFrame.viewport;
+ final AlignViewport bottomViewport = bottomFrame.viewport;
+ final AlignmentI topAlignment = topViewport.getAlignment();
+ final AlignmentI bottomAlignment = bottomViewport.getAlignment();
+ // topAlignment.setDataset(null);
+ // bottomAlignment.setDataset(null);
+ AlignViewport cdna = topAlignment.isNucleotide() ? topViewport
+ : (bottomAlignment.isNucleotide() ? bottomViewport : null);
+ AlignViewport protein = !topAlignment.isNucleotide() ? topViewport
+ : (!bottomAlignment.isNucleotide() ? bottomViewport : null);
+ MappingResult mapped = AlignmentUtils.mapProteinToCdna(
+ protein.getAlignment(), cdna.getAlignment());
+ if (mapped != MappingResult.NotMapped)
+ {
+ final StructureSelectionManager ssm = StructureSelectionManager
+ .getStructureSelectionManager(topViewport.applet);
+ ssm.addMappings(protein.getAlignment().getCodonFrames());
+ topViewport.setCodingComplement(bottomViewport);
+ ssm.addCommandListener(cdna);
+ ssm.addCommandListener(protein);
+ }
+
+ /*
+ * Expand protein to 3 times character width of dna
+ */
+ if (protein != null && cdna != null)
+ {
+ ViewStyleI vs = protein.getViewStyle();
+ vs.setCharWidth(3 * vs.getCharWidth());
+ protein.setViewStyle(vs);
+ }
+
}
/**
private void addAlignFrameComponents(AlignFrame af, Panel panel)
{
panel.setLayout(new BorderLayout());
- Panel menuPanel = makeEmbeddedPopupMenu(af.getMenuBar(), FONT_ARIAL_PLAIN_11, true, false);
+ Panel menuPanel = af
+ .makeEmbeddedPopupMenu(af.getMenuBar(), true, false);
panel.add(menuPanel, BorderLayout.NORTH);
panel.add(af.statusBar, BorderLayout.SOUTH);
panel.add(af.alignPanel, BorderLayout.CENTER);