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;
\r
24 public static String fontSize;
\r
25 public static String fontStyle;
\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 fontName = Cache.getProperty("FONT_NAME");
\r
66 fontStyle = Cache.getProperty("FONT_STYLE");
\r
67 fontSize = Cache.getProperty("FONT_SIZE");
\r
69 string = Cache.getProperty("DEFAULT_COLOUR");
\r
71 defaultColour = string;
\r
73 string = Cache.getProperty("STARTUP_FILE");
\r
75 startupFile = string;
\r
77 string = Cache.getProperty("SHOW_STARTUP_FILE");
\r
79 showStartupFile = Boolean.valueOf(string).booleanValue();
\r
81 preferencesLoaded = true;
\r
84 public Preferences()
\r
86 if(!preferencesLoaded)
\r
89 frame = new JInternalFrame();
\r
90 frame.setContentPane(this);
\r
91 Desktop.addInternalFrame(frame, "Preferences", 480,390 );
\r
93 fullID.setSelected(showFullId);
\r
94 String string = Cache.getProperty("SHOW_FULLSCREEN");
\r
95 boolean value = false;
\r
97 value = Boolean.valueOf(string).booleanValue();
\r
99 fullScreen.setSelected(value);
\r
100 annotations.setSelected(showAnnotation);
\r
102 conservation.setEnabled(showAnnotation);
\r
103 quality.setEnabled(showAnnotation);
\r
104 identity.setEnabled(showAnnotation);
\r
106 conservation.setSelected(showConservation);
\r
107 quality.setSelected(showQuality);
\r
108 identity.setSelected(showIdentity);
\r
110 for(int i=0; i<12; i++)
\r
111 colour.addItem( ColourSchemeProperty.getColourName(i) );
\r
113 string = Cache.getProperty("DEFAULT_COLOUR");
\r
115 colour.setSelectedItem( string );
\r
117 colour.setSelectedIndex( 11 );
\r
119 String fonts[] = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
\r
120 for(int i=0; i<fonts.length; i++)
\r
121 fontNameCB.addItem(fonts[i]);
\r
123 for(int i=1; i<31; i++)
\r
124 fontSizeCB.addItem(i+"");
\r
126 fontStyleCB.addItem("plain");
\r
127 fontStyleCB.addItem("bold");
\r
128 fontStyleCB.addItem("italic");
\r
130 fontNameCB.setSelectedItem(fontName);
\r
131 fontSizeCB.setSelectedItem(fontSize);
\r
132 fontStyleCB.setSelectedItem(fontStyle);
\r
134 gapSymbolCB.addItem("-");
\r
135 gapSymbolCB.addItem(".");
\r
137 gapSymbolCB.setSelectedItem( gapSymbol+"" );
\r
139 startupCheckbox.setSelected(showStartupFile);
\r
140 startupFileTextfield.setText(startupFile);
\r
144 public void ok_actionPerformed(ActionEvent e)
\r
146 showFullId = fullID.isSelected() ;
\r
147 showFullscreen = fullScreen.isSelected();
\r
148 showAnnotation = annotations.isSelected();
\r
149 showConservation = conservation.isSelected();
\r
150 showQuality = quality.isSelected();
\r
151 showIdentity = identity.isSelected();
\r
152 defaultColour = colour.getSelectedItem().toString();
\r
153 gapSymbol = gapSymbolCB.getSelectedItem().toString().charAt(0);
\r
154 fontName = fontNameCB.getSelectedItem().toString();
\r
155 fontSize = fontSizeCB.getSelectedItem().toString();
\r
156 fontStyle = fontStyleCB.getSelectedItem().toString();
\r
157 startupFile = startupFileTextfield.getText();
\r
158 showStartupFile = startupCheckbox.isSelected();
\r
160 Cache.setProperty("SHOW_FULL_ID", Boolean.toString(showFullId));
\r
161 Cache.setProperty("SHOW_FULLSCREEN", Boolean.toString( showFullscreen ) );
\r
163 Cache.setProperty("SHOW_ANNOTATIONS", Boolean.toString( showAnnotation ));
\r
164 Cache.setProperty("SHOW_CONSERVATION", Boolean.toString( showConservation ));
\r
165 Cache.setProperty("SHOW_QUALITY", Boolean.toString( showQuality ));
\r
166 Cache.setProperty("SHOW_IDENTITY", Boolean.toString( showIdentity ));
\r
168 Cache.setProperty("DEFAULT_COLOUR", defaultColour);
\r
169 Cache.setProperty("GAP_SYMBOL", gapSymbol+"");
\r
171 Cache.setProperty("FONT_NAME", fontName);
\r
172 Cache.setProperty("FONT_STYLE", fontStyle);
\r
173 Cache.setProperty("FONT_SIZE", fontSize);
\r
175 Cache.setProperty("STARTUP_FILE", startupFile);
\r
176 Cache.setProperty("SHOW_STARTUP_FILE", Boolean.toString(showStartupFile));
\r
181 frame.setClosed(true);
\r
182 } catch (Exception ex) {}
\r
186 public void startupFileTextfield_mouseClicked()
\r
188 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
\r
189 new String[]{"fa, fasta, fastq", "aln", "pfam", "msf", "pir","blc","jar"},
\r
190 new String[]{"Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview"}
\r
191 ,jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
\r
192 chooser.setFileView(new JalviewFileView());
\r
193 chooser.setDialogTitle("Select startup file");
\r
194 int value = chooser.showOpenDialog(this);
\r
195 if(value == JalviewFileChooser.APPROVE_OPTION)
\r
197 jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
\r
198 startupFileTextfield.setText( chooser.getSelectedFile().getAbsolutePath() );
\r
203 public void cancel_actionPerformed(ActionEvent e)
\r
206 frame.setClosed(true);
\r
207 }catch(Exception ex){}
\r
210 public void annotations_actionPerformed(ActionEvent e)
\r
212 conservation.setEnabled(annotations.isSelected());
\r
213 quality.setEnabled(annotations.isSelected());
\r
214 identity.setEnabled(annotations.isSelected());
\r