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