JAL-1684 better window size parameters; match up sequence id lengths
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 11 Mar 2015 15:53:47 +0000 (15:53 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 11 Mar 2015 15:53:47 +0000 (15:53 +0000)
examples-jbake/templates/jvl_examples.ftl
examples/applets.html
src/jalview/appletgui/SplitFrame.java

index 84c660d..d0e40bf 100644 (file)
@@ -94,12 +94,9 @@ Try out JalviewLite by pressing one of the buttons below.<br/>
                                                     , "file":"estrogenReceptorCdna.fa"
                                                     , "file2":"estrogenReceptorProtein.fa"
                                                     , "defaultColour":"Purine/Pyrimidine"
-                                                    , "showAnnotation":"true"
-                                                    , "windowHeight":"800"
-                                                    , "windowWidth":"650"
-                                                    , "showConservation":"false"
-                                                    , "showQuality":"false"
-                                                    , "showConsensus":"true"
+                                                    , "showAnnotation":"false"
+                                                    , "windowHeight":"300"
+                                                    , "windowWidth":"800"
                                                     , "showFullId":"false"} prots=true /></td>
       <td valign="center">Displays a split window view of protein and its related cDNA</td>
     </tr>
index 11de374..b557efc 100755 (executable)
@@ -325,9 +325,9 @@ Try out JalviewLite by pressing one of the buttons below.<br/>
 <param name="file" value="estrogenReceptorCdna.fa"/>
 <param name="file2" value="estrogenReceptorProtein.fa"/>
 <param name="showFullId" value="false"/>
-<param name="windowHeight" value="800"/>
-<param name="windowWidth" value="650"/>
-<param name="showAnnotation" value="true"/>
+<param name="windowHeight" value="300"/>
+<param name="windowWidth" value="800"/>
+<param name="showAnnotation" value="false"/>
 <param name="defaultColour" value="Purine/Pyrimidine"/>
    <param name="APPLICATION_URL"
      value="http://www.jalview.org/services/launchApp"/>
index fb11a5c..ccfa432 100644 (file)
@@ -8,12 +8,9 @@ import jalview.datamodel.AlignmentI;
 import jalview.structure.StructureSelectionManager;
 
 import java.awt.BorderLayout;
-import java.awt.Component;
+import java.awt.Dimension;
 import java.awt.GridLayout;
-import java.awt.MouseInfo;
 import java.awt.Panel;
-import java.awt.Point;
-import java.awt.Rectangle;
 
 public class SplitFrame extends EmbmenuFrame
 {
@@ -69,7 +66,7 @@ public class SplitFrame extends EmbmenuFrame
       ssm.addCommandListener(protein);
     }
 
-    setCharacterWidth(protein, cdna);
+    adjustLayout();
   }
 
   /**
@@ -90,13 +87,39 @@ public class SplitFrame extends EmbmenuFrame
   }
 
   /**
-   * Expand protein to 3 times character width of dna
-   * 
-   * @param protein
-   * @param cdna
+   * Make any adjustments to the layout
    */
-  protected void setCharacterWidth(AlignViewport protein, AlignViewport cdna)
+  protected void adjustLayout()
   {
+    AlignViewport cdna = topFrame.getAlignViewport().getAlignment()
+            .isNucleotide() ? topFrame.viewport : bottomFrame.viewport;
+    AlignViewport protein = cdna == topFrame.viewport ? bottomFrame.viewport
+            : topFrame.viewport;
+
+    /*
+     * Ensure sequence ids are the same width for good alignment.
+     */
+    // TODO should do this via av.getViewStyle/setViewStyle
+    // however at present av.viewStyle is not set in IdPanel.fontChanged
+    int w1 = topFrame.alignPanel.idPanel.idCanvas.getWidth();
+    int w2 = bottomFrame.alignPanel.idPanel.idCanvas.getWidth();
+    int w3 = Math.max(w1, w2);
+    if (w1 != w3)
+    {
+      Dimension d = topFrame.alignPanel.idPanel.idCanvas.getSize();
+      topFrame.alignPanel.idPanel.idCanvas.setSize(new Dimension(w3,
+              d.height));
+    }
+    if (w2 != w3)
+    {
+      Dimension d = bottomFrame.alignPanel.idPanel.idCanvas.getSize();
+      bottomFrame.alignPanel.idPanel.idCanvas.setSize(new Dimension(w3,
+              d.height));
+    }
+
+    /*
+     * Expand protein to 3 times character width of dna
+     */
     if (protein != null && cdna != null)
     {
       ViewStyleI vs = protein.getViewStyle();
@@ -131,7 +154,7 @@ public class SplitFrame extends EmbmenuFrame
    */
   public void addToDisplay(boolean embedded, JalviewLite applet)
   {
-    createAlignFrameWindow(embedded, applet);
+    createSplitFrameWindow(embedded, applet);
     validate();
     topFrame.alignPanel.adjustAnnotationHeight();
     topFrame.alignPanel.paintAlignment(true);
@@ -146,7 +169,7 @@ public class SplitFrame extends EmbmenuFrame
    * @param embed
    * @param applet
    */
-  public void createAlignFrameWindow(boolean embed, JalviewLite applet)
+  protected void createSplitFrameWindow(boolean embed, JalviewLite applet)
   {
     if (embed)
     {