Search in sources :

Example 56 with NumberFormat

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>";
    }
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) HashMap(java.util.HashMap) DecimalFormat(java.text.DecimalFormat) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) JFreeChart(org.jfree.chart.JFreeChart) NumberFormat(java.text.NumberFormat)

Example 57 with NumberFormat

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()) + "]";
}
Also used : NumberFormat(java.text.NumberFormat)

Example 58 with NumberFormat

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);
        }
    });
}
Also used : GraphViewStyle(com.jjoe64.graphview.GraphViewStyle) CustomLabelFormatter(com.jjoe64.graphview.CustomLabelFormatter) NumberFormat(java.text.NumberFormat)

Example 59 with NumberFormat

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) + "%";
}
Also used : NumberFormat(java.text.NumberFormat)

Example 60 with NumberFormat

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) + "%";
}
Also used : NumberFormat(java.text.NumberFormat)

Aggregations

NumberFormat (java.text.NumberFormat)471 DecimalFormat (java.text.DecimalFormat)92 ArrayList (java.util.ArrayList)24 HashMap (java.util.HashMap)24 BigDecimal (java.math.BigDecimal)23 Locale (java.util.Locale)22 Map (java.util.Map)18 Test (org.junit.Test)17 ParseException (java.text.ParseException)16 DecimalFormatSymbols (java.text.DecimalFormatSymbols)14 JFreeChart (org.jfree.chart.JFreeChart)13 IOException (java.io.IOException)12 ParsePosition (java.text.ParsePosition)12 XYSeries (org.jfree.data.xy.XYSeries)11 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)11 Intent (android.content.Intent)10 PrintWriter (java.io.PrintWriter)9 View (android.view.View)8 TextView (android.widget.TextView)8 Currency (java.util.Currency)8