X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FFontChooser.java;h=9803822ecd1759c9d406af5d052569e90985d006;hb=0fc704a18faa7d11b6d02876bb6c1e8bc19f343c;hp=527bf5d3eabf68feb83ed431098a2e9b3c4690d7;hpb=efc31b4a8d5cee63555586804a2b79c06bdb5a14;p=jalview.git diff --git a/src/jalview/gui/FontChooser.java b/src/jalview/gui/FontChooser.java index 527bf5d..9803822 100755 --- a/src/jalview/gui/FontChooser.java +++ b/src/jalview/gui/FontChooser.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -37,6 +37,7 @@ import javax.swing.*; public class FontChooser extends GFontChooser { AlignmentPanel ap; + TreePanel tp; Font oldFont; boolean init = true; JInternalFrame frame; @@ -46,14 +47,40 @@ public class FontChooser extends GFontChooser * * @param ap DOCUMENT ME! */ + public FontChooser(TreePanel tp) + { + this.tp = tp; + ap = tp.treeCanvas.ap; + oldFont = tp.getTreeFont(); + defaultButton.setVisible(false); + smoothFont.setEnabled(false); + init(); + } + /** + * Creates a new FontChooser object. + * + * @param ap DOCUMENT ME! + */ public FontChooser(AlignmentPanel ap) { + oldFont = ap.av.getFont(); + this.ap = ap; + init(); + } + + void init() + { frame = new JInternalFrame(); frame.setContentPane(this); - Desktop.addInternalFrame(frame, "Change Font", 480, 100, false); - frame.setLayer(JLayeredPane.PALETTE_LAYER); - this.ap = ap; + smoothFont.setSelected(ap.av.antiAlias); + + if(tp!=null) + Desktop.addInternalFrame(frame, "Change Font (Tree Panel)", 340, 170, false); + else + Desktop.addInternalFrame(frame, "Change Font", 340, 170, false); + + frame.setLayer(JLayeredPane.PALETTE_LAYER); String[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment() .getAvailableFontFamilyNames(); @@ -63,7 +90,7 @@ public class FontChooser extends GFontChooser fontName.addItem(fonts[i]); } - for (int i = 1; i < 31; i++) + for (int i = 1; i < 51; i++) { fontSize.addItem(i + ""); } @@ -72,14 +99,27 @@ public class FontChooser extends GFontChooser fontStyle.addItem("bold"); fontStyle.addItem("italic"); - oldFont = ap.av.getFont(); fontName.setSelectedItem(oldFont.getName()); 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; } + public void smoothFont_actionPerformed(ActionEvent e) + { + ap.av.antiAlias = smoothFont.isSelected(); + ap.annotationPanel.image = null; + ap.repaint(); + } + + + /** * DOCUMENT ME! * @@ -95,9 +135,12 @@ public class FontChooser extends GFontChooser { } - if (ap.getOverviewPanel() != null) + if(ap!=null) { + if (ap.getOverviewPanel() != null) + { ap.getOverviewPanel().updateOverviewImage(); + } } } @@ -108,8 +151,15 @@ public class FontChooser extends GFontChooser */ protected void cancel_actionPerformed(ActionEvent e) { - ap.av.setFont(oldFont); - ap.repaint(); + if(ap!=null) + { + ap.av.setFont(oldFont); + ap.repaint(); + } + else if(tp!=null) + { + tp.setTreeFont(oldFont); + } fontName.setSelectedItem(oldFont.getName()); fontSize.setSelectedItem(oldFont.getSize() + ""); fontStyle.setSelectedIndex(oldFont.getStyle()); @@ -128,11 +178,25 @@ public class FontChooser extends GFontChooser */ void changeFont() { - Font newFont = new Font(fontName.getSelectedItem().toString(), - fontStyle.getSelectedIndex(), - Integer.parseInt(fontSize.getSelectedItem().toString())); + Font newFont = new Font(fontName.getSelectedItem().toString(), + fontStyle.getSelectedIndex(), + Integer.parseInt(fontSize.getSelectedItem().toString())); + if(tp != null) + { + tp.setTreeFont(newFont); + } + else if(ap != null) + { ap.av.setFont(newFont); ap.fontChanged(); + } + + + FontMetrics fm = getGraphics().getFontMetrics(newFont); + + monospaced.setSelected( fm.getStringBounds("M",getGraphics()).getWidth() + ==fm.getStringBounds("|",getGraphics()).getWidth()); + } /** @@ -190,5 +254,6 @@ public class FontChooser extends GFontChooser Cache.setProperty("FONT_NAME", fontName.getSelectedItem().toString()); Cache.setProperty("FONT_STYLE", fontStyle.getSelectedIndex() + ""); Cache.setProperty("FONT_SIZE", fontSize.getSelectedItem().toString()); + Cache.setProperty("ANTI_ALIAS", Boolean.toString(smoothFont.isSelected())); } }