JAL-1432 updated copyright notices
[jalview.git] / src / jalview / gui / EPSOptions.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
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 java.awt.*;
22 import java.awt.event.*;
23 import javax.swing.*;
24
25 public class EPSOptions extends JPanel
26 {
27   JDialog dialog;
28
29   public boolean cancelled = false;
30
31   String value;
32
33   public EPSOptions()
34   {
35     try
36     {
37       jbInit();
38     } catch (Exception ex)
39     {
40       ex.printStackTrace();
41     }
42
43     ButtonGroup bg = new ButtonGroup();
44     bg.add(lineart);
45     bg.add(text);
46
47     JOptionPane pane = new JOptionPane(null, JOptionPane.DEFAULT_OPTION,
48             JOptionPane.DEFAULT_OPTION, null, new Object[]
49             { this });
50
51     dialog = pane.createDialog(Desktop.desktop, "EPS Rendering options");
52     dialog.setVisible(true);
53
54   }
55
56   private void jbInit() throws Exception
57   {
58     lineart.setFont(JvSwingUtils.getLabelFont());
59     lineart.setText("Lineart");
60     text.setFont(JvSwingUtils.getLabelFont());
61     text.setText("Text");
62     text.setSelected(true);
63     askAgain.setFont(JvSwingUtils.getLabelFont());
64     askAgain.setText("Don\'t ask me again");
65     ok.setText("OK");
66     ok.addActionListener(new ActionListener()
67     {
68       public void actionPerformed(ActionEvent e)
69       {
70         ok_actionPerformed(e);
71       }
72     });
73     cancel.setText("Cancel");
74     cancel.addActionListener(new ActionListener()
75     {
76       public void actionPerformed(ActionEvent e)
77       {
78         cancel_actionPerformed(e);
79       }
80     });
81     jLabel1.setFont(JvSwingUtils.getLabelFont());
82     jLabel1.setText("Select EPS character rendering style");
83     this.setLayout(borderLayout1);
84     jPanel3.setBorder(BorderFactory.createEtchedBorder());
85     jPanel2.add(text);
86     jPanel2.add(lineart);
87     jPanel2.add(askAgain);
88     jPanel1.add(ok);
89     jPanel1.add(cancel);
90     jPanel3.add(jLabel1);
91     jPanel3.add(jPanel2);
92     this.add(jPanel3, java.awt.BorderLayout.CENTER);
93     this.add(jPanel1, java.awt.BorderLayout.SOUTH);
94   }
95
96   JRadioButton lineart = new JRadioButton();
97
98   JRadioButton text = new JRadioButton();
99
100   JCheckBox askAgain = new JCheckBox();
101
102   JButton ok = new JButton();
103
104   JButton cancel = new JButton();
105
106   JPanel jPanel1 = new JPanel();
107
108   JLabel jLabel1 = new JLabel();
109
110   JPanel jPanel2 = new JPanel();
111
112   JPanel jPanel3 = new JPanel();
113
114   BorderLayout borderLayout1 = new BorderLayout();
115
116   public void ok_actionPerformed(ActionEvent e)
117   {
118     if (lineart.isSelected())
119     {
120       value = "Lineart";
121     }
122     else
123     {
124       value = "Text";
125     }
126
127     if (!askAgain.isSelected())
128     {
129       jalview.bin.Cache.applicationProperties.remove("EPS_RENDERING");
130     }
131     else
132     {
133       jalview.bin.Cache.setProperty("EPS_RENDERING", value);
134     }
135
136     dialog.setVisible(false);
137   }
138
139   public void cancel_actionPerformed(ActionEvent e)
140   {
141     cancelled = true;
142     dialog.setVisible(false);
143   }
144
145   public String getValue()
146   {
147     return value;
148   }
149 }