git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
JAL-1373 generate percentages with appropriate precision
[jalview.git]
/
src
/
jalview
/
analysis
/
StructureFrequency.java
diff --git
a/src/jalview/analysis/StructureFrequency.java
b/src/jalview/analysis/StructureFrequency.java
index
fe022c0
..
948bdc1
100644
(file)
--- a/
src/jalview/analysis/StructureFrequency.java
+++ b/
src/jalview/analysis/StructureFrequency.java
@@
-21,6
+21,7
@@
package jalview.analysis;
import java.util.*;
import java.util.*;
+import jalview.util.Format;
import jalview.datamodel.*;
/**
import jalview.datamodel.*;
/**
@@
-309,6
+310,18
@@
public class StructureFrequency
// initialised properly
return;
}
// 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;
for (int i = iStart; i < width; i++)
{
Hashtable hci;
@@
-385,7
+398,7
@@
public class StructureFrequency
tval = (vl[c] * 100f / profile[1][ignoreGapsInConsensusCalculation ? 1
: 0]);
mouseOver += ((p == 0) ? "" : "; ") + (char) ((int[]) ca[c])[0]
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++;
}
p++;
}
@@
-395,7
+408,7
@@
public class StructureFrequency
}
else
{
}
else
{
- mouseOver += ((int) value + "%");
+ mouseOver += (fmt.form(value) + "%");
}
consensus.annotations[i] = new Annotation(maxRes, mouseOver, ' ',
value);
}
consensus.annotations[i] = new Annotation(maxRes, mouseOver, ' ',
value);