\r
import jalview.jbgui.*;\r
import jalview.schemes.*;\r
+import jalview.io.*;\r
\r
import jalview.bin.Cache;\r
import javax.swing.*;\r
import java.awt.event.ActionEvent;\r
import java.awt.*;\r
\r
+\r
public class Preferences extends GPreferences\r
{\r
- AlignViewport av;\r
+ static boolean preferencesLoaded=false;\r
+\r
+ public static boolean showFullscreen=false;\r
+ public static boolean showFullId=true;\r
+ public static boolean showAnnotation=true;\r
+ public static boolean showConservation=true;\r
+ public static boolean showQuality=true;\r
+ public static boolean showIdentity=true;\r
+ public static String fontName="SansSerif";\r
+ public static String fontSize="10";\r
+ public static String fontStyle=Font.PLAIN+"";\r
+ public static char gapSymbol='-';\r
+ public static String defaultColour=null;\r
+ public static boolean showStartupFile=true;\r
+ public static String startupFile = "http://www.compbio.dundee.ac.uk/~andrew/jalviewTEST/fasta";\r
+\r
JInternalFrame frame;\r
- public Preferences(AlignViewport av)\r
+\r
+ public static void initPreferences()\r
{\r
- this.av = av;\r
+ String string = Cache.getProperty("SHOW_FULL_ID");\r
+ if(string!=null)\r
+ showFullId = Boolean.valueOf(string).booleanValue();\r
+\r
+ string = Cache.getProperty("SHOW_FULLSCREEN");\r
+ if(string!=null)\r
+ showFullscreen = Boolean.valueOf(string).booleanValue();\r
+\r
+ string = Cache.getProperty("SHOW_ANNOTATIONS");\r
+ if(string!=null)\r
+ showAnnotation = Boolean.valueOf(string).booleanValue();\r
+\r
+ string = Cache.getProperty("SHOW_CONSERVATION");\r
+ if(string!=null)\r
+ showConservation = Boolean.valueOf(string).booleanValue();\r
+ string = Cache.getProperty("SHOW_QUALITY");\r
+ if(string!=null)\r
+ showQuality = Boolean.valueOf(string).booleanValue();\r
+ string = Cache.getProperty("SHOW_IDENTITY");\r
+ if(string!=null)\r
+ showIdentity = Boolean.valueOf(string).booleanValue();\r
+\r
+ string = Cache.getProperty("GAP_SYMBOL");\r
+ if(string!=null)\r
+ gapSymbol = string.charAt(0);\r
+\r
+ string = Cache.getProperty("SHOW_FULL_ID");\r
+ if(string!=null)\r
+ showFullId = Boolean.valueOf(string).booleanValue();\r
+\r
+ string = Cache.getProperty("FONT_NAME");\r
+ if (string != null)\r
+ fontName = string;\r
+\r
+ string = Cache.getProperty("FONT_STYLE");\r
+ if (string != null)\r
+ fontStyle = string;\r
+\r
+ string = Cache.getProperty("FONT_SIZE");\r
+ if (string != null)\r
+ fontSize = string;\r
+\r
+\r
+ string = Cache.getProperty("DEFAULT_COLOUR");\r
+ if(string!=null)\r
+ defaultColour = string;\r
+\r
+ string = Cache.getProperty("STARTUP_FILE");\r
+ if(string!=null)\r
+ startupFile = string;\r
+\r
+ string = Cache.getProperty("SHOW_STARTUP_FILE");\r
+ if(string!=null)\r
+ showStartupFile = Boolean.valueOf(string).booleanValue();\r
+\r
+ preferencesLoaded = true;\r
+ }\r
+\r
+ public Preferences()\r
+ {\r
+ initPreferences();\r
+\r
frame = new JInternalFrame();\r
frame.setContentPane(this);\r
- Desktop.addInternalFrame(frame, "Preferences", 480,350 );\r
-\r
+ Desktop.addInternalFrame(frame, "Preferences", 480,390 );\r
\r
- fullID.setSelected(av.getShowFullId());\r
+ fullID.setSelected(showFullId);\r
String string = Cache.getProperty("SHOW_FULLSCREEN");\r
boolean value = false;\r
if(string!=null)\r
value = Boolean.valueOf(string).booleanValue();\r
\r
fullScreen.setSelected(value);\r
- annotations.setSelected(av.getShowAnnotation());\r
+ annotations.setSelected(showAnnotation);\r
\r
- conservation.setEnabled(av.getShowAnnotation());\r
- quality.setEnabled(av.getShowAnnotation());\r
- identity.setEnabled(av.getShowAnnotation());\r
+ conservation.setEnabled(showAnnotation);\r
+ quality.setEnabled(showAnnotation);\r
+ identity.setEnabled(showAnnotation);\r
\r
- conservation.setSelected(av.showConservation);\r
- quality.setSelected(av.showQuality);\r
- identity.setSelected(av.showIdentity);\r
+ conservation.setSelected(showConservation);\r
+ quality.setSelected(showQuality);\r
+ identity.setSelected(showIdentity);\r
\r
for(int i=0; i<12; i++)\r
colour.addItem( ColourSchemeProperty.getColourName(i) );\r
\r
String fonts[] = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();\r
for(int i=0; i<fonts.length; i++)\r
- fontName.addItem(fonts[i]);\r
+ fontNameCB.addItem(fonts[i]);\r
\r
for(int i=1; i<31; i++)\r
- fontSize.addItem(i+"");\r
+ fontSizeCB.addItem(i+"");\r
\r
- fontStyle.addItem("plain");\r
- fontStyle.addItem("bold");\r
- fontStyle.addItem("italic");\r
+ fontStyleCB.addItem("plain");\r
+ fontStyleCB.addItem("bold");\r
+ fontStyleCB.addItem("italic");\r
\r
- Font oldFont = av.getFont();\r
- fontName.setSelectedItem(oldFont.getName());\r
- fontSize.setSelectedItem(oldFont.getSize() + "");\r
- fontStyle.setSelectedIndex(oldFont.getStyle());\r
+ fontNameCB.setSelectedItem(fontName);\r
+ fontSizeCB.setSelectedItem(fontSize);\r
+ fontStyleCB.setSelectedItem(fontStyle);\r
\r
- gapSymbol.addItem("-");\r
- gapSymbol.addItem(".");\r
+ gapSymbolCB.addItem("-");\r
+ gapSymbolCB.addItem(".");\r
\r
- gapSymbol.setSelectedItem( av.getGapCharacter()+"" );\r
+ gapSymbolCB.setSelectedItem( gapSymbol+"" );\r
+\r
+ startupCheckbox.setSelected(showStartupFile);\r
+ startupFileTextfield.setText(startupFile);\r
\r
}\r
\r
public void ok_actionPerformed(ActionEvent e)\r
{\r
- Cache.setProperty("SHOW_FULL_ID", Boolean.toString( fullID.isSelected() ));\r
- Cache.setProperty("SHOW_FULLSCREEN", Boolean.toString( fullScreen.isSelected() ));\r
+ showFullId = fullID.isSelected() ;\r
+ showFullscreen = fullScreen.isSelected();\r
+ showAnnotation = annotations.isSelected();\r
+ showConservation = conservation.isSelected();\r
+ showQuality = quality.isSelected();\r
+ showIdentity = identity.isSelected();\r
+ defaultColour = colour.getSelectedItem().toString();\r
+ gapSymbol = gapSymbolCB.getSelectedItem().toString().charAt(0);\r
+ fontName = fontNameCB.getSelectedItem().toString();\r
+ fontSize = fontSizeCB.getSelectedItem().toString();\r
+ fontStyle = fontStyleCB.getSelectedItem().toString();\r
+ startupFile = startupFileTextfield.getText();\r
+ showStartupFile = startupCheckbox.isSelected();\r
+\r
+ Cache.setProperty("SHOW_FULL_ID", Boolean.toString(showFullId));\r
+ Cache.setProperty("SHOW_FULLSCREEN", Boolean.toString( showFullscreen ) );\r
+\r
+ Cache.setProperty("SHOW_ANNOTATIONS", Boolean.toString( showAnnotation ));\r
+ Cache.setProperty("SHOW_CONSERVATION", Boolean.toString( showConservation ));\r
+ Cache.setProperty("SHOW_QUALITY", Boolean.toString( showQuality ));\r
+ Cache.setProperty("SHOW_IDENTITY", Boolean.toString( showIdentity ));\r
\r
- Cache.setProperty("SHOW_ANNOTATIONS", Boolean.toString( annotations.isSelected() ));\r
- Cache.setProperty("SHOW_CONSERVATION", Boolean.toString( conservation.isSelected() ));\r
- Cache.setProperty("SHOW_QUALITY", Boolean.toString( quality.isSelected() ));\r
- Cache.setProperty("SHOW_IDENTITY", Boolean.toString( identity.isSelected() ));\r
+ Cache.setProperty("DEFAULT_COLOUR", defaultColour);\r
+ Cache.setProperty("GAP_SYMBOL", gapSymbol+"");\r
+\r
+ Cache.setProperty("FONT_NAME", fontName);\r
+ Cache.setProperty("FONT_STYLE", fontStyle);\r
+ Cache.setProperty("FONT_SIZE", fontSize);\r
+\r
+ Cache.setProperty("STARTUP_FILE", startupFile);\r
+ Cache.setProperty("SHOW_STARTUP_FILE", Boolean.toString(showStartupFile));\r
\r
- Cache.setProperty("DEFAULT_COLOUR", colour.getSelectedItem().toString() );\r
- Cache.setProperty("GAP_SYMBOL", gapSymbol.getSelectedItem().toString());\r
\r
- Cache.setProperty("FONT_NAME", fontName.getSelectedItem().toString());\r
- Cache.setProperty("FONT_STYLE", fontStyle.getSelectedIndex()+"");\r
- Cache.setProperty("FONT_SIZE", fontSize.getSelectedItem().toString());\r
\r
try {\r
frame.setClosed(true);\r
} catch (Exception ex) {}\r
\r
- av.updateFromPreferences();\r
-\r
- repaint();\r
+ }\r
\r
+ public void startupFileTextfield_mouseClicked()\r
+ {\r
+ JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY"),\r
+ new String[]{"fa, fasta, fastq", "aln", "pfam", "msf", "pir","blc","jar"},\r
+ new String[]{"Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview"}\r
+ ,jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));\r
+ chooser.setFileView(new JalviewFileView());\r
+ chooser.setDialogTitle("Select startup file");\r
+ int value = chooser.showOpenDialog(this);\r
+ if(value == JalviewFileChooser.APPROVE_OPTION)\r
+ {\r
+ jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());\r
+ startupFileTextfield.setText( chooser.getSelectedFile().getAbsolutePath() );\r
+ }\r
}\r
\r
+\r
public void cancel_actionPerformed(ActionEvent e)\r
{\r
try{\r