JAL-845 applet colour by tree; translate as cDNA; pull up history list
[jalview.git] / src / jalview / appletgui / SplitFrame.java
index d77f331..a012092 100644 (file)
@@ -1,6 +1,11 @@
 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;
@@ -45,6 +50,42 @@ public class SplitFrame extends EmbmenuFrame
 
     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);
+    }
+
   }
 
   /**
@@ -58,7 +99,8 @@ public class SplitFrame extends EmbmenuFrame
   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);