From 818c66fbbbc2cbe6a412776aa86d2a27e30d6e09 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Mon, 30 Jan 2006 14:55:58 +0000 Subject: [PATCH] Monospaced indicator --- src/jalview/gui/FontChooser.java | 15 +++++++++++++-- src/jalview/jbgui/GFontChooser.java | 24 +++++++++++++++++------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/jalview/gui/FontChooser.java b/src/jalview/gui/FontChooser.java index 33bb9de..6eab36b 100755 --- a/src/jalview/gui/FontChooser.java +++ b/src/jalview/gui/FontChooser.java @@ -71,9 +71,9 @@ public class FontChooser extends GFontChooser frame = new JInternalFrame(); frame.setContentPane(this); if(tp!=null) - Desktop.addInternalFrame(frame, "Change Font (Tree Panel)", 480, 100, false); + Desktop.addInternalFrame(frame, "Change Font (Tree Panel)", 540, 100, false); else - Desktop.addInternalFrame(frame, "Change Font", 480, 100, false); + Desktop.addInternalFrame(frame, "Change Font", 540, 100, false); frame.setLayer(JLayeredPane.PALETTE_LAYER); @@ -98,6 +98,11 @@ public class FontChooser extends GFontChooser fontSize.setSelectedItem(oldFont.getSize() + ""); fontStyle.setSelectedIndex(oldFont.getStyle()); + FontMetrics fm = getGraphics().getFontMetrics(oldFont); + monospaced.setSelected( fm.getStringBounds("M",getGraphics()).getWidth() + ==fm.getStringBounds("|",getGraphics()).getWidth()); + + init = false; } @@ -171,6 +176,12 @@ public class FontChooser extends GFontChooser { tp.setTreeFont(newFont); } + + FontMetrics fm = getGraphics().getFontMetrics(newFont); + + monospaced.setSelected( fm.getStringBounds("M",getGraphics()).getWidth() + ==fm.getStringBounds("|",getGraphics()).getWidth()); + } /** diff --git a/src/jalview/jbgui/GFontChooser.java b/src/jalview/jbgui/GFontChooser.java index 0aeeb34..38bddef 100755 --- a/src/jalview/jbgui/GFontChooser.java +++ b/src/jalview/jbgui/GFontChooser.java @@ -48,8 +48,10 @@ public class GFontChooser extends JPanel BorderLayout borderLayout3 = new BorderLayout(); FlowLayout flowLayout1 = new FlowLayout(); protected JButton defaultButton = new JButton(); + protected JCheckBox monospaced = new JCheckBox(); + BorderLayout borderLayout4 = new BorderLayout(); - /** + /** * Creates a new GFontChooser object. */ public GFontChooser() @@ -142,8 +144,10 @@ public class GFontChooser extends JPanel jPanel3.setOpaque(false); jPanel3.setLayout(borderLayout2); flowLayout1.setAlignment(FlowLayout.CENTER); - flowLayout1.setVgap(5); - defaultButton.setText("Set as Default"); + flowLayout1.setHgap(1); + flowLayout1.setVgap(5); + defaultButton.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + defaultButton.setText("Set as Default"); defaultButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -151,19 +155,25 @@ public class GFontChooser extends JPanel defaultButton_actionPerformed(e); } }); - this.add(jPanel1, null); + monospaced.setEnabled(false); + monospaced.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + monospaced.setOpaque(false); + monospaced.setToolTipText("Monospaced fonts are faster to render"); + monospaced.setText("Monospaced"); + this.add(jPanel1, null); jPanel1.add(jLabel1, BorderLayout.WEST); jPanel1.add(fontName, BorderLayout.CENTER); - this.add(jPanel3, null); + this.add(monospaced); + this.add(jPanel3, null); this.add(jPanel2, null); jPanel2.add(jLabel3, BorderLayout.WEST); jPanel2.add(fontStyle, BorderLayout.CENTER); - jPanel3.add(jLabel2, BorderLayout.WEST); + jPanel3.add(jLabel2, BorderLayout.WEST); jPanel3.add(fontSize, BorderLayout.CENTER); this.add(ok, null); this.add(cancel, null); this.add(defaultButton); - } + } /** * DOCUMENT ME! -- 1.7.10.2