*/
package jalview.appletgui;
-import jalview.api.ViewStyleI;
import jalview.util.MessageManager;
import java.awt.BorderLayout;
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;
{
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();
}
/**
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);
}
/*
* 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();
}
}
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"));
if (ap.alignFrame.getSplitFrame() != null)
{
inSplitFrame = true;
+ oldComplementFont = ((AlignViewport) ap.av.getCodingComplement())
+ .getFont();
this.add(scalePanel, BorderLayout.CENTER);
}
this.add(okCancelPanel, BorderLayout.SOUTH);
ap.av.setScaleProteinAsCdna(scaleAsCdna.getState());
ap.av.getCodingComplement().setScaleProteinAsCdna(
scaleAsCdna.getState());
- ap.alignFrame.getSplitFrame().adjustLayout();
- ap.paintAlignment(true);
- ap.alignFrame.getSplitFrame().repaint();
+ changeFont();
}
}
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;
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);
{
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)
*/
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();
}
}
/**
* 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()
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();
}
}