Example usage for org.jfree.chart ChartFrame setSize

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

Introduction

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

Prototype

public void setSize(int width, int height) 

Source Link

Document

The width and height values are automatically enlarged if either is less than the minimum size as specified by previous call to setMinimumSize .

Usage

From source file:UserInterfaces.HAdministration.ReportDataJPanel.java

private void personneljButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_personneljButton3ActionPerformed
    // 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 : organization.getWorkQueue().getWorkRequestList()) {
        for (ErrorPerson ep : workRequest.getEpd().getErrorpersonlist()) {

            if (ep instanceof AdminstrationErrorPerson) {
                // if (ep.getEpt().getValue().equals(ErrorPerson.ErrorPersonType.ADMINSTRATION.getValue())) {
                timeofadmin = timeofadmin + 1;
            }// w w w.ja  v a 2 s. c o  m
            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;

            }

            /*if (ep.getEpt().equals(ErrorPerson.ErrorPersonType.NURESE)) {
             timeofnurse = timeofnurse + 1;
             }
             if (ep.getEpt().equals(ErrorPerson.ErrorPersonType.PATHOLOGIST)) {
             timeofpathology = timeofpathology + 1;
             }
             if (ep.getEpt().equals(ErrorPerson.ErrorPersonType.PHARMACIST)) {
             timeofphar = timeofphar + 1;
             }
             if (ep.getEpt().equals(ErrorPerson.ErrorPersonType.PHYSICIAN)) {
             timeofphysician = timeofphysician + 1;
             }
             if (ep.getEpt().equals(ErrorPerson.ErrorPersonType.SURGEON)) {
             timeofsurgeon = timeofsurgeon + 1;
             }*/
        }
    }
    ReportToReporter report = organization.getReport();
    report.setTimeofadmin(timeofadmin);
    report.setTimeofnurse(timeofnurse);
    report.setTimeofpathology(timeofpathology);
    report.setTimeofphar(timeofphar);
    report.setTimeofphysician(timeofphysician);
    report.setTimeofsurgeon(timeofsurgeon);
    report.setStatus("success");

    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);

    for (Network network : es.getNetworkList()) {
        for (Enterprise e : network.getEd().getEnterprisesList()) {
            if (e.getOrgName().equals(enterprise.getOrgName())) {
                for (Enterprise en : network.getEd().getEnterprisesList()) {
                    if (e instanceof HospitalEnterprise || e instanceof ClinicEnterprise) {
                        e.setReport(report);
                    }
                }
            }

        }

    }

}

From source file:userinterface.HealthAnalystRole.ViewReportJPanel.java

private void createChart() {
    DefaultCategoryDataset healthDataset = new DefaultCategoryDataset();
    int selectedRow = tblHealthTable.getSelectedRow();
    Device effects = (Device) tblHealthTable.getValueAt(selectedRow, 0);
    //Device device= device.getEffectsOnBodyList().getEffectsOnBodyList().;

    for (Device d : organization.getDeviceDirectory().getDeviceList()) {
        if (d.getEffectsOnBodyList().getEffectsOnBodyList().isEmpty()
                || d.getEffectsOnBodyList().getEffectsOnBodyList().size() == 1) {
            JOptionPane.showMessageDialog(this,
                    "No body organs or only one body organ affected found. At least 2 organs effected records needed to show chart!",
                    "Warning", JOptionPane.INFORMATION_MESSAGE);
            return;
        } else {/*from ww  w  . j a va 2 s.  c om*/
            Double organ = Double.parseDouble(txtOrgan.getText());
            Double value = d.getMaxSAR();
        }
    }
    //ArrayList<EffectsOnBody> effectsOnBodyList = device.getEffectsOnBodyList().getEffectsOnBodyList();

    /*if (effectsOnBodyList.isEmpty() || effectsOnBodyList.size() == 1) {
    JOptionPane.showMessageDialog(this, "No body organs or only one body organ affected found. At least 2 organs effected records needed to show chart!", "Warning", JOptionPane.INFORMATION_MESSAGE);
    return;
    }*/
    Double organ = Double.parseDouble(txtOrgan.getText());
    for (Device device : organization.getDeviceDirectory().getDeviceList()) {
        for (EffectsOnBody b1 : device.getEffectsOnBodyList().getEffectsOnBodyList()) {
            Double value = device.getMaxSAR();

            //healthDataset.addValue(vitalSign.getHeartRate(),"Most Likely Diseases", device.getMaxSAR());
            //vitalSignDataset.addValue(vitalSign.getBloodPressure(),"BP", vitalSign.getTimestamp());
            //vitalSignDataset.addValue(vitalSign.getWeight(),"WT", vitalSign.getTimestamp());
        }

    }

    JFreeChart healthSignChart = ChartFactory.createBarChart3D("Effects On Health Chart", "Time Stamp", "Rate",
            healthDataset, PlotOrientation.VERTICAL, true, false, false);
    healthSignChart.setBackgroundPaint(Color.white);
    CategoryPlot vitalSignChartPlot = healthSignChart.getCategoryPlot();
    vitalSignChartPlot.setBackgroundPaint(Color.lightGray);

    CategoryAxis vitalSignDomainAxis = vitalSignChartPlot.getDomainAxis();
    vitalSignDomainAxis
            .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    NumberAxis vitalSignRangeAxis = (NumberAxis) vitalSignChartPlot.getRangeAxis();
    vitalSignRangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    ChartFrame chartFrame = new ChartFrame("Chart", healthSignChart);
    chartFrame.setVisible(true);
    chartFrame.setSize(500, 500);

}

From source file:StoreAdmin.ManageStoreJPanel.java

private void btntopfiveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btntopfiveActionPerformed
    DefaultTableModel dtm = (DefaultTableModel) tblsearchedproduct.getModel();
    dtm.getRowCount();//from   w  w  w.  j a va2  s  .  c  om

    System.out.println(dtm.getRowCount());

    if (dtm.getRowCount() < 4) {
        JOptionPane.showMessageDialog(null, "Inventory must have more than 4 products to plot the graph");

    } else {

        JFreeChart plotGraphInventory = ChartFactory.createBarChart("Top 5 products in Store", "Products",
                "Profit", plotGrapghInventory(), PlotOrientation.VERTICAL, true, true, false);

        ChartPanel chartPanel = new ChartPanel(plotGraphInventory);
        chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
        ChartFrame frame = new ChartFrame("Market Report", plotGraphInventory);
        frame.setVisible(true);
        frame.setSize(500, 270);
    } //GEN-LAST:event_btntopfiveActionPerformed
}

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 w  w. 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:UserInterface.TMAnalystRole.TMAnaylstWorkAreaJPanel.java

private void btnRouteAnalysisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRouteAnalysisActionPerformed
    // TODO add your handling code here:
    Line selectedLine = (Line) cboActiveLines.getSelectedItem();
    ArrayList<Route> routeList = new ArrayList<>();

    for (Segment s : selectedLine.getSegments()) {
        routeList.add(s.getRoutes().get(0));
    }//from   www .  j  a  v a2  s  .c  om

    ArrayList<Segment> segmentList = selectedLine.getSegments();
    for (int i = segmentList.size() - 1; i >= 0; i--) {
        routeList.add(segmentList.get(i).getRoutes().get(1));
    }

    int days = (int) spnrRecord.getValue();
    Date today = new Date();
    Date olderThanToday = new Date();
    olderThanToday.setTime(today.getTime() + (long) (-days) * 1000 * 60 * 60 * 24);
    long todayDate = (today.getTime()) / (1000 * 60 * 60 * 24);
    long olderDate = (olderThanToday.getTime()) / (1000 * 60 * 60 * 24);

    Map<Route, Integer> routesWithCapacityList = new LinkedHashMap<>();

    for (Route r : routeList) {
        int routeCount = 0;

        for (TimeSlot.TimeSlotRange ts : TimeSlot.TimeSlotRange.values()) {
            Train selectedTrain = r.fetchRouteSchedule(ts).getTrainOffered();
            int intermediateCount = 0;
            int trainsFound = 0;
            for (TrainOffered selectedTrainOffered : enterprise.getTrainsOfferedHistory().getTrainsOffered()) {
                if (selectedTrainOffered.getTrain().equals(selectedTrain)) {
                    long selectedDate = (selectedTrainOffered.getDayOffered().getTime())
                            / (1000 * 60 * 60 * 24);
                    if (selectedDate >= olderDate && selectedDate <= todayDate) {
                        intermediateCount += selectedTrainOffered.fetchRunningTrainByTimeSlot(ts)
                                .getRunningCapacity();
                        trainsFound++;
                    }
                }

            }
            if (trainsFound != 0) {
                intermediateCount = intermediateCount / trainsFound;
                routeCount += intermediateCount;
            }
        }
        routeCount = Math.round(routeCount / 15);
        routesWithCapacityList.putIfAbsent(r, routeCount);
    }

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    for (Map.Entry<Route, Integer> entry : routesWithCapacityList.entrySet()) {
        dataset.setValue(entry.getValue(), "Routes", entry.getKey().getRouteName());

    }

    JFreeChart chart = ChartFactory.createBarChart(
            "Congestion Levels of Line : " + selectedLine.getLineName() + " for " + days + " days", "Routes",
            "Average Congestion Levels", dataset, PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setRangeGridlinePaint(Color.BLUE);
    ChartFrame frame = new ChartFrame("Bar Chart for Congestion Analysis", chart);
    frame.setVisible(true);
    frame.setSize(this.getWidth(), this.getHeight() + 200);

}

From source file:UserInterface.WaterSupplyAdmin.UsagePatternJPanel.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    int total = 0;

    for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) {
        if (organization instanceof CustomerOrganization) {
            for (Employee employee : organization.getEmployeeDirectory().getEmployeeList()) {
                Customer customer = (Customer) employee;
                total += customer.getTotalUsageVolume();
            }/*  w  w w  .  jav  a 2  s  .  c  o  m*/
        }
    }
    if (total == 0) {
        JOptionPane.showMessageDialog(null, "No Customer has used water yet");
        return;
    }
    DefaultPieDataset dataset = new DefaultPieDataset();
    for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) {
        if (organization instanceof CustomerOrganization) {
            for (Employee employee : organization.getEmployeeDirectory().getEmployeeList()) {
                Customer customer = (Customer) employee;
                dataset.setValue(customer.getName(), customer.getTotalUsageVolume());
            }
        }
    }

    JFreeChart chart = ChartFactory.createPieChart3D("Customer Water Usage", dataset, true, true, true);
    ChartFrame frame = new ChartFrame("Pie Chart demonstrating customer water usage ", chart);
    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(200);
    plot.setForegroundAlpha(0.50f);
    RefineryUtilities.centerFrameOnScreen(frame);
    frame.setVisible(true);
    frame.setSize(650, 550);
}

From source file:UserInterface.CustomerRole.CustomerTaxJPanel.java

public void displayChart(Date date1) {
    int total = 0;
    int k;// ww  w.  ja  va  2s  .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:UserInterface.TMAnalystRole.TMAnaylstWorkAreaJPanel.java

private void generateGraph(Train selectedTrain) {

    ArrayList<TrainOffered> selectedTrainOfferedListWEEKDAYS = new ArrayList<>();
    ArrayList<TrainOffered> selectedTrainOfferedListWEEKENDS = new ArrayList<>();

    int days = (int) spnrRecord.getValue();
    Date today = new Date();
    Date olderThanToday = new Date();
    olderThanToday.setTime(today.getTime() + (long) (-days) * 1000 * 60 * 60 * 24);
    long todayDate = (today.getTime()) / (1000 * 60 * 60 * 24);
    long olderDate = (olderThanToday.getTime()) / (1000 * 60 * 60 * 24);

    for (TrainOffered selectedTrainOffered : enterprise.getTrainsOfferedHistory().getTrainsOffered()) {
        if (selectedTrainOffered.getTrain().equals(selectedTrain)) {
            long selectedDate = (selectedTrainOffered.getDayOffered().getTime()) / (1000 * 60 * 60 * 24);
            if (selectedDate >= olderDate && selectedDate <= todayDate) {
                Calendar date = Calendar.getInstance();
                date.setTime(selectedTrainOffered.getDayOffered());
                if ((date.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
                        || ((date.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY))) {
                    if (!selectedTrainOfferedListWEEKENDS.contains(selectedTrainOffered)) {
                        selectedTrainOfferedListWEEKENDS.add(selectedTrainOffered);
                    }//from   w ww . j a v a 2s  . c  om
                } else {
                    if (!selectedTrainOfferedListWEEKDAYS.contains(selectedTrainOffered)) {
                        selectedTrainOfferedListWEEKDAYS.add(selectedTrainOffered);
                    }
                }
            }
        }
    }

    Map<TimeSlot.TimeSlotRange, Integer> weekendData = new HashMap<TimeSlot.TimeSlotRange, Integer>();

    for (TrainOffered selectedTrainOfferedOnWeekend : selectedTrainOfferedListWEEKENDS) {
        for (TrainStatus rt : selectedTrainOfferedOnWeekend.getRunningTrains()) {
            if (weekendData.containsKey(rt.getTrainSchedule().getTimeSlot())) {
                Integer previousValue = weekendData.get(rt.getTrainSchedule().getTimeSlot());
                weekendData.put(rt.getTrainSchedule().getTimeSlot(), previousValue + rt.getRunningCapacity());
            } else {
                weekendData.put(rt.getTrainSchedule().getTimeSlot(), rt.getRunningCapacity());
            }
        }
    }

    ArrayList<Integer> sortedWeekendData = new ArrayList<>();
    if (weekendData.size() > 0) {
        for (TimeSlot.TimeSlotRange tsr : TimeSlot.TimeSlotRange.values()) {
            sortedWeekendData.add(weekendData.get(tsr));
        }
    }

    Map<TimeSlot.TimeSlotRange, Integer> weekdayData = new HashMap<>();

    for (TrainOffered selectedTrainOfferedOnWeekDays : selectedTrainOfferedListWEEKDAYS) {
        for (TrainStatus rt : selectedTrainOfferedOnWeekDays.getRunningTrains()) {
            if (weekdayData.containsKey(rt.getTrainSchedule().getTimeSlot())) {
                Integer previousValue = weekdayData.get(rt.getTrainSchedule().getTimeSlot());
                weekdayData.put(rt.getTrainSchedule().getTimeSlot(), previousValue + rt.getRunningCapacity());
            } else {
                weekdayData.put(rt.getTrainSchedule().getTimeSlot(), rt.getRunningCapacity());
            }
        }
    }

    ArrayList<Integer> sortedWeekDayDataList = new ArrayList<>();
    if (weekdayData.size() > 0) {
        for (TimeSlot.TimeSlotRange tsr : TimeSlot.TimeSlotRange.values()) {
            sortedWeekDayDataList.add(weekdayData.get(tsr));
        }
    }

    CategoryDataset dataset;
    String series1 = "Weekdays";
    String series2 = "Weekends";
    String series3 = "Maximum Capcity";

    DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();

    for (int i = 0; i < sortedWeekendData.size(); i++) {
        dataset1.addValue(Math.round(sortedWeekendData.get(i) / selectedTrainOfferedListWEEKENDS.size()),
                series2, TimeSlot.TimeSlotRange.values()[i].getValue());
    }

    for (int i = 0; i < sortedWeekDayDataList.size(); i++) {
        // System.out.println("Key = " + entry.getKey().getValue() + ", Value = " + Math.round(entry.getValue()/selectedTrainOfferedListWEEKENDS.size()));
        dataset1.addValue(Math.round(sortedWeekDayDataList.get(i) / selectedTrainOfferedListWEEKDAYS.size()),
                series1, TimeSlot.TimeSlotRange.values()[i].getValue());
    }

    for (int i = 0; i < 15; i++) {
        // System.out.println("Key = " + entry.getKey().getValue() + ", Value = " + Math.round(entry.getValue()/selectedTrainOfferedListWEEKENDS.size()));
        dataset1.addValue(selectedTrain.getTrainCapacity(), series3,
                TimeSlot.TimeSlotRange.values()[i].getValue());
    }

    dataset = dataset1;

    final JFreeChart chart = ChartFactory.createLineChart(
            "Average Congestion of Train : " + selectedTrain.getTrainName(), // chart title
            "Time Slot", // domain axis label
            "Congestion Level", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

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

    ChartFrame chartPanel = new ChartFrame("Line Chart of Train", chart);
    chartPanel.setSize(this.getWidth(), this.getHeight() + 200);
    chartPanel.setVisible(true);

}

From source file:userInteface.Patient.ManageVitalSignsJPanel.java

private void createChart() {
    DefaultCategoryDataset vitalSignDataset = new DefaultCategoryDataset();
    int selectedRow = viewPatientsJTable.getSelectedRow();
    Person person = (Person) viewPatientsJTable.getValueAt(selectedRow, 0);
    Patient patient = person.getPatient();
    if (patient == null) {
        JOptionPane.showMessageDialog(this, "Patient not created, Please create Patient first.", "Error",
                JOptionPane.ERROR_MESSAGE);
        return;//from w  ww  .j av  a 2s.  c o  m
    }

    ArrayList<VitalSign> vitalSignList = patient.getVitalSignHistory().getHistory();
    /*At least 2 vital sign records needed to show chart */
    if (vitalSignList.isEmpty() || vitalSignList.size() == 1) {
        JOptionPane.showMessageDialog(this,
                "No vital signs or only one vital sign found. At least 2 vital sign records needed to show chart!",
                "Warning", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    for (VitalSign vitalSign : vitalSignList) {
        vitalSignDataset.addValue(vitalSign.getRespiratoryRate(), "RR", vitalSign.getTimestamp());
        vitalSignDataset.addValue(vitalSign.getHeartRate(), "HR", vitalSign.getTimestamp());
        vitalSignDataset.addValue(vitalSign.getBloodPressure(), "BP", vitalSign.getTimestamp());
        vitalSignDataset.addValue(vitalSign.getWeight(), "WT", vitalSign.getTimestamp());
    }

    JFreeChart vitalSignChart = ChartFactory.createBarChart3D("Vital Sign Chart", "Time Stamp", "Rate",
            vitalSignDataset, PlotOrientation.VERTICAL, true, false, false);
    vitalSignChart.setBackgroundPaint(Color.white);
    CategoryPlot vitalSignChartPlot = vitalSignChart.getCategoryPlot();
    vitalSignChartPlot.setBackgroundPaint(Color.lightGray);

    CategoryAxis vitalSignDomainAxis = vitalSignChartPlot.getDomainAxis();
    vitalSignDomainAxis
            .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    NumberAxis vitalSignRangeAxis = (NumberAxis) vitalSignChartPlot.getRangeAxis();
    vitalSignRangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    ChartFrame chartFrame = new ChartFrame("Chart", vitalSignChart);
    chartFrame.setVisible(true);
    chartFrame.setSize(500, 500);

}

From source file:view.ResultsPanel.java

public void showHistogram(List<ElementaryMode> modes) {

    //for the JTable
    DefaultTableModel tableModel = new DefaultTableModel();
    JTable tableResult = new JTable();
    tableResult.setModel(tableModel);/*  ww  w  . j a  v  a2 s  .c  om*/

    tableModel.addColumn("Reaction");
    tableModel.addColumn("Presence in the modes");

    tableResult.setAutoCreateRowSorter(true);

    Map<Reaction, Double> stats = new HashMap<Reaction, Double>();

    DecimalFormat df = new DecimalFormat("0.00");

    for (ElementaryMode em : modes) {
        for (Reaction r : em.getContent().keySet()) {
            if (em.getContent().containsKey(r)) {
                if (!stats.containsKey(r)) {
                    stats.put(r, 1.0);
                } else {
                    Reaction key = r;
                    Double value = stats.get(r) + 1;
                    stats.remove(key);
                    stats.put(key, value);
                }
            }
        }
    }

    for (Reaction r : stats.keySet()) {
        tableModel
                .addRow(new Object[] { r, String.valueOf(df.format(stats.get(r) * 100 / modes.size())) + "%" });
    }

    JFrame statisticFrame = new JFrame();
    statisticFrame.add(new JScrollPane(tableResult), BorderLayout.CENTER);
    statisticFrame.setVisible(true);
    statisticFrame.setSize(400, 350);
    statisticFrame.setTitle("Representativeness of each reaction");
    statisticFrame.setLocation(500, 600);

    //histogram
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    Map<Integer, Integer> data = new TreeMap<Integer, Integer>();
    int maxSize = 0;
    for (ElementaryMode em : modes) {
        int modeLength = em.getContent().size();
        if (modeLength > maxSize) {
            maxSize = modeLength;
        }
        if (data.containsKey(modeLength)) {
            int value = data.get(modeLength) + 1;
            data.put(modeLength, value);
        } else {
            data.put(modeLength, 1);
        }
    }

    for (int i = 1; i < maxSize; i++) {
        if (!data.containsKey(i)) {
            data.put(i, 0);
        }
    }
    for (int key : data.keySet()) {
        dataset.addValue(Integer.valueOf((data.get(key))), "test", Integer.valueOf(key));
    }

    String plotTitle = "Number of reactions per elementary mode";
    String xaxis = "Reaction number";
    String yaxis = "Elementary mode number";
    PlotOrientation orientation = PlotOrientation.VERTICAL;
    boolean show = false;
    boolean toolTips = false;
    boolean urls = false;
    JFreeChart chart = ChartFactory.createBarChart3D(plotTitle, xaxis, yaxis, dataset, orientation, show,
            toolTips, urls);

    CategoryPlot plot = chart.getCategoryPlot();
    CategoryAxis axis = plot.getDomainAxis();

    plot.getDomainAxis(0).setLabelFont(plot.getDomainAxis().getLabelFont().deriveFont(new Float(11)));

    ChartFrame frame = new ChartFrame("Elementary modes", chart);
    frame.setVisible(true);
    frame.setSize(400, 350);
    frame.setLocation(500, 100);

}