2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.gui;
\r
22 import java.awt.event.*;
\r
23 import javax.swing.*;
\r
25 import jalview.bin.*;
\r
26 import jalview.io.*;
\r
27 import jalview.jbgui.*;
\r
28 import jalview.schemes.*;
\r
30 public class Preferences
\r
31 extends GPreferences
\r
33 static boolean preferencesLoaded = false;
\r
34 public static boolean showFullscreen = false;
\r
35 public static boolean showFullId = true;
\r
36 public static boolean showAnnotation = true;
\r
37 public static boolean showConservation = true;
\r
38 public static boolean showQuality = true;
\r
39 public static boolean showIdentity = true;
\r
40 public static String fontName = "SansSerif";
\r
41 public static String fontSize = "10";
\r
42 public static String fontStyle = Font.PLAIN + "";
\r
43 public static char gapSymbol = '-';
\r
44 public static String defaultColour = null;
\r
45 public static boolean showStartupFile = true;
\r
46 public static String startupFile =
\r
47 "http://www.jalview.org/examples/exampleFile.jar";
\r
48 JInternalFrame frame;
\r
50 public Preferences()
\r
54 frame = new JInternalFrame();
\r
55 frame.setContentPane(this);
\r
56 Desktop.addInternalFrame(frame, "Preferences", 480, 390);
\r
58 fullID.setSelected(showFullId);
\r
60 String string = Cache.getProperty("SHOW_FULLSCREEN");
\r
61 boolean value = false;
\r
65 value = Boolean.valueOf(string).booleanValue();
\r
68 fullScreen.setSelected(value);
\r
69 annotations.setSelected(showAnnotation);
\r
71 conservation.setEnabled(showAnnotation);
\r
72 quality.setEnabled(showAnnotation);
\r
73 identity.setEnabled(showAnnotation);
\r
75 conservation.setSelected(showConservation);
\r
76 quality.setSelected(showQuality);
\r
77 identity.setSelected(showIdentity);
\r
79 for (int i = 0; i < 12; i++)
\r
81 colour.addItem(ColourSchemeProperty.getColourName(i));
\r
84 string = Cache.getProperty("DEFAULT_COLOUR");
\r
88 colour.setSelectedItem(string);
\r
92 colour.setSelectedIndex(11);
\r
95 String[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment()
\r
96 .getAvailableFontFamilyNames();
\r
98 for (int i = 0; i < fonts.length; i++)
\r
100 fontNameCB.addItem(fonts[i]);
\r
103 for (int i = 1; i < 31; i++)
\r
105 fontSizeCB.addItem(i + "");
\r
108 fontStyleCB.addItem("plain");
\r
109 fontStyleCB.addItem("bold");
\r
110 fontStyleCB.addItem("italic");
\r
112 fontNameCB.setSelectedItem(fontName);
\r
113 fontSizeCB.setSelectedItem(fontSize);
\r
114 fontStyleCB.setSelectedItem(fontStyle);
\r
116 gapSymbolCB.addItem("-");
\r
117 gapSymbolCB.addItem(".");
\r
119 gapSymbolCB.setSelectedItem(gapSymbol + "");
\r
121 startupCheckbox.setSelected(showStartupFile);
\r
122 startupFileTextfield.setText(startupFile);
\r
125 public static void initPreferences()
\r
127 String string = Cache.getProperty("SHOW_FULL_ID");
\r
129 if (string != null)
\r
131 showFullId = Boolean.valueOf(string).booleanValue();
\r
134 string = Cache.getProperty("SHOW_FULLSCREEN");
\r
136 if (string != null)
\r
138 showFullscreen = Boolean.valueOf(string).booleanValue();
\r
141 string = Cache.getProperty("SHOW_ANNOTATIONS");
\r
143 if (string != null)
\r
145 showAnnotation = Boolean.valueOf(string).booleanValue();
\r
148 string = Cache.getProperty("SHOW_CONSERVATION");
\r
150 if (string != null)
\r
152 showConservation = Boolean.valueOf(string).booleanValue();
\r
155 string = Cache.getProperty("SHOW_QUALITY");
\r
157 if (string != null)
\r
159 showQuality = Boolean.valueOf(string).booleanValue();
\r
162 string = Cache.getProperty("SHOW_IDENTITY");
\r
164 if (string != null)
\r
166 showIdentity = Boolean.valueOf(string).booleanValue();
\r
169 string = Cache.getProperty("GAP_SYMBOL");
\r
171 if (string != null)
\r
173 gapSymbol = string.charAt(0);
\r
176 string = Cache.getProperty("SHOW_FULL_ID");
\r
178 if (string != null)
\r
180 showFullId = Boolean.valueOf(string).booleanValue();
\r
183 string = Cache.getProperty("FONT_NAME");
\r
185 if (string != null)
\r
190 string = Cache.getProperty("FONT_STYLE");
\r
192 if (string != null)
\r
194 fontStyle = string;
\r
197 string = Cache.getProperty("FONT_SIZE");
\r
199 if (string != null)
\r
204 string = Cache.getProperty("DEFAULT_COLOUR");
\r
206 if (string != null)
\r
208 defaultColour = string;
\r
211 string = Cache.getProperty("STARTUP_FILE");
\r
213 if (string != null)
\r
215 startupFile = string;
\r
218 string = Cache.getProperty("SHOW_STARTUP_FILE");
\r
220 if (string != null)
\r
222 showStartupFile = Boolean.valueOf(string).booleanValue();
\r
225 preferencesLoaded = true;
\r
228 public void ok_actionPerformed(ActionEvent e)
\r
230 showFullId = fullID.isSelected();
\r
231 showFullscreen = fullScreen.isSelected();
\r
232 showAnnotation = annotations.isSelected();
\r
233 showConservation = conservation.isSelected();
\r
234 showQuality = quality.isSelected();
\r
235 showIdentity = identity.isSelected();
\r
236 defaultColour = colour.getSelectedItem().toString();
\r
237 gapSymbol = gapSymbolCB.getSelectedItem().toString().charAt(0);
\r
238 fontName = fontNameCB.getSelectedItem().toString();
\r
239 fontSize = fontSizeCB.getSelectedItem().toString();
\r
240 fontStyle = fontStyleCB.getSelectedItem().toString();
\r
241 startupFile = startupFileTextfield.getText();
\r
242 showStartupFile = startupCheckbox.isSelected();
\r
244 Cache.setProperty("SHOW_FULL_ID", Boolean.toString(showFullId));
\r
245 Cache.setProperty("SHOW_FULLSCREEN", Boolean.toString(showFullscreen));
\r
247 Cache.setProperty("SHOW_ANNOTATIONS", Boolean.toString(showAnnotation));
\r
248 Cache.setProperty("SHOW_CONSERVATION",
\r
249 Boolean.toString(showConservation));
\r
250 Cache.setProperty("SHOW_QUALITY", Boolean.toString(showQuality));
\r
251 Cache.setProperty("SHOW_IDENTITY", Boolean.toString(showIdentity));
\r
253 Cache.setProperty("DEFAULT_COLOUR", defaultColour);
\r
254 Cache.setProperty("GAP_SYMBOL", gapSymbol + "");
\r
256 Cache.setProperty("FONT_NAME", fontName);
\r
257 Cache.setProperty("FONT_STYLE", fontStyle);
\r
258 Cache.setProperty("FONT_SIZE", fontSize);
\r
260 Cache.setProperty("STARTUP_FILE", startupFile);
\r
261 Cache.setProperty("SHOW_STARTUP_FILE", Boolean.toString(showStartupFile));
\r
265 frame.setClosed(true);
\r
267 catch (Exception ex)
\r
272 public void startupFileTextfield_mouseClicked()
\r
274 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
\r
279 "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
\r
284 "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview"
\r
285 }, jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
\r
286 chooser.setFileView(new JalviewFileView());
\r
287 chooser.setDialogTitle("Select startup file");
\r
289 int value = chooser.showOpenDialog(this);
\r
291 if (value == JalviewFileChooser.APPROVE_OPTION)
\r
293 jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT",
\r
294 chooser.getSelectedFormat());
\r
295 startupFileTextfield.setText(chooser.getSelectedFile()
\r
296 .getAbsolutePath());
\r
300 public void cancel_actionPerformed(ActionEvent e)
\r
304 frame.setClosed(true);
\r
306 catch (Exception ex)
\r
311 public void annotations_actionPerformed(ActionEvent e)
\r
313 conservation.setEnabled(annotations.isSelected());
\r
314 quality.setEnabled(annotations.isSelected());
\r
315 identity.setEnabled(annotations.isSelected());
\r