From 5744abb4cd51c570f17eb440a17dcb3a2a93f8d2 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Wed, 14 Sep 2005 11:22:13 +0000 Subject: [PATCH] Change fonts in Treepanel --- src/jalview/gui/FontChooser.java | 58 +++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/src/jalview/gui/FontChooser.java b/src/jalview/gui/FontChooser.java index 527bf5d..98d3ecb 100755 --- a/src/jalview/gui/FontChooser.java +++ b/src/jalview/gui/FontChooser.java @@ -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,35 @@ public class FontChooser extends GFontChooser * * @param ap DOCUMENT ME! */ + public FontChooser(TreePanel tp) + { + this.tp = tp; + oldFont = tp.getFont(); + defaultButton.setVisible(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); + if(tp!=null) + Desktop.addInternalFrame(frame, "Change Font (Tree Panel)", 480, 100, false); + else + Desktop.addInternalFrame(frame, "Change Font", 480, 100, false); - this.ap = ap; + frame.setLayer(JLayeredPane.PALETTE_LAYER); String[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment() .getAvailableFontFamilyNames(); @@ -72,7 +94,6 @@ 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()); @@ -95,9 +116,12 @@ public class FontChooser extends GFontChooser { } - if (ap.getOverviewPanel() != null) + if(ap!=null) { + if (ap.getOverviewPanel() != null) + { ap.getOverviewPanel().updateOverviewImage(); + } } } @@ -108,8 +132,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.setFont(oldFont); + } fontName.setSelectedItem(oldFont.getName()); fontSize.setSelectedItem(oldFont.getSize() + ""); fontStyle.setSelectedIndex(oldFont.getStyle()); @@ -128,11 +159,18 @@ 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 (ap != null) + { ap.av.setFont(newFont); ap.fontChanged(); + } + else if(tp != null) + { + tp.setFont(newFont); + } } /** -- 1.7.10.2