From 62fcb83be442a0d2bbce77423a6bfed2303f6959 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Fri, 29 Apr 2005 10:42:48 +0000 Subject: [PATCH] preferences held statically --- src/jalview/gui/AlignViewport.java | 59 ++++++--------- src/jalview/gui/Preferences.java | 142 +++++++++++++++++++++++++----------- 2 files changed, 123 insertions(+), 78 deletions(-) diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index a135620..98fd229 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -71,49 +71,36 @@ public class AlignViewport public void updateFromPreferences() { - String string = Cache.getProperty("SHOW_FULL_ID"); - if(string!=null) - showFullId = 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("SHOW_FULL_ID"); - if(string!=null) - showFullId = Boolean.valueOf(string).booleanValue(); - - String fontName = Cache.getProperty("FONT_NAME"); - String fontStyle= Cache.getProperty("FONT_STYLE"); - String fontSize = Cache.getProperty("FONT_SIZE"); - if(fontName!=null && fontStyle!=null && fontSize!=null) - setFont( new Font(fontName,Integer.parseInt(fontStyle),Integer.parseInt(fontSize)) ); - else - setFont( font ); - - string = Cache.getProperty("GAP_SYMBOL"); - if(string!=null) - alignment.setGapCharacter( string.charAt(0) ); + showFullId = Preferences.showFullId; + showAnnotation = Preferences.showAnnotation; + showConservation = Preferences.showConservation; + showQuality = Preferences.showQuality; + showIdentity = Preferences.showIdentity; + showFullId = Preferences.showFullId; + String fontName = Preferences.fontName; + String fontStyle = Preferences.fontStyle; + String fontSize = Cache.getProperty("FONT_SIZE"); + if (fontName != null && fontStyle != null && fontSize != null) + { + int style = 0; + if(fontStyle.equals("bold")) + style = 1; + else if(fontStyle.equals("italic")) + style = 2; + setFont(new Font(fontName, style, Integer.parseInt(fontSize))); + } + else + setFont(font); + alignment.setGapCharacter(Preferences.gapSymbol); // We must set conservation and consensus before setting colour, // as Blosum and Clustal require this to be done updateConservation(); updateConsensus(); - string = Cache.getProperty("DEFAULT_COLOUR"); - if(string!=null) + if(Preferences.defaultColour!=null) { - globalColourScheme = ColourSchemeProperty.getColour(alignment, string); + globalColourScheme = ColourSchemeProperty.getColour(alignment, Preferences.defaultColour); if(globalColourScheme!=null) globalColourScheme.setConsensus( vconsensus ); } diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 6c07d23..264ef03 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -10,32 +10,83 @@ import java.awt.*; public class Preferences extends GPreferences { - AlignViewport av; + static boolean preferencesLoaded=false; + + public static boolean showFullscreen=false; + public static boolean showFullId=true; + public static boolean showAnnotation=true; + public static boolean showConservation=true; + public static boolean showQuality=true; + public static boolean showIdentity=true; + public static String fontName; + public static String fontSize; + public static String fontStyle; + public static char gapSymbol='-'; + public static String defaultColour=null; + JInternalFrame frame; - public Preferences(AlignViewport av) + + 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("SHOW_FULL_ID"); + if(string!=null) + showFullId = Boolean.valueOf(string).booleanValue(); + + fontName = Cache.getProperty("FONT_NAME"); + fontStyle = Cache.getProperty("FONT_STYLE"); + fontSize = Cache.getProperty("FONT_SIZE"); + + preferencesLoaded = true; + } + + public Preferences() { - this.av = av; + if(!preferencesLoaded) + initPreferences(); + frame = new JInternalFrame(); frame.setContentPane(this); Desktop.addInternalFrame(frame, "Preferences", 480,350 ); - - fullID.setSelected(av.getShowFullId()); + 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(av.getShowAnnotation()); + annotations.setSelected(showAnnotation); - conservation.setEnabled(av.getShowAnnotation()); - quality.setEnabled(av.getShowAnnotation()); - identity.setEnabled(av.getShowAnnotation()); + conservation.setEnabled(showAnnotation); + quality.setEnabled(showAnnotation); + identity.setEnabled(showAnnotation); - conservation.setSelected(av.showConservation); - quality.setSelected(av.showQuality); - identity.setSelected(av.showIdentity); + conservation.setSelected(showConservation); + quality.setSelected(showQuality); + identity.setSelected(showIdentity); for(int i=0; i<12; i++) colour.addItem( ColourSchemeProperty.getColourName(i) ); @@ -48,52 +99,59 @@ public class Preferences extends GPreferences String fonts[] = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); for(int i=0; i