Merge branch 'Release_2_8_0b1_Branch' into try_r20b1_merge
[jalview.git] / src / jalview / analysis / StructureFrequency.java
index fe794be..6409413 100644 (file)
@@ -20,6 +20,7 @@ package jalview.analysis;
 
 import java.util.*;
 
+import jalview.util.Format;
 import jalview.datamodel.*;
 
 /**
@@ -298,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
@@ -308,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;
@@ -384,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++;
 
           }
@@ -394,7 +407,7 @@ public class StructureFrequency
       }
       else
       {
-        mouseOver += ((int) value + "%");
+        mouseOver += (fmt.form(value) + "%");
       }
       consensus.annotations[i] = new Annotation(maxRes, mouseOver, ' ',
               value);