3 import jalview.jbgui.*;
\r
4 import jalview.schemes.*;
\r
7 import jalview.bin.Cache;
\r
8 import javax.swing.*;
\r
9 import java.awt.event.ActionEvent;
\r
13 public class Preferences extends GPreferences
\r
15 static boolean preferencesLoaded=false;
\r
17 public static boolean showFullscreen=false;
\r
18 public static boolean showFullId=true;
\r
19 public static boolean showAnnotation=true;
\r
20 public static boolean showConservation=true;
\r
21 public static boolean showQuality=true;
\r
22 public static boolean showIdentity=true;
\r
23 public static String fontName="SansSerif";
\r
24 public static String fontSize="10";
\r
25 public static String fontStyle=Font.PLAIN+"";
\r
26 public static char gapSymbol='-';
\r
27 public static String defaultColour=null;
\r
28 public static boolean showStartupFile=true;
\r
29 public static String startupFile = "http://www.compbio.dundee.ac.uk/~andrew/jalviewTEST/fasta";
\r
31 JInternalFrame frame;
\r
33 public static void initPreferences()
\r
35 String string = Cache.getProperty("SHOW_FULL_ID");
\r
37 showFullId = Boolean.valueOf(string).booleanValue();
\r
39 string = Cache.getProperty("SHOW_FULLSCREEN");
\r
41 showFullscreen = Boolean.valueOf(string).booleanValue();
\r
43 string = Cache.getProperty("SHOW_ANNOTATIONS");
\r
45 showAnnotation = Boolean.valueOf(string).booleanValue();
\r
47 string = Cache.getProperty("SHOW_CONSERVATION");
\r
49 showConservation = Boolean.valueOf(string).booleanValue();
\r
50 string = Cache.getProperty("SHOW_QUALITY");
\r
52 showQuality = Boolean.valueOf(string).booleanValue();
\r
53 string = Cache.getProperty("SHOW_IDENTITY");
\r
55 showIdentity = Boolean.valueOf(string).booleanValue();
\r
57 string = Cache.getProperty("GAP_SYMBOL");
\r
59 gapSymbol = string.charAt(0);
\r
61 string = Cache.getProperty("SHOW_FULL_ID");
\r
63 showFullId = Boolean.valueOf(string).booleanValue();
\r
65 string = Cache.getProperty("FONT_NAME");
\r
69 string = Cache.getProperty("FONT_STYLE");
\r
73 string = Cache.getProperty("FONT_SIZE");
\r
78 string = Cache.getProperty("DEFAULT_COLOUR");
\r
80 defaultColour = string;
\r
82 string = Cache.getProperty("STARTUP_FILE");
\r
84 startupFile = string;
\r
86 string = Cache.getProperty("SHOW_STARTUP_FILE");
\r
88 showStartupFile = Boolean.valueOf(string).booleanValue();
\r
90 preferencesLoaded = true;
\r
93 public Preferences()
\r
97 frame = new JInternalFrame();
\r
98 frame.setContentPane(this);
\r
99 Desktop.addInternalFrame(frame, "Preferences", 480,390 );
\r
101 fullID.setSelected(showFullId);
\r
102 String string = Cache.getProperty("SHOW_FULLSCREEN");
\r
103 boolean value = false;
\r
105 value = Boolean.valueOf(string).booleanValue();
\r
107 fullScreen.setSelected(value);
\r
108 annotations.setSelected(showAnnotation);
\r
110 conservation.setEnabled(showAnnotation);
\r
111 quality.setEnabled(showAnnotation);
\r
112 identity.setEnabled(showAnnotation);
\r
114 conservation.setSelected(showConservation);
\r
115 quality.setSelected(showQuality);
\r
116 identity.setSelected(showIdentity);
\r
118 for(int i=0; i<12; i++)
\r
119 colour.addItem( ColourSchemeProperty.getColourName(i) );
\r
121 string = Cache.getProperty("DEFAULT_COLOUR");
\r
123 colour.setSelectedItem( string );
\r
125 colour.setSelectedIndex( 11 );
\r
127 String fonts[] = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
\r
128 for(int i=0; i<fonts.length; i++)
\r
129 fontNameCB.addItem(fonts[i]);
\r
131 for(int i=1; i<31; i++)
\r
132 fontSizeCB.addItem(i+"");
\r
134 fontStyleCB.addItem("plain");
\r
135 fontStyleCB.addItem("bold");
\r
136 fontStyleCB.addItem("italic");
\r
138 fontNameCB.setSelectedItem(fontName);
\r
139 fontSizeCB.setSelectedItem(fontSize);
\r
140 fontStyleCB.setSelectedItem(fontStyle);
\r
142 gapSymbolCB.addItem("-");
\r
143 gapSymbolCB.addItem(".");
\r
145 gapSymbolCB.setSelectedItem( gapSymbol+"" );
\r
147 startupCheckbox.setSelected(showStartupFile);
\r
148 startupFileTextfield.setText(startupFile);
\r
152 public void ok_actionPerformed(ActionEvent e)
\r
154 showFullId = fullID.isSelected() ;
\r
155 showFullscreen = fullScreen.isSelected();
\r
156 showAnnotation = annotations.isSelected();
\r
157 showConservation = conservation.isSelected();
\r
158 showQuality = quality.isSelected();
\r
159 showIdentity = identity.isSelected();
\r
160 defaultColour = colour.getSelectedItem().toString();
\r
161 gapSymbol = gapSymbolCB.getSelectedItem().toString().charAt(0);
\r
162 fontName = fontNameCB.getSelectedItem().toString();
\r
163 fontSize = fontSizeCB.getSelectedItem().toString();
\r
164 fontStyle = fontStyleCB.getSelectedItem().toString();
\r
165 startupFile = startupFileTextfield.getText();
\r
166 showStartupFile = startupCheckbox.isSelected();
\r
168 Cache.setProperty("SHOW_FULL_ID", Boolean.toString(showFullId));
\r
169 Cache.setProperty("SHOW_FULLSCREEN", Boolean.toString( showFullscreen ) );
\r
171 Cache.setProperty("SHOW_ANNOTATIONS", Boolean.toString( showAnnotation ));
\r
172 Cache.setProperty("SHOW_CONSERVATION", Boolean.toString( showConservation ));
\r
173 Cache.setProperty("SHOW_QUALITY", Boolean.toString( showQuality ));
\r
174 Cache.setProperty("SHOW_IDENTITY", Boolean.toString( showIdentity ));
\r
176 Cache.setProperty("DEFAULT_COLOUR", defaultColour);
\r
177 Cache.setProperty("GAP_SYMBOL", gapSymbol+"");
\r
179 Cache.setProperty("FONT_NAME", fontName);
\r
180 Cache.setProperty("FONT_STYLE", fontStyle);
\r
181 Cache.setProperty("FONT_SIZE", fontSize);
\r
183 Cache.setProperty("STARTUP_FILE", startupFile);
\r
184 Cache.setProperty("SHOW_STARTUP_FILE", Boolean.toString(showStartupFile));
\r
189 frame.setClosed(true);
\r
190 } catch (Exception ex) {}
\r
194 public void startupFileTextfield_mouseClicked()
\r
196 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
\r
197 new String[]{"fa, fasta, fastq", "aln", "pfam", "msf", "pir","blc","jar"},
\r
198 new String[]{"Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview"}
\r
199 ,jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
\r
200 chooser.setFileView(new JalviewFileView());
\r
201 chooser.setDialogTitle("Select startup file");
\r
202 int value = chooser.showOpenDialog(this);
\r
203 if(value == JalviewFileChooser.APPROVE_OPTION)
\r
205 jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
\r
206 startupFileTextfield.setText( chooser.getSelectedFile().getAbsolutePath() );
\r
211 public void cancel_actionPerformed(ActionEvent e)
\r
214 frame.setClosed(true);
\r
215 }catch(Exception ex){}
\r
218 public void annotations_actionPerformed(ActionEvent e)
\r
220 conservation.setEnabled(annotations.isSelected());
\r
221 quality.setEnabled(annotations.isSelected());
\r
222 identity.setEnabled(annotations.isSelected());
\r