3 import jalview.jbgui.*;
\r
4 import jalview.schemes.*;
\r
6 import jalview.bin.Cache;
\r
7 import javax.swing.*;
\r
8 import java.awt.event.ActionEvent;
\r
11 public class Preferences extends GPreferences
\r
13 static boolean preferencesLoaded=false;
\r
15 public static boolean showFullscreen=false;
\r
16 public static boolean showFullId=true;
\r
17 public static boolean showAnnotation=true;
\r
18 public static boolean showConservation=true;
\r
19 public static boolean showQuality=true;
\r
20 public static boolean showIdentity=true;
\r
21 public static String fontName;
\r
22 public static String fontSize;
\r
23 public static String fontStyle;
\r
24 public static char gapSymbol='-';
\r
25 public static String defaultColour=null;
\r
27 JInternalFrame frame;
\r
29 public static void initPreferences()
\r
31 String string = Cache.getProperty("SHOW_FULL_ID");
\r
33 showFullId = Boolean.valueOf(string).booleanValue();
\r
35 string = Cache.getProperty("SHOW_FULLSCREEN");
\r
37 showFullscreen = Boolean.valueOf(string).booleanValue();
\r
40 string = Cache.getProperty("SHOW_ANNOTATIONS");
\r
42 showAnnotation = Boolean.valueOf(string).booleanValue();
\r
44 string = Cache.getProperty("SHOW_CONSERVATION");
\r
46 showConservation = Boolean.valueOf(string).booleanValue();
\r
47 string = Cache.getProperty("SHOW_QUALITY");
\r
49 showQuality = Boolean.valueOf(string).booleanValue();
\r
50 string = Cache.getProperty("SHOW_IDENTITY");
\r
52 showIdentity = Boolean.valueOf(string).booleanValue();
\r
54 string = Cache.getProperty("SHOW_FULL_ID");
\r
56 showFullId = Boolean.valueOf(string).booleanValue();
\r
58 fontName = Cache.getProperty("FONT_NAME");
\r
59 fontStyle = Cache.getProperty("FONT_STYLE");
\r
60 fontSize = Cache.getProperty("FONT_SIZE");
\r
62 preferencesLoaded = true;
\r
65 public Preferences()
\r
67 if(!preferencesLoaded)
\r
70 frame = new JInternalFrame();
\r
71 frame.setContentPane(this);
\r
72 Desktop.addInternalFrame(frame, "Preferences", 480,350 );
\r
74 fullID.setSelected(showFullId);
\r
75 String string = Cache.getProperty("SHOW_FULLSCREEN");
\r
76 boolean value = false;
\r
78 value = Boolean.valueOf(string).booleanValue();
\r
80 fullScreen.setSelected(value);
\r
81 annotations.setSelected(showAnnotation);
\r
83 conservation.setEnabled(showAnnotation);
\r
84 quality.setEnabled(showAnnotation);
\r
85 identity.setEnabled(showAnnotation);
\r
87 conservation.setSelected(showConservation);
\r
88 quality.setSelected(showQuality);
\r
89 identity.setSelected(showIdentity);
\r
91 for(int i=0; i<12; i++)
\r
92 colour.addItem( ColourSchemeProperty.getColourName(i) );
\r
94 string = Cache.getProperty("DEFAULT_COLOUR");
\r
96 colour.setSelectedItem( string );
\r
98 colour.setSelectedIndex( 11 );
\r
100 String fonts[] = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
\r
101 for(int i=0; i<fonts.length; i++)
\r
102 fontNameCB.addItem(fonts[i]);
\r
104 for(int i=1; i<31; i++)
\r
105 fontSizeCB.addItem(i+"");
\r
107 fontStyleCB.addItem("plain");
\r
108 fontStyleCB.addItem("bold");
\r
109 fontStyleCB.addItem("italic");
\r
111 fontNameCB.setSelectedItem(fontName);
\r
112 fontSizeCB.setSelectedItem(fontSize);
\r
113 fontStyleCB.setSelectedItem(fontStyle);
\r
115 gapSymbolCB.addItem("-");
\r
116 gapSymbolCB.addItem(".");
\r
118 gapSymbolCB.setSelectedItem( gapSymbol+"" );
\r
122 public void ok_actionPerformed(ActionEvent e)
\r
124 showFullId = fullID.isSelected() ;
\r
125 showFullscreen = fullScreen.isSelected();
\r
126 showAnnotation = annotations.isSelected();
\r
127 showConservation = conservation.isSelected();
\r
128 showQuality = quality.isSelected();
\r
129 showIdentity = identity.isSelected();
\r
130 defaultColour = colour.getSelectedItem().toString();
\r
131 gapSymbol = gapSymbolCB.getSelectedItem().toString().charAt(0);
\r
132 fontName = fontNameCB.getSelectedItem().toString();
\r
133 fontSize = fontSizeCB.getSelectedItem().toString();
\r
134 fontStyle = fontStyleCB.getSelectedItem().toString();
\r
136 Cache.setProperty("SHOW_FULL_ID", Boolean.toString(showFullId));
\r
137 Cache.setProperty("SHOW_FULLSCREEN", Boolean.toString( showFullscreen ) );
\r
139 Cache.setProperty("SHOW_ANNOTATIONS", Boolean.toString( showAnnotation ));
\r
140 Cache.setProperty("SHOW_CONSERVATION", Boolean.toString( showConservation ));
\r
141 Cache.setProperty("SHOW_QUALITY", Boolean.toString( showQuality ));
\r
142 Cache.setProperty("SHOW_IDENTITY", Boolean.toString( showIdentity ));
\r
144 Cache.setProperty("DEFAULT_COLOUR", defaultColour);
\r
145 Cache.setProperty("GAP_SYMBOL", gapSymbol+"");
\r
147 Cache.setProperty("FONT_NAME", fontName);
\r
148 Cache.setProperty("FONT_STYLE", fontStyle);
\r
149 Cache.setProperty("FONT_SIZE", fontSize);
\r
152 frame.setClosed(true);
\r
153 } catch (Exception ex) {}
\r
157 public void cancel_actionPerformed(ActionEvent e)
\r
160 frame.setClosed(true);
\r
161 }catch(Exception ex){}
\r
164 public void annotations_actionPerformed(ActionEvent e)
\r
166 conservation.setEnabled(annotations.isSelected());
\r
167 quality.setEnabled(annotations.isSelected());
\r
168 identity.setEnabled(annotations.isSelected());
\r