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:UserInterfaces.HAdministration.DeviceReportJPanel.java

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

    int timeofem = 0;
    int timeofpha = 0;
    int timeofward = 0;
    int timeofor = 0;
    int timeoflab = 0;
    int timeofoutpatient = 0;

    int i;/*  www . j a v  a  2s.  c  om*/
    int max = 0;

    for (WorkRequest workRequest : enterprise.getWorkQueue().getWorkRequestList()) {
        if (workRequest.getLevel2().equals(ErrorUtil.DEVICE_OR_MEDICAL)) {
            if (workRequest.getLocation().equals(Location.EMERGENCY)) {
                timeofem = timeofem + 1;
            }
            if (workRequest.getLocation().equals(Location.LABORATORY)) {
                timeoflab = timeoflab + 1;
            }
            if (workRequest.getLocation().equals(Location.OR)) {
                timeofor = timeofor + 1;
            }
            if (workRequest.getLocation().equals(Location.OUTPATIEN)) {
                timeofoutpatient = timeofoutpatient + 1;
            }
            if (workRequest.getLocation().equals(Location.PHARMACY)) {
                timeofpha = timeofpha + 1;
            }
            if (workRequest.getLocation().equals(Location.WARD)) {
                timeofward = timeofward + 1;
            }

        }
    }

    int[] numbs;
    numbs = new int[6];
    numbs[0] = timeofem;
    numbs[1] = timeoflab;
    numbs[2] = timeofor;
    numbs[3] = timeofoutpatient;
    numbs[4] = timeofpha;
    numbs[5] = timeofward;

    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue(Location.EMERGENCY, timeofem);
    dataset.setValue(Location.LABORATORY, timeoflab);
    dataset.setValue(Location.OR, timeofor);
    dataset.setValue(Location.OUTPATIEN, timeofoutpatient);
    dataset.setValue(Location.PHARMACY, timeofpha);
    dataset.setValue(Location.WARD, timeofward);

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

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

    ChartFrame chartFrame = new ChartFrame("Location of events", chart);
    chartFrame.setSize(450, 550);
    chartFrame.setVisible(true);

}

From source file:tema11.GUI.java

private void PlotButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_PlotButton1MouseClicked

    //TxRes.setText(" ");

    String p1, p2 = new String();
    p1 = TxPol1.getText();/*from   w  ww  .  j a v a  2  s. c  o  m*/
    //p2 = TxPol2.getText();
    int g1;
    int[] coef1;

    // g2 = Integer.parseInt(TxGrad2.getText());

    try {
        g1 = Integer.parseInt(TxGrad1.getText());
        coef1 = PolinomOperations.parseString(p1, g1);
        //coef2 = PolinomOperations.parseString(p1, g1);
        String chartTitle = "Object Movement Chart";
        String xAxisLabel = "X";
        String yAxisLabel = "Y";

        XYDataset dataset = createDataset(coef1);

        JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, xAxisLabel, yAxisLabel, dataset);

        BarRenderer renderer = null;
        CategoryPlot plot = null;
        renderer = new BarRenderer();

        ChartFrame myFrame = new ChartFrame("Polinom chart", chart);
        myFrame.setLocation(200, 200);
        myFrame.setSize(400, 400);
        myFrame.setVisible(true);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, "Wrong polinom format", "Polinom Error", JOptionPane.ERROR_MESSAGE);
    }

}

From source file:tema11.GUI.java

private void PlotButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_PlotButton2MouseClicked

    //TxRes.setText(" ");

    String p1, p2 = new String();
    p1 = TxPol2.getText();//from  w  w w  .ja  v  a  2 s  . c  o m
    //p2 = TxPol2.getText();
    int g1;
    int[] coef1;

    // g2 = Integer.parseInt(TxGrad2.getText());

    try {
        g1 = Integer.parseInt(TxGrad2.getText());
        coef1 = PolinomOperations.parseString(p1, g1);
        //coef2 = PolinomOperations.parseString(p1, g1);
        String chartTitle = "Object Movement Chart";
        String xAxisLabel = "X";
        String yAxisLabel = "Y";

        XYDataset dataset = createDataset(coef1);

        JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, xAxisLabel, yAxisLabel, dataset);

        BarRenderer renderer = null;
        CategoryPlot plot = null;
        renderer = new BarRenderer();

        ChartFrame myFrame = new ChartFrame("Polinom chart", chart);
        myFrame.setLocation(200, 200);
        myFrame.setSize(400, 400);
        myFrame.setVisible(true);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, "Wrong polinom format", "Polinom Error", JOptionPane.ERROR_MESSAGE);
    }

}

From source file:userInterface.EnergySourceBoardSupervisor.ManageEnergyConsumptionsJPanel.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    DefaultPieDataset piedataset = new DefaultPieDataset();
    int rowcount = applianceTable.getRowCount();

    for (int i = 0; i <= rowcount - 1; i++) {
        Sensor sensor = (Sensor) applianceTable.getValueAt(i, 0);
        int j = sensor.getNumberWatt() * sensor.getHours();
        piedataset.setValue(sensor.getSensorType(), j);

    }//ww w  .  j  ava  2 s  .  c  om
    JFreeChart freechart = ChartFactory.createPieChart("Pie Chart for Carbon Monoxide Levels", piedataset, true,
            true, Locale.ENGLISH);
    PiePlot plot = (PiePlot) freechart.getPlot();
    ChartFrame frame = new ChartFrame("Pie Chart", freechart);
    frame.setVisible(true);
    frame.setSize(500, 500);
}

From source file:tema11.GUI.java

private void PlotResultButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_PlotResultButtonMouseClicked

    // TxRes.setText(" ");

    String p1, p2 = new String();
    p1 = TxRes.getText();//from w  w w  . j a  v a  2 s.c  o m
    //p2 = TxPol2.getText();
    int g1, g2;
    int[] coef1;

    // g2 = Integer.parseInt(TxGrad2.getText());

    try {
        g1 = Integer.parseInt(TxGrad1.getText());
        g2 = Integer.parseInt(TxGrad2.getText());
        coef1 = PolinomOperations.parseString(p1, g1 + g2);
        //coef2 = PolinomOperations.parseString(p1, g1);
        String chartTitle = "Object Movement Chart";
        String xAxisLabel = "X";
        String yAxisLabel = "Y";

        XYDataset dataset = createDataset(coef1);

        JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, xAxisLabel, yAxisLabel, dataset);

        BarRenderer renderer = null;
        CategoryPlot plot = null;
        renderer = new BarRenderer();

        ChartFrame myFrame = new ChartFrame("Result Polinom chart", chart);
        myFrame.setLocation(200, 200);
        myFrame.setSize(400, 400);
        myFrame.setVisible(true);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this,
                "Wrong polinom format! Va rog sa editati rezultatul si in locul coeficientului liber adaugati astfel coef_liberx^0 (exemplu in loc de 5 scrieti 5x^0)",
                "Polinom Error", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:UserInterfaces.HAdministration.SurgeryJPanel.java

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

    int timeofem = 0;
    int timeofpha = 0;
    int timeofward = 0;
    int timeofor = 0;
    int timeoflab = 0;
    int timeofoutpatient = 0;

    int i;/*from   w ww.j  av a2  s  .  c o  m*/
    int max = 0;

    for (WorkRequest workRequest : enterprise.getWorkQueue().getWorkRequestList()) {
        if (workRequest.getLevel2().equals(ErrorUtil.SURGERY_OR_ANESTHESIA)) {
            if (workRequest.getLocation().equals(Location.EMERGENCY)) {
                timeofem = timeofem + 1;
            }
            if (workRequest.getLocation().equals(Location.LABORATORY)) {
                timeoflab = timeoflab + 1;
            }
            if (workRequest.getLocation().equals(Location.OR)) {
                timeofor = timeofor + 1;
            }
            if (workRequest.getLocation().equals(Location.OUTPATIEN)) {
                timeofoutpatient = timeofoutpatient + 1;
            }
            if (workRequest.getLocation().equals(Location.PHARMACY)) {
                timeofpha = timeofpha + 1;
            }
            if (workRequest.getLocation().equals(Location.WARD)) {
                timeofward = timeofward + 1;
            }

        }
    }

    int[] numbs;
    numbs = new int[6];
    numbs[0] = timeofem;
    numbs[1] = timeoflab;
    numbs[2] = timeofor;
    numbs[3] = timeofoutpatient;
    numbs[4] = timeofpha;
    numbs[5] = timeofward;

    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue(Location.EMERGENCY, timeofem);
    dataset.setValue(Location.LABORATORY, timeoflab);
    dataset.setValue(Location.OR, timeofor);
    dataset.setValue(Location.OUTPATIEN, timeofoutpatient);
    dataset.setValue(Location.PHARMACY, timeofpha);
    dataset.setValue(Location.WARD, timeofward);

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

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

    ChartFrame chartFrame = new ChartFrame("Location of events", chart);
    chartFrame.setSize(450, 550);
    chartFrame.setVisible(true);
}

From source file:UserInfo_Frame.java

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
    try {//from www .ja  v  a 2 s  .  c o m
        String query = "select date,pressure from UserInfo";
        JDBCCategoryDataset dataset = new JDBCCategoryDataset(javaconnect.ConnectDB(), query);
        JFreeChart chart = ChartFactory.createLineChart("Query Chart", "Date", "Pressure", dataset,
                PlotOrientation.VERTICAL, false, true, true);
        BarRenderer renderer = null;
        CategoryPlot plot = null;
        renderer = new BarRenderer();
        ChartFrame frame = new ChartFrame("Query Chart", chart);
        frame.setVisible(true);
        frame.setSize(400, 650);
    } catch (Exception e) {

    }
}

From source file:UserInterfaces.HAdministration.FallReportJPanel.java

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

    int timeofadmin = 0;
    int timeofnurse = 0;
    int timeofpathology = 0;
    int timeofphar = 0;
    int timeofphysician = 0;
    int timeofsurgeon = 0;

    for (WorkRequest workRequest : enterprise.getWorkQueue().getWorkRequestList()) {
        if (workRequest.getLevel2().equals(ErrorUtil.FALL)) {
            for (ErrorPerson ep : workRequest.getEpd().getErrorpersonlist()) {
                if (ep instanceof AdminstrationErrorPerson) {
                    // if (ep.getEpt().getValue().equals(ErrorPerson.ErrorPersonType.ADMINSTRATION.getValue())) {
                    timeofadmin = timeofadmin + 1;
                }/*  ww w. j  a v a2s.  c  om*/
                if (ep instanceof NurseErrorPerson) {
                    timeofnurse = timeofnurse + 1;
                }
                if (ep instanceof PathologistriceErrorPerson) {
                    timeofpathology = timeofpathology + 1;
                }
                if (ep instanceof PharmacistErrorPerson) {
                    timeofphar = timeofphar + 1;
                }
                if (ep instanceof PhysicianErrorPerson) {
                    timeofphysician = timeofphysician + 1;
                }
                if (ep instanceof SurgeonErrorPerson) {
                    timeofsurgeon = timeofsurgeon + 1;
                }

            }
        }
    }

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.addValue(timeofadmin, "Adminstration", "Adminstration");
    dataset.addValue(timeofnurse, "Nurse", "Nurse");
    dataset.addValue(timeofpathology, "Pathologist", "Pathologist");
    dataset.addValue(timeofphar, "Pharmacist", "Pharmacist");
    dataset.addValue(timeofphysician, "Physician", "Physician");
    dataset.addValue(timeofsurgeon, "Surgeon", "Surgeon");
    //dataset.setValue(80, "masd", "sss");

    JFreeChart chart = ChartFactory.createBarChart("Personnel", "Position", "Times", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setRangeGridlinePaint(Color.WHITE);
    ChartFrame frame = new ChartFrame("Chart for ERROR", chart);
    frame.setVisible(true);
    frame.setSize(900, 700);

}

From source file:UserInfo_Frame.java

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
    String pressure = txt_pressure.getText();
    String temperature = txt_temperature.getText();
    String volumeflow = txt_volume.getText();
    String rotationalSpeed = txt_rotationalSpd.getText();

    DefaultPieDataset pieDataset = new DefaultPieDataset();

    pieDataset.setValue("Pressure", new Double(pressure));
    pieDataset.setValue("Temperature", new Double(temperature));
    pieDataset.setValue("Volume Flow", new Double(volumeflow));
    pieDataset.setValue("Rotational Speeed", new Double(rotationalSpeed));

    //JFreeChart chart = ChartFactory.createPieChart("Pie Chart",pieDataset,true,true,true); // create normal piechart
    //PiePlot3D p = (PiePlot)chart.getPlot();
    JFreeChart chart = ChartFactory.createPieChart3D("Parameter Pie Chart", pieDataset, true, true, true);// create 3D piechart
    PiePlot3D p = (PiePlot3D) chart.getPlot();
    //p.setForegroundAlpha(TOP_ALIGNMENT);
    ChartFrame cframe = new ChartFrame("Pie Chart", chart);
    cframe.setVisible(true);
    cframe.setSize(450, 500);/*from w ww.j  a  v a 2  s. c om*/
    try {
        //save chart as PNG
        final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
        final File file1 = new File("chart.png");
        ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
    } catch (Exception e) {

    }

}

From source file:UserInfo_Frame.java

private void barChart_btnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_barChart_btnActionPerformed
    //create dataset values
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(80, "Marks", "Student1");
    dataset.setValue(50, "Marks", "Student2");
    dataset.setValue(75, "Marks", "Student3");
    dataset.setValue(95, "Marks", "Student4");
    //create bar chart
    JFreeChart chart = ChartFactory.createBarChart("Student Score", "Student Name", "Marks", dataset,
            PlotOrientation.VERTICAL, false, true, true);
    // create Line chart FreeChart chart = ChartFactory.createLineChart("Student Score", "Student Name", "Marks", dataset,PlotOrientation.VERTICAL,false,true,true);
    // set properties
    chart.setBackgroundPaint(Color.YELLOW);// change background color to yellow
    chart.getTitle().setPaint(Color.RED);

    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLUE);
    ChartFrame bframe = new ChartFrame("Bar Chart for student", chart);
    bframe.setVisible(true);
    bframe.setSize(450, 350);/*from   w ww  . j  ava  2s.  c o m*/

}