JAL-1503 update version in GPL header
[jalview.git] / src / jalview / gui / EPSOptions.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
3  * Copyright (C) 2014 The Jalview Authors
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  * The Jalview Authors are detailed in the 'AUTHORS' file.
18  */
19 package jalview.gui;
20
21 import jalview.util.MessageManager;
22
23 import java.awt.*;
24 import java.awt.event.*;
25 import javax.swing.*;
26
27 public class EPSOptions extends JPanel
28 {
29   JDialog dialog;
30
31   public boolean cancelled = false;
32
33   String value;
34
35   public EPSOptions()
36   {
37     try
38     {
39       jbInit();
40     } catch (Exception ex)
41     {
42       ex.printStackTrace();
43     }
44
45     ButtonGroup bg = new ButtonGroup();
46     bg.add(lineart);
47     bg.add(text);
48
49     JOptionPane pane = new JOptionPane(null, JOptionPane.DEFAULT_OPTION,
50             JOptionPane.DEFAULT_OPTION, null, new Object[]
51             { this });
52
53     dialog = pane.createDialog(Desktop.desktop, "EPS Rendering options");
54     dialog.setVisible(true);
55
56   }
57
58   private void jbInit() throws Exception
59   {
60     lineart.setFont(JvSwingUtils.getLabelFont());
61     lineart.setText(MessageManager.getString("label.lineart"));
62     text.setFont(JvSwingUtils.getLabelFont());
63     text.setText(MessageManager.getString("action.text"));
64     text.setSelected(true);
65     askAgain.setFont(JvSwingUtils.getLabelFont());
66     askAgain.setText(MessageManager.getString("label.dont_ask_me_again"));
67     ok.setText(MessageManager.getString("action.ok"));
68     ok.addActionListener(new ActionListener()
69     {
70       public void actionPerformed(ActionEvent e)
71       {
72         ok_actionPerformed(e);
73       }
74     });
75     cancel.setText(MessageManager.getString("action.cancel"));
76     cancel.addActionListener(new ActionListener()
77     {
78       public void actionPerformed(ActionEvent e)
79       {
80         cancel_actionPerformed(e);
81       }
82     });
83     jLabel1.setFont(JvSwingUtils.getLabelFont());
84     jLabel1.setText(MessageManager.getString("label.select_eps_character_rendering_style"));
85     this.setLayout(borderLayout1);
86     jPanel3.setBorder(BorderFactory.createEtchedBorder());
87     jPanel2.add(text);
88     jPanel2.add(lineart);
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
100   JRadioButton text = new JRadioButton();
101
102   JCheckBox askAgain = new JCheckBox();
103
104   JButton ok = new JButton();
105
106   JButton cancel = new JButton();
107
108   JPanel jPanel1 = new JPanel();
109
110   JLabel jLabel1 = new JLabel();
111
112   JPanel jPanel2 = new JPanel();
113
114   JPanel jPanel3 = new JPanel();
115
116   BorderLayout borderLayout1 = new BorderLayout();
117
118   public void ok_actionPerformed(ActionEvent e)
119   {
120     if (lineart.isSelected())
121     {
122       value = "Lineart";
123     }
124     else
125     {
126       value = "Text";
127     }
128
129     if (!askAgain.isSelected())
130     {
131       jalview.bin.Cache.applicationProperties.remove("EPS_RENDERING");
132     }
133     else
134     {
135       jalview.bin.Cache.setProperty("EPS_RENDERING", value);
136     }
137
138     dialog.setVisible(false);
139   }
140
141   public void cancel_actionPerformed(ActionEvent e)
142   {
143     cancelled = true;
144     dialog.setVisible(false);
145   }
146
147   public String getValue()
148   {
149     return value;
150   }
151 }