Search in sources :

Example 96 with NumberFormat

use of java.text.NumberFormat in project gephi by gephi.

the class WeightedDegree method getDirectedReport.

public String getDirectedReport() {
    //Distribution series
    XYSeries dSeries = ChartUtils.createXYSeries(degreeDist, "Degree Distribution");
    XYSeries idSeries = ChartUtils.createXYSeries(inDegreeDist, "In-Degree Distribution");
    XYSeries odSeries = ChartUtils.createXYSeries(outDegreeDist, "Out-Degree Distribution");
    XYSeriesCollection dataset1 = new XYSeriesCollection();
    dataset1.addSeries(dSeries);
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(idSeries);
    XYSeriesCollection dataset3 = new XYSeriesCollection();
    dataset3.addSeries(odSeries);
    JFreeChart chart1 = ChartFactory.createXYLineChart("Degree Distribution", "Value", "Count", dataset1, PlotOrientation.VERTICAL, true, false, false);
    ChartUtils.decorateChart(chart1);
    ChartUtils.scaleChart(chart1, dSeries, false);
    String degreeImageFile = ChartUtils.renderChart(chart1, "w-degree-distribution.png");
    JFreeChart chart2 = ChartFactory.createXYLineChart("In-Degree Distribution", "Value", "Count", dataset2, PlotOrientation.VERTICAL, true, false, false);
    ChartUtils.decorateChart(chart2);
    ChartUtils.scaleChart(chart2, dSeries, false);
    String indegreeImageFile = ChartUtils.renderChart(chart2, "indegree-distribution.png");
    JFreeChart chart3 = ChartFactory.createXYLineChart("Out-Degree Distribution", "Value", "Count", dataset3, PlotOrientation.VERTICAL, true, false, false);
    ChartUtils.decorateChart(chart3);
    ChartUtils.scaleChart(chart3, dSeries, false);
    String outdegreeImageFile = ChartUtils.renderChart(chart3, "outdegree-distribution.png");
    NumberFormat f = new DecimalFormat("#0.000");
    String report = "<HTML> <BODY> <h1>Weighted Degree Report </h1> " + "<hr>" + "<br> <h2> Results: </h2>" + "Average Weighted Degree: " + f.format(avgWDegree) + "<br /><br />" + degreeImageFile + "<br /><br />" + indegreeImageFile + "<br /><br />" + outdegreeImageFile + "</BODY></HTML>";
    return report;
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) DecimalFormat(java.text.DecimalFormat) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) JFreeChart(org.jfree.chart.JFreeChart) NumberFormat(java.text.NumberFormat)

Example 97 with NumberFormat

use of java.text.NumberFormat in project gephi by gephi.

the class DynamicNbEdges method getReport.

@Override
public String getReport() {
    //Time series
    XYSeries dSeries = ChartUtils.createXYSeries(counts, "Nb Edges Time Series");
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dSeries);
    JFreeChart chart = ChartFactory.createXYLineChart("# Edges Time Series", "Time", "# Edges", dataset, PlotOrientation.VERTICAL, true, false, false);
    chart.removeLegend();
    ChartUtils.decorateChart(chart);
    ChartUtils.scaleChart(chart, dSeries, false);
    String imageFile = ChartUtils.renderChart(chart, "nb-edges-ts.png");
    NumberFormat f = new DecimalFormat("#0.000");
    String report = "<HTML> <BODY> <h1>Dynamic Number of Edges Report </h1> " + "<hr>" + "<br> Bounds: from " + f.format(bounds.getLow()) + " to " + f.format(bounds.getHigh()) + "<br> Window: " + window + "<br> Tick: " + tick + "<br><br><h2> Number of edges over time: </h2>" + "<br /><br />" + imageFile;
    /*for (Interval<Integer> count : counts) {
        report += count.toString(dynamicModel.getTimeFormat().equals(DynamicModel.TimeFormat.DOUBLE)) + "<br />";
        }*/
    report += "<br /><br /></BODY></HTML>";
    return report;
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) DecimalFormat(java.text.DecimalFormat) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) JFreeChart(org.jfree.chart.JFreeChart) NumberFormat(java.text.NumberFormat)

Example 98 with NumberFormat

use of java.text.NumberFormat in project gephi by gephi.

the class ConnectedComponents method getReport.

@Override
public String getReport() {
    Map<Integer, Integer> sizeDist = new HashMap<>();
    for (int v : componentsSize) {
        if (!sizeDist.containsKey(v)) {
            sizeDist.put(v, 0);
        }
        sizeDist.put(v, sizeDist.get(v) + 1);
    }
    //Distribution series
    XYSeries dSeries = ChartUtils.createXYSeries(sizeDist, "Size Distribution");
    XYSeriesCollection dataset1 = new XYSeriesCollection();
    dataset1.addSeries(dSeries);
    JFreeChart chart = ChartFactory.createXYLineChart("Size Distribution", "Size (number of nodes)", "Count", dataset1, PlotOrientation.VERTICAL, true, false, false);
    chart.removeLegend();
    ChartUtils.decorateChart(chart);
    ChartUtils.scaleChart(chart, dSeries, false);
    String imageFile = ChartUtils.renderChart(chart, "cc-size-distribution.png");
    NumberFormat f = new DecimalFormat("#0.000");
    String report = "<HTML> <BODY> <h1>Connected Components Report </h1> " + "<hr>" + "<br>" + "<h2> Parameters: </h2>" + "Network Interpretation:  " + (isDirected ? "directed" : "undirected") + "<br>" + "<br> <h2> Results: </h2>" + "Number of Weakly Connected Components: " + componentCount + "<br>" + (isDirected ? "Number of Stronlgy Connected Components: " + stronglyCount + "<br>" : "") + "<br /><br />" + imageFile + "<br />" + "<h2> Algorithm: </h2>" + "Robert Tarjan, <i>Depth-First Search and Linear Graph Algorithms</i>, in SIAM Journal on Computing 1 (2): 146–160 (1972)<br />" + "</BODY> </HTML>";
    return report;
}
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 99 with NumberFormat

use of java.text.NumberFormat in project gephi by gephi.

the class SplineControlPanel method getNumberFormatter.

private static NumberFormat getNumberFormatter() {
    NumberFormat formatter = NumberFormat.getInstance(Locale.ENGLISH);
    formatter.setMinimumFractionDigits(2);
    formatter.setMaximumFractionDigits(2);
    return formatter;
}
Also used : NumberFormat(java.text.NumberFormat)

Example 100 with NumberFormat

use of java.text.NumberFormat in project gephi by gephi.

the class CustomBoundsDialog method setup.

public void setup(TimelineModel timelineModel) {
    this.model = timelineModel;
    this.controller = Lookup.getDefault().lookup(TimelineController.class);
    setDefaults();
    switch(model.getTimeFormat()) {
        case DATE:
            minTextField.setText(AttributeUtils.printDate(model.getCustomMin()));
            maxTextField.setText(AttributeUtils.printDate(model.getCustomMax()));
            startTextField.setText(AttributeUtils.printDate(model.getIntervalStart()));
            endTextField.setText(AttributeUtils.printDate(model.getIntervalEnd()));
            break;
        case DATETIME:
            minTextField.setText(AttributeUtils.printDateTime(model.getCustomMin()));
            maxTextField.setText(AttributeUtils.printDateTime(model.getCustomMax()));
            startTextField.setText(AttributeUtils.printDateTime(model.getIntervalStart()));
            endTextField.setText(AttributeUtils.printDateTime(model.getIntervalEnd()));
            break;
        default:
            NumberFormat f = NumberFormat.getInstance(Locale.ENGLISH);
            f.setGroupingUsed(false);
            f.setMaximumFractionDigits(20);
            minTextField.setText(f.format(model.getCustomMin()));
            maxTextField.setText(f.format(model.getCustomMax()));
            startTextField.setText(f.format(model.getIntervalStart()));
            endTextField.setText(f.format(model.getIntervalEnd()));
            break;
    }
}
Also used : TimelineController(org.gephi.timeline.api.TimelineController) NumberFormat(java.text.NumberFormat)

Aggregations

NumberFormat (java.text.NumberFormat)429 DecimalFormat (java.text.DecimalFormat)87 BigDecimal (java.math.BigDecimal)23 ArrayList (java.util.ArrayList)23 HashMap (java.util.HashMap)23 Locale (java.util.Locale)22 Map (java.util.Map)18 Test (org.junit.Test)17 ParseException (java.text.ParseException)15 DecimalFormatSymbols (java.text.DecimalFormatSymbols)14 JFreeChart (org.jfree.chart.JFreeChart)13 XYSeries (org.jfree.data.xy.XYSeries)11 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)11 Intent (android.content.Intent)10 ParsePosition (java.text.ParsePosition)10 View (android.view.View)8 TextView (android.widget.TextView)8 Paint (android.graphics.Paint)7 Rect (android.graphics.Rect)6 IOException (java.io.IOException)6