List of usage examples for org.jfree.chart ChartFrame ChartFrame
public ChartFrame(String title, JFreeChart chart)
From source file:UserInterface.AdministrativeRole.ReportsJPanel.java
private void appEasyReportBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_appEasyReportBtnActionPerformed // TODO add your handling code here: int countEasy = 0; int countSomewhat = 0; int countVery = 0; for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) { if (organization instanceof AdminOrganization) { for (FarmerFeedbackWorkRequest request : organization.getFeedbackWorkQueue() .getFarmerFeedbackList()) { if (request.getSiteUserFriendly().equalsIgnoreCase("Easy To Use")) { countEasy++;//ww w .j a v a 2s.c om } else if (request.getSiteUserFriendly().equalsIgnoreCase("Somewhat Difficult")) { countSomewhat++; } else if (request.getSiteUserFriendly().equalsIgnoreCase("Very Difficult")) { countVery++; } } break; } } float total = countEasy + countSomewhat + countVery; float pEasy = (countEasy / total) * 100; float pSomewhat = (countSomewhat / total) * 100; float pVery = (countVery / total) * 100; DefaultPieDataset pieDataSet = new DefaultPieDataset(); pieDataSet.setValue("Easy To Use%: " + pEasy, pEasy); pieDataSet.setValue("Somewhat Difficult%: " + pSomewhat, pSomewhat); pieDataSet.setValue("Very Difficult%: " + pVery, pVery); JFreeChart chart = ChartFactory.createPieChart("Application Easiness Level", pieDataSet, true, true, true); PiePlot plot = (PiePlot) chart.getPlot(); ChartFrame frame = new ChartFrame("Application Easiness Level", chart); frame.setVisible(true); frame.setSize(500, 500); }
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; }/*from w w w. j a v a 2s.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; } /*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:view.ResultsPanel.java
public void showHistogram(List<ElementaryMode> modes) { //for the JTable DefaultTableModel tableModel = new DefaultTableModel(); JTable tableResult = new JTable(); tableResult.setModel(tableModel);//w ww . j a va2s . c o m 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); }
From source file:statisticslabro.StatisticsLabr.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed List<String> Temp = new ArrayList<String>(); List<String> check = new ArrayList<String>(); List<Double> fnl = new ArrayList<>(); List<String> frame = new ArrayList<String>(); List<String> name = new ArrayList<String>(); List<String> name2 = new ArrayList<String>(); List<Double> frame2 = new ArrayList<Double>(); List<Double> limitLeft = new ArrayList<>(); List<Double> limitRight = new ArrayList<>(); List<Double> trueLimitLeft = new ArrayList<>(); List<Double> trueLimitRight = new ArrayList<>(); List<Double> midpoint = new ArrayList<>(); List<Integer> frequency = new ArrayList<>(); List<Double> percent = new ArrayList<>(); List<Integer> cf = new ArrayList<>(); List<Double> cp = new ArrayList<>(); Integer freq = 0;//from w w w . ja v a2 s . c om Double freqtot = 0.0; if (Categorical.isSelected() == true && Numerical.isSelected() == false) { for (int i = 0; i < jTable1.getRowCount(); i++) { frame.add((String) jTable1.getModel().getValueAt(i, 0)); } Collections.sort(frame); Integer size = frame.size(); System.out.println(size); for (Object b : frame) { String c = b + ""; Temp.add(c); } for (int i = 0; i < jTable1.getRowCount(); i++) { for (int j = 0; j < jTable1.getColumnCount(); j++) { jTable1.setValueAt("", i, j); } } int ct = 0; for (Object z : frame) { String a = z + ""; System.out.print(check.contains(a)); if (!(check.contains(a))) { for (int i = 0; i < Temp.size(); i++) { if (a.equals(Temp.get(i))) { freq++; } } Double freque = (((freq + .0) / size) * 100); fnl.add(freque); name.add(a); freqtot += freque; jTable1.getModel().setValueAt(a, ct, 0); jTable1.getModel().setValueAt(String.format("%1.1f", freque) + "%", ct, 1); ct++; freq = 0; check.add(a); } total.setText("Total :" + String.format("%1.1f", freqtot)); } if (Chart.isSelected() == true) { DefaultPieDataset chart = new DefaultPieDataset(); int h = 0; for (Double z : fnl) { chart.setValue(name.get(h) + "", new Double(z)); h++; } JFreeChart mychart = ChartFactory.createPieChart3D(Desc.getText() + "", chart, true, true, true); PiePlot3D p = (PiePlot3D) mychart.getPlot(); ChartFrame charteuFrame = new ChartFrame(Desc.getText(), mychart); charteuFrame.setVisible(true); charteuFrame.setSize(450, 500); } } else if (Numerical.isSelected() == true && Categorical.isSelected() == false) { double subtrahend = 0.5; for (int i = 0; i < jTable1.getRowCount();) { double d = Double.parseDouble((String) jTable1.getModel().getValueAt(i, 0)); frame2.add(d); i++; } double max = 0; double min = frame2.get(0); for (int j = 0; j < frame2.size(); j++) { System.out.print("Sulod"); if (max < frame2.get(j)) { max = frame2.get(j); } if (min > frame2.get(j)) { min = frame2.get(j); } } System.out.print(frame2); double range = max - min; double k = Math.ceil(1 + 3.322 * Math.log10(frame2.size())); int width = (int) Math.ceil(range / k); System.out.println("char: " + max + " " + min + " " + range + " " + k + " width: " + width); double limit = min; while (limit < max) { limitLeft.add(limit); limit += width; } for (int j = 0; j < limitLeft.size(); j++) { System.out.print(limitLeft.get(j) + " "); } double limit2 = min + width - 1; while (limit2 <= max) { limitRight.add(limit2); limit2 += width; } if (limitRight.get(limitRight.size() - 1) != max) { limitRight.add(max); } System.out.println(); for (int j = 0; j < limitRight.size(); j++) { System.out.print(limitRight.get(j) + " "); } //true limit if (((String) choice.getSelectedItem()).equals("Integer")) { for (int j = 0; j < limitLeft.size(); j++) { trueLimitLeft.add(limitLeft.get(j) - 0.5); } System.out.println(); for (int j = 0; j < trueLimitLeft.size(); j++) { System.out.print(trueLimitLeft.get(j) + " "); } for (int j = 0; j < limitRight.size(); j++) { trueLimitRight.add(limitRight.get(j) + 0.5); } System.out.println(); for (int j = 0; j < trueLimitRight.size(); j++) { System.out.print(trueLimitRight.get(j) + " "); } } else if (((String) choice.getSelectedItem()).equals("Floating")) { int count1 = 0; float diff = 0; boolean flag = false; for (int j = 0; j < frame2.size(); j++) { double value = Math.floor(frame2.get(j)); System.out.println(frame.get(j)); diff = (float) (frame2.get(j) - value); System.out.println("diff: " + diff); String counts = String.valueOf(diff); if (diff > 0.0) { if (counts.length() - 1 > count1) { count1 = counts.length() - 1; System.out.println(count1); } } } System.out.println(count1); for (int j = 0; j < count1 - 1; j++) { subtrahend /= 10; System.out.println(subtrahend); } System.out.println("sub: " + subtrahend); for (int j = 0; j < limitLeft.size(); j++) { trueLimitLeft.add(limitLeft.get(j) - subtrahend); } for (int j = 0; j < limitRight.size(); j++) { trueLimitRight.add(limitRight.get(j) + subtrahend); } } //midpoint for (int j = 0; j < limitLeft.size(); j++) { midpoint.add((limitLeft.get(j) + limitRight.get(j)) / 2); } System.out.println(); for (int j = 0; j < midpoint.size(); j++) { System.out.print(midpoint.get(j) + " "); } //frequency for (int j = 0; j < limitLeft.size(); j++) { int count = 0; for (int m = 0; m < frame2.size(); m++) { if (frame2.get(m) >= limitLeft.get(j) && frame2.get(m) <= limitRight.get(j)) { count++; } } frequency.add(count); } System.out.println(); for (int j = 0; j < frequency.size(); j++) { System.out.print(frequency.get(j) + " "); } //percent for (int j = 0; j < frequency.size(); j++) { double pp = (((double) frequency.get(j) / frame2.size()) * 100); percent.add(pp); } System.out.println(); for (int j = 0; j < percent.size(); j++) { System.out.print(percent.get(j) + " "); } int cff = 0; for (int j = 0; j < frequency.size(); j++) { cff += frequency.get(j); cf.add(cff); } System.out.println(); for (int j = 0; j < cf.size(); j++) { System.out.print(cf.get(j) + " "); } double cpp = 0; for (int j = 0; j < percent.size(); j++) { cpp += percent.get(j); cp.add(cpp); } System.out.println(); for (int j = 0; j < cp.size(); j++) { System.out.print(cp.get(j) + " "); } DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel(); dtm.setRowCount(limitLeft.size()); int ct = 0; if (collapse.isSelected() == true) { for (int j = 0; j < limitLeft.size(); j++) { if (ct == 0) { jTable1.getModel().setValueAt("< " + limitRight.get(j), ct, 1); jTable1.getModel().setValueAt("-", ct, 3); name.add("<"); } else if (ct == limitLeft.size() - 1) { jTable1.getModel().setValueAt("> " + limitLeft.get(j), ct, 1); jTable1.getModel().setValueAt("-", ct, 3); name.add(">"); } else { jTable1.getModel().setValueAt(limitLeft.get(j) + "-" + limitRight.get(j), ct, 1); jTable1.getModel().setValueAt(midpoint.get(j), ct, 3); name.add(midpoint.get(j) + ""); } jTable1.getModel().setValueAt(trueLimitLeft.get(j) + "-" + trueLimitRight.get(j), ct, 2); jTable1.getModel().setValueAt(frequency.get(j), ct, 4); jTable1.getModel().setValueAt(percent.get(j), ct, 5); jTable1.getModel().setValueAt(cf.get(j), ct, 6); jTable1.getModel().setValueAt(cp.get(j), ct, 7); ct++; } } else { for (int j = 0; j < limitLeft.size(); j++) { jTable1.getModel().setValueAt(limitLeft.get(j) + "-" + limitRight.get(j), ct, 1); jTable1.getModel().setValueAt(trueLimitLeft.get(j) + "-" + trueLimitRight.get(j), ct, 2); jTable1.getModel().setValueAt(midpoint.get(j), ct, 3); name.add(midpoint.get(j) + ""); jTable1.getModel().setValueAt(frequency.get(j), ct, 4); jTable1.getModel().setValueAt(percent.get(j), ct, 5); jTable1.getModel().setValueAt(cf.get(j), ct, 6); jTable1.getModel().setValueAt(cp.get(j), ct, 7); ct++; } } } if (Chart.isSelected() == true) { DefaultCategoryDataset chart = new DefaultCategoryDataset(); int h = 0; for (Integer z : frequency) { chart.setValue(z, "Frequency", name.get(h)); h++; } JFreeChart mychart = ChartFactory.createBarChart(Desc.getText() + "", "Midpoint", "Frequency", chart, PlotOrientation.VERTICAL, true, false, false); CategoryPlot p = (CategoryPlot) mychart.getPlot(); p.setDomainGridlinesVisible(true); p.getDomainAxis().setCategoryMargin(0.0); ChartFrame charteuFrame = new ChartFrame(Desc.getText(), mychart); charteuFrame.setVisible(true); charteuFrame.setSize(450, 500); } }
From source file:Graficas.java
public void opera() { String sql = "select nombre,turno,grado,materia,Resultado,Criterios,anio, avg(Resultado) promedio,sum(Resultado) suma\n" + "from nivellogro n,turno t, escuela e, materias m, grados g\n" + "where n.idMaterias = m.idMaterias and n.idEscuela = e.idEscuela and n.idTurno = t.idTurno and n.idGrados = g.idGrados\n" + "group by nombre ORDER BY rand() LIMIT 0,20;"; int cont = 0; try {/*from ww w . j a v a 2 s . co m*/ Connection con = conexionMySQL.GetConnection(); DefaultPieDataset data = new DefaultPieDataset(); // Statement st = con.createStatement(); PreparedStatement ps = con.prepareStatement(sql); ResultSet rs = ps.executeQuery(); while (rs.next()) { if (cont <= 10) { data.setValue(rs.getString("nombre"), rs.getDouble("promedio")); cont++; } } JFreeChart chart = ChartFactory.createPieChart("Aprovechamiento por escuelas", data, true, true, false); ChartFrame frame = new ChartFrame("JFreeChart", chart); frame.pack(); frame.setVisible(true); } catch (SQLException ex) { Logger.getLogger(Graficas.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:UserInterface.AdministrativeRole.ReportsJPanel.java
private void ApplicationUsageBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ApplicationUsageBtnActionPerformed // TODO add your handling code here: int countResearch = 0; int countSale = 0; int countBoth = 0; for (Organization org : enterprise.getOrganizationDirectory().getOrganizationList()) { for (UserAccount userAccount : org.getUserAccountDirectory().getUserAccountList()) { if (userAccount.getFarmer() != null) { if (userAccount.getWorkQueue().getWorkRequestList().size() > 0 && userAccount.getMarketWorkQueue().getMarkerWorkRequestList().isEmpty()) { countResearch++;/* w w w . ja v a 2s. co m*/ } else if (userAccount.getWorkQueue().getWorkRequestList().isEmpty() && userAccount.getMarketWorkQueue().getMarkerWorkRequestList().size() > 0) { countSale++; } else if (userAccount.getWorkQueue().getWorkRequestList().size() > 0 && userAccount.getMarketWorkQueue().getMarkerWorkRequestList().size() > 0) { countBoth++; } } } } float total = countResearch + countSale + countBoth; float pResearch = (countResearch / total) * 100; float pSale = (countSale / total) * 100; float pBoth = (countBoth / total) * 100; DefaultPieDataset pieDataSet = new DefaultPieDataset(); pieDataSet.setValue("Farmers Using Soil Research Facility: " + pResearch + "%", pResearch); pieDataSet.setValue("Farmers Using Sale Facility: " + pSale + "%", pSale); pieDataSet.setValue("Farmers Using Both Facility " + pBoth + "%", pBoth); JFreeChart chart = ChartFactory.createPieChart("Application Usage Study", pieDataSet, true, true, true); PiePlot plot = (PiePlot) chart.getPlot(); ChartFrame frame = new ChartFrame("Application Usage Study", chart); frame.setVisible(true); frame.setSize(500, 500); }
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 w w .j av a 2 s . c o m } 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:Interface.ApplicationAdmin.Analytics.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed int x = Integer.parseInt(MaxCaruserride.getText()); int y = Integer.parseInt(MinCarUserride.getText()); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(x, "Max Car ride", "Rides"); dataset.setValue(y, "Min Car ride", "Rides"); JFreeChart chart = ChartFactory.createBarChart("Car owner Min - Max ride chart", "Car ride", "Number of rides", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.black); ChartFrame frame = new ChartFrame("Ride chart ", chart); frame.setVisible(true);//from w w w .j a v a 2 s.c o m frame.setSize(450, 350); frame.setLocation(400, 150); }
From source file:statisticsintegration.StatisticsLabr.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed List<String> Temp = new ArrayList<String>(); List<String> check = new ArrayList<String>(); List<Double> fnl = new ArrayList<>(); List<String> frame = new ArrayList<String>(); List<String> name = new ArrayList<String>(); List<String> name2 = new ArrayList<String>(); List<Double> frame2 = new ArrayList<Double>(); List<Double> limitLeft = new ArrayList<>(); List<Double> limitRight = new ArrayList<>(); List<Double> trueLimitLeft = new ArrayList<>(); List<Double> trueLimitRight = new ArrayList<>(); List<Double> midpoint = new ArrayList<>(); List<Integer> frequency = new ArrayList<>(); List<Double> percent = new ArrayList<>(); List<Integer> cf = new ArrayList<>(); List<Double> cp = new ArrayList<>(); Integer freq = 0;/* w ww . j a v a 2s . c o m*/ Double freqtot = 0.0; if (Categorical.isSelected() == true && Numerical.isSelected() == false) { for (int i = 0; i < jTable1.getRowCount(); i++) { frame.add((String) jTable1.getModel().getValueAt(i, 0)); } Collections.sort(frame); Integer size = frame.size(); System.out.println(size); for (Object b : frame) { String c = b + ""; Temp.add(c); } for (int i = 0; i < jTable1.getRowCount(); i++) { for (int j = 0; j < jTable1.getColumnCount(); j++) { jTable1.setValueAt("", i, j); } } int ct = 0; for (Object z : frame) { String a = z + ""; System.out.print(check.contains(a)); if (!(check.contains(a))) { for (int i = 0; i < Temp.size(); i++) { if (a.equals(Temp.get(i))) { freq++; } } Double freque = (((freq + .0) / size) * 100); fnl.add(freque); name.add(a); freqtot += freque; jTable1.getModel().setValueAt(a, ct, 0); jTable1.getModel().setValueAt(String.format("%1.1f", freque) + "%", ct, 1); ct++; freq = 0; check.add(a); } total.setText("Total :" + String.format("%1.1f", freqtot)); } if (Chart.isSelected() == true) { DefaultPieDataset chart = new DefaultPieDataset(); int h = 0; for (Double z : fnl) { chart.setValue(name.get(h) + "", new Double(z)); h++; } JFreeChart mychart = ChartFactory.createPieChart3D(Desc.getText() + "", chart, true, true, true); PiePlot3D p = (PiePlot3D) mychart.getPlot(); ChartFrame charteuFrame = new ChartFrame(Desc.getText(), mychart); charteuFrame.setVisible(true); charteuFrame.setSize(450, 500); } } else if (Numerical.isSelected() == true && Categorical.isSelected() == false) { double subtrahend = 0.5; for (int i = 0; i < jTable1.getRowCount();) { double d = Double.parseDouble((String) jTable1.getModel().getValueAt(i, 0)); frame2.add(d); i++; } double max = 0; double min = frame2.get(0); for (int j = 0; j < frame2.size(); j++) { System.out.print("Sulod"); if (max < frame2.get(j)) { max = frame2.get(j); } if (min > frame2.get(j)) { min = frame2.get(j); } } System.out.print(frame2); double range = max - min; double k = Math.ceil(1 + 3.322 * Math.log10(frame2.size())); int width = (int) Math.ceil(range / k); System.out.println("char: " + max + " " + min + " " + range + " " + k + " width: " + width); double limit = min; while (limit < max) { limitLeft.add(limit); limit += width; } for (int j = 0; j < limitLeft.size(); j++) { System.out.print(limitLeft.get(j) + " "); } double limit2 = min + width - 1; while (limit2 <= max) { limitRight.add(limit2); limit2 += width; } if (limitRight.get(limitRight.size() - 1) != max) { limitRight.add(max); } System.out.println(); for (int j = 0; j < limitRight.size(); j++) { System.out.print(limitRight.get(j) + " "); } //true limit if (((String) choice.getSelectedItem()).equals("Integer")) { for (int j = 0; j < limitLeft.size(); j++) { trueLimitLeft.add(limitLeft.get(j) - 0.5); } System.out.println(); for (int j = 0; j < trueLimitLeft.size(); j++) { System.out.print(trueLimitLeft.get(j) + " "); } for (int j = 0; j < limitRight.size(); j++) { trueLimitRight.add(limitRight.get(j) + 0.5); } System.out.println(); for (int j = 0; j < trueLimitRight.size(); j++) { System.out.print(trueLimitRight.get(j) + " "); } } else if (((String) choice.getSelectedItem()).equals("Floating")) { int count1 = 0; float diff = 0; boolean flag = false; for (int j = 0; j < frame2.size(); j++) { double value = Math.floor(frame2.get(j)); // System.out.println(frame.get(j)); diff = (float) (frame2.get(j) - value); System.out.println("diff: " + diff); String counts = String.valueOf(diff); if (diff > 0.0) { if (counts.length() - 1 > count1) { count1 = counts.length() - 1; System.out.println(count1); } } } System.out.println(count1); for (int j = 0; j < count1 - 1; j++) { subtrahend /= 10; System.out.println(subtrahend); } System.out.println("sub: " + subtrahend); for (int j = 0; j < limitLeft.size(); j++) { trueLimitLeft.add(limitLeft.get(j) - subtrahend); } for (int j = 0; j < limitRight.size(); j++) { trueLimitRight.add(limitRight.get(j) + subtrahend); } } //midpoint for (int j = 0; j < limitLeft.size(); j++) { midpoint.add((limitLeft.get(j) + limitRight.get(j)) / 2); } System.out.println(); for (int j = 0; j < midpoint.size(); j++) { System.out.print(midpoint.get(j) + " "); } //frequency for (int j = 0; j < limitLeft.size(); j++) { int count = 0; for (int m = 0; m < frame2.size(); m++) { if (frame2.get(m) >= limitLeft.get(j) && frame2.get(m) <= limitRight.get(j)) { count++; } } frequency.add(count); } System.out.println(); for (int j = 0; j < frequency.size(); j++) { System.out.print(frequency.get(j) + " "); } //percent for (int j = 0; j < frequency.size(); j++) { double pp = (((double) frequency.get(j) / frame2.size()) * 100); percent.add(pp); } System.out.println(); for (int j = 0; j < percent.size(); j++) { System.out.print(percent.get(j) + " "); } int cff = 0; for (int j = 0; j < frequency.size(); j++) { cff += frequency.get(j); cf.add(cff); } System.out.println(); for (int j = 0; j < cf.size(); j++) { System.out.print(cf.get(j) + " "); } double cpp = 0; for (int j = 0; j < percent.size(); j++) { cpp += percent.get(j); cp.add(cpp); } System.out.println(); for (int j = 0; j < cp.size(); j++) { System.out.print(cp.get(j) + " "); } DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel(); dtm.setRowCount(limitLeft.size()); int ct = 0; if (collapse.isSelected() == true) { for (int j = 0; j < limitLeft.size(); j++) { if (ct == 0) { jTable1.getModel().setValueAt("< " + limitRight.get(j), ct, 1); jTable1.getModel().setValueAt("-", ct, 3); name.add("<"); } else if (ct == limitLeft.size() - 1) { jTable1.getModel().setValueAt("> " + limitLeft.get(j), ct, 1); jTable1.getModel().setValueAt("-", ct, 3); name.add(">"); } else { jTable1.getModel().setValueAt(limitLeft.get(j) + "-" + limitRight.get(j), ct, 1); jTable1.getModel().setValueAt(midpoint.get(j), ct, 3); name.add(midpoint.get(j) + ""); } jTable1.getModel().setValueAt(trueLimitLeft.get(j) + "-" + trueLimitRight.get(j), ct, 2); jTable1.getModel().setValueAt(frequency.get(j), ct, 4); jTable1.getModel().setValueAt(percent.get(j), ct, 5); jTable1.getModel().setValueAt(cf.get(j), ct, 6); jTable1.getModel().setValueAt(cp.get(j), ct, 7); ct++; } } else { for (int j = 0; j < limitLeft.size(); j++) { jTable1.getModel().setValueAt(limitLeft.get(j) + "-" + limitRight.get(j), ct, 1); jTable1.getModel().setValueAt(trueLimitLeft.get(j) + "-" + trueLimitRight.get(j), ct, 2); jTable1.getModel().setValueAt(midpoint.get(j), ct, 3); name.add(midpoint.get(j) + ""); jTable1.getModel().setValueAt(frequency.get(j), ct, 4); jTable1.getModel().setValueAt(percent.get(j), ct, 5); jTable1.getModel().setValueAt(cf.get(j), ct, 6); jTable1.getModel().setValueAt(cp.get(j), ct, 7); ct++; } } if (Chart.isSelected() == true) { DefaultCategoryDataset chart = new DefaultCategoryDataset(); int h = 0; for (Integer z : frequency) { chart.setValue(z, "Frequency", name.get(h)); h++; } JFreeChart mychart = ChartFactory.createBarChart(Desc.getText() + "", "Midpoint", "Frequency", chart, PlotOrientation.VERTICAL, true, false, false); CategoryPlot p = (CategoryPlot) mychart.getPlot(); p.setDomainGridlinesVisible(true); p.getDomainAxis().setCategoryMargin(0.0); ChartFrame charteuFrame = new ChartFrame(Desc.getText(), mychart); charteuFrame.setVisible(true); charteuFrame.setSize(450, 500); } } }
From source file:Interface.ApplicationAdmin.Analytics.java
private void caruserdatajButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_caruserdatajButtonActionPerformed int x = Integer.parseInt(MaxcarownerridejLabel.getText()); int y = Integer.parseInt(MincarownerridejLabel.getText()); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(x, "Max Car ride", "Rides"); dataset.setValue(y, "Min Car ride", "Rides"); JFreeChart chart = ChartFactory.createBarChart("User Min - Max ride chart", "Car ride", "Number of rides", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.black); ChartFrame frame = new ChartFrame("User Ride chart ", chart); frame.setVisible(true);/*from w w w . ja v a 2 s. c o m*/ frame.setSize(450, 350); frame.setLocation(400, 150); }