Example usage for org.jfree.data.category DefaultCategoryDataset DefaultCategoryDataset

List of usage examples for org.jfree.data.category DefaultCategoryDataset DefaultCategoryDataset

Introduction

In this page you can find the example usage for org.jfree.data.category DefaultCategoryDataset DefaultCategoryDataset.

Prototype

public DefaultCategoryDataset() 

Source Link

Document

Creates a new (empty) dataset.

Usage

From source file:sernet.gs.ui.rcp.main.bsi.views.chart.StufenBarChart.java

protected Object createBarDataset() throws CommandException {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    MassnahmenSummaryHome dao = new MassnahmenSummaryHome();

    Map<String, Integer> items1 = dao.getNotCompletedStufenSummary();
    Set<Entry<String, Integer>> entrySet = items1.entrySet();
    for (Entry<String, Integer> entry : entrySet) {
        dataset.addValue(entry.getValue(), Messages.StufenBarChart_3, entry.getKey());
    }/*from   w  w  w . j  a v a  2 s. com*/

    Map<String, Integer> completedItems = dao.getCompletedStufenSummary();
    Set<Entry<String, Integer>> entrySet2 = completedItems.entrySet();
    for (Entry<String, Integer> entry : entrySet2) {
        dataset.addValue(entry.getValue(), Messages.StufenBarChart_4, entry.getKey());
    }

    return dataset;
}

From source file:playground.dgrether.analysis.charts.DgModalSplitGroupChart.java

public DgModalSplitGroupChart(DgAnalysisPopulation ana, String runid, int threshold) {
    this.ana = ana;
    this.runId = runid;
    this.groupThreshold = threshold;
    this.ana.calculateMinMaxIncome();
    this.dataset = new DefaultCategoryDataset();
    this.calculateData();
}

From source file:org.jfree.chart.demo.BarChartDemo1.java

/**
 * Returns a sample dataset./*from  w  w  w  .  j a v  a 2  s .  c  o m*/
 *
 * @return The dataset.
 */
private static CategoryDataset createDataset() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.addValue(7445, "JFreeSVG", "Warm-up");
    dataset.addValue(24448, "Batik", "Warm-up");
    dataset.addValue(4297, "JFreeSVG", "Test");
    dataset.addValue(21022, "Batik", "Test");
    return dataset;
}

From source file:brightwell.gui.drawingplane.Chart3D.java

public Chart3D(String s) {
    super(s);
    defaultcategorydataset = new DefaultCategoryDataset();
}

From source file:cz.muni.fi.nbs.utils.Helpers.java

private static void exportToPNG(Map<String, Collection<Result>> results) {

    for (Entry<String, Collection<Result>> entry : results.entrySet()) {
        double number = 0;
        String key = entry.getKey();
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        Iterator<Result> resultsIterator = results.get(key).iterator();
        while (resultsIterator.hasNext()) {
            Result r = resultsIterator.next();
            dataset.addValue(r.getScore(), r.getLabel(), "");
            number += 0.8;/*from   ww w  .  j av a 2 s .  co m*/
        }
        double width = number > 1 ? number * 200 : 300;
        String unit = entry.getValue().iterator().next().getScoreUnit();
        String[] splitKey = key.split("_");

        JFreeChart chart = ChartFactory.createBarChart3D(splitKey[0], null, unit, dataset);

        int len = splitKey.length / 2;
        for (int i = 0; i < len; i++) {
            String subtitle = splitKey[i * 2 + 1] + ":" + splitKey[i * 2 + 2];
            TextTitle title = new TextTitle(subtitle);
            Font oldFont = title.getFont();
            int fontSize = (int) Math.round(oldFont.getSize() * 1.2);
            int fontStyle = oldFont.getStyle();
            String fontName = oldFont.getName();

            title.setFont(new Font(fontName, fontStyle, fontSize));
            chart.addSubtitle(title);
        }
        try {
            ChartUtilities.saveChartAsPNG(new File(resultsDir + "/charts/" + key + "Chart.png"), chart,
                    (int) Math.round(width), 800);
        } catch (IOException ex) {
            Logger.getLogger(Helpers.class.getName()).log(Level.SEVERE,
                    "Could not export chart to PNG file for " + key, ex);
        }
    }
}

From source file:org.jfree.data.category.CategoryToPieDatasetTest.java

/**
 * Some checks for the getValue() method.
 *///  w  ww .  jav a2  s. c  om
@Test
public void testGetValue() {
    DefaultCategoryDataset underlying = new DefaultCategoryDataset();
    underlying.addValue(1.1, "R1", "C1");
    underlying.addValue(2.2, "R1", "C2");
    CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_ROW, 0);
    assertEquals(d1.getValue("C1"), new Double(1.1));
    assertEquals(d1.getValue("C2"), new Double(2.2));

    // check negative index throws exception
    try {
        /* Number n = */ d1.getValue(-1);
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }

    // check index == getItemCount() throws exception
    try {
        /* Number n = */ d1.getValue(d1.getItemCount());
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }

    // test null source
    CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0);
    try {
        /* Number n = */ p1.getValue(0);
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }
}

From source file:org.matsim.core.utils.charts.LineChart.java

/**
 * Creates a new BarChart with the specified category-labels.
 *
 * @param title/*from  www .j a va 2  s  .c  om*/
 * @param xAxisLabel
 * @param yAxisLabel
 * @param categories
 */
public LineChart(final String title, final String xAxisLabel, final String yAxisLabel,
        final String[] categories) {
    super(title, xAxisLabel, yAxisLabel);
    this.dataset = new DefaultCategoryDataset();
    this.chart = createChart(title, xAxisLabel, yAxisLabel, this.dataset);
    this.categories = categories.clone();
    addDefaultFormatting();
}

From source file:wtw.ui.GetChartAction.java

@Override
public String execute() throws Exception {
    Object start = ActionContext.getContext().getSession().get("start");
    Object end = ActionContext.getContext().getSession().get("end");
    if (start != null && end != null) {
        startdate = (String) start;
        enddate = (String) end;//from   w  ww. j  a  v a  2 s.c o  m
    }
    if (start == null || end == null) {
        all = 6;
        mobile = 1;
        web = 1;
        software = 1;
        design = 1;
        data = 1;
        other = 1;
    } else {
        Date date2;
        Date date;
        DateFormat formater = new SimpleDateFormat("yyyy-MM-dd");
        date = (Date) formater.parse(startdate);
        date2 = (Date) formater.parse(enddate);
        all = projectManager.getCountProjectInMonth(date, date2);
        mobile = projectManager.getCountProjectInMonthAndCategory(date, date2, " Mobile");
        web = projectManager.getCountProjectInMonthAndCategory(date, date2, " Website");
        software = projectManager.getCountProjectInMonthAndCategory(date, date2, " Software");
        design = projectManager.getCountProjectInMonthAndCategory(date, date2, " Design");
        data = projectManager.getCountProjectInMonthAndCategory(date, date2, " Data Entry");
        other = projectManager.getCountProjectInMonthAndCategory(date, date2, " Other");
    }
    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
    dataSet.setValue(all, "Population", "Total");
    dataSet.setValue(mobile, "Population", "Mobile");
    dataSet.setValue(web, "Population", "Website");
    dataSet.setValue(software, "Population", "Software");
    dataSet.setValue(data, "Population", "Data Entry");
    dataSet.setValue(design, "Population", "Design");
    dataSet.setValue(other, "Population", "Other");

    chart = ChartFactory.createBarChart3D("Report Quantity Project By Category", "Project Category",
            "Quantity of Project", dataSet, PlotOrientation.VERTICAL, false, true, false);
    return SUCCESS;
}

From source file:Estadistica.VEstadistica.java

public void graficar(boolean isConcurrente, ArrayList<PaginasWeb> sitiosWeb,
        ArrayList<EstadisticaPalabra> tiemposPalabras, ArrayList<Resultado> resultados) {

    DefaultCategoryDataset barChartDatos = new DefaultCategoryDataset();// grafico de secuencial

    for (PaginasWeb paginas : sitiosWeb) {
        barChartDatos.setValue(paginas.getIncidencias(), "Sitios",
                paginas.getListaResultados().get(0).getTitulo());
    }// www  . jav a2s  .  c  o m

    //generar los datos de las tablas
    DefaultTableModel modeloTablaIncidencias;
    if (isConcurrente == false) {
        modeloTablaIncidencias = (DefaultTableModel) tablaIncidenciaSec.getModel();
    } else {
        modeloTablaIncidencias = (DefaultTableModel) tablaIncidenciaSConc.getModel();
    }
    Object[] fila = new Object[modeloTablaIncidencias.getColumnCount()];
    int cont = 0;
    for (EstadisticaPalabra palabra : tiemposPalabras) {
        fila[0] = palabra.getPalabra();
        fila[1] = palabra.getTiempo();
        modeloTablaIncidencias.addRow(fila);
        cont++;
        System.out.println(palabra.getPalabra());
    }
    System.out.println(cont);
    //         Grafico
    //        titulo-titulo arriba
    JFreeChart grafico = ChartFactory.createBarChart3D("Incidencias por sitio", "Sitios",
            "Numero de Incidencias", barChartDatos, PlotOrientation.HORIZONTAL, false, true, false);
    //

    CategoryPlot barChartCP = grafico.getCategoryPlot();
    barChartCP.setRangeGridlinePaint(Color.cyan);

    ChartPanel barPanel = new ChartPanel(grafico);
    if (isConcurrente == true) {
        lienzoConc.removeAll();
        lienzoConc.add(barPanel, BorderLayout.CENTER);
        lienzoConc.validate();
    }

    if (isConcurrente == false) {
        lienzoSec.removeAll();
        lienzoSec.add(barPanel, BorderLayout.CENTER);
        lienzoSec.validate();
    }
}

From source file:ws.moor.bt.gui.charts.TotalBlocksPerPeer.java

private DefaultCategoryDataset createDataset() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    Map<Long, String> rateToKey = new TreeMap<Long, String>();
    Collection<String> keys = new HashSet<String>();
    keys.addAll(counterRepository.getKeys("torrent.blocks.leecher"));
    keys.addAll(counterRepository.getKeys("torrent.blocks.seed"));
    for (String key : keys) {
        CounterStatistics leechStats = counterRepository.getStatistics("torrent.blocks.leecher", key);
        CounterStatistics seedStats = counterRepository.getStatistics("torrent.blocks.seed", key);

        long blocks = leechStats.latestValue() + seedStats.latestValue();
        rateToKey.put(-blocks, key);/*ww  w.ja va  2 s.  c  o m*/
    }

    for (String key : rateToKey.values()) {
        CounterStatistics leechStats = counterRepository.getStatistics("torrent.blocks.leecher", key);
        CounterStatistics seedStats = counterRepository.getStatistics("torrent.blocks.seed", key);

        dataset.addValue(seedStats.latestValue(), "seed", key);
        dataset.addValue(leechStats.latestValue(), "leecher", key);
        if (dataset.getColumnCount() >= 20) {
            break;
        }
    }

    return dataset;
}