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

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

Introduction

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

Prototype

public void setValue(double value, Comparable rowKey, Comparable columnKey) 

Source Link

Document

Adds or updates a value in the table and sends a DatasetChangeEvent to all registered listeners.

Usage

From source file:jmemorize.gui.swing.panels.DeckChartPanel.java

/**
 * Sets the values for the column with given id. This method also handles
 * the order in which the rows will appear in the column.
 *//*from w w w  . jav a  2s  .com*/
private void setValues(DefaultCategoryDataset dataset, String column, int unlearned, int expired, int learned) {
    // if you change the order of the rows, don't forget to also update the
    // method setSeriesPaint

    dataset.setValue(unlearned, UNLEARNED_CARDS_ROW, column);
    dataset.setValue(expired, EXPIRED_CARDS_ROW, column);
    dataset.setValue(learned, LEARNED_CARDS_ROW, column);
}

From source file:jmemorize.gui.swing.panels.HistoryChartPanel.java

private CategoryDataset createDataSet(List<SessionSummary> summaries, DateFormat format) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (SessionSummary summary : summaries) {
        Date start = summary.getStart();
        String date = format.format(start);

        int passed = (int) summary.getPassed();
        int relearned = (int) summary.getRelearned();
        int failed = (int) summary.getFailed();

        dataset.setValue(failed, Localization.get(LC.FAILED), date);
        dataset.setValue(relearned, Localization.get(LC.RELEARNED), date);
        dataset.setValue(passed, Localization.get(LC.PASSED), date);
    }// ww  w  .j a v  a  2 s.  co m

    return dataset;
}

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());
    }/* w w  w . j a v a 2 s. 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:UserInterface.CustomerRole.CustomerTaxJPanel.java

public void displayChart(Date date1) {
    int total = 0;
    int k;/*  w  w w.  ja v  a  2  s  . c  o  m*/
    int count = 0;
    int avg = 0;

    Sensor s = (Sensor) jTable1.getValueAt(0, 0);
    Date b = s.getDate();
    DateFormat formatter = new SimpleDateFormat("MM/dd/yy");
    Date date = new Date();
    try {
        date = formatter.parse("12/11/16");
    } catch (Exception e) {

    }
    //date = 
    System.out.println(jTable1.getValueAt(0, 5));
    System.out.println(jTable1.getValueAt(0, 4));
    list = new ArrayList<>();

    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getCurrentEmissionCO2();
            count++;
        }
    }
    avg = total / count;
    list.add(avg);

    int avg1 = 0;

    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getCurrentEmissionCO2();
            count++;
        }
    }

    avg = total / count;
    list.add(avg);
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getNormalCO2();
            count++;
        }
    }
    avg1 = total / count;
    int avg3 = 0;
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getCurrentEmissionNOx();
            count++;
        }
    }
    avg3 = total / count;

    int avg4 = 0;
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getNormalNOx();
            count++;
        }
    }
    avg4 = total / count;

    int avg5 = 0;
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getSolarCurrentEmissionCO2();
            count++;
        }
    }
    avg5 = total / count;
    int avg6 = 0;

    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getSolarNormalCO2();
            count++;
        }
    }

    avg6 = total / count;
    int avg7 = 0;
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getSolarCurrentEmissionNOx();
            count++;
        }
    }
    avg7 = total / count;
    int avg8 = 0;
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getSolarNormalNOx();
            count++;
        }
    }
    avg8 = total / count;

    int combo = avg + avg3;
    int combo1 = avg5 + avg7;

    DefaultPieDataset dataset22 = new DefaultPieDataset();
    dataset22.setValue("Fuel Emission", new Integer(combo));
    dataset22.setValue("Solar Emission ", new Integer(combo1));

    JFreeChart chart22 = ChartFactory.createPieChart3D("Comparison Chart ", // chart title                   
            dataset22, // data 
            true, // include legend                   
            true, false);

    final PiePlot3D plot = (PiePlot3D) chart22.getPlot();
    plot.setStartAngle(270);
    plot.setForegroundAlpha(0.60f);
    plot.setInteriorGap(0.02);

    ChartFrame frame33 = new ChartFrame("3D Pie Chart for EMission Comparison from different sources", chart22);
    frame33.setVisible(true);
    frame33.setSize(500, 400);

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(avg, b, "curr CO2");
    dataset.setValue(avg1, b, "normal CO2");
    dataset.setValue(avg3, b, "current NOx");
    dataset.setValue(avg4, b, "normal NOx");
    //dataset.setValue(a1,b1,"current");
    JFreeChart chart = ChartFactory.createBarChart("Normal Fuel Emission Chart", "CO2 Emission", "in (g/KM)",
            dataset, PlotOrientation.VERTICAL, false, false, false);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLACK);
    ChartFrame frame = new ChartFrame("Bar Chart for Customer", chart);
    frame.setVisible(true);
    frame.setSize(500, 400);

    DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
    dataset1.setValue(avg5, b, "curr CO2");
    dataset1.setValue(avg6, b, "normal CO2");
    dataset1.setValue(avg7, b, "current NOx");
    dataset1.setValue(avg8, b, "normal NOx");
    //dataset.setValue(a1,b1,"current");
    JFreeChart chart2 = ChartFactory.createBarChart("Solar Emission Chart", "CO2 Emission", "in (g/KM)",
            dataset1, PlotOrientation.VERTICAL, false, false, false);
    CategoryPlot p1 = chart.getCategoryPlot();
    p1.setRangeGridlinePaint(Color.BLACK);
    ChartFrame frame1 = new ChartFrame("Bar Chart for Customer", chart2);
    frame1.setVisible(true);
    frame1.setSize(500, 400);
}

From source file:com.smanempat.controller.ControllerClassification.java

public void showChart(JLabel jumlahSiswaIPA, JLabel jumlahSiswaIPS, JLabel labelKeterangan) {
    DefaultCategoryDataset barChartData = new DefaultCategoryDataset();
    barChartData.setValue(Integer.parseInt(jumlahSiswaIPA.getText()), "IPA", "IPA");
    barChartData.setValue(Integer.parseInt(jumlahSiswaIPS.getText()), "IPS", "IPS");
    JFreeChart barchart = ChartFactory.createBarChart3D(
            "Grafik Jumlah Siswa per Jurusan, Tahun Ajaran " + labelKeterangan.getText().substring(53, 62) + "",
            "Jurusan", "Jumlah Siswa", barChartData, PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot plotBarChart = barchart.getCategoryPlot();
    ChartFrame chartFrame = new ChartFrame("Grafik Jumlah Siswa Tiap Jurusan", barchart, true);
    chartFrame.setVisible(true);// w  ww  . j a v  a2  s .  co m
    chartFrame.setSize(700, 500);
    chartFrame.setLocationRelativeTo(null);
    plotBarChart.setRangeGridlinePaint(java.awt.Color.black);
    ChartPanel chartPanel = new ChartPanel(barchart);
}

From source file:Gui.HistoryAdminGUINew.java

public void showStatHistory() {
    // method statGreensociety......  History 
    int tempRepair = history.statGreensocietyRepair();
    int tempBorrow = history.statGreensocietyBorrow();
    int tempReturn = history.statGreensocietyReturn();
    DefaultCategoryDataset barchartData = new DefaultCategoryDataset();

    barchartData.setValue(tempRepair, "0", "RepairHistory");
    barchartData.setValue(tempBorrow, "1", "BorrowHistory");
    barchartData.setValue(tempReturn, "2", "ReturnHistory");

    JFreeChart chart = ChartFactory.createBarChart("History Statictics", "History", "Times", barchartData,
            PlotOrientation.HORIZONTAL, false, true, false);

    //        chart.getTitle().setPaint(Color.WHITE);   //??

    //--------SET FONT--------------
    try {//w w  w. j  a  v a  2  s  .c  om
        File f = new File("leelawad.ttf");
        Font customFont = Font.createFont(Font.TRUETYPE_FONT, f);
        customFont = customFont.deriveFont(16f);
        chart.getTitle().setFont(customFont);
        System.out.println(customFont.getFontName());
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (FontFormatException | IOException e) {
        e.printStackTrace();
    }
    //------------------------------
    chart.setBackgroundPaint(new Color(19, 175, 248)); //setBackground ?

    CategoryPlot barchartPlot = chart.getCategoryPlot();

    barchartPlot.setRangeGridlinePaint(Color.BLACK); //set ??

    //Customize renderer
    BarRenderer renderer = (BarRenderer) barchartPlot.getRenderer();
    java.awt.Paint paint1 = new Color(255, 0, 0);
    java.awt.Paint paint2 = new Color(0, 0, 255);
    java.awt.Paint paint3 = new Color(255, 255, 0);

    renderer.setSeriesPaint(0, paint1); //Color for RepairGraph
    renderer.setSeriesPaint(1, paint2); //Color for BorrowGraph
    renderer.setSeriesPaint(2, paint3); //Color for ReturnGraph

    ChartPanel barPanel = new ChartPanel(chart);
    jPanelShowGraph.removeAll();
    jPanelShowGraph.add(barPanel, BorderLayout.CENTER);
    jPanelShowGraph.validate();
}

From source file:GUI.Framedashboard.java

public void stat() {
    Statestique st = new Statestique();
    int u = st.nbUser();
    int f = st.nbfemme();
    int h = u - f;
    int p = st.nbProduit();
    int s = st.nbService();
    int c = st.nbComment();
    int pp = st.nbPauP();

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(s, "", "Service");
    dataset.setValue(p, "", "Produit");

    JFreeChart chart = ChartFactory.createBarChart("Service et Produit", null, null, dataset,
            PlotOrientation.VERTICAL, false, false, false);
    CategoryPlot cp = chart.getCategoryPlot();
    //   cp.setRangeGridlinePaint(Color.BLACK);
    ChartPanel chp = new ChartPanel(chart);
    jPanel5.removeAll();/*w w w .  ja  v a2 s.  co  m*/
    jPanel5.add(chp);
    jPanel5.validate();

    DefaultCategoryDataset ds = new DefaultCategoryDataset();
    ds.setValue(pp, "", "Commande");
    ds.setValue(c, "", "Commentaire");
    JFreeChart cht = ChartFactory.createBarChart("Graphe de Commentaire & Commande", null, null, ds,
            PlotOrientation.VERTICAL, false, false, false);
    CategoryPlot catp = chart.getCategoryPlot();
    // catp.setRangeGridlinePaint(Color.BLACK);
    ChartPanel chartp = new ChartPanel(cht);
    jPanel6.removeAll();
    jPanel6.add(chartp);
    jPanel6.validate();

    DefaultPieDataset pds = new DefaultPieDataset();
    pds.setValue("Femme", new Integer(f));
    pds.setValue("Homme", new Integer(h));

    JFreeChart chartpie = ChartFactory.createPieChart("Genre", pds, true, true, false);
    PiePlot plot = (PiePlot) chartpie.getPlot();
    ChartPanel chartpiepanel = new ChartPanel(chartpie);
    jPanel7.removeAll();
    jPanel7.add(chartpiepanel);
    jPanel7.validate();

}

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

/**
 * Creates a new demo./*from  w ww  .  ja v a2  s .com*/
 *
 * @param title  the frame title.
 */
public EventFrequencyDemo(final String title) {

    super(title);

    // create a dataset...
    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    // initialise the data...
    final Day d1 = new Day(12, SerialDate.JUNE, 2002);
    final Day d2 = new Day(14, SerialDate.JUNE, 2002);
    final Day d3 = new Day(15, SerialDate.JUNE, 2002);
    final Day d4 = new Day(10, SerialDate.JULY, 2002);
    final Day d5 = new Day(20, SerialDate.JULY, 2002);
    final Day d6 = new Day(22, SerialDate.AUGUST, 2002);

    dataset.setValue(new Long(d1.getMiddleMillisecond()), "Series 1", "Requirement 1");
    dataset.setValue(new Long(d1.getMiddleMillisecond()), "Series 1", "Requirement 2");
    dataset.setValue(new Long(d2.getMiddleMillisecond()), "Series 1", "Requirement 3");
    dataset.setValue(new Long(d3.getMiddleMillisecond()), "Series 2", "Requirement 1");
    dataset.setValue(new Long(d4.getMiddleMillisecond()), "Series 2", "Requirement 3");
    dataset.setValue(new Long(d5.getMiddleMillisecond()), "Series 3", "Requirement 2");
    dataset.setValue(new Long(d6.getMiddleMillisecond()), "Series 1", "Requirement 4");

    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart("Event Frequency Demo", // title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // dataset
            PlotOrientation.HORIZONTAL, // orientation
            true, // include legend
            true, // tooltips
            false // URLs
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(new Color(0xFF, 0xFF, 0xCC));

    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setDisplaySeriesShapes(true);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    //    plot.getDomainAxis().setMaxCategoryLabelWidthRatio(10.0f);
    plot.setRangeAxis(new DateAxis("Date"));
    final CategoryToolTipGenerator toolTipGenerator = new StandardCategoryToolTipGenerator("",
            DateFormat.getDateInstance());
    //        final CategoryItemRenderer renderer = new LineAndShapeRenderer(LineAndShapeRenderer.SHAPES);
    //      renderer.setToolTipGenerator(toolTipGenerator);
    //    plot.setRenderer(renderer);

    // ****************************************************************************
    // * JFREECHART DEVELOPER GUIDE                                               *
    // * The JFreeChart Developer Guide, written by David Gilbert, is available   *
    // * to purchase from Object Refinery Limited:                                *
    // *                                                                          *
    // * http://www.object-refinery.com/jfreechart/guide.html                     *
    // *                                                                          *
    // * Sales are used to provide funding for the JFreeChart project - please    * 
    // * support us so that we can continue developing free software.             *
    // ****************************************************************************

    // OPTIONAL CUSTOMISATION COMPLETED.

    // add the chart to a panel...
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

}

From source file:edu.esprit.charts.JfreeChart.java

private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    int i = 0;/* w ww. j  a va2  s .co  m*/
    int j = 0;
    List<Reservation> listReservation = ReservationDAO.getInstance().DisplayAllReservation();
    for (Reservation listReservation1 : listReservation) {
        i++;
    }
    List<Client> listClient = ClientDAO.getInstance().DisplayAllClients();
    for (Client listClient1 : listClient) {
        j++;
    }
    try {
        dataset.setValue(i, "", "t1");
        dataset.setValue(j, "", "t2");

        JFreeChart chart = ChartFactory.createBarChart("Statistiques", "", "", dataset,
                PlotOrientation.VERTICAL, false, false, false);
        // JFreeChart chart = ChartFactory.createPieChart3D("Liste des fazet", (PieDataset) dataset);
        CategoryPlot catPlot = chart.getCategoryPlot();
        ChartPanel ChartPanel = new ChartPanel(chart);
        jPanel1.removeAll();
        jPanel1.add(ChartPanel, BorderLayout.CENTER);
        jPanel1.validate();
    } catch (Exception e) {
        System.out.println(i);
    }
}

From source file:edu.esprit.charts.JfreeChart.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    // TODO add your handling code here:

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    int i = 0;//from ww  w  .  ja v a  2  s  .  co  m
    int j = 0;
    List<Reservation> listReservation = ReservationDAO.getInstance().DisplayAllReservation();
    for (Reservation listReservation1 : listReservation) {
        i++;
    }
    List<Client> listClient = ClientDAO.getInstance().DisplayAllClients();
    for (Client listClient1 : listClient) {
        j++;
    }
    try {
        dataset.setValue(i, "", "t1");
        dataset.setValue(j, "", "t2");

        JFreeChart chart = ChartFactory.createBarChart("Statistiques", "", "", dataset,
                PlotOrientation.HORIZONTAL, false, false, false);
        CategoryPlot catPlot = chart.getCategoryPlot();
        ChartPanel ChartPanel = new ChartPanel(chart);
        jPanel1.removeAll();
        jPanel1.add(ChartPanel, BorderLayout.CENTER);
        jPanel1.validate();
    } catch (Exception e) {
        System.out.println(i);
    }

}