use of java.text.NumberFormat in project gephi by gephi.
the class ClusteringCoefficient method getReport.
@Override
public String getReport() {
//distribution of values
Map<Double, Integer> dist = new HashMap<>();
for (int i = 0; i < N; i++) {
Double d = nodeClustering[i];
if (dist.containsKey(d)) {
Integer v = dist.get(d);
dist.put(d, v + 1);
} else {
dist.put(d, 1);
}
}
//Distribution series
XYSeries dSeries = ChartUtils.createXYSeries(dist, "Clustering Coefficient");
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(dSeries);
JFreeChart chart = ChartFactory.createScatterPlot("Clustering Coefficient Distribution", "Value", "Count", dataset, PlotOrientation.VERTICAL, true, false, false);
chart.removeLegend();
ChartUtils.decorateChart(chart);
ChartUtils.scaleChart(chart, dSeries, false);
String imageFile = ChartUtils.renderChart(chart, "clustering-coefficient.png");
NumberFormat f = new DecimalFormat("#0.000");
if (isDirected) {
return "<HTML> <BODY> <h1> Clustering Coefficient Metric Report </h1> " + "<hr>" + "<br />" + "<h2> Parameters: </h2>" + "Network Interpretation: " + (isDirected ? "directed" : "undirected") + "<br />" + "<br>" + "<h2> Results: </h2>" + "Average Clustering Coefficient: " + f.format(avgClusteringCoeff) + "<br />" + "The Average Clustering Coefficient is the mean value of individual coefficients.<br /><br />" + imageFile + "<br /><br />" + "<h2> Algorithm: </h2>" + "Simple and slow brute force.<br />" + "</BODY> </HTML>";
} else {
return "<HTML> <BODY> <h1> Clustering Coefficient Metric Report </h1> " + "<hr>" + "<br />" + "<h2> Parameters: </h2>" + "Network Interpretation: " + (isDirected ? "directed" : "undirected") + "<br />" + "<br>" + "<h2> Results: </h2>" + "Average Clustering Coefficient: " + f.format(avgClusteringCoeff) + "<br />" + "Total triangles: " + totalTriangles + "<br />" + "The Average Clustering Coefficient is the mean value of individual coefficients.<br /><br />" + imageFile + "<br /><br />" + "<h2> Algorithm: </h2>" + "Matthieu Latapy, <i>Main-memory Triangle Computations for Very Large (Sparse (Power-Law)) Graphs</i>, in Theoretical Computer Science (TCS) 407 (1-3), pages 458-473, 2008<br />" + "</BODY> </HTML>";
}
}
use of java.text.NumberFormat in project hibernate-orm by hibernate.
the class FloatLeg method toString.
public String toString() {
NumberFormat format = NumberFormat.getNumberInstance();
format.setMinimumFractionDigits(1);
format.setMaximumFractionDigits(1);
return "[" + getRateIndex().toString() + "+" + format.format(getRateSpread()) + "]";
}
use of java.text.NumberFormat in project WordPress-Android by wordpress-mobile.
the class StatsBarGraph method setProperties.
private void setProperties() {
GraphViewStyle gStyle = getGraphViewStyle();
gStyle.setHorizontalLabelsIndexDependentColor(new HorizontalLabelsColor());
gStyle.setHorizontalLabelsColor(getResources().getColor(R.color.grey_darken_30));
gStyle.setVerticalLabelsColor(getResources().getColor(R.color.grey_darken_10));
gStyle.setTextSize(getResources().getDimensionPixelSize(R.dimen.text_sz_extra_small));
gStyle.setGridXColor(Color.TRANSPARENT);
gStyle.setGridYColor(getResources().getColor(R.color.grey_lighten_30));
gStyle.setNumVerticalLabels(3);
setCustomLabelFormatter(new CustomLabelFormatter() {
private NumberFormat numberFormatter;
@Override
public String formatLabel(double value, boolean isValueX) {
if (isValueX) {
return null;
}
if (numberFormatter == null) {
numberFormatter = NumberFormat.getNumberInstance();
numberFormatter.setMaximumFractionDigits(0);
}
return numberFormatter.format(value);
}
});
}
use of java.text.NumberFormat in project translationstudio8 by heartsome.
the class EditProgressFAResult method getApprovedParasRatio.
/**
* 获取已批准文本段的比例
* @return 如25.00%
*/
public String getApprovedParasRatio() {
float ratio = (float) approvedParas / (notApprovedParas + approvedParas);
NumberFormat format = NumberFormat.getNumberInstance();
format.setMaximumFractionDigits(2);
return format.format(ratio * 100) + "%";
}
use of java.text.NumberFormat in project translationstudio8 by heartsome.
the class TransProgressFAResult method getTransWordsRatio.
/**
* 获取已翻译字数的比例
* @return 如25.00%
*/
public String getTransWordsRatio() {
float ratio = (float) translatedWords / (notTransWords + translatedWords);
NumberFormat format = NumberFormat.getNumberInstance();
format.setMaximumFractionDigits(2);
return format.format(ratio * 100) + "%";
}
Aggregations