/* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ package jalview.gui; import jalview.bin.*; import jalview.io.*; import jalview.jbgui.*; import jalview.schemes.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; /** * DOCUMENT ME! * * @author $author$ * @version $Revision$ */ public class Preferences extends GPreferences { static boolean preferencesLoaded = false; /** DOCUMENT ME!! */ public static boolean showFullscreen = false; /** DOCUMENT ME!! */ public static boolean showFullId = true; /** DOCUMENT ME!! */ public static boolean showAnnotation = true; /** DOCUMENT ME!! */ public static boolean showConservation = true; /** DOCUMENT ME!! */ public static boolean showQuality = true; /** DOCUMENT ME!! */ public static boolean showIdentity = true; /** DOCUMENT ME!! */ public static String fontName = "SansSerif"; /** DOCUMENT ME!! */ public static String fontSize = "10"; /** DOCUMENT ME!! */ public static String fontStyle = Font.PLAIN + ""; /** DOCUMENT ME!! */ public static char gapSymbol = '-'; /** DOCUMENT ME!! */ public static String defaultColour = null; /** DOCUMENT ME!! */ public static boolean showStartupFile = true; /** DOCUMENT ME!! */ public static String startupFile = "http://www.jalview.org/examples/exampleFile.jar"; JInternalFrame frame; /** * Creates a new Preferences object. */ public Preferences() { initPreferences(); frame = new JInternalFrame(); frame.setContentPane(this); Desktop.addInternalFrame(frame, "Preferences", 480, 390); fullID.setSelected(showFullId); String string = Cache.getProperty("SHOW_FULLSCREEN"); boolean value = false; if (string != null) { value = Boolean.valueOf(string).booleanValue(); } fullScreen.setSelected(value); annotations.setSelected(showAnnotation); conservation.setEnabled(showAnnotation); quality.setEnabled(showAnnotation); identity.setEnabled(showAnnotation); conservation.setSelected(showConservation); quality.setSelected(showQuality); identity.setSelected(showIdentity); for (int i = 0; i < 12; i++) { colour.addItem(ColourSchemeProperty.getColourName(i)); } string = Cache.getProperty("DEFAULT_COLOUR"); if (string != null) { colour.setSelectedItem(string); } else { colour.setSelectedIndex(11); } String[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment() .getAvailableFontFamilyNames(); for (int i = 0; i < fonts.length; i++) { fontNameCB.addItem(fonts[i]); } for (int i = 1; i < 31; i++) { fontSizeCB.addItem(i + ""); } fontStyleCB.addItem("plain"); fontStyleCB.addItem("bold"); fontStyleCB.addItem("italic"); fontNameCB.setSelectedItem(fontName); fontSizeCB.setSelectedItem(fontSize); fontStyleCB.setSelectedItem(fontStyle); gapSymbolCB.addItem("-"); gapSymbolCB.addItem("."); gapSymbolCB.setSelectedItem(gapSymbol + ""); startupCheckbox.setSelected(showStartupFile); startupFileTextfield.setText(startupFile); } /** * DOCUMENT ME! */ public static void initPreferences() { String string = Cache.getProperty("SHOW_FULL_ID"); if (string != null) { showFullId = Boolean.valueOf(string).booleanValue(); } string = Cache.getProperty("SHOW_FULLSCREEN"); if (string != null) { showFullscreen = Boolean.valueOf(string).booleanValue(); } string = Cache.getProperty("SHOW_ANNOTATIONS"); if (string != null) { showAnnotation = Boolean.valueOf(string).booleanValue(); } string = Cache.getProperty("SHOW_CONSERVATION"); if (string != null) { showConservation = Boolean.valueOf(string).booleanValue(); } string = Cache.getProperty("SHOW_QUALITY"); if (string != null) { showQuality = Boolean.valueOf(string).booleanValue(); } string = Cache.getProperty("SHOW_IDENTITY"); if (string != null) { showIdentity = Boolean.valueOf(string).booleanValue(); } string = Cache.getProperty("GAP_SYMBOL"); if (string != null) { gapSymbol = string.charAt(0); } string = Cache.getProperty("SHOW_FULL_ID"); if (string != null) { showFullId = Boolean.valueOf(string).booleanValue(); } string = Cache.getProperty("FONT_NAME"); if (string != null) { fontName = string; } string = Cache.getProperty("FONT_STYLE"); if (string != null) { fontStyle = string; } string = Cache.getProperty("FONT_SIZE"); if (string != null) { fontSize = string; } string = Cache.getProperty("DEFAULT_COLOUR"); if (string != null) { defaultColour = string; } string = Cache.getProperty("STARTUP_FILE"); if (string != null) { startupFile = string; } string = Cache.getProperty("SHOW_STARTUP_FILE"); if (string != null) { showStartupFile = Boolean.valueOf(string).booleanValue(); } preferencesLoaded = true; } /** * DOCUMENT ME! * * @param e DOCUMENT ME! */ public void ok_actionPerformed(ActionEvent e) { showFullId = fullID.isSelected(); showFullscreen = fullScreen.isSelected(); showAnnotation = annotations.isSelected(); showConservation = conservation.isSelected(); showQuality = quality.isSelected(); showIdentity = identity.isSelected(); defaultColour = colour.getSelectedItem().toString(); gapSymbol = gapSymbolCB.getSelectedItem().toString().charAt(0); fontName = fontNameCB.getSelectedItem().toString(); fontSize = fontSizeCB.getSelectedItem().toString(); fontStyle = fontStyleCB.getSelectedItem().toString(); startupFile = startupFileTextfield.getText(); showStartupFile = startupCheckbox.isSelected(); Cache.setProperty("SHOW_FULL_ID", Boolean.toString(showFullId)); Cache.setProperty("SHOW_FULLSCREEN", Boolean.toString(showFullscreen)); Cache.setProperty("SHOW_ANNOTATIONS", Boolean.toString(showAnnotation)); Cache.setProperty("SHOW_CONSERVATION", Boolean.toString(showConservation)); Cache.setProperty("SHOW_QUALITY", Boolean.toString(showQuality)); Cache.setProperty("SHOW_IDENTITY", Boolean.toString(showIdentity)); Cache.setProperty("DEFAULT_COLOUR", defaultColour); Cache.setProperty("GAP_SYMBOL", gapSymbol + ""); Cache.setProperty("FONT_NAME", fontName); Cache.setProperty("FONT_STYLE", fontStyle); Cache.setProperty("FONT_SIZE", fontSize); Cache.setProperty("STARTUP_FILE", startupFile); Cache.setProperty("SHOW_STARTUP_FILE", Boolean.toString(showStartupFile)); try { frame.setClosed(true); } catch (Exception ex) { } } /** * DOCUMENT ME! */ public void startupFileTextfield_mouseClicked() { JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty( "LAST_DIRECTORY"), new String[] { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" }, jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle("Select startup file"); int value = chooser.showOpenDialog(this); if (value == JalviewFileChooser.APPROVE_OPTION) { jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", chooser.getSelectedFormat()); startupFileTextfield.setText(chooser.getSelectedFile() .getAbsolutePath()); } } /** * DOCUMENT ME! * * @param e DOCUMENT ME! */ public void cancel_actionPerformed(ActionEvent e) { try { frame.setClosed(true); } catch (Exception ex) { } } /** * DOCUMENT ME! * * @param e DOCUMENT ME! */ public void annotations_actionPerformed(ActionEvent e) { conservation.setEnabled(annotations.isSelected()); quality.setEnabled(annotations.isSelected()); identity.setEnabled(annotations.isSelected()); } }