Example usage for org.jfree.chart ChartFrame setVisible

List of usage examples for org.jfree.chart ChartFrame setVisible

Introduction

In this page you can find the example usage for org.jfree.chart ChartFrame setVisible.

Prototype

public void setVisible(boolean b) 

Source Link

Document

Shows or hides this Window depending on the value of parameter b .

Usage

From source file:flight_ranker.my_Jframe.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(85, "Marks", "Science");
    dataset.setValue(91, "Marks", "Maths");
    dataset.setValue(97, "Marks", "Computer");
    dataset.setValue(95, "Marks", "English");

    JFreeChart chart = ChartFactory.createBarChart("Bar Chart", "Subject", "Marks", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot P = chart.getCategoryPlot();
    P.setRangeGridlinePaint(Color.black);
    ChartFrame frame = new ChartFrame("Bar chart", chart);
    frame.setVisible(true);
    frame.setSize(450, 351);/* w w  w.java2 s .c o m*/

}

From source file:br.unicamp.cst.motivational.MotivationalMonitor.java

@Override
public synchronized void run() {

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    final JFreeChart chart = ChartFactory.createBarChart(getTitle(), getEntity(), "Value", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    chart.setBackgroundPaint(Color.lightGray);

    ChartFrame frame = new ChartFrame(getTitle(), chart);
    frame.pack();//ww  w .ja v a  2  s. c o m
    frame.setVisible(true);

    while (true) {
        ArrayList<Codelet> tempCodeletsList = new ArrayList<Codelet>();
        tempCodeletsList.addAll(this.getListOfMotivationalEntities());

        synchronized (tempCodeletsList) {

            for (Codelet co : tempCodeletsList) {
                dataset.addValue(co.getActivation(), co.getName(), "activation");
            }
            try {
                Thread.currentThread().sleep(getRefreshPeriod());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    }
}

From source file:GUI.TelaPrincipal.java

private void botaoConsultarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoConsultarActionPerformed
    DefaultCategoryDataset barChartData = new DefaultCategoryDataset();
    barChartData.setValue(20000, "Contribution", "JANUARY");
    barChartData.setValue(15000, "Contribution", "FEBRUARY");
    barChartData.setValue(30000, "Contribution", "MARCH");

    JFreeChart barChart = ChartFactory.createBarChart("Church", "Monthly", "Contribution", barChartData,
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot barchrt = barChart.getCategoryPlot();
    barchrt.setRangeGridlinePaint(Color.PINK);
    barchrt.setBackgroundPaint(Color.WHITE);

    ChartFrame frame = new ChartFrame("Lala", barChart);
    frame.setVisible(true);
    frame.setSize(800, 500);/* ww  w  .  j a  v  a 2  s .c  o m*/

}

From source file:userInterface.MonitoringTeamRole.AnalysisJPanel.java

private void jLabel2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel2MouseClicked
    // TODO add your handling code here:

    JFreeChart chart = createChart(createDataset());
    chart.setBackgroundPaint(Color.YELLOW);
    chart.getTitle().setPaint(Color.red);

    ChartFrame frame = new ChartFrame("XYChart", chart);
    frame.setVisible(true);
    frame.setSize(450, 500);//ww w.jav a2  s  . c  o m
}

From source file:UserInterface.CDC.VARESReportingJPanel.java

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

    DefaultPieDataset pieDataset = new DefaultPieDataset();
    for (StateNetwork state : business.getStateList()) {
        pieDataset.setValue(state.getStateName(), state.getTotalFailedVaccinesInState());

    }//from  w  ww. j  a v a 2 s.c  o m
    JFreeChart chart = ChartFactory.createPieChart("Total Vaccines Failed", pieDataset, true, true, true);
    PiePlot p = (PiePlot) chart.getPlot();
    ChartFrame frame = new ChartFrame("Total Vaccines Failed", chart);
    frame.setVisible(true);
    frame.setSize(450, 500);

}

From source file:UserInterface.DoctorRole.ViewDonorReport.java

public void Graph() {
    dataset = new DefaultCategoryDataset();
    if (vitalSigndir.getVitalSignDir().isEmpty()) {
        for (VitalSign vs : vitalSigndir.getVitalSignDir()) {

            dataset.addValue(Float.parseFloat(vs.getBloodPressure()), "Blood Pressure", vs.getTimestamp());
            dataset.addValue(Float.parseFloat(vs.getBloodPlatlets()), "Blood Platelets", vs.getTimestamp());
            dataset.addValue(Float.parseFloat(vs.getHemoglobinLevel()), "Hemoglobin Level", vs.getTimestamp());
            //dataset.addValue(vs.getWeight(), "Weight", vs.getTimestamp());

        }/*from   w  w w .j av  a2  s . com*/

        JFreeChart chartFactory = ChartFactory.createBarChart3D("VitalSign", "Time", "VitalSign", dataset,
                PlotOrientation.VERTICAL, true, true, false);

        BarRenderer renderer = null;
        CategoryPlot plot = chartFactory.getCategoryPlot();
        renderer = new BarRenderer();
        ChartFrame frame = new ChartFrame("Bar Chart for VitalSign", chartFactory);
        frame.setVisible(true);
        frame.setSize(700, 320);
    }

}

From source file:UserInterface.CDC.VaccineStateDistributionJPanel.java

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

    DefaultPieDataset pieDataset = new DefaultPieDataset();
    for (StateNetwork state : business.getStateList()) {
        pieDataset.setValue(state.getStateName(), state.getTotalVaccinesDistributedInState());

    }// ww w  .  j av  a  2 s  .co m
    JFreeChart chart = ChartFactory.createPieChart("Total Vaccines Distributed", pieDataset, true, true, true);
    PiePlot p = (PiePlot) chart.getPlot();
    ChartFrame frame = new ChartFrame("Total Vaccines Distributed", chart);
    frame.setVisible(true);
    frame.setSize(450, 500);

}

From source file:lectorarchivos.MostrarGraficaCSV.java

/**
 * Creates new form MostrarGraficaCSV//  ww w  .j av  a2  s  . co m
 */
public MostrarGraficaCSV(JTable jTableInfoCSV) {
    initComponents();
    this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    panel = new JPanel();
    getContentPane().add(panel);

    //Fuente de datos
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    //Recorremos la columna del consumo de la tabla
    for (int i = jTableInfoCSV.getRowCount() - 1; i >= 0; i--) {
        if (Double.parseDouble(jTableInfoCSV.getValueAt(i, 4).toString()) > 0)
            dataset.setValue(Double.parseDouble(jTableInfoCSV.getValueAt(i, 4).toString()), "Consumo",
                    jTableInfoCSV.getValueAt(i, 0).toString());
    }

    //Creando el grfico
    JFreeChart chart = ChartFactory.createBarChart3D("Consumo", "Fecha", "Consumo", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.cyan);
    chart.getTitle().setPaint(Color.black);
    chart.setBackgroundPaint(Color.white);
    chart.removeLegend();

    //Cambiar color de barras
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
    barRenderer.setSeriesPaint(0, Color.decode("#5882FA"));

    // Mostrar Grafico
    ChartFrame frame = new ChartFrame("CONSUMO", chart);
    frame.pack();
    frame.getChartPanel().setMouseZoomable(false);
    frame.setVisible(true);

    panel.add(frame);

}

From source file:k_means.Kmeans.java

public void DisplayData() {
    for (int i = 0; i < dataSet.size(); i++) {
        System.out.println("X:" + dataSet.get(i).getX() + " Y:" + dataSet.get(i).getY() + " CLUSTER :"
                + dataSet.get(i).getCluster());
    }/*from   w  ww.  j  av  a 2s  .  com*/

    XYDataset d = Plot.createDataset(dataSet, k);

    JFreeChart chart = ChartFactory.createScatterPlot("DataPlot", "X", "Y", d, PlotOrientation.VERTICAL, true,
            true, false);
    // create and display a frame...
    ChartFrame frame = new ChartFrame("First", chart);
    frame.pack();
    frame.setVisible(true);

}

From source file:frames.Screen2.java

private void PiechartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PiechartActionPerformed
    DefaultPieDataset piedataset = new DefaultPieDataset();
    piedataset.setValue("Process one", new Integer(10));
    piedataset.setValue("Process two", new Integer(20));
    piedataset.setValue("Process three", new Integer(30));
    piedataset.setValue("Process four", new Integer(40));
    JFreeChart chart = ChartFactory.createPieChart("Piechart", piedataset, true, true, true);
    PiePlot P = (PiePlot) chart.getPlot();
    //P.setForegroundAlpha(TOP_ALIGNMENT);
    ChartFrame frame = new ChartFrame("piechart", chart);
    frame.setVisible(true);
    frame.setSize(450, 500);//www.j a  va2  s.c  om

}