new ROWPROPERTIES statement for setting an individual row's label format
authorjprocter <Jim Procter>
Thu, 11 Mar 2010 17:08:15 +0000 (17:08 +0000)
committerjprocter <Jim Procter>
Thu, 11 Mar 2010 17:08:15 +0000 (17:08 +0000)
src/jalview/io/AnnotationFile.java

index 0095aef..4e15c18 100755 (executable)
@@ -85,7 +85,7 @@ public class AnnotationFile
 \r
       StringBuffer colours = new StringBuffer();\r
       StringBuffer graphLine = new StringBuffer();\r
-\r
+      StringBuffer rowprops = new StringBuffer();\r
       Hashtable graphGroup = new Hashtable();\r
 \r
       java.awt.Color color;\r
@@ -276,7 +276,14 @@ public class AnnotationFile
           colours.append("COLOUR\t" + row.label + "\t"\r
                   + jalview.util.Format.getHexString(color) + "\n");\r
         }\r
-\r
+        if (row.scaleColLabel || row.showAllColLabels || row.centreColLabels)\r
+        {\r
+          rowprops.append("ROWPROPERTIES\t"+row.label);\r
+          rowprops.append("\tscaletofit="+row.scaleColLabel);\r
+          rowprops.append("\tshowalllabs="+row.showAllColLabels);\r
+          rowprops.append("\tcentrelabs="+row.centreColLabels);\r
+          rowprops.append("\n");\r
+        }\r
       }\r
 \r
       text.append("\n");\r
@@ -292,6 +299,7 @@ public class AnnotationFile
           text.append(en.nextElement() + "\n");\r
         }\r
       }\r
+      text.append(rowprops);\r
     }\r
 \r
     if (groups != null)\r
@@ -498,7 +506,11 @@ public class AnnotationFile
           combineAnnotations(al, st);\r
           continue;\r
         }\r
-\r
+        else if (token.equalsIgnoreCase("ROWPROPERTIES"))\r
+        {\r
+          addRowProperties(al, st);\r
+          continue;\r
+        }\r
         else if (token.equalsIgnoreCase("GRAPHLINE"))\r
         {\r
           addLine(al, st);\r
@@ -933,6 +945,35 @@ public class AnnotationFile
     }\r
   }\r
 \r
+  void addRowProperties(AlignmentI al, StringTokenizer st)\r
+  {\r
+    String label = st.nextToken(),keyValue,key,value;\r
+    boolean scaletofit=false,centerlab=false,showalllabs=false;\r
+    while (st.hasMoreTokens()) {\r
+      keyValue=st.nextToken();\r
+      key = keyValue.substring(0, keyValue.indexOf("="));\r
+      value = keyValue.substring(keyValue.indexOf("=") + 1);\r
+      if (key.equalsIgnoreCase("scaletofit")) {\r
+        scaletofit = Boolean.valueOf(value).booleanValue();\r
+      }\r
+        if (key.equalsIgnoreCase("showalllabs")) {\r
+          showalllabs = Boolean.valueOf(value).booleanValue();\r
+        }\r
+        if (key.equalsIgnoreCase("centrelabs")) {\r
+          centerlab = Boolean.valueOf(value).booleanValue();\r
+    }\r
+        AlignmentAnnotation[] alr = al.getAlignmentAnnotation(); \r
+        for (int i = 0; i < alr.length; i++)\r
+        {\r
+          if (alr[i].label.equalsIgnoreCase(label))\r
+          {\r
+            alr[i].centreColLabels = centerlab;\r
+            alr[i].scaleColLabel = scaletofit;\r
+            alr[i].showAllColLabels = showalllabs;\r
+          }\r
+        }\r
+    }\r
+  }\r
   void addProperties(AlignmentI al, StringTokenizer st)\r
   {\r
 \r