* when true, charWidth/height is set according to font metrics
*/
void setFont(Font newFont, boolean b);
+
+ /**
+ * Answers true if split screen protein and cDNA use the same font
+ *
+ * @return
+ */
+ boolean isProteinFontAsCdna();
+
+ /**
+ * Set the flag for whether split screen protein and cDNA use the same font
+ *
+ * @return
+ */
+ void setProteinFontAsCdna(boolean b);
}
* @return
*/
void setScaleProteinAsCdna(boolean b);
+
+ /**
+ * Answers true if split screen protein and cDNA use the same font
+ *
+ * @return
+ */
+ boolean isProteinFontAsCdna();
+
+ /**
+ * Set the flag for whether split screen protein and cDNA use the same font
+ *
+ * @return
+ */
+ void setProteinFontAsCdna(boolean b);
}
import java.awt.Font;
import java.awt.FontMetrics;
-import java.awt.event.ActionEvent;
import java.awt.geom.Rectangle2D;
import javax.swing.JInternalFrame;
*/
Font oldFont;
+ /*
+ * the state of 'scale protein as cDNA' on opening the dialog
+ */
boolean oldProteinScale;
+ /*
+ * the state of 'same font for protein and cDNA' on opening the dialog
+ */
+ boolean oldMirrorFont;
+
boolean init = true;
JInternalFrame frame;
private boolean lastSelMono = false;
/**
- * Creates a new FontChooser object.
+ * Creates a new FontChooser for a tree panel
*
- * @param ap
- * DOCUMENT ME!
+ * @param treePanel
*/
- public FontChooser(TreePanel tp)
+ public FontChooser(TreePanel treePanel)
{
- this.tp = tp;
- ap = tp.treeCanvas.ap;
- oldFont = tp.getTreeFont();
+ this.tp = treePanel;
+ ap = treePanel.treeCanvas.ap;
+ oldFont = treePanel.getTreeFont();
defaultButton.setVisible(false);
smoothFont.setEnabled(false);
init();
}
/**
- * Creates a new FontChooser object.
+ * Creates a new FontChooser for an alignment panel
*
- * @param ap
- * DOCUMENT ME!
+ * @param alignPanel
*/
- public FontChooser(AlignmentPanel ap)
+ public FontChooser(AlignmentPanel alignPanel)
{
- oldFont = ap.av.getFont();
- oldProteinScale = ap.av.isScaleProteinAsCdna();
+ oldFont = alignPanel.av.getFont();
+ oldProteinScale = alignPanel.av.isScaleProteinAsCdna();
+ oldMirrorFont = alignPanel.av.isProteinFontAsCdna();
- this.ap = ap;
+ this.ap = alignPanel;
init();
}
scaleAsCdna.setVisible(true);
scaleAsCdna.setSelected(ap.av.isScaleProteinAsCdna());
fontAsCdna.setVisible(true);
- fontAsCdna.setSelected(true);
+ fontAsCdna.setSelected(ap.av.isProteinFontAsCdna());
}
if (tp != null)
}
@Override
- public void smoothFont_actionPerformed(ActionEvent e)
+ protected void smoothFont_actionPerformed()
{
ap.av.antiAlias = smoothFont.isSelected();
ap.getAnnotationPanel().image = null;
* DOCUMENT ME!
*/
@Override
- protected void ok_actionPerformed(ActionEvent e)
+ protected void ok_actionPerformed()
{
try
{
* DOCUMENT ME!
*/
@Override
- protected void cancel_actionPerformed(ActionEvent e)
+ protected void cancel_actionPerformed()
{
if (ap != null)
{
ap.av.setFont(oldFont, true);
ap.av.setScaleProteinAsCdna(oldProteinScale);
+ ap.av.setProteinFontAsCdna(oldMirrorFont);
ap.paintAlignment(true);
+
if (scaleAsCdna.isVisible() && scaleAsCdna.isEnabled())
{
ap.av.getCodingComplement().setScaleProteinAsCdna(oldProteinScale);
+ ap.av.getCodingComplement().setProteinFontAsCdna(oldMirrorFont);
ap.av.getCodingComplement().setFont(oldFont, true);
}
}
{
tp.setTreeFont(oldFont);
}
- fontName.setSelectedItem(oldFont.getName());
- fontSize.setSelectedItem(oldFont.getSize());
- fontStyle.setSelectedIndex(oldFont.getStyle());
try
{
ap.fontChanged();
/*
- * and change font in other half of split frame if any
+ * adjust other half of split frame if any, if either same
+ * font, or proportionate scaling, is selected
*/
- if (fontAsCdna.isEnabled() && fontAsCdna.isSelected())
+ if (fontAsCdna.isEnabled())
{
- ap.av.getCodingComplement().setFont(newFont, true);
- SplitFrame splitFrame = (SplitFrame) ap.alignFrame
- .getSplitViewContainer();
- splitFrame.repaint();
+ if (fontAsCdna.isSelected())
+ {
+ /*
+ * copy the font
+ */
+ 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();
+ }
}
}
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Updates on change of selected font name
*/
@Override
- protected void fontName_actionPerformed(ActionEvent e)
+ protected void fontName_actionPerformed()
{
if (init)
{
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Updates on change of selected font size
*/
@Override
- protected void fontSize_actionPerformed(ActionEvent e)
+ protected void fontSize_actionPerformed()
{
if (init)
{
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Updates on change of selected font style
*/
@Override
- protected void fontStyle_actionPerformed(ActionEvent e)
+ protected void fontStyle_actionPerformed()
{
if (init)
{
/**
* Make selected settings the defaults by storing them (via Cache class) in
* the .jalview_properties file (the file is only written when Jalview exits)
- *
- * @param e
*/
@Override
- public void defaultButton_actionPerformed(ActionEvent e)
+ public void defaultButton_actionPerformed()
{
Cache.setProperty("FONT_NAME", fontName.getSelectedItem().toString());
Cache.setProperty("FONT_STYLE", fontStyle.getSelectedIndex() + "");
* characters
*/
@Override
- protected void scaleAsCdna_actionPerformed(ActionEvent e)
+ protected void scaleAsCdna_actionPerformed()
{
ap.av.setScaleProteinAsCdna(scaleAsCdna.isSelected());
ap.av.getCodingComplement().setScaleProteinAsCdna(
splitFrame.adjustLayout();
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.
+ */
+ @Override
+ protected void mirrorFonts_actionPerformed()
+ {
+ boolean selected = fontAsCdna.isSelected();
+ ap.av.setProteinFontAsCdna(selected);
+ ap.av.getCodingComplement().setProteinFontAsCdna(selected);
+
+ if (selected)
+ {
+ changeFont();
+ }
+ }
}
package jalview.gui;
import jalview.api.SplitContainerI;
-import jalview.api.ViewStyleI;
import jalview.datamodel.AlignmentI;
import jalview.jbgui.GAlignFrame;
import jalview.jbgui.GSplitFrame;
: (!bottomAlignment.isNucleotide() ? bottomViewport : null);
if (protein != null && cdna != null)
{
- ViewStyleI vs = protein.getViewStyle();
- int scale = vs.isScaleProteinAsCdna() ? 3 : 1;
- vs.setCharWidth(scale * cdna.getViewStyle().getCharWidth());
- protein.setViewStyle(vs);
+ // if (protein.isProteinFontAsCdna())
+ // {
+ // TODO handle different fonts
+ int scale = protein.isScaleProteinAsCdna() ? 3 : 1;
+ protein.setCharWidth(scale * cdna.getViewStyle().getCharWidth());
+ // }
}
}
@Override
public void actionPerformed(ActionEvent e)
{
- fontSize_actionPerformed(e);
+ fontSize_actionPerformed();
}
});
@Override
public void actionPerformed(ActionEvent e)
{
- fontStyle_actionPerformed(e);
+ fontStyle_actionPerformed();
}
});
@Override
public void actionPerformed(ActionEvent e)
{
- fontName_actionPerformed(e);
+ fontName_actionPerformed();
}
});
@Override
public void actionPerformed(ActionEvent e)
{
- ok_actionPerformed(e);
+ ok_actionPerformed();
}
});
@Override
public void actionPerformed(ActionEvent e)
{
- cancel_actionPerformed(e);
+ cancel_actionPerformed();
}
});
@Override
public void actionPerformed(ActionEvent e)
{
- defaultButton_actionPerformed(e);
+ defaultButton_actionPerformed();
}
});
@Override
public void actionPerformed(ActionEvent e)
{
- smoothFont_actionPerformed(e);
+ smoothFont_actionPerformed();
}
});
@Override
public void actionPerformed(ActionEvent e)
{
- scaleAsCdna_actionPerformed(e);
+ scaleAsCdna_actionPerformed();
}
});
fontAsCdna.setOpaque(false);
fontAsCdna.setText(MessageManager.getString("label.font_as_cdna"));
fontAsCdna.setBounds(new Rectangle(1, 105, 350, 23));
+ fontAsCdna.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ mirrorFonts_actionPerformed();
+ }
+ });
monospaced.setEnabled(false);
monospaced.setFont(JvSwingUtils.getLabelFont());
this.add(jPanel1, null);
}
- protected void scaleAsCdna_actionPerformed(ActionEvent e)
+ protected void mirrorFonts_actionPerformed()
{
}
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
- protected void ok_actionPerformed(ActionEvent e)
+ protected void scaleAsCdna_actionPerformed()
{
}
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
- protected void cancel_actionPerformed(ActionEvent e)
+ protected void ok_actionPerformed()
{
}
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
- protected void fontName_actionPerformed(ActionEvent e)
+ protected void cancel_actionPerformed()
{
}
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
- protected void fontSize_actionPerformed(ActionEvent e)
+ protected void fontName_actionPerformed()
{
}
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
- protected void fontStyle_actionPerformed(ActionEvent e)
+ protected void fontSize_actionPerformed()
{
}
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
- public void defaultButton_actionPerformed(ActionEvent e)
+ protected void fontStyle_actionPerformed()
{
}
- public void smoothFont_actionPerformed(ActionEvent e)
+ public void defaultButton_actionPerformed()
{
+ }
+ protected void smoothFont_actionPerformed()
+ {
}
}
*/
package jalview.viewmodel;
-import java.awt.Color;
-import java.beans.PropertyChangeSupport;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
import jalview.analysis.Conservation;
import jalview.api.AlignCalcManagerI;
import jalview.workers.ConsensusThread;
import jalview.workers.StrucConsensusThread;
+import java.awt.Color;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
/**
* base class holding visualization and analysis attributes and common logic for
* an active alignment view displayed in the GUI
viewStyle.setScaleProteinAsCdna(b);
}
+ @Override
+ public boolean isProteinFontAsCdna()
+ {
+ return viewStyle.isProteinFontAsCdna();
+ }
+
+ @Override
+ public void setProteinFontAsCdna(boolean b)
+ {
+ viewStyle.setProteinFontAsCdna(b);
+ }
+
/**
* @return true if view should scroll to show the highlighted region of a
* sequence
*/
private boolean scaleProteinAsCdna = true;
+ /*
+ * if true, font changes to protein or cDNA are applied to both
+ * sides of a split screen
+ */
+ private boolean proteinFontAsCdna = true;
+
/**
* Copy constructor
*
setScaleAboveWrapped(vs.getScaleAboveWrapped());
setScaleLeftWrapped(vs.getScaleLeftWrapped());
setScaleProteinAsCdna(vs.isScaleProteinAsCdna());
+ setProteinFontAsCdna(vs.isProteinFontAsCdna());
setScaleRightWrapped(vs.getScaleRightWrapped());
setSeqNameItalics(vs.isSeqNameItalics());
setShowAnnotation(vs.isShowAnnotation());
&& getScaleAboveWrapped() == vs.getScaleAboveWrapped()
&& getScaleLeftWrapped() == vs.getScaleLeftWrapped()
&& isScaleProteinAsCdna() == vs.isScaleProteinAsCdna()
+ && isProteinFontAsCdna() == vs.isProteinFontAsCdna()
&& getScaleRightWrapped() == vs.getScaleRightWrapped()
&& isSeqNameItalics() == vs.isSeqNameItalics()
&& isShowAnnotation() == vs.isShowAnnotation()
{
this.scaleProteinAsCdna = b;
}
+
+ @Override
+ public boolean isProteinFontAsCdna()
+ {
+ return proteinFontAsCdna;
+ }
+
+ @Override
+ public void setProteinFontAsCdna(boolean b)
+ {
+ proteinFontAsCdna = b;
+ }
}