font chooser added
authoramwaterhouse <Andrew Waterhouse>
Wed, 9 Mar 2005 18:37:09 +0000 (18:37 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 9 Mar 2005 18:37:09 +0000 (18:37 +0000)
src/jalview/gui/FontChooser.java [new file with mode: 0755]
src/jalview/jbgui/GAlignFrame.java
src/jalview/jbgui/GFontChooser.java [new file with mode: 0755]

diff --git a/src/jalview/gui/FontChooser.java b/src/jalview/gui/FontChooser.java
new file mode 100755 (executable)
index 0000000..782d2d6
--- /dev/null
@@ -0,0 +1,59 @@
+package jalview.gui;\r
+\r
+import jalview.jbgui.GFontChooser;\r
+import jalview.gui.*;\r
+import java.awt.*;\r
+import java.awt.event.*;\r
+import javax.swing.*;\r
+import javax.swing.event.*;\r
+\r
+\r
+public class FontChooser extends GFontChooser\r
+{\r
+  AlignmentPanel ap;\r
+  Font oldFont;\r
+\r
+  public FontChooser(AlignmentPanel ap)\r
+  {\r
+    this.ap = ap;\r
+\r
+    String fonts[] = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();\r
+    for(int i=0; i<fonts.length; i++)\r
+      fontName.addItem(fonts[i]);\r
+\r
+    for(int i=1; i<31; i++)\r
+      fontSize.addItem(i+"");\r
+\r
+   fontStyle.addItem("plain");\r
+   fontStyle.addItem("bold");\r
+   fontStyle.addItem("italic");\r
+\r
+   oldFont = ap.av.getFont();\r
+   fontName.setSelectedItem(oldFont.getName());\r
+   fontSize.setSelectedItem(oldFont.getSize()+"");\r
+   fontStyle.setSelectedIndex(oldFont.getStyle());\r
+\r
+  }\r
+\r
+  protected void ok_actionPerformed(ActionEvent e)\r
+  {\r
+    Font newFont = new Font(fontName.getSelectedItem().toString(),\r
+                            fontStyle.getSelectedIndex(),\r
+                            Integer.parseInt(fontSize.getSelectedItem().toString()+"")\r
+                            );\r
+    ap.av.setFont(newFont);\r
+    ap.RefreshPanels();\r
+    ap.RefreshPanels();\r
+  }\r
+\r
+  protected void cancel_actionPerformed(ActionEvent e)\r
+  {\r
+    ap.av.setFont(oldFont);\r
+    ap.RefreshPanels();\r
+    fontName.setSelectedItem(oldFont.getName());\r
+    fontSize.setSelectedItem(oldFont.getSize()+"");\r
+    fontStyle.setSelectedIndex(oldFont.getStyle());\r
+  }\r
+\r
+\r
+}\r
index aedbca5..8411b6e 100755 (executable)
@@ -18,7 +18,6 @@ public class GAlignFrame extends JInternalFrame
   protected JMenu fileMenu = new JMenu();\r
   protected JMenuItem closeMenuItem = new JMenuItem();\r
   protected JMenu editMenu = new JMenu();\r
-  protected JMenu fontMenu = new JMenu();\r
   protected JMenu viewMenu = new JMenu();\r
   protected JMenu colourMenu = new JMenu();\r
   protected JMenu calculateMenu = new JMenu();\r
@@ -33,9 +32,6 @@ public class GAlignFrame extends JInternalFrame
   protected JMenuItem removeGappedColumnMenuItem = new JMenuItem();\r
   protected JMenuItem removeAllGapsMenuItem = new JMenuItem();\r
   protected JMenuItem setGapCharMenuItem = new JMenuItem();\r
-  protected JMenuItem fontNameMenuItem = new JMenuItem();\r
-  protected JMenuItem fontSizeMenuItem = new JMenuItem();\r
-  protected JMenuItem fontStyleMenuItem = new JMenuItem();\r
   protected JCheckBoxMenuItem viewBoxesMenuItem = new JCheckBoxMenuItem();\r
   protected JCheckBoxMenuItem viewTextMenuItem = new JCheckBoxMenuItem();\r
   protected JMenuItem sortPairwiseMenuItem = new JMenuItem();\r
@@ -74,7 +70,6 @@ public class GAlignFrame extends JInternalFrame
   protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();\r
   JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();\r
   protected JCheckBoxMenuItem wrapMenuItem = new JCheckBoxMenuItem();\r
-  JMenuItem pdbTest = new JMenuItem();\r
   JMenuItem printMenuItem = new JMenuItem();\r
   protected JCheckBoxMenuItem renderGapsMenuItem = new JCheckBoxMenuItem();\r
   JMenuItem findMenuItem = new JMenuItem();\r
@@ -91,6 +86,7 @@ public class GAlignFrame extends JInternalFrame
   JMenuItem pasteThis = new JMenuItem();\r
   protected JCheckBoxMenuItem applyToAllGroups = new JCheckBoxMenuItem();\r
   JMenuItem createJPG = new JMenuItem();\r
+  protected JMenuItem font = new JMenuItem();\r
   public GAlignFrame()\r
   {\r
 \r
@@ -162,7 +158,6 @@ public class GAlignFrame extends JInternalFrame
       }\r
     });\r
     editMenu.setText("Edit");\r
-    fontMenu.setText("Font");\r
     viewMenu.setText("View");\r
     colourMenu.setText("Colour");\r
     calculateMenu.setText("Calculate");\r
@@ -248,29 +243,6 @@ public class GAlignFrame extends JInternalFrame
         setGapCharMenuItem_actionPerformed(e);\r
       }\r
     });\r
-    fontNameMenuItem.addActionListener(new java.awt.event.ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        fontNameMenuItem_actionPerformed(e);\r
-      }\r
-    });\r
-    fontSizeMenuItem.setText("10");\r
-    fontSizeMenuItem.addActionListener(new java.awt.event.ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        fontSizeMenuItem_actionPerformed(e);\r
-      }\r
-    });\r
-    fontStyleMenuItem.setText("Plain");\r
-    fontStyleMenuItem.addActionListener(new java.awt.event.ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        fontStyleMenuItem_actionPerformed(e);\r
-      }\r
-    });\r
     viewBoxesMenuItem.setText("Boxes");\r
     viewBoxesMenuItem.setState(true);\r
     viewBoxesMenuItem.addActionListener(new java.awt.event.ActionListener()\r
@@ -561,14 +533,6 @@ public class GAlignFrame extends JInternalFrame
         wrapMenuItem_actionPerformed(e);\r
       }\r
     });\r
-    pdbTest.setText("PDB Test Viewer");\r
-    pdbTest.addActionListener(new java.awt.event.ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        pdbTest_actionPerformed(e);\r
-      }\r
-    });\r
     printMenuItem.setText("Print");\r
     printMenuItem.addActionListener(new java.awt.event.ActionListener()\r
     {\r
@@ -689,10 +653,17 @@ public class GAlignFrame extends JInternalFrame
       }\r
     });\r
     createJPG.setText("Save as JPG Image");\r
+    font.setText("Change Font");\r
+    font.addActionListener(new java.awt.event.ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        font_actionPerformed(e);\r
+      }\r
+    });\r
     alignFrameMenuBar.add(fileMenu);\r
     alignFrameMenuBar.add(editMenu);\r
     alignFrameMenuBar.add(searchMenu);\r
-    alignFrameMenuBar.add(fontMenu);\r
     alignFrameMenuBar.add(viewMenu);\r
     alignFrameMenuBar.add(colourMenu);\r
     alignFrameMenuBar.add(calculateMenu);\r
@@ -726,9 +697,7 @@ public class GAlignFrame extends JInternalFrame
     editMenu.add(removeAllGapsMenuItem);\r
     editMenu.add(setGapCharMenuItem);\r
     searchMenu.add(findMenuItem);\r
-    fontMenu.add(fontNameMenuItem);\r
-    fontMenu.add(fontSizeMenuItem);\r
-    fontMenu.add(fontStyleMenuItem);\r
+    viewMenu.add(font);\r
     viewMenu.add(wrapMenuItem);\r
     viewMenu.add(viewBoxesMenuItem);\r
     viewMenu.add(viewTextMenuItem);\r
@@ -768,7 +737,6 @@ public class GAlignFrame extends JInternalFrame
     calculateMenu.add(avDistanceTreeBlosumMenuItem);\r
     calculateMenu.add(njTreeBlosumMenuItem);\r
     alignMenu.add(clustalAlignMenuItem);\r
-    alignMenu.add(pdbTest);\r
     this.getContentPane().add(statusBar, BorderLayout.SOUTH);\r
     jMenu1.add(pasteNew);\r
     jMenu1.add(pasteThis);\r
@@ -862,20 +830,8 @@ public class GAlignFrame extends JInternalFrame
   }\r
 \r
 \r
-  protected void fontNameMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-\r
-  }\r
-\r
-  protected void fontSizeMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-\r
-  }\r
 \r
-  protected void fontStyleMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
 \r
-  }\r
 \r
   protected void wrapMenuItem_actionPerformed(ActionEvent e)\r
   {\r
@@ -1046,10 +1002,6 @@ public class GAlignFrame extends JInternalFrame
 \r
   }\r
 \r
-  protected void pdbTest_actionPerformed(ActionEvent e)\r
-  {\r
-\r
-  }\r
 \r
   protected void printMenuItem_actionPerformed(ActionEvent e)\r
   {\r
@@ -1122,6 +1074,11 @@ public class GAlignFrame extends JInternalFrame
 \r
   }\r
 \r
+  protected void font_actionPerformed(ActionEvent e)\r
+  {\r
+\r
+  }\r
+\r
 \r
 \r
 }\r
diff --git a/src/jalview/jbgui/GFontChooser.java b/src/jalview/jbgui/GFontChooser.java
new file mode 100755 (executable)
index 0000000..3444c5b
--- /dev/null
@@ -0,0 +1,112 @@
+package jalview.jbgui;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+
+
+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();
+  JButton ok = new JButton();
+  JButton cancel = new JButton();
+  JPanel jPanel1 = new JPanel();
+  JPanel jPanel2 = new JPanel();
+  JPanel jPanel3 = new JPanel();
+  BorderLayout borderLayout1 = new BorderLayout();
+  BorderLayout borderLayout2 = new BorderLayout();
+  BorderLayout borderLayout3 = new BorderLayout();
+  FlowLayout flowLayout1 = new FlowLayout();
+
+  public GFontChooser()
+  {
+    try
+    {
+      jbInit();
+    }
+    catch(Exception e)
+    {
+      e.printStackTrace();
+    }
+  }
+  private void jbInit() throws Exception
+  {
+    jLabel1.setFont(new java.awt.Font("Verdana", 0, 11));
+    jLabel1.setHorizontalAlignment(SwingConstants.RIGHT);
+    jLabel1.setText("Font: ");
+    jLabel1.setVerticalTextPosition(javax.swing.SwingConstants.CENTER);
+    this.setLayout(flowLayout1);
+    fontSize.setFont(new java.awt.Font("Verdana", 0, 11));
+    fontSize.setOpaque(false);
+    fontSize.setPreferredSize(new Dimension(50, 21));
+    fontStyle.setFont(new java.awt.Font("Verdana", 0, 11));
+    fontStyle.setOpaque(false);
+    fontStyle.setPreferredSize(new Dimension(90, 21));
+    jLabel2.setFont(new java.awt.Font("Verdana", 0, 11));
+    jLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
+    jLabel2.setText("Size: ");
+    jLabel2.setVerticalTextPosition(javax.swing.SwingConstants.CENTER);
+    jLabel3.setFont(new java.awt.Font("Verdana", 0, 11));
+    jLabel3.setHorizontalAlignment(SwingConstants.RIGHT);
+    jLabel3.setText("Style: ");
+    jLabel3.setVerticalTextPosition(javax.swing.SwingConstants.CENTER);
+    fontName.setFont(new java.awt.Font("Verdana", 0, 11));
+    fontName.setMaximumSize(new Dimension(32767, 32767));
+    fontName.setMinimumSize(new Dimension(300, 21));
+    fontName.setOpaque(false);
+    fontName.setPreferredSize(new Dimension(180, 21));
+    ok.setFont(new java.awt.Font("Verdana", 0, 11));
+    ok.setText("OK");
+    ok.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        ok_actionPerformed(e);
+      }
+    });
+    cancel.setFont(new java.awt.Font("Verdana", 0, 11));
+    cancel.setText("Cancel");
+    cancel.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        cancel_actionPerformed(e);
+      }
+    });
+    this.setBackground(Color.white);
+    jPanel1.setOpaque(false);
+    jPanel1.setLayout(borderLayout1);
+    jPanel2.setOpaque(false);
+    jPanel2.setLayout(borderLayout3);
+    jPanel3.setOpaque(false);
+    jPanel3.setLayout(borderLayout2);
+    flowLayout1.setAlignment(FlowLayout.CENTER);
+    flowLayout1.setVgap(10);
+    this.add(jPanel1, null);
+    jPanel1.add(jLabel1, BorderLayout.WEST);
+    jPanel1.add(fontName, BorderLayout.CENTER);
+    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(fontSize, BorderLayout.CENTER);
+    this.add(ok, null);
+    this.add(cancel, null);
+  }
+
+  protected void ok_actionPerformed(ActionEvent e)
+  {
+
+  }
+
+  protected void cancel_actionPerformed(ActionEvent e)
+  {
+
+  }
+}