JAL-1503 update version in GPL header
[jalview.git] / src / jalview / analysis / StructureFrequency.java
index 08bb3fd..f56a70b 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
- * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
+ * Copyright (C) 2014 The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  * PURPOSE.  See the GNU General Public License for more details.
  * 
  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
-
-
 package jalview.analysis;
 
 import java.util.*;
 
+import jalview.util.Format;
 import jalview.datamodel.*;
 
 /**
@@ -299,7 +299,7 @@ public class StructureFrequency
   public static void completeConsensus(AlignmentAnnotation consensus,
           Hashtable[] hconsensus, int iStart, int width,
           boolean ignoreGapsInConsensusCalculation,
-          boolean includeAllConsSymbols)
+          boolean includeAllConsSymbols, long nseq)
   {
     float tval, value;
     if (consensus == null || consensus.annotations == null
@@ -309,6 +309,18 @@ public class StructureFrequency
       // initialised properly
       return;
     }
+    String fmtstr="%3.1f";
+    int precision=2;
+    while (nseq>100) {
+      precision++;
+      nseq/=10;
+    }
+    if (precision>2)
+    {
+      fmtstr = "%"+(2+precision)+"."+precision+"f";
+    }
+    Format fmt = new Format(fmtstr);
+    
     for (int i = iStart; i < width; i++)
     {
       Hashtable hci;
@@ -385,7 +397,7 @@ public class StructureFrequency
             tval = (vl[c] * 100f / profile[1][ignoreGapsInConsensusCalculation ? 1
                     : 0]);
             mouseOver += ((p == 0) ? "" : "; ") + (char) ((int[]) ca[c])[0]
-                    + (char) ((int[]) ca[c])[1] + " " + ((int) tval) + "%";
+                    + (char) ((int[]) ca[c])[1] + " " + fmt.form(tval) + "%";
             p++;
 
           }
@@ -395,7 +407,7 @@ public class StructureFrequency
       }
       else
       {
-        mouseOver += ((int) value + "%");
+        mouseOver += (fmt.form(value) + "%");
       }
       consensus.annotations[i] = new Annotation(maxRes, mouseOver, ' ',
               value);