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:server.ServerUI.java

void displayUsersStatusChart(int availableNum, int busyNum, int awayNum, int offlineNum) {
    DefaultPieDataset pieDataset = new DefaultPieDataset();
    pieDataset.setValue("Avaliable", new Integer(availableNum));
    pieDataset.setValue("Away", new Integer(awayNum));
    pieDataset.setValue("Busy", new Integer(busyNum));
    pieDataset.setValue("Offline", new Integer(offlineNum));
    JFreeChart chart = ChartFactory.createPieChart("Users Statistics", pieDataset, true, true, true);
    PiePlot p;//from   w ww. java2s.co  m
    p = (PiePlot) chart.getPlot();
    ChartFrame chartPanelObj = new ChartFrame("USERS", chart);
    chartPanelObj.setVisible(true);
    chartPanelObj.setSize(450, 500);
}

From source file:userInterface.CustomerWorkArea.ViewChartJPanel.java

private void batteryBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_batteryBtnActionPerformed
    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();

    for (CarInspection carList : userAccount.getPerson().getCarInspectionHistory().getCarInspectionHistory()) {
        dataSet.setValue(carList.getBattery(), "Battery", carList.getTimestamp());
    }/*from   w  ww.ja  va  2  s  .c o m*/
    JFreeChart chart = ChartFactory.createBarChart("Battery", "Timestamp", "Battery", dataSet,
            PlotOrientation.HORIZONTAL.VERTICAL, false, true, false);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLACK);
    ChartFrame frame = new ChartFrame("BATTERY GRAPH", chart);
    frame.setVisible(true);
    frame.setSize(600, 600);
    // TODO add your handling code here:
}

From source file:userInterface.CustomerWorkArea.ViewChartJPanel.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();

    for (CarInspection carList : userAccount.getPerson().getCarInspectionHistory().getCarInspectionHistory()) {
        dataSet.setValue(carList.getBrakingSys(), "Brakes", carList.getTimestamp());
    }/*from ww  w . j a v  a2  s .c  o m*/
    JFreeChart chart = ChartFactory.createBarChart("Brakes", "Timestamp", "Brakes", dataSet,
            PlotOrientation.HORIZONTAL.VERTICAL, false, true, false);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLACK);
    ChartFrame frame = new ChartFrame("BRAKES GRAPH", chart);
    frame.setVisible(true);
    frame.setSize(600, 600);
    // TODO add your handling code here:
}

From source file:userInterface.CustomerWorkArea.ViewChartJPanel.java

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();

    for (CarInspection carList : userAccount.getPerson().getCarInspectionHistory().getCarInspectionHistory()) {
        dataSet.setValue(carList.getPollutionLevel(), "Pollution", carList.getTimestamp());
    }//from  w w w . j  av  a  2s. c om
    JFreeChart chart = ChartFactory.createBarChart("Pollution", "Timestamp", "Pollution", dataSet,
            PlotOrientation.HORIZONTAL.VERTICAL, false, true, false);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLACK);
    ChartFrame frame = new ChartFrame("POLLUTION GRAPH", chart);
    frame.setVisible(true);
    frame.setSize(600, 600); // TODO add your handling code here:
}

From source file:userInterface.CustomerWorkArea.ViewChartJPanel.java

private void viewAlignmentBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewAlignmentBtnActionPerformed
    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();

    for (CarInspection carList : userAccount.getPerson().getCarInspectionHistory().getCarInspectionHistory()) {
        dataSet.setValue(carList.getAlignment(), "Alignment", carList.getTimestamp());
    }//from  ww w  .  jav a2 s .  c  om
    JFreeChart chart = ChartFactory.createBarChart("Alignment", "Timestamp", "Alignment", dataSet,
            PlotOrientation.HORIZONTAL.VERTICAL, false, true, false);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLACK);
    ChartFrame frame = new ChartFrame("ALIGNMENT GRAPH", chart);
    frame.setVisible(true);
    frame.setSize(600, 600);
    // TODO add your handling code here:
}

From source file:UserInterface.DoctorRole.ViewPatientReport.java

private void LineGraphButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LineGraphButtonActionPerformed
    // TODO add your handling code here:
    //dataset = new DefaultCategoryDataset();
    XYSeriesCollection dataset = new XYSeriesCollection();
    if (!(patient.getTestDir().getTestdir().isEmpty())) {
        for (Test vs : patient.getTestDir().getTestdir()) {
            XYSeries series1 = new XYSeries(vs.getBloodPressure());
            series1.add(10, Float.parseFloat(vs.getBloodPressure()));
            series1.add(20, Float.parseFloat(vs.getBloodPlatlets()));
            series1.add(30, Float.parseFloat(vs.getHemoglobinLevel()));
            series1.add(40, Float.parseFloat(vs.getBloodPlatlets()));
            dataset.addSeries(series1);// ww w . java 2 s.  c om

            //            dataset.addValue(Integer.parseInt(vs.getBloodPressure()), "Blood Pressure", vs.getTimestamp());
            //            dataset.addValue(Integer.parseInt(vs.getBloodPlatlets()), "Blood Platelets", vs.getTimestamp());
            //            //dataset.addValue(Integer.parseInt(vs.getHemoglobinLevel()), "Hemoglobin Level", vs.getTimestamp());
            //            //dataset.addValue(vs.getWeight(), "Weight", vs.getTimestamp());
            //     
        }
        JFreeChart chartFactory = ChartFactory.createXYLineChart("GRAPHICAL REPRESENTATION OF SENSOR DATA",
                "X-Axis", "SIGN", (XYDataset) dataset);
        XYLineAndShapeRenderer renderer = null;

        //      
        XYPlot plot = chartFactory.getXYPlot();
        renderer = new XYLineAndShapeRenderer();
        ChartFrame frame = new ChartFrame("Line Chart Of Sensor Data", chartFactory);
        frame.setVisible(true);
        frame.setSize(700, 320);
    } //GEN-LAST:event_LineGraphButtonActionPerformed
    else {
        JOptionPane.showMessageDialog(this, "No Vital Signs To Display On Graph!!!");
    }

}

From source file:UserInterface.DoctorRole.DoctorReportChartJPanel.java

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

    ReportToReporter report = enterprise.getReport();
    if (report.getStatus() != null) {
        DefaultPieDataset dataset = new DefaultPieDataset();
        dataset.setValue("First hand", report.getFirsthandsource());
        dataset.setValue("Second hand", report.getSecondhandsource());

        JFreeChart chart = ChartFactory.createPieChart("bar chart", dataset, true, true, true);

        PiePlot p = (PiePlot) chart.getPlot();

        ChartFrame chartFrame = new ChartFrame("Source of Reports", chart);
        chartFrame.setSize(450, 550);/*from  www.  j  av  a 2 s . co m*/
        chartFrame.setVisible(true);
    } else {
        JOptionPane.showMessageDialog(null, "Sorry, the final report has not been generated");
    }

}

From source file:userInterface.CustomerWorkArea.ViewChartJPanel.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();

    for (CarInspection carList : userAccount.getPerson().getCarInspectionHistory().getCarInspectionHistory()) {
        dataSet.setValue(carList.getTyrePressure(), "Tyre Pressure", carList.getTimestamp());
    }/*from  w  w w.j  av  a  2  s  . c o m*/
    JFreeChart chart = ChartFactory.createBarChart("Tyre Pressure", "Timestamp", "Tyre Pressure", dataSet,
            PlotOrientation.HORIZONTAL.VERTICAL, false, true, false);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLACK);
    ChartFrame frame = new ChartFrame("TYRE PRESSURE GRAPH", chart);
    frame.setVisible(true);
    frame.setSize(600, 600); // TODO add your handling code here:
}

From source file:UserInterface.PatientRole.PatientReportChartJPanel.java

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

    ReportToReporter report = enterprise.getReport();
    if (report.getStatus() != null) {
        DefaultPieDataset dataset = new DefaultPieDataset();
        dataset.setValue("First hand", report.getFirsthandsource());
        dataset.setValue("Second hand", report.getSecondhandsource());

        JFreeChart chart = ChartFactory.createPieChart("bar chart", dataset, true, true, true);

        PiePlot p = (PiePlot) chart.getPlot();

        ChartFrame chartFrame = new ChartFrame("Source of Reports", chart);
        chartFrame.setSize(450, 550);/*from   ww  w .j  av a 2 s .  c  o  m*/
        chartFrame.setVisible(true);
    } else {
        JOptionPane.showMessageDialog(null, "Sorry, the final report has not been generated");
    }
}

From source file:teambootje.A1.java

public A1() {
    initComponents();// w  ww  .j  ava2  s .  c  om
    setLocationRelativeTo(null);
    setLayout(new BorderLayout());
    setSize(500, 500);

    //Create and set up the window.
    setTitle("SS Rotterdam Analyse || Analyse 1");
    ImageIcon icon = new ImageIcon("img/bootje.jpg");
    setIconImage(icon.getImage());

    // back BTN
    JButton back = new JButton("Back");
    add(back, BorderLayout.NORTH);

    back.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });

    // panel
    JPanel ana = new JPanel();
    add(ana, BorderLayout.CENTER);

    //tabel
    String nvt = "SELECT Geslacht, COUNT(*) AS Aantal FROM persoon GROUP BY geslacht";
    String male = "SELECT Geslacht AS male, COUNT(*) AS Aantal_Male FROM persoon WHERE Geslacht = 'man'";
    String Female = "SELECT Geslacht AS female, COUNT(*) AS Aantal_Female FROM persoon WHERE Geslacht = 'vrouw'";
    List<Object[]> list = new ArrayList<Object[]>();
    ResultSet rs = null;
    try {
        rs = db.runSql(nvt);
        while (rs.next()) {
            String geslacht = rs.getString("Geslacht");
            int aantal = rs.getInt("Aantal");
            String[] row = new String[rs.getMetaData().getColumnCount()];
            for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
                row[i - 1] = rs.getString(i);
            }
            list.add(row);

            try {
                rs = db.runSql(male);
                while (rs.next()) {
                    String man = rs.getString("male");
                    int am = rs.getInt("Aantal_Male");
                    String[] row1 = new String[rs.getMetaData().getColumnCount()];
                    for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
                        row1[i - 1] = rs.getString(i);
                    }

                    try {
                        rs = db.runSql(Female);
                        while (rs.next()) {
                            String vrouw = rs.getString("female");
                            int af = rs.getInt("Aantal_Female");
                            String[] row2 = new String[rs.getMetaData().getColumnCount()];
                            for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
                                row2[i - 1] = rs.getString(i);
                            }
                            Object[][] array = new Object[list.size()][];
                            Object columnNames[] = { "Geslacht", "Aantal" };
                            list.toArray(array);

                            JTable table = new JTable(array, columnNames);
                            JScrollPane scroll = new JScrollPane(table);
                            scroll.setPreferredSize(new Dimension(400, 400));
                            ana.add(scroll);

                            //chart
                            JButton chart = new JButton("Chart");
                            add(chart, BorderLayout.SOUTH);

                            chart.addActionListener(new ActionListener() {
                                String g1 = geslacht;
                                String m = man;
                                String v = vrouw;
                                int a1 = aantal;
                                int a2 = am;
                                int a3 = af;

                                @Override
                                public void actionPerformed(ActionEvent e) {

                                    DefaultPieDataset pieDataset = new DefaultPieDataset();
                                    pieDataset.setValue("Niet vrij gegeven", a1);
                                    pieDataset.setValue("Man", a2);
                                    pieDataset.setValue("vrouw", a3);

                                    JFreeChart chart = ChartFactory.createPieChart3D("Aantal mannen en vrouwen",
                                            pieDataset, true, true, true);
                                    PiePlot3D p = (PiePlot3D) chart.getPlot();
                                    //p.setForegroundAlpha(TOP_ALIGNMENT);
                                    ChartFrame pie = new ChartFrame("Aantal mannen en vrouwen", chart);
                                    pie.setVisible(true);
                                    pie.setSize(500, 500);
                                    pie.setLocationRelativeTo(null);

                                    //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
                                }
                            });
                        }
                    } catch (SQLException v) {
                        JOptionPane.showMessageDialog(null, v);
                    }
                }
            } catch (SQLException m) {
                JOptionPane.showMessageDialog(null, m);
            }

        }
    } catch (SQLException e) {
        JOptionPane.showMessageDialog(null, e);
    }
}