Preferences panel added
authoramwaterhouse <Andrew Waterhouse>
Thu, 28 Apr 2005 15:28:28 +0000 (15:28 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 28 Apr 2005 15:28:28 +0000 (15:28 +0000)
src/jalview/gui/Preferences.java [new file with mode: 0755]

diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java
new file mode 100755 (executable)
index 0000000..6c07d23
--- /dev/null
@@ -0,0 +1,113 @@
+package jalview.gui;\r
+\r
+import jalview.jbgui.*;\r
+import jalview.schemes.*;\r
+\r
+import jalview.bin.Cache;\r
+import javax.swing.*;\r
+import java.awt.event.ActionEvent;\r
+import java.awt.*;\r
+\r
+public class Preferences extends GPreferences\r
+{\r
+  AlignViewport av;\r
+  JInternalFrame frame;\r
+  public Preferences(AlignViewport av)\r
+  {\r
+    this.av = av;\r
+    frame = new JInternalFrame();\r
+    frame.setContentPane(this);\r
+    Desktop.addInternalFrame(frame, "Preferences", 480,350 );\r
+\r
+\r
+    fullID.setSelected(av.getShowFullId());\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
+\r
+    conservation.setEnabled(av.getShowAnnotation());\r
+    quality.setEnabled(av.getShowAnnotation());\r
+    identity.setEnabled(av.getShowAnnotation());\r
+\r
+    conservation.setSelected(av.showConservation);\r
+    quality.setSelected(av.showQuality);\r
+    identity.setSelected(av.showIdentity);\r
+\r
+    for(int i=0; i<12; i++)\r
+      colour.addItem( ColourSchemeProperty.getColourName(i) );\r
+\r
+    string = Cache.getProperty("DEFAULT_COLOUR");\r
+    if(string!=null)\r
+      colour.setSelectedItem( string );\r
+    else\r
+      colour.setSelectedIndex( 11 );\r
+\r
+    String fonts[] = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();\r
+    for(int i=0; i<fonts.length; i++)\r
+      fontName.addItem(fonts[i]);\r
+\r
+    for(int i=1; i<31; i++)\r
+      fontSize.addItem(i+"");\r
+\r
+   fontStyle.addItem("plain");\r
+   fontStyle.addItem("bold");\r
+   fontStyle.addItem("italic");\r
+\r
+   Font oldFont = av.getFont();\r
+   fontName.setSelectedItem(oldFont.getName());\r
+   fontSize.setSelectedItem(oldFont.getSize() + "");\r
+   fontStyle.setSelectedIndex(oldFont.getStyle());\r
+\r
+   gapSymbol.addItem("-");\r
+   gapSymbol.addItem(".");\r
+\r
+   gapSymbol.setSelectedItem( av.getGapCharacter()+"" );\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
+\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
+\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
+\r
+  public void cancel_actionPerformed(ActionEvent e)\r
+  {\r
+    try{\r
+      frame.setClosed(true);\r
+    }catch(Exception ex){}\r
+  }\r
+\r
+  public void annotations_actionPerformed(ActionEvent e)\r
+  {\r
+    conservation.setEnabled(annotations.isSelected());\r
+    quality.setEnabled(annotations.isSelected());\r
+    identity.setEnabled(annotations.isSelected());\r
+  }\r
+\r
+}\r