updated to jalview 2.1 and begun ArchiveClient/VamsasClient/VamsasStore updates.
[jalview.git] / src / jalview / gui / EPSOptions.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer
3  * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18  */
19 package jalview.gui;
20
21 import javax.swing.*;
22 import java.awt.*;
23 import java.awt.event.ActionListener;
24 import java.awt.event.ActionEvent;
25
26 public class EPSOptions
27     extends JPanel
28 {
29   JDialog dialog;
30   public boolean cancelled = false;
31   String value;
32
33   public EPSOptions()
34   {
35     try
36     {
37       jbInit();
38     }
39     catch (Exception ex)
40     {
41       ex.printStackTrace();
42     }
43
44     ButtonGroup bg = new ButtonGroup();
45     bg.add(lineart);
46     bg.add(text);
47
48     JOptionPane pane = new JOptionPane(null,
49         JOptionPane.DEFAULT_OPTION, JOptionPane.DEFAULT_OPTION,
50        null, new Object[]{this});
51
52     dialog = pane.createDialog(Desktop.desktop, "EPS Rendering options");
53     dialog.setVisible(true);
54
55   }
56
57   private void jbInit()
58       throws Exception
59   {
60     lineart.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
61     lineart.setSelected(true);
62     lineart.setText("Lineart");
63     text.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
64     text.setText("Text");
65     askAgain.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
66     askAgain.setText("Don\'t ask me again");
67     ok.setText("OK");
68     ok.addActionListener(new ActionListener()
69     {
70       public void actionPerformed(ActionEvent e)
71       {
72         ok_actionPerformed(e);
73       }
74     });
75     cancel.setText("Cancel");
76     cancel.addActionListener(new ActionListener()
77     {
78       public void actionPerformed(ActionEvent e)
79       {
80         cancel_actionPerformed(e);
81       }
82     });
83     jLabel1.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
84     jLabel1.setText("Select EPS character rendering style");
85     this.setLayout(borderLayout1);
86     jPanel3.setBorder(BorderFactory.createEtchedBorder());
87     jPanel2.add(lineart);
88     jPanel2.add(text);
89     jPanel2.add(askAgain);
90     jPanel1.add(ok);
91     jPanel1.add(cancel);
92     jPanel3.add(jLabel1);
93     jPanel3.add(jPanel2);
94     this.add(jPanel3, java.awt.BorderLayout.CENTER);
95     this.add(jPanel1, java.awt.BorderLayout.SOUTH);
96   }
97
98   JRadioButton lineart = new JRadioButton();
99   JRadioButton text = new JRadioButton();
100   JCheckBox askAgain = new JCheckBox();
101   JButton ok = new JButton();
102   JButton cancel = new JButton();
103   JPanel jPanel1 = new JPanel();
104   JLabel jLabel1 = new JLabel();
105   JPanel jPanel2 = new JPanel();
106   JPanel jPanel3 = new JPanel();
107   BorderLayout borderLayout1 = new BorderLayout();
108
109   public void ok_actionPerformed(ActionEvent e)
110   {
111     if (lineart.isSelected())
112       value = "Lineart";
113     else
114       value = "Text";
115
116     if (!askAgain.isSelected())
117     {
118       jalview.bin.Cache.applicationProperties.remove("EPS_RENDERING");
119     }
120     else
121     {
122       jalview.bin.Cache.setProperty("EPS_RENDERING", value);
123     }
124
125     dialog.setVisible(false);
126   }
127
128   public void cancel_actionPerformed(ActionEvent e)
129   {
130     cancelled = true;
131     dialog.setVisible(false);
132   }
133
134   public String getValue()
135   {
136     return value;
137   }
138 }