Get alignPanel from treeCanvas
[jalview.git] / src / jalview / gui / FontChooser.java
index ddaf4aa..16d1f55 100755 (executable)
@@ -1,6 +1,6 @@
 /*\r
  * Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
  *\r
  * This program is free software; you can redistribute it and/or\r
  * modify it under the terms of the GNU General Public License\r
@@ -50,6 +50,7 @@ public class FontChooser extends GFontChooser
     public FontChooser(TreePanel tp)\r
     {\r
       this.tp = tp;\r
+      ap = tp.treeCanvas.ap;\r
       oldFont = tp.getTreeFont();\r
       defaultButton.setVisible(false);\r
       init();\r
@@ -70,10 +71,13 @@ public class FontChooser extends GFontChooser
     {\r
         frame = new JInternalFrame();\r
         frame.setContentPane(this);\r
+\r
+        smoothFont.setSelected(ap.av.antiAlias);\r
+\r
         if(tp!=null)\r
-           Desktop.addInternalFrame(frame, "Change Font (Tree Panel)", 480, 100, false);\r
+           Desktop.addInternalFrame(frame, "Change Font (Tree Panel)", 340, 170, false);\r
         else\r
-           Desktop.addInternalFrame(frame, "Change Font", 480, 100, false);\r
+           Desktop.addInternalFrame(frame, "Change Font", 340, 170, false);\r
 \r
         frame.setLayer(JLayeredPane.PALETTE_LAYER);\r
 \r
@@ -85,7 +89,7 @@ public class FontChooser extends GFontChooser
             fontName.addItem(fonts[i]);\r
         }\r
 \r
-        for (int i = 1; i < 31; i++)\r
+        for (int i = 1; i < 51; i++)\r
         {\r
             fontSize.addItem(i + "");\r
         }\r
@@ -98,9 +102,23 @@ public class FontChooser extends GFontChooser
         fontSize.setSelectedItem(oldFont.getSize() + "");\r
         fontStyle.setSelectedIndex(oldFont.getStyle());\r
 \r
+        FontMetrics fm = getGraphics().getFontMetrics(oldFont);\r
+        monospaced.setSelected( fm.getStringBounds("M",getGraphics()).getWidth()\r
+                              ==fm.getStringBounds("|",getGraphics()).getWidth());\r
+\r
+\r
         init = false;\r
     }\r
 \r
+    public void smoothFont_actionPerformed(ActionEvent e)\r
+    {\r
+      ap.av.antiAlias = smoothFont.isSelected();\r
+      ap.annotationPanel.image = null;\r
+      ap.repaint();\r
+    }\r
+\r
+\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -171,6 +189,12 @@ public class FontChooser extends GFontChooser
       {\r
         tp.setTreeFont(newFont);\r
       }\r
+\r
+      FontMetrics fm = getGraphics().getFontMetrics(newFont);\r
+\r
+      monospaced.setSelected( fm.getStringBounds("M",getGraphics()).getWidth()\r
+                                ==fm.getStringBounds("|",getGraphics()).getWidth());\r
+\r
     }\r
 \r
     /**\r
@@ -228,5 +252,6 @@ public class FontChooser extends GFontChooser
         Cache.setProperty("FONT_NAME", fontName.getSelectedItem().toString());\r
         Cache.setProperty("FONT_STYLE", fontStyle.getSelectedIndex() + "");\r
         Cache.setProperty("FONT_SIZE", fontSize.getSelectedItem().toString());\r
+        Cache.setProperty("ANTI_ALIAS", Boolean.toString(smoothFont.isSelected()));\r
     }\r
 }\r