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
20 package jalview.gui;
\r
22 import jalview.jbgui.*;
\r
23 import jalview.schemes.*;
\r
24 import jalview.io.*;
\r
26 import jalview.bin.Cache;
\r
27 import javax.swing.*;
\r
28 import java.awt.event.ActionEvent;
\r
32 public class Preferences extends GPreferences
\r
34 static boolean preferencesLoaded=false;
\r
36 public static boolean showFullscreen=false;
\r
37 public static boolean showFullId=true;
\r
38 public static boolean showAnnotation=true;
\r
39 public static boolean showConservation=true;
\r
40 public static boolean showQuality=true;
\r
41 public static boolean showIdentity=true;
\r
42 public static String fontName="SansSerif";
\r
43 public static String fontSize="10";
\r
44 public static String fontStyle=Font.PLAIN+"";
\r
45 public static char gapSymbol='-';
\r
46 public static String defaultColour=null;
\r
47 public static boolean showStartupFile=true;
\r
48 public static String startupFile = "http://www.jalview.org/examples/exampleFile.jar";
\r
50 JInternalFrame frame;
\r
52 public static void initPreferences()
\r
54 String string = Cache.getProperty("SHOW_FULL_ID");
\r
56 showFullId = Boolean.valueOf(string).booleanValue();
\r
58 string = Cache.getProperty("SHOW_FULLSCREEN");
\r
60 showFullscreen = Boolean.valueOf(string).booleanValue();
\r
62 string = Cache.getProperty("SHOW_ANNOTATIONS");
\r
64 showAnnotation = Boolean.valueOf(string).booleanValue();
\r
66 string = Cache.getProperty("SHOW_CONSERVATION");
\r
68 showConservation = Boolean.valueOf(string).booleanValue();
\r
69 string = Cache.getProperty("SHOW_QUALITY");
\r
71 showQuality = Boolean.valueOf(string).booleanValue();
\r
72 string = Cache.getProperty("SHOW_IDENTITY");
\r
74 showIdentity = Boolean.valueOf(string).booleanValue();
\r
76 string = Cache.getProperty("GAP_SYMBOL");
\r
78 gapSymbol = string.charAt(0);
\r
80 string = Cache.getProperty("SHOW_FULL_ID");
\r
82 showFullId = Boolean.valueOf(string).booleanValue();
\r
84 string = Cache.getProperty("FONT_NAME");
\r
88 string = Cache.getProperty("FONT_STYLE");
\r
92 string = Cache.getProperty("FONT_SIZE");
\r
97 string = Cache.getProperty("DEFAULT_COLOUR");
\r
99 defaultColour = string;
\r
101 string = Cache.getProperty("STARTUP_FILE");
\r
103 startupFile = string;
\r
105 string = Cache.getProperty("SHOW_STARTUP_FILE");
\r
107 showStartupFile = Boolean.valueOf(string).booleanValue();
\r
109 preferencesLoaded = true;
\r
112 public Preferences()
\r
116 frame = new JInternalFrame();
\r
117 frame.setContentPane(this);
\r
118 Desktop.addInternalFrame(frame, "Preferences", 480,390 );
\r
120 fullID.setSelected(showFullId);
\r
121 String string = Cache.getProperty("SHOW_FULLSCREEN");
\r
122 boolean value = false;
\r
124 value = Boolean.valueOf(string).booleanValue();
\r
126 fullScreen.setSelected(value);
\r
127 annotations.setSelected(showAnnotation);
\r
129 conservation.setEnabled(showAnnotation);
\r
130 quality.setEnabled(showAnnotation);
\r
131 identity.setEnabled(showAnnotation);
\r
133 conservation.setSelected(showConservation);
\r
134 quality.setSelected(showQuality);
\r
135 identity.setSelected(showIdentity);
\r
137 for(int i=0; i<12; i++)
\r
138 colour.addItem( ColourSchemeProperty.getColourName(i) );
\r
140 string = Cache.getProperty("DEFAULT_COLOUR");
\r
142 colour.setSelectedItem( string );
\r
144 colour.setSelectedIndex( 11 );
\r
146 String fonts[] = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
\r
147 for(int i=0; i<fonts.length; i++)
\r
148 fontNameCB.addItem(fonts[i]);
\r
150 for(int i=1; i<31; i++)
\r
151 fontSizeCB.addItem(i+"");
\r
153 fontStyleCB.addItem("plain");
\r
154 fontStyleCB.addItem("bold");
\r
155 fontStyleCB.addItem("italic");
\r
157 fontNameCB.setSelectedItem(fontName);
\r
158 fontSizeCB.setSelectedItem(fontSize);
\r
159 fontStyleCB.setSelectedItem(fontStyle);
\r
161 gapSymbolCB.addItem("-");
\r
162 gapSymbolCB.addItem(".");
\r
164 gapSymbolCB.setSelectedItem( gapSymbol+"" );
\r
166 startupCheckbox.setSelected(showStartupFile);
\r
167 startupFileTextfield.setText(startupFile);
\r
171 public void ok_actionPerformed(ActionEvent e)
\r
173 showFullId = fullID.isSelected() ;
\r
174 showFullscreen = fullScreen.isSelected();
\r
175 showAnnotation = annotations.isSelected();
\r
176 showConservation = conservation.isSelected();
\r
177 showQuality = quality.isSelected();
\r
178 showIdentity = identity.isSelected();
\r
179 defaultColour = colour.getSelectedItem().toString();
\r
180 gapSymbol = gapSymbolCB.getSelectedItem().toString().charAt(0);
\r
181 fontName = fontNameCB.getSelectedItem().toString();
\r
182 fontSize = fontSizeCB.getSelectedItem().toString();
\r
183 fontStyle = fontStyleCB.getSelectedItem().toString();
\r
184 startupFile = startupFileTextfield.getText();
\r
185 showStartupFile = startupCheckbox.isSelected();
\r
187 Cache.setProperty("SHOW_FULL_ID", Boolean.toString(showFullId));
\r
188 Cache.setProperty("SHOW_FULLSCREEN", Boolean.toString( showFullscreen ) );
\r
190 Cache.setProperty("SHOW_ANNOTATIONS", Boolean.toString( showAnnotation ));
\r
191 Cache.setProperty("SHOW_CONSERVATION", Boolean.toString( showConservation ));
\r
192 Cache.setProperty("SHOW_QUALITY", Boolean.toString( showQuality ));
\r
193 Cache.setProperty("SHOW_IDENTITY", Boolean.toString( showIdentity ));
\r
195 Cache.setProperty("DEFAULT_COLOUR", defaultColour);
\r
196 Cache.setProperty("GAP_SYMBOL", gapSymbol+"");
\r
198 Cache.setProperty("FONT_NAME", fontName);
\r
199 Cache.setProperty("FONT_STYLE", fontStyle);
\r
200 Cache.setProperty("FONT_SIZE", fontSize);
\r
202 Cache.setProperty("STARTUP_FILE", startupFile);
\r
203 Cache.setProperty("SHOW_STARTUP_FILE", Boolean.toString(showStartupFile));
\r
208 frame.setClosed(true);
\r
209 } catch (Exception ex) {}
\r
213 public void startupFileTextfield_mouseClicked()
\r
215 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
\r
216 new String[]{"fa, fasta, fastq", "aln", "pfam", "msf", "pir","blc","jar"},
\r
217 new String[]{"Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview"}
\r
218 ,jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
\r
219 chooser.setFileView(new JalviewFileView());
\r
220 chooser.setDialogTitle("Select startup file");
\r
221 int value = chooser.showOpenDialog(this);
\r
222 if(value == JalviewFileChooser.APPROVE_OPTION)
\r
224 jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
\r
225 startupFileTextfield.setText( chooser.getSelectedFile().getAbsolutePath() );
\r
230 public void cancel_actionPerformed(ActionEvent e)
\r
233 frame.setClosed(true);
\r
234 }catch(Exception ex){}
\r
237 public void annotations_actionPerformed(ActionEvent e)
\r
239 conservation.setEnabled(annotations.isSelected());
\r
240 quality.setEnabled(annotations.isSelected());
\r
241 identity.setEnabled(annotations.isSelected());
\r