X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FStructureFrequency.java;h=cae5da29d277c6be93ea1c3cc806ed3baaed32a8;hb=60f7107d9fc77f34e96ae4b9780e2d11195aed3b;hp=32a4e29e7b57f7a70cfe906035778b54c0d430a9;hpb=b2506e2308c75bf0b3cd2c25e1b45d96711cb581;p=jalview.git diff --git a/src/jalview/analysis/StructureFrequency.java b/src/jalview/analysis/StructureFrequency.java index 32a4e29..cae5da2 100644 --- a/src/jalview/analysis/StructureFrequency.java +++ b/src/jalview/analysis/StructureFrequency.java @@ -21,6 +21,7 @@ package jalview.analysis; import java.util.*; +import jalview.util.Format; import jalview.datamodel.*; /** @@ -344,7 +345,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 @@ -354,6 +355,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; @@ -430,7 +443,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++; } @@ -440,7 +453,7 @@ public class StructureFrequency } else { - mouseOver += ((int) value + "%"); + mouseOver += (fmt.form(value) + "%"); } consensus.annotations[i] = new Annotation(maxRes, mouseOver, ' ', value);