From c45601b486d1a9fd51273134699ca980c872ea6f Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 11 Mar 2015 15:53:47 +0000 Subject: [PATCH] JAL-1684 better window size parameters; match up sequence id lengths --- examples-jbake/templates/jvl_examples.ftl | 9 ++---- examples/applets.html | 6 ++-- src/jalview/appletgui/SplitFrame.java | 47 +++++++++++++++++++++-------- 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/examples-jbake/templates/jvl_examples.ftl b/examples-jbake/templates/jvl_examples.ftl index 84c660d..d0e40bf 100644 --- a/examples-jbake/templates/jvl_examples.ftl +++ b/examples-jbake/templates/jvl_examples.ftl @@ -94,12 +94,9 @@ Try out JalviewLite by pressing one of the buttons below.
, "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 /> Displays a split window view of protein and its related cDNA diff --git a/examples/applets.html b/examples/applets.html index 11de374..b557efc 100755 --- a/examples/applets.html +++ b/examples/applets.html @@ -325,9 +325,9 @@ Try out JalviewLite by pressing one of the buttons below.
- - - + + + diff --git a/src/jalview/appletgui/SplitFrame.java b/src/jalview/appletgui/SplitFrame.java index fb11a5c..ccfa432 100644 --- a/src/jalview/appletgui/SplitFrame.java +++ b/src/jalview/appletgui/SplitFrame.java @@ -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) { -- 1.7.10.2