Viewport now looks at preferences when loading up
authoramwaterhouse <Andrew Waterhouse>
Thu, 28 Apr 2005 15:33:12 +0000 (15:33 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 28 Apr 2005 15:33:12 +0000 (15:33 +0000)
src/jalview/gui/AlignViewport.java

index 7fd7461..a135620 100755 (executable)
@@ -6,6 +6,7 @@ import jalview.analysis.NJTree;
 import jalview.datamodel.*;\r
 import jalview.schemes.*;\r
 import java.util.*;\r
+import jalview.bin.Cache;\r
 \r
 public class AlignViewport\r
 {\r
@@ -23,6 +24,9 @@ public class AlignViewport
   boolean renderGaps = true;\r
   boolean showSequenceFeatures = false;\r
   boolean showAnnotation = true;\r
+  boolean showConservation = true;\r
+  boolean showQuality = true;\r
+  boolean showIdentity = true;\r
 \r
   boolean colourAppliesToAllGroups = true;\r
   ColourSchemeI globalColourScheme = null;\r
@@ -53,21 +57,67 @@ public class AlignViewport
   boolean scaleRightWrapped = true;\r
 \r
 \r
-  public AlignViewport(AlignmentI al,\r
-                       boolean showText,\r
-                       boolean showBoxes,\r
-                       boolean wrapAlignment) {\r
-\r
+  public AlignViewport(AlignmentI al)\r
+  {\r
+    setAlignment(al);\r
     this.startRes = 0;\r
     this.endRes = al.getWidth()-1;\r
     this.startSeq = 0;\r
     this.endSeq = al.getHeight()-1;\r
-    this.showText = showText;\r
-    this.showBoxes = showBoxes;\r
-    this.wrapAlignment = wrapAlignment;\r
 \r
-    setAlignment(al);\r
-    setFont( font );\r
+    updateFromPreferences();\r
+\r
+  }\r
+\r
+  public void updateFromPreferences()\r
+  {\r
+    String string = Cache.getProperty("SHOW_FULL_ID");\r
+    if(string!=null)\r
+      showFullId = 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("SHOW_FULL_ID");\r
+      if(string!=null)\r
+        showFullId = Boolean.valueOf(string).booleanValue();\r
+\r
+  String fontName = Cache.getProperty("FONT_NAME");\r
+  String fontStyle= Cache.getProperty("FONT_STYLE");\r
+  String fontSize = Cache.getProperty("FONT_SIZE");\r
+  if(fontName!=null && fontStyle!=null && fontSize!=null)\r
+      setFont( new Font(fontName,Integer.parseInt(fontStyle),Integer.parseInt(fontSize)) );\r
+  else\r
+      setFont( font );\r
+\r
+    string = Cache.getProperty("GAP_SYMBOL");\r
+    if(string!=null)\r
+      alignment.setGapCharacter( string.charAt(0) );\r
+\r
+\r
+    // We must set conservation and consensus before setting colour,\r
+    // as Blosum and Clustal require this to be done\r
+    updateConservation();\r
+    updateConsensus();\r
+    string = Cache.getProperty("DEFAULT_COLOUR");\r
+    if(string!=null)\r
+    {\r
+      globalColourScheme = ColourSchemeProperty.getColour(alignment, string);\r
+      if(globalColourScheme!=null)\r
+        globalColourScheme.setConsensus( vconsensus );\r
+   }\r
+\r
  }\r
 \r
  public void showSequenceFeatures(boolean b)\r
@@ -137,6 +187,7 @@ public class AlignViewport
                                              0f, // cons.qualityRange[0].floatValue(),\r
                                              11f, // cons.qualityRange[1].floatValue()\r
                                              1);\r
+      if(showConservation)\r
       alignment.addAnnotation(conservation);\r
       quality = new AlignmentAnnotation("Quality",\r
                                         "Alignment Quality based on Blosum62 scores",\r
@@ -144,11 +195,13 @@ public class AlignViewport
                                         cons.qualityRange[0].floatValue(),\r
                                         cons.qualityRange[1].floatValue(),\r
                                         1);\r
-      alignment.addAnnotation(quality);\r
+      if(showQuality)\r
+        alignment.addAnnotation(quality);\r
     }\r
     else {\r
       conservation.annotations = annotations;\r
       quality.annotations = qannotations;\r
+      quality.graphMax = cons.qualityRange[1].floatValue();\r
     }\r
 \r
 \r
@@ -198,7 +251,8 @@ public class AlignViewport
      {\r
        consensus = new AlignmentAnnotation("% Identity",\r
                                            "PID", annotations, 0f, 100f, 1);\r
-       alignment.addAnnotation(consensus);\r
+       if(showIdentity)\r
+         alignment.addAnnotation(consensus);\r
      }\r
      else\r
        consensus.annotations = annotations;\r