--- /dev/null
+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
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
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
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
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
}\r
});\r
editMenu.setText("Edit");\r
- fontMenu.setText("Font");\r
viewMenu.setText("View");\r
colourMenu.setText("Colour");\r
calculateMenu.setText("Calculate");\r
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
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
}\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
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
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
}\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
\r
}\r
\r
- protected void pdbTest_actionPerformed(ActionEvent e)\r
- {\r
-\r
- }\r
\r
protected void printMenuItem_actionPerformed(ActionEvent e)\r
{\r
\r
}\r
\r
+ protected void font_actionPerformed(ActionEvent e)\r
+ {\r
+\r
+ }\r
+\r
\r
\r
}\r
--- /dev/null
+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)
+ {
+
+ }
+}