From f69e96788c2ae3a08f56c4461d8d197a3b3a06a2 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 2 Apr 2015 15:37:06 +0100 Subject: [PATCH] JAL-1690 'scale protein as cDNA' options in Preferences, FontChooser --- resources/lang/Messages.properties | 11 +- src/jalview/api/ViewStyleI.java | 15 ++ src/jalview/appletgui/AlignFrame.java | 11 + src/jalview/appletgui/AlignViewport.java | 3 + src/jalview/appletgui/FontChooser.java | 287 +++++++++++++--------- src/jalview/appletgui/SplitFrame.java | 7 +- src/jalview/gui/AlignViewport.java | 6 +- src/jalview/gui/FontChooser.java | 52 +++- src/jalview/gui/Preferences.java | 32 ++- src/jalview/gui/SplitFrame.java | 34 ++- src/jalview/jbgui/GFontChooser.java | 180 ++++++++------ src/jalview/jbgui/GPreferences.java | 238 +++++++++--------- src/jalview/viewmodel/AlignmentViewport.java | 12 + src/jalview/viewmodel/styles/ViewStyle.java | 25 +- test/jalview/viewmodel/styles/TestviewStyle.java | 4 + 15 files changed, 568 insertions(+), 349 deletions(-) diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index e103758..027a9ce 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -574,8 +574,8 @@ label.conservation = Conservation label.consensus = Consensus label.histogram = Histogram label.logo = Logo -label.non_positional_features = Non-positional Features -label.database_references = Database References +label.non_positional_features = List Non-positional Features +label.database_references = List Database References label.share_selection_across_views = Share selection across views label.scroll_highlighted_regions = Scroll to highlighted regions label.gap_symbol = Gap Symbol @@ -601,7 +601,7 @@ label.figure_id_column_width = Figure ID column width label.use_modeller_output = Use Modeller Output label.wrap_alignment = Wrap Alignment label.right_align_ids = Right Align Ids -label.sequence_name_italics = Sequence Name Italics +label.sequence_name_italics = Italic Sequence Ids label.open_overview = Open Overview label.default_colour_scheme_for_alignment = Default Colour Scheme for alignment label.annotation_shading_default = Annotation Shading Default @@ -1241,4 +1241,7 @@ info.select_filter_option = Select Filter Option/Manual Entry info.associate_wit_sequence = Associate with Sequence label.search_result = Search Result label.found_structures_summary = Found Structures Summary -label.configure_displayed_columns = Configure Displayed Columns \ No newline at end of file +label.configure_displayed_columns = Configure Displayed Columns +label.scale_as_cdna = Scale residues to width of codons +label.scale_protein_to_cdna = Scale Protein to cDNA +label.scale_protein_to_cdna_tip = Make protein residues same width as codons in split frame views diff --git a/src/jalview/api/ViewStyleI.java b/src/jalview/api/ViewStyleI.java index 8fa7f8f..0313c5c 100644 --- a/src/jalview/api/ViewStyleI.java +++ b/src/jalview/api/ViewStyleI.java @@ -199,4 +199,19 @@ public interface ViewStyleI */ void setShowNPFeats(boolean shownpfeats); + /** + * Get flag to scale protein residues 3 times the width of cDNA bases (only + * applicable in SplitFrame views) + * + * @return + */ + boolean isScaleProteinAsCdna(); + + /** + * Set flag to scale protein residues 3 times the width of cDNA bases (only + * applicable in SplitFrame views) + * + * @return + */ + void setScaleProteinAsCdna(boolean b); } diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 93bd155..5c8135d 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -3740,6 +3740,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, private CheckboxMenuItem showAutoLast; + private SplitFrame splitFrame; + /** * Attach the alignFrame panels after embedding menus, if necessary. This used * to be called setEmbedded, but is now creates the dropdown menus in a @@ -4166,4 +4168,13 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, return false; } + public SplitFrame getSplitFrame() + { + return this.splitFrame; + } + + public void setSplitFrame(SplitFrame sf) + { + this.splitFrame = sf; + } } diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index 2d38008..b0e29da 100644 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -157,6 +157,9 @@ public class AlignViewport extends AlignmentViewport implements setShowUnconserved(applet.getDefaultParameter("showUnconserved", getShowUnconserved())); + setScaleProteinAsCdna(applet.getDefaultParameter( + "scaleProteinAsCdna", isScaleProteinAsCdna())); + String param = applet.getParameter("upperCase"); if (param != null) { diff --git a/src/jalview/appletgui/FontChooser.java b/src/jalview/appletgui/FontChooser.java index 48f11b5..ae59470 100644 --- a/src/jalview/appletgui/FontChooser.java +++ b/src/jalview/appletgui/FontChooser.java @@ -20,11 +20,9 @@ */ package jalview.appletgui; -import jalview.api.ViewStyleI; -import jalview.util.MessageManager; - import java.awt.BorderLayout; import java.awt.Button; +import java.awt.Checkbox; import java.awt.Choice; import java.awt.Color; import java.awt.FlowLayout; @@ -39,21 +37,57 @@ import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -public class FontChooser extends Panel implements ActionListener, - ItemListener +import jalview.api.ViewStyleI; +import jalview.util.MessageManager; + +/** + * This dialog allows the user to try different font settings and related + * options. Changes are immediately visible on the alignment or tree. The user + * can dismiss the dialog by confirming changes with 'OK', or reverting to + * previous settings with 'Cancel'. + */ +@SuppressWarnings("serial") +public class FontChooser extends Panel implements ItemListener { - AlignmentPanel ap; + private static final Font VERDANA_11PT = new Font("Verdana", 0, 11); + + private Choice fontSize = new Choice(); + + private Choice fontStyle = new Choice(); + + private Choice fontName = new Choice(); + + private Checkbox scaleAsCdna = new Checkbox(); + + private Button ok = new Button(); - TreePanel tp; + private Button cancel = new Button(); - Font oldFont; + private AlignmentPanel ap; - int oldCharWidth = 0; + private TreePanel tp; - boolean init = true; + private Font oldFont; - Frame frame; + private int oldCharWidth = 0; + private boolean oldScaleProtein = false; + + private Font lastSelected = null; + + private int lastSelStyle = 0; + + private int lastSelSize = 0; + + private boolean init = true; + + private Frame frame; + + /** + * Constructor for a TreePanel font chooser + * + * @param tp + */ public FontChooser(TreePanel tp) { try @@ -69,8 +103,18 @@ public class FontChooser extends Panel implements ActionListener, init(); } + /** + * Constructor for an AlignmentPanel font chooser + * + * @param ap + */ public FontChooser(AlignmentPanel ap) { + this.ap = ap; + oldFont = ap.av.getFont(); + oldCharWidth = ap.av.getViewStyle().getCharWidth(); + oldScaleProtein = ap.av.getViewStyle().isScaleProteinAsCdna(); + try { jbInit(); @@ -78,13 +122,12 @@ public class FontChooser extends Panel implements ActionListener, { e.printStackTrace(); } - - this.ap = ap; - oldFont = ap.av.getFont(); - oldCharWidth = ap.av.getViewStyle().getCharWidth(); init(); } + /** + * Populate choice lists and open this dialog + */ void init() { String fonts[] = Toolkit.getDefaultToolkit().getFontList(); @@ -106,8 +149,7 @@ public class FontChooser extends Panel implements ActionListener, fontSize.select(oldFont.getSize() + ""); fontStyle.select(oldFont.getStyle()); - Frame frame = new Frame(); - this.frame = frame; + this.frame = new Frame(); frame.add(this); jalview.bin.JalviewLite.addFrame(frame, MessageManager.getString("action.change_font"), 440, 115); @@ -115,34 +157,34 @@ public class FontChooser extends Panel implements ActionListener, init = false; } - public void actionPerformed(ActionEvent evt) - { - if (evt.getSource() == ok) - { - ok_actionPerformed(); - } - else if (evt.getSource() == cancel) - { - cancel_actionPerformed(); - } - } - + /** + * Actions on change of font name, size or style. + */ public void itemStateChanged(ItemEvent evt) { - if (evt.getSource() == fontName) + final Object source = evt.getSource(); + if (source == fontName) { fontName_actionPerformed(); } - else if (evt.getSource() == fontSize) + else if (source == fontSize) { fontSize_actionPerformed(); } - else if (evt.getSource() == fontStyle) + else if (source == fontStyle) { fontStyle_actionPerformed(); } + else if (source == scaleAsCdna) + { + scaleAsCdna_actionPerformed(); + } } + /** + * Close this dialog on OK to confirm any changes. Also updates the overview + * window if displayed. + */ protected void ok_actionPerformed() { frame.setVisible(false); @@ -153,9 +195,11 @@ public class FontChooser extends Panel implements ActionListener, ap.getOverviewPanel().updateOverviewImage(); } } - } + /** + * Close this dialog on Cancel, reverting to previous font settings. + */ protected void cancel_actionPerformed() { if (ap != null) @@ -182,12 +226,6 @@ public class FontChooser extends Panel implements ActionListener, frame.setVisible(false); } - private Font lastSelected = null; - - private int lastSelStyle = 0; - - private int lastSelSize = 0; - /** * DOCUMENT ME! */ @@ -265,86 +303,113 @@ public class FontChooser extends Panel implements ActionListener, changeFont(); } - Label label1 = new Label(); - - protected Choice fontSize = new Choice(); - - protected Choice fontStyle = new Choice(); - - Label label2 = new Label(); - - Label label3 = new Label(); - - protected Choice fontName = new Choice(); - - Button ok = new Button(); - - Button cancel = new Button(); - - Panel panel1 = new Panel(); - - Panel panel2 = new Panel(); - - Panel panel3 = new Panel(); - - BorderLayout borderLayout1 = new BorderLayout(); + /** + * Construct this panel's contents + * + * @throws Exception + */ + private void jbInit() throws Exception + { + this.setLayout(new BorderLayout()); + this.setBackground(Color.white); - BorderLayout borderLayout2 = new BorderLayout(); + Label fontLabel = new Label(MessageManager.getString("label.font")); + fontLabel.setFont(VERDANA_11PT); + fontLabel.setAlignment(Label.RIGHT); + fontSize.setFont(VERDANA_11PT); + fontSize.addItemListener(this); + fontStyle.setFont(VERDANA_11PT); + fontStyle.addItemListener(this); - BorderLayout borderLayout3 = new BorderLayout(); + Label sizeLabel = new Label(MessageManager.getString("label.size")); + sizeLabel.setAlignment(Label.RIGHT); + sizeLabel.setFont(VERDANA_11PT); - Panel panel4 = new Panel(); + Label styleLabel = new Label(MessageManager.getString("label.style")); + styleLabel.setAlignment(Label.RIGHT); + styleLabel.setFont(VERDANA_11PT); - Panel panel5 = new Panel(); + fontName.setFont(VERDANA_11PT); + fontName.addItemListener(this); - BorderLayout borderLayout4 = new BorderLayout(); + scaleAsCdna.setLabel(MessageManager.getString("label.scale_as_cdna")); + scaleAsCdna.setFont(VERDANA_11PT); + scaleAsCdna.addItemListener(this); + scaleAsCdna.setState(ap.av.isScaleProteinAsCdna()); - private void jbInit() throws Exception - { - label1.setFont(new java.awt.Font("Verdana", 0, 11)); - label1.setAlignment(Label.RIGHT); - label1.setText(MessageManager.getString("label.font")); - this.setLayout(borderLayout4); - fontSize.setFont(new java.awt.Font("Verdana", 0, 11)); - fontSize.addItemListener(this); - fontStyle.setFont(new java.awt.Font("Verdana", 0, 11)); - fontStyle.addItemListener(this); - label2.setAlignment(Label.RIGHT); - label2.setFont(new java.awt.Font("Verdana", 0, 11)); - label2.setText(MessageManager.getString("label.size")); - label3.setAlignment(Label.RIGHT); - label3.setFont(new java.awt.Font("Verdana", 0, 11)); - label3.setText(MessageManager.getString("label.style")); - fontName.setFont(new java.awt.Font("Verdana", 0, 11)); - fontName.addItemListener(this); - ok.setFont(new java.awt.Font("Verdana", 0, 11)); + ok.setFont(VERDANA_11PT); ok.setLabel(MessageManager.getString("action.ok")); - ok.addActionListener(this); - cancel.setFont(new java.awt.Font("Verdana", 0, 11)); + ok.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + ok_actionPerformed(); + } + }); + cancel.setFont(VERDANA_11PT); cancel.setLabel(MessageManager.getString("action.cancel")); - cancel.addActionListener(this); - this.setBackground(Color.white); - panel1.setLayout(borderLayout1); - panel2.setLayout(borderLayout3); - panel3.setLayout(borderLayout2); - panel5.setBackground(Color.white); - panel4.setBackground(Color.white); - panel1.setBackground(Color.white); - panel2.setBackground(Color.white); - panel3.setBackground(Color.white); - panel1.add(label1, BorderLayout.WEST); - panel1.add(fontName, BorderLayout.CENTER); - panel5.add(panel1, null); - panel5.add(panel3, null); - panel5.add(panel2, null); - panel2.add(label3, BorderLayout.WEST); - panel2.add(fontStyle, BorderLayout.CENTER); - panel3.add(label2, BorderLayout.WEST); - panel3.add(fontSize, BorderLayout.CENTER); - this.add(panel4, BorderLayout.SOUTH); - panel4.add(ok, null); - panel4.add(cancel, null); - this.add(panel5, BorderLayout.CENTER); + cancel.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + cancel_actionPerformed(); + } + }); + + Panel fontPanel = new Panel(); + fontPanel.setLayout(new BorderLayout()); + Panel stylePanel = new Panel(); + stylePanel.setLayout(new BorderLayout()); + Panel sizePanel = new Panel(); + sizePanel.setLayout(new BorderLayout()); + Panel scalePanel = new Panel(); + scalePanel.setLayout(new BorderLayout()); + Panel okCancelPanel = new Panel(); + Panel optionsPanel = new Panel(); + + fontPanel.setBackground(Color.white); + stylePanel.setBackground(Color.white); + sizePanel.setBackground(Color.white); + okCancelPanel.setBackground(Color.white); + optionsPanel.setBackground(Color.white); + + fontPanel.add(fontLabel, BorderLayout.WEST); + fontPanel.add(fontName, BorderLayout.CENTER); + stylePanel.add(styleLabel, BorderLayout.WEST); + stylePanel.add(fontStyle, BorderLayout.CENTER); + sizePanel.add(sizeLabel, BorderLayout.WEST); + sizePanel.add(fontSize, BorderLayout.CENTER); + scalePanel.add(scaleAsCdna, BorderLayout.CENTER); + okCancelPanel.add(ok, null); + okCancelPanel.add(cancel, null); + + optionsPanel.add(fontPanel, null); + optionsPanel.add(sizePanel, null); + optionsPanel.add(stylePanel, null); + + /* + * Only show 'scale protein as cDNA' in protein half of a SplitFrame + */ + this.add(optionsPanel, BorderLayout.NORTH); + if (ap.alignFrame.getSplitFrame() != null + && !ap.av.getAlignment().isNucleotide()) + { + this.add(scalePanel, BorderLayout.CENTER); + } + this.add(okCancelPanel, BorderLayout.SOUTH); + } + + /** + * Turn on/off scaling of protein characters to 3 times the width of cDNA + * characters + */ + protected void scaleAsCdna_actionPerformed() + { + ap.av.setScaleProteinAsCdna(scaleAsCdna.getState()); + ap.alignFrame.getSplitFrame().adjustLayout(); + ap.paintAlignment(true); } } diff --git a/src/jalview/appletgui/SplitFrame.java b/src/jalview/appletgui/SplitFrame.java index 59b66c6..4fbf65a 100644 --- a/src/jalview/appletgui/SplitFrame.java +++ b/src/jalview/appletgui/SplitFrame.java @@ -126,12 +126,13 @@ public class SplitFrame extends EmbmenuFrame } /* - * Expand protein to 3 times character width of dna + * Scale protein to either 1 or 3 times character width of dna */ if (protein != null && cdna != null) { ViewStyleI vs = protein.getViewStyle(); - vs.setCharWidth(3 * vs.getCharWidth()); + int scale = vs.isScaleProteinAsCdna() ? 3 : 1; + vs.setCharWidth(scale * cdna.getViewStyle().getCharWidth()); protein.setViewStyle(vs); } } @@ -152,6 +153,8 @@ public class SplitFrame extends EmbmenuFrame panel.add(menuPanel, BorderLayout.NORTH); panel.add(af.statusBar, BorderLayout.SOUTH); panel.add(af.alignPanel, BorderLayout.CENTER); + + af.setSplitFrame(this); } /** diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index e4593a3..44b4167 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -221,6 +221,9 @@ public class AlignViewport extends AlignmentViewport implements init(); } + /** + * Apply any settings saved in user preferences + */ private void applyViewProperties() { antiAlias = Cache.getDefault("ANTI_ALIAS", false); @@ -246,7 +249,8 @@ public class AlignViewport extends AlignmentViewport implements SequenceAnnotationOrder.NONE.name())); showAutocalculatedAbove = Cache.getDefault( Preferences.SHOW_AUTOCALC_ABOVE, false); - + viewStyle.setScaleProteinAsCdna(Cache.getDefault( + Preferences.SCALE_PROTEIN_TO_CDNA, false)); } void init() diff --git a/src/jalview/gui/FontChooser.java b/src/jalview/gui/FontChooser.java index fc66965..72b7bd6 100755 --- a/src/jalview/gui/FontChooser.java +++ b/src/jalview/gui/FontChooser.java @@ -20,10 +20,6 @@ */ package jalview.gui; -import jalview.bin.Cache; -import jalview.jbgui.GFontChooser; -import jalview.util.MessageManager; - import java.awt.Font; import java.awt.FontMetrics; import java.awt.event.ActionEvent; @@ -32,6 +28,10 @@ import javax.swing.JInternalFrame; import javax.swing.JLayeredPane; import javax.swing.JOptionPane; +import jalview.bin.Cache; +import jalview.jbgui.GFontChooser; +import jalview.util.MessageManager; + /** * DOCUMENT ME! * @@ -46,6 +46,8 @@ public class FontChooser extends GFontChooser Font oldFont; + boolean oldProteinScale; + boolean init = true; JInternalFrame frame; @@ -75,6 +77,8 @@ public class FontChooser extends GFontChooser public FontChooser(AlignmentPanel ap) { oldFont = ap.av.getFont(); + oldProteinScale = ap.av.isScaleProteinAsCdna(); + this.ap = ap; init(); } @@ -86,16 +90,27 @@ public class FontChooser extends GFontChooser smoothFont.setSelected(ap.av.antiAlias); + /* + * Enable 'scale protein as cDNA' in protein half of a SplitFrame view. The + * selection is stored in the ViewStyle of the Viewport + */ + if (ap.av.getCodingComplement() != null + && !ap.av.getAlignment().isNucleotide()) + { + scaleAsCdna.setVisible(true); + scaleAsCdna.setSelected(ap.av.isScaleProteinAsCdna()); + } + if (tp != null) { Desktop.addInternalFrame(frame, MessageManager.getString("action.change_font_tree_panel"), - 340, 170, false); + 400, 200, false); } else { Desktop.addInternalFrame(frame, - MessageManager.getString("action.change_font"), 340, 170, + MessageManager.getString("action.change_font"), 380, 200, false); } @@ -111,7 +126,7 @@ public class FontChooser extends GFontChooser for (int i = 1; i < 51; i++) { - fontSize.addItem(i + ""); + fontSize.addItem(i); } fontStyle.addItem("plain"); @@ -119,7 +134,7 @@ public class FontChooser extends GFontChooser fontStyle.addItem("italic"); fontName.setSelectedItem(oldFont.getName()); - fontSize.setSelectedItem(oldFont.getSize() + ""); + fontSize.setSelectedItem(oldFont.getSize()); fontStyle.setSelectedIndex(oldFont.getStyle()); FontMetrics fm = getGraphics().getFontMetrics(oldFont); @@ -172,6 +187,7 @@ public class FontChooser extends GFontChooser if (ap != null) { ap.av.setFont(oldFont, true); + ap.av.setScaleProteinAsCdna(oldProteinScale); ap.paintAlignment(true); } else if (tp != null) @@ -179,7 +195,7 @@ public class FontChooser extends GFontChooser tp.setTreeFont(oldFont); } fontName.setSelectedItem(oldFont.getName()); - fontSize.setSelectedItem(oldFont.getSize() + ""); + fontSize.setSelectedItem(oldFont.getSize()); fontStyle.setSelectedIndex(oldFont.getStyle()); try @@ -216,8 +232,8 @@ public class FontChooser extends GFontChooser } Font newFont = new Font(fontName.getSelectedItem().toString(), - fontStyle.getSelectedIndex(), Integer.parseInt(fontSize - .getSelectedItem().toString())); + fontStyle.getSelectedIndex(), + (Integer) fontSize.getSelectedItem()); FontMetrics fm = getGraphics().getFontMetrics(newFont); double mw = fm.getStringBounds("M", getGraphics()).getWidth(), iw = fm .getStringBounds("I", getGraphics()).getWidth(); @@ -225,7 +241,7 @@ public class FontChooser extends GFontChooser { fontName.setSelectedItem(lastSelected.getName()); fontStyle.setSelectedIndex(lastSelStyle); - fontSize.setSelectedItem("" + lastSelSize); + fontSize.setSelectedItem(lastSelSize); monospaced.setSelected(lastSelMono); JOptionPane .showInternalMessageDialog( @@ -311,4 +327,16 @@ public class FontChooser extends GFontChooser Cache.setProperty("ANTI_ALIAS", Boolean.toString(smoothFont.isSelected())); } + + /** + * Turn on/off scaling of protein characters to 3 times the width of cDNA + * characters + */ + @Override + protected void scaleAsCdna_actionPerformed(ActionEvent e) + { + ap.av.setScaleProteinAsCdna(scaleAsCdna.isSelected()); + ((SplitFrame) ap.alignFrame.getSplitViewContainer()).adjustLayout(); + ap.paintAlignment(true); + } } diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 2a24491..ef9b030 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -20,17 +20,6 @@ */ package jalview.gui; -import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; -import jalview.bin.Cache; -import jalview.gui.Help.HelpId; -import jalview.gui.StructureViewer.ViewerType; -import jalview.io.JalviewFileChooser; -import jalview.io.JalviewFileView; -import jalview.jbgui.GPreferences; -import jalview.jbgui.GSequenceLink; -import jalview.schemes.ColourSchemeProperty; -import jalview.util.MessageManager; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; @@ -53,6 +42,17 @@ import javax.swing.JPanel; import ext.edu.ucsf.rbvi.strucviz2.StructureManager; +import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; +import jalview.bin.Cache; +import jalview.gui.Help.HelpId; +import jalview.gui.StructureViewer.ViewerType; +import jalview.io.JalviewFileChooser; +import jalview.io.JalviewFileView; +import jalview.jbgui.GPreferences; +import jalview.jbgui.GSequenceLink; +import jalview.schemes.ColourSchemeProperty; +import jalview.util.MessageManager; + /** * DOCUMENT ME! * @@ -62,6 +62,8 @@ import ext.edu.ucsf.rbvi.strucviz2.StructureManager; public class Preferences extends GPreferences { + public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA"; + public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR"; public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT"; @@ -171,11 +173,11 @@ public class Preferences extends GPreferences dasTab.add(dasSource, BorderLayout.CENTER); wsPrefs = new WsPreferences(); wsTab.add(wsPrefs, BorderLayout.CENTER); - int width = 500, height = 420; + int width = 500, height = 450; if (new jalview.util.Platform().isAMac()) { width = 570; - height = 460; + height = 480; } Desktop.addInternalFrame(frame, @@ -231,6 +233,8 @@ public class Preferences extends GPreferences + "")); smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false)); + scaleProteinToCdna.setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA, + false)); idItalics.setSelected(Cache.getDefault("ID_ITALICS", true)); @@ -430,6 +434,8 @@ public class Preferences extends GPreferences Boolean.toString(showConsensLogo.isSelected())); Cache.applicationProperties.setProperty("ANTI_ALIAS", Boolean.toString(smoothFont.isSelected())); + Cache.applicationProperties.setProperty(SCALE_PROTEIN_TO_CDNA, + Boolean.toString(scaleProteinToCdna.isSelected())); Cache.applicationProperties.setProperty("SHOW_NPFEATS_TOOLTIP", Boolean.toString(showNpTooltip.isSelected())); Cache.applicationProperties.setProperty("SHOW_DBREFS_TOOLTIP", diff --git a/src/jalview/gui/SplitFrame.java b/src/jalview/gui/SplitFrame.java index 5c4e4d2..bfb3719 100644 --- a/src/jalview/gui/SplitFrame.java +++ b/src/jalview/gui/SplitFrame.java @@ -100,7 +100,7 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI public void adjustLayout() { /* - * Ensure sequence ids are the same width for good alignment. + * Ensure sequence ids are the same width so sequences line up */ int w1 = ((AlignFrame) getTopFrame()).getViewport().getIdWidth(); int w2 = ((AlignFrame) getBottomFrame()).getViewport().getIdWidth(); @@ -115,26 +115,22 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI } /* - * Set the character width for protein to 3 times that for dna. + * Scale protein to either 1 or 3 times character width of dna */ - boolean scaleThreeToOne = true; // TODO a new Preference option? - if (scaleThreeToOne) + 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 + : (bottomAlignment.isNucleotide() ? bottomViewport : null); + AlignmentViewport protein = !topAlignment.isNucleotide() ? topViewport + : (!bottomAlignment.isNucleotide() ? bottomViewport : null); + if (protein != null && cdna != null) { - 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 - : (bottomAlignment.isNucleotide() ? bottomViewport : null); - AlignmentViewport protein = !topAlignment.isNucleotide() ? topViewport - : (!bottomAlignment.isNucleotide() ? bottomViewport : null); - if (protein != null && cdna != null) - { - ViewStyleI vs = cdna.getViewStyle(); - ViewStyleI vs2 = protein.getViewStyle(); - vs2.setCharWidth(3 * vs.getCharWidth()); - protein.setViewStyle(vs2); - } + ViewStyleI vs = protein.getViewStyle(); + int scale = vs.isScaleProteinAsCdna() ? 3 : 1; + vs.setCharWidth(scale * cdna.getViewStyle().getCharWidth()); + protein.setViewStyle(vs); } } diff --git a/src/jalview/jbgui/GFontChooser.java b/src/jalview/jbgui/GFontChooser.java index 2a2676c..f379de8 100755 --- a/src/jalview/jbgui/GFontChooser.java +++ b/src/jalview/jbgui/GFontChooser.java @@ -20,13 +20,24 @@ */ package jalview.jbgui; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingConstants; + import jalview.gui.JvSwingUtils; import jalview.util.MessageManager; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - /** * DOCUMENT ME! * @@ -35,43 +46,21 @@ import javax.swing.*; */ public class GFontChooser extends JPanel { - JLabel jLabel1 = new JLabel(); - - protected JComboBox fontSize = new JComboBox(); - - protected JComboBox fontStyle = new JComboBox(); - - JLabel jLabel2 = new JLabel(); - - JLabel jLabel3 = new JLabel(); - - protected JComboBox fontName = new JComboBox(); + private static final Font VERDANA_11PT = new java.awt.Font("Verdana", 0, 11); - JButton ok = new JButton(); + protected JComboBox fontSize = new JComboBox(); - JButton cancel = new JButton(); + protected JComboBox fontStyle = new JComboBox(); - JPanel jPanel1 = new JPanel(); - - JPanel jPanel2 = new JPanel(); - - JPanel jPanel3 = new JPanel(); - - BorderLayout borderLayout1 = new BorderLayout(); - - BorderLayout borderLayout2 = new BorderLayout(); - - BorderLayout borderLayout3 = new BorderLayout(); + protected JComboBox fontName = new JComboBox(); protected JButton defaultButton = new JButton(); protected JCheckBox smoothFont = new JCheckBox(); - BorderLayout borderLayout4 = new BorderLayout(); - protected JCheckBox monospaced = new JCheckBox(); - JPanel jPanel4 = new JPanel(); + protected JCheckBox scaleAsCdna = new JCheckBox(); /** * Creates a new GFontChooser object. @@ -95,12 +84,15 @@ public class GFontChooser extends JPanel */ private void jbInit() throws Exception { - jLabel1.setFont(new java.awt.Font("Verdana", 0, 11)); - jLabel1.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel1.setText(MessageManager.getString("label.font")); - jLabel1.setVerticalTextPosition(javax.swing.SwingConstants.CENTER); this.setLayout(null); - fontSize.setFont(new java.awt.Font("Verdana", 0, 11)); + this.setBackground(Color.white); + + JLabel fontLabel = new JLabel(MessageManager.getString("label.font")); + fontLabel.setFont(VERDANA_11PT); + fontLabel.setHorizontalAlignment(SwingConstants.RIGHT); + fontLabel.setVerticalTextPosition(javax.swing.SwingConstants.CENTER); + + fontSize.setFont(VERDANA_11PT); fontSize.setOpaque(false); fontSize.setPreferredSize(new Dimension(50, 21)); fontSize.addActionListener(new java.awt.event.ActionListener() @@ -110,7 +102,8 @@ public class GFontChooser extends JPanel fontSize_actionPerformed(e); } }); - fontStyle.setFont(new java.awt.Font("Verdana", 0, 11)); + + fontStyle.setFont(VERDANA_11PT); fontStyle.setOpaque(false); fontStyle.setPreferredSize(new Dimension(90, 21)); fontStyle.addActionListener(new java.awt.event.ActionListener() @@ -120,15 +113,18 @@ public class GFontChooser extends JPanel fontStyle_actionPerformed(e); } }); - jLabel2.setFont(new java.awt.Font("Verdana", 0, 11)); - jLabel2.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel2.setText(MessageManager.getString("label.size")); - jLabel2.setVerticalTextPosition(javax.swing.SwingConstants.CENTER); - jLabel3.setFont(new java.awt.Font("Verdana", 0, 11)); - jLabel3.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel3.setText(MessageManager.getString("label.style")); - jLabel3.setVerticalTextPosition(javax.swing.SwingConstants.CENTER); - fontName.setFont(new java.awt.Font("Verdana", 0, 11)); + + JLabel sizeLabel = new JLabel(MessageManager.getString("label.size")); + sizeLabel.setFont(VERDANA_11PT); + sizeLabel.setHorizontalAlignment(SwingConstants.RIGHT); + sizeLabel.setVerticalTextPosition(javax.swing.SwingConstants.CENTER); + + JLabel styleLabel = new JLabel(MessageManager.getString("label.style")); + styleLabel.setFont(VERDANA_11PT); + styleLabel.setHorizontalAlignment(SwingConstants.RIGHT); + styleLabel.setVerticalTextPosition(javax.swing.SwingConstants.CENTER); + + fontName.setFont(VERDANA_11PT); fontName.setMaximumSize(new Dimension(32767, 32767)); fontName.setMinimumSize(new Dimension(300, 21)); fontName.setOpaque(false); @@ -140,8 +136,9 @@ public class GFontChooser extends JPanel fontName_actionPerformed(e); } }); - ok.setFont(new java.awt.Font("Verdana", 0, 11)); - ok.setText(MessageManager.getString("action.ok")); + + JButton ok = new JButton(MessageManager.getString("action.ok")); + ok.setFont(VERDANA_11PT); ok.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) @@ -149,8 +146,9 @@ public class GFontChooser extends JPanel ok_actionPerformed(e); } }); - cancel.setFont(new java.awt.Font("Verdana", 0, 11)); - cancel.setText(MessageManager.getString("action.cancel")); + + JButton cancel = new JButton(MessageManager.getString("action.cancel")); + cancel.setFont(VERDANA_11PT); cancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) @@ -158,16 +156,7 @@ public class GFontChooser extends JPanel cancel_actionPerformed(e); } }); - this.setBackground(Color.white); - jPanel1.setOpaque(false); - jPanel1.setBounds(new Rectangle(5, 6, 308, 23)); - jPanel1.setLayout(borderLayout1); - jPanel2.setOpaque(false); - jPanel2.setBounds(new Rectangle(5, 37, 128, 21)); - jPanel2.setLayout(borderLayout3); - jPanel3.setOpaque(false); - jPanel3.setBounds(new Rectangle(174, 38, 134, 21)); - jPanel3.setLayout(borderLayout2); + defaultButton.setFont(JvSwingUtils.getLabelFont()); defaultButton.setText(MessageManager.getString("label.set_as_default")); defaultButton.addActionListener(new ActionListener() @@ -177,10 +166,11 @@ public class GFontChooser extends JPanel defaultButton_actionPerformed(e); } }); + smoothFont.setFont(JvSwingUtils.getLabelFont()); smoothFont.setOpaque(false); smoothFont.setText(MessageManager.getString("label.anti_alias_fonts")); - smoothFont.setBounds(new Rectangle(41, 65, 223, 23)); + smoothFont.setBounds(new Rectangle(41, 65, 260, 23)); smoothFont.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -188,31 +178,83 @@ public class GFontChooser extends JPanel smoothFont_actionPerformed(e); } }); + + /* + * Scale protein as cDNA is only visible in SplitFrame protein alignment + */ + scaleAsCdna.setVisible(false); + scaleAsCdna.setFont(JvSwingUtils.getLabelFont()); + scaleAsCdna.setOpaque(false); + scaleAsCdna.setText(MessageManager.getString("label.scale_as_cdna")); + scaleAsCdna.setBounds(new Rectangle(41, 85, 260, 23)); + scaleAsCdna.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + scaleAsCdna_actionPerformed(e); + } + }); + monospaced.setEnabled(false); monospaced.setFont(JvSwingUtils.getLabelFont()); monospaced.setOpaque(false); monospaced.setToolTipText(MessageManager .getString("label.monospaced_fonts_faster_to_render")); monospaced.setText(MessageManager.getString("label.monospaced_font")); - jPanel4.setOpaque(false); - jPanel4.setBounds(new Rectangle(24, 92, 259, 35)); - jPanel1.add(jLabel1, BorderLayout.WEST); + + /* + * jPanel1: Font dropdown, Monospaced checkbox + */ + JPanel jPanel1 = new JPanel(); + jPanel1.setOpaque(false); + jPanel1.setBounds(new Rectangle(5, 6, 308, 23)); + jPanel1.setLayout(new BorderLayout()); + jPanel1.add(fontLabel, BorderLayout.WEST); jPanel1.add(fontName, BorderLayout.CENTER); jPanel1.add(monospaced, java.awt.BorderLayout.EAST); - this.add(jPanel3, null); - this.add(jPanel2, null); + + /* + * jPanel2: font size dropdown + */ + JPanel jPanel2 = new JPanel(); + jPanel2.setOpaque(false); + jPanel2.setBounds(new Rectangle(5, 37, 128, 21)); + jPanel2.setLayout(new BorderLayout()); jPanel2.add(fontSize, java.awt.BorderLayout.CENTER); - jPanel2.add(jLabel2, java.awt.BorderLayout.WEST); + jPanel2.add(sizeLabel, java.awt.BorderLayout.WEST); + + /* + * jPanel3: font style dropdown + */ + JPanel jPanel3 = new JPanel(); + jPanel3.setOpaque(false); + jPanel3.setBounds(new Rectangle(174, 38, 134, 21)); + jPanel3.setLayout(new BorderLayout()); + jPanel3.add(styleLabel, java.awt.BorderLayout.WEST); + jPanel3.add(fontStyle, java.awt.BorderLayout.CENTER); + + /* + * jPanel4: Default and OK buttons + */ + JPanel jPanel4 = new JPanel(); + jPanel4.setOpaque(false); + jPanel4.setBounds(new Rectangle(24, 112, 300, 35)); jPanel4.add(defaultButton); jPanel4.add(ok); jPanel4.add(cancel); + this.add(smoothFont); + this.add(scaleAsCdna); + this.add(jPanel3, null); + this.add(jPanel2, null); this.add(jPanel4); - jPanel3.add(jLabel3, java.awt.BorderLayout.WEST); - jPanel3.add(fontStyle, java.awt.BorderLayout.CENTER); this.add(jPanel1, null); } + protected void scaleAsCdna_actionPerformed(ActionEvent e) + { + } + /** * DOCUMENT ME! * diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index 1d35477..97edb36 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -20,11 +20,6 @@ */ package jalview.jbgui; -import jalview.gui.JvSwingUtils; -import jalview.gui.StructureViewer.ViewerType; -import jalview.jbgui.PDBDocFieldPreferences.PreferenceSource; -import jalview.util.MessageManager; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -59,12 +54,18 @@ import javax.swing.ListSelectionModel; import javax.swing.SwingConstants; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; +import javax.swing.border.EtchedBorder; import javax.swing.border.TitledBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import jalview.gui.JvSwingUtils; +import jalview.gui.StructureViewer.ViewerType; +import jalview.jbgui.PDBDocFieldPreferences.PreferenceSource; +import jalview.util.MessageManager; + /** * Base class for the Preferences panel. * @@ -73,7 +74,10 @@ import javax.swing.event.ListSelectionListener; */ public class GPreferences extends JPanel { - private static final Font verdana11 = JvSwingUtils.getLabelFont(); + private static final Font LABEL_FONT = JvSwingUtils.getLabelFont(); + + private static final Font LABEL_FONT_ITALIC = JvSwingUtils + .getLabelFont(false, true); /* * Visual tab components @@ -98,6 +102,8 @@ public class GPreferences extends JPanel protected JCheckBox smoothFont = new JCheckBox(); + protected JCheckBox scaleProteinToCdna = new JCheckBox(); + protected JComboBox gapSymbolCB = new JComboBox(); protected JCheckBox wrap = new JCheckBox(); @@ -320,14 +326,14 @@ public class GPreferences extends JPanel { JPanel editingTab = new JPanel(); editingTab.setLayout(null); - autoCalculateConsCheck.setFont(verdana11); + autoCalculateConsCheck.setFont(LABEL_FONT); autoCalculateConsCheck.setText(MessageManager .getString("label.autocalculate_consensus")); autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23)); - padGaps.setFont(verdana11); + padGaps.setFont(LABEL_FONT); padGaps.setText(MessageManager.getString("label.pad_gaps_when_editing")); padGaps.setBounds(new Rectangle(22, 94, 168, 23)); - sortByTree.setFont(verdana11); + sortByTree.setFont(LABEL_FONT); sortByTree .setText(MessageManager.getString("label.sort_with_new_tree")); sortByTree @@ -350,18 +356,18 @@ public class GPreferences extends JPanel JPanel outputTab = new JPanel(); outputTab.setLayout(null); JLabel epsLabel = new JLabel(); - epsLabel.setFont(verdana11); + epsLabel.setFont(LABEL_FONT); epsLabel.setHorizontalAlignment(SwingConstants.RIGHT); epsLabel.setText(MessageManager.getString("label.eps_rendering_style")); epsLabel.setBounds(new Rectangle(9, 31, 140, 24)); - epsRendering.setFont(verdana11); + epsRendering.setFont(LABEL_FONT); epsRendering.setBounds(new Rectangle(154, 34, 187, 21)); JLabel jLabel1 = new JLabel(); - jLabel1.setFont(verdana11); + jLabel1.setFont(LABEL_FONT); jLabel1.setHorizontalAlignment(SwingConstants.CENTER); jLabel1.setText(MessageManager.getString("label.append_start_end")); - jLabel1.setFont(verdana11); - fastajv.setFont(verdana11); + jLabel1.setFont(LABEL_FONT); + fastajv.setFont(LABEL_FONT); fastajv.setHorizontalAlignment(SwingConstants.LEFT); clustaljv.setText(MessageManager.getString("label.clustal") + " "); blcjv.setText(MessageManager.getString("label.blc") + " "); @@ -369,11 +375,11 @@ public class GPreferences extends JPanel msfjv.setText(MessageManager.getString("label.msf") + " "); pfamjv.setText(MessageManager.getString("label.pfam") + " "); pileupjv.setText(MessageManager.getString("label.pileup") + " "); - msfjv.setFont(verdana11); + msfjv.setFont(LABEL_FONT); msfjv.setHorizontalAlignment(SwingConstants.LEFT); pirjv.setText(MessageManager.getString("label.pir") + " "); JPanel jPanel11 = new JPanel(); - jPanel11.setFont(verdana11); + jPanel11.setFont(LABEL_FONT); TitledBorder titledBorder2 = new TitledBorder( MessageManager.getString("label.file_output")); jPanel11.setBorder(titledBorder2); @@ -381,17 +387,17 @@ public class GPreferences extends JPanel GridLayout gridLayout3 = new GridLayout(); jPanel11.setLayout(gridLayout3); gridLayout3.setRows(8); - blcjv.setFont(verdana11); + blcjv.setFont(LABEL_FONT); blcjv.setHorizontalAlignment(SwingConstants.LEFT); - clustaljv.setFont(verdana11); + clustaljv.setFont(LABEL_FONT); clustaljv.setHorizontalAlignment(SwingConstants.LEFT); - pfamjv.setFont(verdana11); + pfamjv.setFont(LABEL_FONT); pfamjv.setHorizontalAlignment(SwingConstants.LEFT); - pileupjv.setFont(verdana11); + pileupjv.setFont(LABEL_FONT); pileupjv.setHorizontalAlignment(SwingConstants.LEFT); - pirjv.setFont(verdana11); + pirjv.setFont(LABEL_FONT); pirjv.setHorizontalAlignment(SwingConstants.LEFT); - autoIdWidth.setFont(verdana11); + autoIdWidth.setFont(LABEL_FONT); autoIdWidth.setText(MessageManager .getString("label.automatically_set_id_width")); autoIdWidth @@ -406,7 +412,7 @@ public class GPreferences extends JPanel autoIdWidth_actionPerformed(); } }); - userIdWidthlabel.setFont(verdana11); + userIdWidthlabel.setFont(LABEL_FONT); userIdWidthlabel.setText(MessageManager .getString("label.figure_id_column_width")); userIdWidth @@ -441,7 +447,7 @@ public class GPreferences extends JPanel outputTab.add(epsLabel); outputTab.add(epsRendering); outputTab.add(jPanel11); - modellerOutput.setFont(verdana11); + modellerOutput.setFont(LABEL_FONT); modellerOutput.setText(MessageManager .getString("label.use_modeller_output")); modellerOutput.setBounds(new Rectangle(228, 226, 168, 23)); @@ -460,11 +466,11 @@ public class GPreferences extends JPanel JLabel serverLabel = new JLabel(); serverLabel.setText(MessageManager.getString("label.address")); serverLabel.setHorizontalAlignment(SwingConstants.RIGHT); - serverLabel.setFont(verdana11); - proxyServerTB.setFont(verdana11); - proxyPortTB.setFont(verdana11); + serverLabel.setFont(LABEL_FONT); + proxyServerTB.setFont(LABEL_FONT); + proxyPortTB.setFont(LABEL_FONT); JLabel portLabel = new JLabel(); - portLabel.setFont(verdana11); + portLabel.setFont(LABEL_FONT); portLabel.setHorizontalAlignment(SwingConstants.RIGHT); portLabel.setText(MessageManager.getString("label.port")); JLabel browserLabel = new JLabel(); @@ -472,21 +478,21 @@ public class GPreferences extends JPanel browserLabel.setHorizontalAlignment(SwingConstants.TRAILING); browserLabel.setText(MessageManager .getString("label.default_browser_unix")); - defaultBrowser.setFont(verdana11); + defaultBrowser.setFont(LABEL_FONT); defaultBrowser.setText(""); usagestats.setText(MessageManager .getString("label.send_usage_statistics")); - usagestats.setFont(verdana11); + usagestats.setFont(LABEL_FONT); usagestats.setHorizontalAlignment(SwingConstants.RIGHT); usagestats.setHorizontalTextPosition(SwingConstants.LEADING); questionnaire.setText(MessageManager .getString("label.check_for_questionnaires")); - questionnaire.setFont(verdana11); + questionnaire.setFont(LABEL_FONT); questionnaire.setHorizontalAlignment(SwingConstants.RIGHT); questionnaire.setHorizontalTextPosition(SwingConstants.LEADING); versioncheck.setText(MessageManager .getString("label.check_for_latest_version")); - versioncheck.setFont(verdana11); + versioncheck.setFont(LABEL_FONT); versioncheck.setHorizontalAlignment(SwingConstants.RIGHT); versioncheck.setHorizontalTextPosition(SwingConstants.LEADING); JButton newLink = new JButton(); @@ -545,12 +551,12 @@ public class GPreferences extends JPanel JPanel editLinkButtons = new JPanel(); editLinkButtons.setLayout(gridLayout1); gridLayout1.setRows(3); - linkNameList.setFont(verdana11); + linkNameList.setFont(LABEL_FONT); linkNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); BorderLayout borderLayout3 = new BorderLayout(); JPanel linkPanel2 = new JPanel(); linkPanel2.setLayout(borderLayout3); - linkURLList.setFont(verdana11); + linkURLList.setFont(LABEL_FONT); linkURLList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); defaultBrowser.addMouseListener(new MouseAdapter() @@ -563,7 +569,7 @@ public class GPreferences extends JPanel } } }); - useProxy.setFont(verdana11); + useProxy.setFont(LABEL_FONT); useProxy.setHorizontalAlignment(SwingConstants.RIGHT); useProxy.setHorizontalTextPosition(SwingConstants.LEADING); useProxy.setText(MessageManager.getString("label.use_proxy_server")); @@ -669,10 +675,10 @@ public class GPreferences extends JPanel .getString("action.open_new_alignment"))); coloursTab.setLayout(new FlowLayout()); JLabel mincolourLabel = new JLabel(); - mincolourLabel.setFont(verdana11); + mincolourLabel.setFont(LABEL_FONT); mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT); mincolourLabel.setText(MessageManager.getString("label.min_colour")); - minColour.setFont(verdana11); + minColour.setFont(LABEL_FONT); minColour.setBorder(BorderFactory.createEtchedBorder()); minColour.setPreferredSize(new Dimension(40, 20)); minColour.addMouseListener(new MouseAdapter() @@ -683,10 +689,10 @@ public class GPreferences extends JPanel } }); JLabel maxcolourLabel = new JLabel(); - maxcolourLabel.setFont(verdana11); + maxcolourLabel.setFont(LABEL_FONT); maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT); maxcolourLabel.setText(MessageManager.getString("label.max_colour")); - maxColour.setFont(verdana11); + maxColour.setFont(LABEL_FONT); maxColour.setBorder(BorderFactory.createEtchedBorder()); maxColour.setPreferredSize(new Dimension(40, 20)); maxColour.addMouseListener(new MouseAdapter() @@ -697,10 +703,10 @@ public class GPreferences extends JPanel } }); - protColour.setFont(verdana11); + protColour.setFont(LABEL_FONT); protColour.setBounds(new Rectangle(172, 225, 155, 21)); JLabel protColourLabel = new JLabel(); - protColourLabel.setFont(verdana11); + protColourLabel.setFont(LABEL_FONT); protColourLabel.setHorizontalAlignment(SwingConstants.LEFT); protColourLabel.setText(MessageManager .getString("label.prot_alignment_colour") + " "); @@ -708,10 +714,10 @@ public class GPreferences extends JPanel .getString("label.default_colour_scheme_for_alignment"), protColourLabel, protColour); - nucColour.setFont(verdana11); + nucColour.setFont(LABEL_FONT); nucColour.setBounds(new Rectangle(172, 240, 155, 21)); JLabel nucColourLabel = new JLabel(); - nucColourLabel.setFont(verdana11); + nucColourLabel.setFont(LABEL_FONT); nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT); nucColourLabel.setText(MessageManager .getString("label.nuc_alignment_colour") @@ -751,7 +757,7 @@ public class GPreferences extends JPanel final int lineSpacing = 25; int ypos = 30; - structFromPdb.setFont(verdana11); + structFromPdb.setFont(LABEL_FONT); structFromPdb.setText(MessageManager.getString("label.struct_from_pdb")); structFromPdb.setBounds(new Rectangle(5, ypos, width, height)); structFromPdb.addActionListener(new ActionListener() @@ -770,33 +776,33 @@ public class GPreferences extends JPanel // indent checkboxes that are conditional on the first one ypos += lineSpacing; - useRnaView.setFont(verdana11); + useRnaView.setFont(LABEL_FONT); useRnaView.setText(MessageManager.getString("label.use_rnaview")); useRnaView.setBounds(new Rectangle(25, ypos, width, height)); structureTab.add(useRnaView); ypos += lineSpacing; - addSecondaryStructure.setFont(verdana11); + addSecondaryStructure.setFont(LABEL_FONT); addSecondaryStructure.setText(MessageManager .getString("label.autoadd_secstr")); addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height)); structureTab.add(addSecondaryStructure); ypos += lineSpacing; - addTempFactor.setFont(verdana11); + addTempFactor.setFont(LABEL_FONT); addTempFactor.setText(MessageManager.getString("label.autoadd_temp")); addTempFactor.setBounds(new Rectangle(25, ypos, width, height)); structureTab.add(addTempFactor); ypos += lineSpacing; JLabel viewerLabel = new JLabel(); - viewerLabel.setFont(verdana11); + viewerLabel.setFont(LABEL_FONT); viewerLabel.setHorizontalAlignment(SwingConstants.LEFT); viewerLabel.setText(MessageManager.getString("label.structure_viewer")); viewerLabel.setBounds(new Rectangle(10, ypos, 200, height)); structureTab.add(viewerLabel); - structViewer.setFont(verdana11); + structViewer.setFont(LABEL_FONT); structViewer.setBounds(new Rectangle(160, ypos, 120, height)); structViewer.addItem(ViewerType.JMOL.name()); structViewer.addItem(ViewerType.CHIMERA.name()); @@ -822,7 +828,7 @@ public class GPreferences extends JPanel pathLabel.setBounds(new Rectangle(10, ypos, 140, height)); structureTab.add(pathLabel); - chimeraPath.setFont(verdana11); + chimeraPath.setFont(LABEL_FONT); chimeraPath.setText(""); chimeraPath.setBounds(new Rectangle(160, ypos, 300, height)); chimeraPath.addMouseListener(new MouseAdapter() @@ -924,81 +930,81 @@ public class GPreferences extends JPanel visualTab.setBorder(new TitledBorder(MessageManager .getString("action.open_new_alignment"))); visualTab.setLayout(null); - fullScreen.setFont(verdana11); + fullScreen.setFont(LABEL_FONT); fullScreen.setHorizontalAlignment(SwingConstants.RIGHT); fullScreen.setHorizontalTextPosition(SwingConstants.LEFT); fullScreen.setText(MessageManager.getString("label.maximize_window")); quality.setEnabled(false); - quality.setFont(verdana11); + quality.setFont(LABEL_FONT); quality.setHorizontalAlignment(SwingConstants.RIGHT); quality.setHorizontalTextPosition(SwingConstants.LEFT); quality.setSelected(true); quality.setText(MessageManager.getString("label.quality")); conservation.setEnabled(false); - conservation.setFont(verdana11); + conservation.setFont(LABEL_FONT); conservation.setHorizontalAlignment(SwingConstants.RIGHT); conservation.setHorizontalTextPosition(SwingConstants.LEFT); conservation.setSelected(true); conservation.setText(MessageManager.getString("label.conservation")); identity.setEnabled(false); - identity.setFont(verdana11); + identity.setFont(LABEL_FONT); identity.setHorizontalAlignment(SwingConstants.RIGHT); identity.setHorizontalTextPosition(SwingConstants.LEFT); identity.setSelected(true); identity.setText(MessageManager.getString("label.consensus")); JLabel showGroupbits = new JLabel(); - showGroupbits.setFont(verdana11); + showGroupbits.setFont(LABEL_FONT); showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT); showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT); showGroupbits.setText(MessageManager.getString("action.show_group") + ":"); JLabel showConsensbits = new JLabel(); - showConsensbits.setFont(verdana11); + showConsensbits.setFont(LABEL_FONT); showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT); showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT); showConsensbits.setText(MessageManager.getString("label.consensus") + ":"); showConsensHistogram.setEnabled(false); - showConsensHistogram.setFont(verdana11); + showConsensHistogram.setFont(LABEL_FONT); showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT); showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT); showConsensHistogram.setSelected(true); showConsensHistogram.setText(MessageManager .getString("label.histogram")); showConsensLogo.setEnabled(false); - showConsensLogo.setFont(verdana11); + showConsensLogo.setFont(LABEL_FONT); showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT); showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT); showConsensLogo.setSelected(true); showConsensLogo.setText(MessageManager.getString("label.logo")); showGroupConsensus.setEnabled(false); - showGroupConsensus.setFont(verdana11); + showGroupConsensus.setFont(LABEL_FONT); showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT); showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT); showGroupConsensus.setSelected(true); showGroupConsensus.setText(MessageManager.getString("label.consensus")); showGroupConservation.setEnabled(false); - showGroupConservation.setFont(verdana11); + showGroupConservation.setFont(LABEL_FONT); showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT); showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT); showGroupConservation.setSelected(true); showGroupConservation.setText(MessageManager .getString("label.conservation")); showNpTooltip.setEnabled(true); - showNpTooltip.setFont(verdana11); + showNpTooltip.setFont(LABEL_FONT); showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT); showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT); showNpTooltip.setSelected(true); showNpTooltip.setText(MessageManager .getString("label.non_positional_features")); showDbRefTooltip.setEnabled(true); - showDbRefTooltip.setFont(verdana11); + showDbRefTooltip.setFont(LABEL_FONT); showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT); showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT); showDbRefTooltip.setSelected(true); showDbRefTooltip.setText(MessageManager .getString("label.database_references")); - annotations.setFont(verdana11); + annotations.setFont(LABEL_FONT); annotations.setHorizontalAlignment(SwingConstants.RIGHT); annotations.setHorizontalTextPosition(SwingConstants.LEADING); annotations.setSelected(true); @@ -1025,7 +1031,7 @@ public class GPreferences extends JPanel annotations_actionPerformed(e); } }); - showUnconserved.setFont(verdana11); + showUnconserved.setFont(LABEL_FONT); showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT); showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT); showUnconserved.setSelected(true); @@ -1056,41 +1062,48 @@ public class GPreferences extends JPanel // followHighlight.setText(MessageManager // .getString("label.scroll_highlighted_regions")); - seqLimit.setFont(verdana11); + seqLimit.setFont(LABEL_FONT); seqLimit.setHorizontalAlignment(SwingConstants.RIGHT); seqLimit.setHorizontalTextPosition(SwingConstants.LEFT); seqLimit.setText(MessageManager.getString("label.full_sequence_id")); - smoothFont.setFont(verdana11); + smoothFont.setFont(LABEL_FONT); smoothFont.setHorizontalAlignment(SwingConstants.RIGHT); smoothFont.setHorizontalTextPosition(SwingConstants.LEADING); smoothFont.setText(MessageManager.getString("label.smooth_font")); + scaleProteinToCdna.setFont(LABEL_FONT); + scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT); + scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING); + scaleProteinToCdna.setText(MessageManager + .getString("label.scale_protein_to_cdna")); + scaleProteinToCdna.setToolTipText(MessageManager + .getString("label.scale_protein_to_cdna_tip")); JLabel gapLabel = new JLabel(); - gapLabel.setFont(verdana11); + gapLabel.setFont(LABEL_FONT); gapLabel.setHorizontalAlignment(SwingConstants.RIGHT); gapLabel.setText(MessageManager.getString("label.gap_symbol") + " "); JLabel fontLabel = new JLabel(); - fontLabel.setFont(verdana11); + fontLabel.setFont(LABEL_FONT); fontLabel.setHorizontalAlignment(SwingConstants.RIGHT); fontLabel.setText(MessageManager.getString("label.font")); - fontSizeCB.setFont(verdana11); - fontSizeCB.setBounds(new Rectangle(320, 104, 65, 23)); - fontStyleCB.setFont(verdana11); - fontStyleCB.setBounds(new Rectangle(382, 104, 80, 23)); - fontNameCB.setFont(verdana11); - fontNameCB.setBounds(new Rectangle(172, 104, 147, 23)); - gapSymbolCB.setFont(verdana11); - gapSymbolCB.setBounds(new Rectangle(172, 196, 69, 23)); + fontSizeCB.setFont(LABEL_FONT); + fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23)); + fontStyleCB.setFont(LABEL_FONT); + fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23)); + fontNameCB.setFont(LABEL_FONT); + fontNameCB.setBounds(new Rectangle(172, 112, 147, 23)); + gapSymbolCB.setFont(LABEL_FONT); + gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23)); DefaultListCellRenderer dlcr = new DefaultListCellRenderer(); dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER); gapSymbolCB.setRenderer(dlcr); startupCheckbox.setText(MessageManager.getString("action.open_file")); - startupCheckbox.setFont(verdana11); + startupCheckbox.setFont(LABEL_FONT); startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT); startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT); startupCheckbox.setSelected(true); - startupFileTextfield.setFont(verdana11); - startupFileTextfield.setBounds(new Rectangle(172, 290, 270, 20)); + startupFileTextfield.setFont(LABEL_FONT); + startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20)); startupFileTextfield.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) @@ -1102,32 +1115,25 @@ public class GPreferences extends JPanel } }); - sortby.setFont(verdana11); - sortby.setBounds(new Rectangle(172, 240, 155, 21)); + sortby.setFont(LABEL_FONT); + sortby.setBounds(new Rectangle(172, 260, 155, 21)); JLabel sortLabel = new JLabel(); - sortLabel.setFont(verdana11); + sortLabel.setFont(LABEL_FONT); sortLabel.setHorizontalAlignment(SwingConstants.RIGHT); sortLabel.setText(MessageManager.getString("label.sort_by")); - sortAnnBy.setFont(verdana11); - sortAnnBy.setBounds(new Rectangle(172, 265, 110, 21)); + sortAnnBy.setFont(LABEL_FONT); + sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21)); JLabel sortAnnLabel = new JLabel(); - sortAnnLabel.setFont(verdana11); + sortAnnLabel.setFont(LABEL_FONT); sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT); sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by")); - sortAutocalc.setFont(verdana11); - sortAutocalc.setBounds(new Rectangle(290, 265, 165, 21)); + sortAutocalc.setFont(LABEL_FONT); + sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21)); + JPanel annsettingsPanel = new JPanel(); - annsettingsPanel.setBounds(new Rectangle(173, 34, 300, 61)); + annsettingsPanel.setBounds(new Rectangle(173, 34, 320, 75)); annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - JPanel autoAnnotSettings1 = new JPanel(); - autoAnnotSettings1.setLayout(new GridLayout(3, 1, 0, 0)); - annsettingsPanel.add(autoAnnotSettings1); - JPanel autoAnnotSettings2 = new JPanel(); - autoAnnotSettings2.setLayout(new GridLayout(3, 1, 0, 0)); - annsettingsPanel.add(autoAnnotSettings2); - JPanel autoAnnotSettings3 = new JPanel(); - autoAnnotSettings3.setLayout(new GridLayout(3, 1, 0, 0)); - annsettingsPanel.add(autoAnnotSettings3); + annsettingsPanel.setBorder(new EtchedBorder()); visualTab.add(annsettingsPanel); Border jb = new EmptyBorder(1, 1, 4, 5); quality.setBorder(jb); @@ -1140,50 +1146,51 @@ public class GPreferences extends JPanel showConsensHistogram.setBorder(jb); showConsensLogo.setBorder(jb); - autoAnnotSettings2.add(conservation); - autoAnnotSettings1.add(quality); - autoAnnotSettings3.add(identity); - autoAnnotSettings1.add(showGroupbits); - autoAnnotSettings3.add(showGroupConsensus); - autoAnnotSettings2.add(showGroupConservation); - autoAnnotSettings1.add(showConsensbits); - autoAnnotSettings2.add(showConsensHistogram); - autoAnnotSettings3.add(showConsensLogo); + JPanel autoAnnotSettings = new JPanel(); + autoAnnotSettings.setLayout(new GridLayout(3, 3)); + annsettingsPanel.add(autoAnnotSettings); + autoAnnotSettings.add(quality); + autoAnnotSettings.add(conservation); + autoAnnotSettings.add(identity); + autoAnnotSettings.add(showGroupbits); + autoAnnotSettings.add(showGroupConservation); + autoAnnotSettings.add(showGroupConsensus); + autoAnnotSettings.add(showConsensbits); + autoAnnotSettings.add(showConsensHistogram); + autoAnnotSettings.add(showConsensLogo); JPanel tooltipSettings = new JPanel(); tooltipSettings.setBorder(new TitledBorder(MessageManager .getString("label.sequence_id_tooltip"))); - tooltipSettings.setBounds(173, 130, 200, 62); + tooltipSettings.setBounds(173, 140, 220, 62); tooltipSettings.setLayout(new GridLayout(2, 1)); tooltipSettings.add(showDbRefTooltip); tooltipSettings.add(showNpTooltip); visualTab.add(tooltipSettings); - wrap.setFont(verdana11); + wrap.setFont(LABEL_FONT); wrap.setHorizontalAlignment(SwingConstants.TRAILING); wrap.setHorizontalTextPosition(SwingConstants.LEADING); wrap.setText(MessageManager.getString("label.wrap_alignment")); - rightAlign.setFont(verdana11); + rightAlign.setFont(LABEL_FONT); rightAlign.setForeground(Color.black); rightAlign.setHorizontalAlignment(SwingConstants.RIGHT); rightAlign.setHorizontalTextPosition(SwingConstants.LEFT); rightAlign.setText(MessageManager.getString("label.right_align_ids")); - idItalics.setFont(verdana11); + idItalics.setFont(LABEL_FONT_ITALIC); idItalics.setHorizontalAlignment(SwingConstants.RIGHT); idItalics.setHorizontalTextPosition(SwingConstants.LEADING); idItalics.setText(MessageManager .getString("label.sequence_name_italics")); - openoverv.setFont(verdana11); + openoverv.setFont(LABEL_FONT); openoverv.setActionCommand(MessageManager .getString("label.open_overview")); openoverv.setHorizontalAlignment(SwingConstants.RIGHT); openoverv.setHorizontalTextPosition(SwingConstants.LEFT); openoverv.setText(MessageManager.getString(("label.open_overview"))); JPanel jPanel2 = new JPanel(); - jPanel2.setBounds(new Rectangle(7, 17, 158, 297)); - GridLayout gridLayout2 = new GridLayout(); - jPanel2.setLayout(gridLayout2); - gridLayout2.setRows(13); + jPanel2.setBounds(new Rectangle(7, 17, 158, 310)); + jPanel2.setLayout(new GridLayout(14, 1)); jPanel2.add(fullScreen); jPanel2.add(openoverv); jPanel2.add(seqLimit); @@ -1192,6 +1199,7 @@ public class GPreferences extends JPanel jPanel2.add(showUnconserved); jPanel2.add(idItalics); jPanel2.add(smoothFont); + jPanel2.add(scaleProteinToCdna); jPanel2.add(gapLabel); jPanel2.add(wrap); jPanel2.add(sortLabel); diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 1270c15..c0e86cb 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -2411,4 +2411,16 @@ public abstract class AlignmentViewport implements AlignViewportI, { this.showAutocalculatedAbove = showAutocalculatedAbove; } + + @Override + public boolean isScaleProteinAsCdna() + { + return viewStyle.isScaleProteinAsCdna(); + } + + @Override + public void setScaleProteinAsCdna(boolean b) + { + viewStyle.setScaleProteinAsCdna(b); + } } diff --git a/src/jalview/viewmodel/styles/ViewStyle.java b/src/jalview/viewmodel/styles/ViewStyle.java index 1e97af4..fc34be8 100644 --- a/src/jalview/viewmodel/styles/ViewStyle.java +++ b/src/jalview/viewmodel/styles/ViewStyle.java @@ -1,11 +1,11 @@ package jalview.viewmodel.styles; -import jalview.api.ViewStyleI; - import java.awt.Color; import java.lang.reflect.Method; import java.util.HashMap; +import jalview.api.ViewStyleI; + /** * A container for holding alignment view properties. View properties are * data-independent, which means they can be safely copied between views @@ -139,11 +139,18 @@ public class ViewStyle implements ViewStyleI * name of base font for view */ private String fontName; + /** * size for base font */ private int fontSize; - + + /* + * If true, scale protein residues to 3 times width of cDNA bases (in + * SplitFrame views only) + */ + private boolean scaleProteinAsCdna = false; + public ViewStyle(ViewStyleI viewStyle) { ViewStyle.configureFrom(this, viewStyle); @@ -1004,4 +1011,16 @@ public class ViewStyle implements ViewStyleI { this.shownpfeats = shownpfeats; } + + @Override + public boolean isScaleProteinAsCdna() + { + return this.scaleProteinAsCdna; + } + + @Override + public void setScaleProteinAsCdna(boolean b) + { + this.scaleProteinAsCdna = b; + } } diff --git a/test/jalview/viewmodel/styles/TestviewStyle.java b/test/jalview/viewmodel/styles/TestviewStyle.java index 88ea82e..47735b5 100644 --- a/test/jalview/viewmodel/styles/TestviewStyle.java +++ b/test/jalview/viewmodel/styles/TestviewStyle.java @@ -13,11 +13,15 @@ public class TestviewStyle orig.setCharHeight(23); orig.setWrappedWidth(253); orig.setWrapAlignment(true); + orig.setScaleProteinAsCdna(true); + ViewStyle copy = new ViewStyle(orig); orig.setWrapAlignment(false); Assert.assertEquals(copy.getCharHeight(), orig.getCharHeight()); Assert.assertEquals(copy.getWrappedWidth(), orig.getWrappedWidth()); Assert.assertEquals(copy.getWrapAlignment(), !orig.getWrapAlignment()); + Assert.assertEquals(copy.isScaleProteinAsCdna(), + orig.isScaleProteinAsCdna()); } } -- 1.7.10.2