forked from I2P_Developers/i2p.i2p
Replace with thin non-breaking space   for byte sizes
The latter has more consistent/predictable width between fonts & point sizes.
This commit is contained in:
@ -2565,13 +2565,15 @@ public class I2PSnarkServlet extends BasicServlet {
|
|||||||
// rounding makes us look faster :)
|
// rounding makes us look faster :)
|
||||||
private static String formatSize(long bytes) {
|
private static String formatSize(long bytes) {
|
||||||
if (bytes < 5000)
|
if (bytes < 5000)
|
||||||
return bytes + " B";
|
|
||||||
|
// replace with narrow non-breaking space ( )
|
||||||
|
return bytes + " B";
|
||||||
else if (bytes < 5*1024*1024)
|
else if (bytes < 5*1024*1024)
|
||||||
return ((bytes + 512)/1024) + " KB";
|
return ((bytes + 512)/1024) + " KB";
|
||||||
else if (bytes < 10*1024*1024*1024l)
|
else if (bytes < 10*1024*1024*1024l)
|
||||||
return ((bytes + 512*1024)/(1024*1024)) + " MB";
|
return ((bytes + 512*1024)/(1024*1024)) + " MB";
|
||||||
else
|
else
|
||||||
return ((bytes + 512*1024*1024)/(1024*1024*1024)) + " GB";
|
return ((bytes + 512*1024*1024)/(1024*1024*1024)) + " GB";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2942,7 +2944,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
|||||||
if (uploaded > 0) {
|
if (uploaded > 0) {
|
||||||
double ratio = uploaded / ((double) snark.getTotalLength());
|
double ratio = uploaded / ((double) snark.getTotalLength());
|
||||||
buf.append((new DecimalFormat("0.000")).format(ratio));
|
buf.append((new DecimalFormat("0.000")).format(ratio));
|
||||||
buf.append(" x");
|
buf.append(" x");
|
||||||
} else {
|
} else {
|
||||||
buf.append('0');
|
buf.append('0');
|
||||||
}
|
}
|
||||||
|
@ -1560,17 +1560,19 @@ public class DataHelper {
|
|||||||
|
|
||||||
DecimalFormat fmt = new DecimalFormat("##0.00");
|
DecimalFormat fmt = new DecimalFormat("##0.00");
|
||||||
|
|
||||||
|
// Replace with thin non-breaking space   (more consistent/predictable width between fonts & point sizes)
|
||||||
|
|
||||||
String str = fmt.format(val);
|
String str = fmt.format(val);
|
||||||
switch (scale) {
|
switch (scale) {
|
||||||
case 1: return str + " K";
|
case 1: return str + " K";
|
||||||
case 2: return str + " M";
|
case 2: return str + " M";
|
||||||
case 3: return str + " G";
|
case 3: return str + " G";
|
||||||
case 4: return str + " T";
|
case 4: return str + " T";
|
||||||
case 5: return str + " P";
|
case 5: return str + " P";
|
||||||
case 6: return str + " E";
|
case 6: return str + " E";
|
||||||
case 7: return str + " Z";
|
case 7: return str + " Z";
|
||||||
case 8: return str + " Y";
|
case 8: return str + " Y";
|
||||||
default: return bytes + " ";
|
default: return bytes + " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user