X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FStructureFrequency.java;h=f56a70b511f02a8ecc813ce5f8d3c06bed471c5c;hb=b2f9a8d7bce642ff4011bc6d49e02bb0569fbb11;hp=08bb3fdd18dd0d9530bbdd8f172393718c74363f;hpb=59d682209891099d46b960509907c79e3fb276fe;p=jalview.git diff --git a/src/jalview/analysis/StructureFrequency.java b/src/jalview/analysis/StructureFrequency.java index 08bb3fd..f56a70b 100644 --- a/src/jalview/analysis/StructureFrequency.java +++ b/src/jalview/analysis/StructureFrequency.java @@ -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. * @@ -14,13 +14,13 @@ * 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 . + * 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);