GPL license added
[jalview.git] / src / jalview / datamodel / AlignmentAnnotation.java
index 43ebf38..337d879 100755 (executable)
@@ -1,3 +1,22 @@
+/*\r
+* Jalview - A Sequence Alignment Editor and Viewer\r
+* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+*\r
+* This program is free software; you can redistribute it and/or\r
+* modify it under the terms of the GNU General Public License\r
+* as published by the Free Software Foundation; either version 2\r
+* of the License, or (at your option) any later version.\r
+*\r
+* This program is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+* GNU General Public License for more details.\r
+*\r
+* You should have received a copy of the GNU General Public License\r
+* along with this program; if not, write to the Free Software\r
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
+*/\r
+\r
 package jalview.datamodel;\r
 \r
 public class AlignmentAnnotation\r
@@ -42,6 +61,19 @@ public class AlignmentAnnotation
     this.description = description;\r
     this.annotations = annotations;\r
     isGraph = true;\r
+    if(min==max)\r
+    {\r
+      for(int i=0; i<annotations.length; i++)\r
+      {\r
+        if(annotations[i]==null)\r
+          continue;\r
+        if(annotations[i].value>max)\r
+          max = annotations[i].value;\r
+        if(annotations[i].value<min)\r
+          min = annotations[i].value;\r
+      }\r
+    }\r
+\r
     graphMin = min;\r
     graphMax = max;\r
     windowLength = winLength;\r
@@ -55,8 +87,36 @@ public class AlignmentAnnotation
       if (annotations[i]!=null && annotations[i].displayCharacter.length()>0)\r
         hasText = true;\r
     }\r
+  }\r
 \r
+  public String toString()\r
+  {\r
+    StringBuffer buffer = new StringBuffer();\r
+    for(int i=0; i<annotations.length; i++)\r
+   {\r
+     if(annotations[i]!=null)\r
+     {\r
+       if(isGraph)\r
+         buffer.append(annotations[i].value);\r
+       else if(hasIcons)\r
+         buffer.append(annotations[i].secondaryStructure);\r
+       else\r
+         buffer.append(annotations[i].displayCharacter);\r
 \r
+     }\r
+     buffer.append(", ");\r
+   }\r
+   if(label.equals("Consensus"))\r
+   {\r
+     buffer.append("\n");\r
+     for (int i = 0; i < annotations.length; i++)\r
+     {\r
+       if (annotations[i] != null)\r
+           buffer.append(annotations[i].description);\r
+       buffer.append(", ");\r
+     }\r
+   }\r
+   return buffer.toString();\r
   }\r
 \r
 }\r