From: gmungoc Date: Mon, 3 Apr 2017 11:07:46 +0000 (+0100) Subject: JAL-2435 further adjustments to behaviour in split screen X-Git-Tag: Release_2_10_2~3^2~91^2~7 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e3f93aa087ce63e7b557497d1f4563ed4dbe2941;p=jalview.git JAL-2435 further adjustments to behaviour in split screen --- diff --git a/src/jalview/appletgui/AlignmentPanel.java b/src/jalview/appletgui/AlignmentPanel.java index 3ae0394..5ec2a01 100644 --- a/src/jalview/appletgui/AlignmentPanel.java +++ b/src/jalview/appletgui/AlignmentPanel.java @@ -748,8 +748,8 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, if ((hextent + x) > width) { - System.err.println("hextent was " + hextent + " and x was " + x); - + // System.err.println("hextent was " + hextent + " and x was " + x); + // x = width - hextent; } diff --git a/src/jalview/appletgui/FontChooser.java b/src/jalview/appletgui/FontChooser.java index 727aa88..96dfc20 100644 --- a/src/jalview/appletgui/FontChooser.java +++ b/src/jalview/appletgui/FontChooser.java @@ -20,7 +20,6 @@ */ package jalview.appletgui; -import jalview.api.ViewStyleI; import jalview.util.MessageManager; import java.awt.BorderLayout; @@ -71,10 +70,20 @@ public class FontChooser extends Panel implements ItemListener private Font oldFont; + private Font oldComplementFont; + private int oldCharWidth = 0; + /* + * the state of 'scale protein to cDNA' on opening the dialog + */ private boolean oldScaleProtein = false; + /* + * the state of 'same font for protein and cDNA' on opening the dialog + */ + boolean oldMirrorFont; + private Font lastSelected = null; private int lastSelStyle = 0; @@ -184,6 +193,29 @@ public class FontChooser extends Panel implements ItemListener { scaleAsCdna_actionPerformed(); } + else if (source == fontAsCdna) + { + mirrorFont_actionPerformed(); + } + } + + /** + * Action on checking or unchecking 'use same font across split screen' + * option. When checked, the font settings are copied to the other half of the + * split screen. When unchecked, the other half is restored to its initial + * settings. + */ + protected void mirrorFont_actionPerformed() + { + boolean selected = fontAsCdna.getState(); + ap.av.setProteinFontAsCdna(selected); + ap.av.getCodingComplement().setProteinFontAsCdna(selected); + + if (!selected) + { + ap.av.getCodingComplement().setFont(oldComplementFont, true); + } + changeFont(); } /** @@ -210,19 +242,23 @@ public class FontChooser extends Panel implements ItemListener if (ap != null) { ap.av.setScaleProteinAsCdna(oldScaleProtein); + ap.av.setProteinFontAsCdna(oldMirrorFont); + if (ap.av.getCodingComplement() != null) { ap.av.getCodingComplement().setScaleProteinAsCdna(oldScaleProtein); - ap.av.getCodingComplement().setFont(oldFont, true); - ap.alignFrame.getSplitFrame().repaint(); + ap.av.getCodingComplement().setProteinFontAsCdna(oldMirrorFont); + ap.av.getCodingComplement().setFont(oldComplementFont, true); + SplitFrame splitFrame = ap.alignFrame.getSplitFrame(); + splitFrame.adjustLayout(); + splitFrame.getComplement(ap.alignFrame).alignPanel.fontChanged(); + splitFrame.repaint(); } ap.av.setFont(oldFont, true); - ViewStyleI style = ap.av.getViewStyle(); - if (style.getCharWidth() != oldCharWidth) + if (ap.av.getCharWidth() != oldCharWidth) { - style.setCharWidth(oldCharWidth); - ap.av.setViewStyle(style); + ap.av.setCharWidth(oldCharWidth); } ap.paintAlignment(true); } @@ -288,11 +324,15 @@ public class FontChooser extends Panel implements ItemListener /* * and change font in other half of split frame if any */ - if (inSplitFrame && fontAsCdna.getState()) + if (inSplitFrame) { - ap.av.getCodingComplement().setFont(newFont, true); + if (fontAsCdna.getState()) + { + ap.av.getCodingComplement().setFont(newFont, true); + } SplitFrame splitFrame = ap.alignFrame.getSplitFrame(); splitFrame.adjustLayout(); + splitFrame.getComplement(ap.alignFrame).alignPanel.fontChanged(); splitFrame.repaint(); } } @@ -363,7 +403,8 @@ public class FontChooser extends Panel implements ItemListener fontAsCdna.setLabel(MessageManager.getString("label.font_as_cdna")); fontAsCdna.setFont(VERDANA_11PT); - fontAsCdna.setState(true); + fontAsCdna.addItemListener(this); + fontAsCdna.setState(ap.av.isProteinFontAsCdna()); ok.setFont(VERDANA_11PT); ok.setLabel(MessageManager.getString("action.ok")); @@ -425,6 +466,8 @@ public class FontChooser extends Panel implements ItemListener if (ap.alignFrame.getSplitFrame() != null) { inSplitFrame = true; + oldComplementFont = ((AlignViewport) ap.av.getCodingComplement()) + .getFont(); this.add(scalePanel, BorderLayout.CENTER); } this.add(okCancelPanel, BorderLayout.SOUTH); @@ -439,9 +482,7 @@ public class FontChooser extends Panel implements ItemListener ap.av.setScaleProteinAsCdna(scaleAsCdna.getState()); ap.av.getCodingComplement().setScaleProteinAsCdna( scaleAsCdna.getState()); - ap.alignFrame.getSplitFrame().adjustLayout(); - ap.paintAlignment(true); - ap.alignFrame.getSplitFrame().repaint(); + changeFont(); } } diff --git a/src/jalview/gui/FontChooser.java b/src/jalview/gui/FontChooser.java index fdf3d2a..547f528 100755 --- a/src/jalview/gui/FontChooser.java +++ b/src/jalview/gui/FontChooser.java @@ -49,6 +49,12 @@ public class FontChooser extends GFontChooser Font oldFont; /* + * The font on opening the dialog (to be restored on Cancel) + * on the other half of a split frame (if applicable) + */ + Font oldComplementFont; + + /* * the state of 'scale protein as cDNA' on opening the dialog */ boolean oldProteinScale; @@ -114,6 +120,8 @@ public class FontChooser extends GFontChooser boolean inSplitFrame = ap.av.getCodingComplement() != null; if (inSplitFrame) { + oldComplementFont = ((AlignViewport) ap.av.getCodingComplement()) + .getFont(); scaleAsCdna.setVisible(true); scaleAsCdna.setSelected(ap.av.isScaleProteinAsCdna()); fontAsCdna.setVisible(true); @@ -217,7 +225,7 @@ public class FontChooser extends GFontChooser { ap.av.getCodingComplement().setScaleProteinAsCdna(oldProteinScale); ap.av.getCodingComplement().setProteinFontAsCdna(oldMirrorFont); - ap.av.getCodingComplement().setFont(oldFont, true); + ap.av.getCodingComplement().setFont(oldComplementFont, true); } } else if (tp != null) @@ -308,15 +316,13 @@ public class FontChooser extends GFontChooser */ ap.av.getCodingComplement().setFont(newFont, true); } - if (fontAsCdna.isSelected() || scaleAsCdna.isSelected()) - { - /* - * adjust layout for font change and/or sizing - */ - SplitFrame splitFrame = (SplitFrame) ap.alignFrame - .getSplitViewContainer(); - splitFrame.repaint(); - } + + /* + * adjust layout for font change / reset / sizing + */ + SplitFrame splitFrame = (SplitFrame) ap.alignFrame + .getSplitViewContainer(); + splitFrame.repaint(); } } @@ -405,8 +411,8 @@ public class FontChooser extends GFontChooser /** * Turn on/off mirroring of font across split frame. If turning on, also - * copies the current font across the split frame. If turning off, does not - * change fonts. + * copies the current font across the split frame. If turning off, restores + * the other half of the split frame to its initial font. */ @Override protected void mirrorFonts_actionPerformed() @@ -415,9 +421,14 @@ public class FontChooser extends GFontChooser ap.av.setProteinFontAsCdna(selected); ap.av.getCodingComplement().setProteinFontAsCdna(selected); - if (selected) + /* + * reset other half of split frame if turning option off + */ + if (!selected) { - changeFont(); + ap.av.getCodingComplement().setFont(oldComplementFont, true); } + + changeFont(); } }