From 1d95f81a9aa2f30581fe4f63be4e387f52d60885 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 19 Aug 2019 17:30:56 +0100 Subject: [PATCH] JAL-3364 align split frame sequence panels with wrapped view scale left --- src/jalview/gui/AlignmentPanel.java | 10 +++++++--- src/jalview/gui/FontChooser.java | 5 ----- src/jalview/gui/IdwidthAdjuster.java | 1 + src/jalview/gui/SeqPanel.java | 2 -- src/jalview/gui/SplitFrame.java | 34 +++++++++++++++++++++------------- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index cd31bed..716c237 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -565,9 +565,6 @@ public class AlignmentPanel extends GAlignmentPanel implements /** * update alignment layout for viewport settings - * - * @param wrap - * DOCUMENT ME! */ public void updateLayout() { @@ -614,6 +611,13 @@ public class AlignmentPanel extends GAlignmentPanel implements idSpaceFillerPanel1.setVisible(!wrap); + AlignViewportI complement = av.getCodingComplement(); + if (complement != null) + { + SplitFrame splitFrame = (SplitFrame) alignFrame + .getSplitViewContainer(); + splitFrame.adjustLayout(); + } repaint(); } diff --git a/src/jalview/gui/FontChooser.java b/src/jalview/gui/FontChooser.java index 92cc4c6..1b9ec1e 100755 --- a/src/jalview/gui/FontChooser.java +++ b/src/jalview/gui/FontChooser.java @@ -190,9 +190,7 @@ public class FontChooser extends GFontChooser .getCodingComplement()).antiAlias = ap.av.antiAlias; SplitFrame sv = (SplitFrame) ap.alignFrame.getSplitViewContainer(); sv.adjustLayout(); - sv.repaint(); } - } /** @@ -251,7 +249,6 @@ public class FontChooser extends GFontChooser SplitFrame splitFrame = (SplitFrame) ap.alignFrame .getSplitViewContainer(); splitFrame.adjustLayout(); - splitFrame.repaint(); } } @@ -346,7 +343,6 @@ public class FontChooser extends GFontChooser SplitFrame splitFrame = (SplitFrame) ap.alignFrame .getSplitViewContainer(); splitFrame.adjustLayout(); - splitFrame.repaint(); } } @@ -430,7 +426,6 @@ public class FontChooser extends GFontChooser final SplitFrame splitFrame = (SplitFrame) ap.alignFrame .getSplitViewContainer(); splitFrame.adjustLayout(); - splitFrame.repaint(); } /** diff --git a/src/jalview/gui/IdwidthAdjuster.java b/src/jalview/gui/IdwidthAdjuster.java index 0cffc3b..368b7b8 100755 --- a/src/jalview/gui/IdwidthAdjuster.java +++ b/src/jalview/gui/IdwidthAdjuster.java @@ -94,6 +94,7 @@ public class IdwidthAdjuster extends JPanel { viewport.getCodingComplement().setIdWidth(viewport.getIdWidth()); SplitFrame sf = (SplitFrame) ap.alignFrame.getSplitViewContainer(); + sf.adjustLayout(); sf.repaint(); } diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 1176df5..d64a034 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -1253,7 +1253,6 @@ public class SeqPanel extends JPanel SplitFrame splitFrame = (SplitFrame) ap.alignFrame .getSplitViewContainer(); splitFrame.adjustLayout(); - splitFrame.repaint(); } } } @@ -1287,7 +1286,6 @@ public class SeqPanel extends JPanel SplitFrame splitFrame = (SplitFrame) ap.alignFrame .getSplitViewContainer(); splitFrame.adjustLayout(); - splitFrame.repaint(); } } } diff --git a/src/jalview/gui/SplitFrame.java b/src/jalview/gui/SplitFrame.java index b1eb6b8..fd0ec63 100644 --- a/src/jalview/gui/SplitFrame.java +++ b/src/jalview/gui/SplitFrame.java @@ -161,26 +161,32 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI */ public void adjustLayout() { + final AlignViewport topViewport = ((AlignFrame) getTopFrame()).viewport; + final AlignViewport bottomViewport = ((AlignFrame) getBottomFrame()).viewport; + /* - * Ensure sequence ids are the same width so sequences line up + * Ensure sequence ids are the same width so sequences line up; + * reduce the idwidth of a panel with a longer wrapped left scale */ - int w1 = ((AlignFrame) getTopFrame()).getViewport().getIdWidth(); - int w2 = ((AlignFrame) getBottomFrame()).getViewport().getIdWidth(); + int w1 = topViewport.getIdWidth(); + int w2 = bottomViewport.getIdWidth(); + int topScaleLeft = topViewport.getWrapAlignment() + ? ((AlignFrame) getTopFrame()).alignPanel + .getSeqPanel().seqCanvas.getLabelWidthWest() + : 0; + int bottomScaleLeft = bottomViewport.getWrapAlignment() + ? ((AlignFrame) getBottomFrame()).alignPanel + .getSeqPanel().seqCanvas.getLabelWidthWest() + : 0; int w3 = Math.max(w1, w2); - if (w1 != w3) - { - ((AlignFrame) getTopFrame()).getViewport().setIdWidth(w3); - } - if (w2 != w3) - { - ((AlignFrame) getBottomFrame()).getViewport().setIdWidth(w3); - } + topViewport + .setIdWidth(w3 - Math.max(0, topScaleLeft - bottomScaleLeft)); + bottomViewport + .setIdWidth(w3 - Math.max(0, bottomScaleLeft - topScaleLeft)); /* * Scale protein to either 1 or 3 times character width of 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 @@ -192,6 +198,8 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI int scale = protein.isScaleProteinAsCdna() ? 3 : 1; protein.setCharWidth(scale * cdna.getViewStyle().getCharWidth()); } + + repaint(); } /** -- 1.7.10.2