List of usage examples for org.jfree.chart ChartFrame ChartFrame
public ChartFrame(String title, JFreeChart chart)
From source file:Interface.FoodDistributionWorkArea.FoodDistributionWorkArea.java
private void btnCalculateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCalculateActionPerformed // TODO add your handling code here: Date toDate1 = jDateChooser1.getDate(); Date toDate2 = jDateChooser2.getDate(); if ((toDate1 == null) || (toDate2 == null)) { JOptionPane.showMessageDialog(null, "Invalid date..Kindly enter valid date."); return;// ww w.j a v a2 s .c om } long fromDate = (jDateChooser1.getDate().getTime()) / (1000 * 60 * 60 * 24); long toDate = (jDateChooser2.getDate().getTime()) / (1000 * 60 * 60 * 24); int noOfBeneficiaryCanned = 1; int noOfBeneficiaryPurchased = 1; int noOfBeneficiaryHome = 1; //int i = 0; for (WorkRequest request : organization.getWorkQueue().getWorkRequestList()) { long requestDate = (request.getRequestDate().getTime()) / (1000 * 60 * 60 * 24); if ((requestDate >= fromDate) && (requestDate <= toDate)) { if (((FoodDistributionWorkRequest) request).getFood().getFoodType() .equalsIgnoreCase("Canned Food")) { noOfBeneficiaryCanned += (int) ((FoodDistributionWorkRequest) request).getFood() .getNumberOfBenificary(); } else if (((FoodDistributionWorkRequest) request).getFood().getFoodType() .equalsIgnoreCase("Purchased food")) { noOfBeneficiaryPurchased += (int) ((FoodDistributionWorkRequest) request).getFood() .getNumberOfBenificary(); } else if (((FoodDistributionWorkRequest) request).getFood().getFoodType() .equalsIgnoreCase("Home made food")) { noOfBeneficiaryHome += (int) ((FoodDistributionWorkRequest) request).getFood() .getNumberOfBenificary(); } else { JOptionPane.showMessageDialog(null, "There are no records for this search criteria."); } } } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(noOfBeneficiaryCanned, "Number of food collected", "Canned Food"); dataset.setValue(noOfBeneficiaryPurchased, "Number of food collected", "Purchased Food"); dataset.setValue(noOfBeneficiaryHome, "Number of food collected", "Home madde Food"); JFreeChart chart = ChartFactory.createBarChart("Number of beneficiary", "Types of food donated to bebeficiary", "Number of food collected", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeGridlinePaint(Color.BLUE); ChartFrame frame = new ChartFrame("Bar Chart for Number of beneficiary", chart); frame.setVisible(true); frame.setSize(1000, 600); }
From source file:ui.Interface.java
private void butChartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butChartActionPerformed try {//from ww w.j av a 2s . co m if (txtNumbersAll.getText().equals("")) { JOptionPane.showMessageDialog(this, "Please fill out the Empty fields!", "Sorting Algo Simulator v2.0", javax.swing.JOptionPane.ERROR_MESSAGE); return; } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(InsertInstructionCount, "InsertionSort", "InsertionSort"); dataset.setValue(SelectInstructionCount, "SelectionSort", "SelectionSort"); JFreeChart chart = ChartFactory.createBarChart("Instruction Count", "Instruction Count", "Unique Counts", dataset, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.white); chart.getTitle().setPaint(Color.blue); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.red); ChartFrame frame1 = new ChartFrame("Insertion Sort Vs Selection Sort - Performance Analyze", chart); Dimension screenSize = new Dimension(Toolkit.getDefaultToolkit().getScreenSize()); Dimension windowSize = new Dimension(getPreferredSize()); int wdwLeft2 = screenSize.width / 2 - windowSize.width / 2 - 200; int wdwTop2 = screenSize.height / 2 - windowSize.height / 2; frame1.setLocation(wdwLeft2, wdwTop2); frame1.pack(); frame1.setSize(400, 350); frame1.setVisible(true); DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(InsertTimeDiff, "InsertionSort", "InsertionSort"); dataset2.setValue(SelectTimeDiff, "SelectionSort", "SelectionSort"); JFreeChart chart2 = ChartFactory.createBarChart("Time Complexity* (can be vary)", "Time Complexity", "Nano Seconds", dataset2, PlotOrientation.VERTICAL, false, true, false); chart2.setBackgroundPaint(Color.white); chart2.getTitle().setPaint(Color.blue); CategoryPlot p2 = chart2.getCategoryPlot(); p2.setRangeGridlinePaint(Color.red); ChartFrame frame2 = new ChartFrame("Insertion Sort Vs Selection Sort - Performance Analyze", chart2); int wdwLeft = 50 + screenSize.width / 2 - windowSize.width / 2 + 200; int wdwTop = screenSize.height / 2 - windowSize.height / 2; frame2.setLocation(wdwLeft, wdwTop); frame2.pack(); frame2.setVisible(true); frame2.setSize(400, 350); } catch (Exception e) { e.printStackTrace(); } }
From source file:userinterface.PatientRole.PatientWorkAreaJPanel.java
private void btnViewPieChartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewPieChartActionPerformed if (patient.vitalSignHistory.getVitalSignHistory().size() > 0) { int selectedRow = tblVS.getSelectedRow(); if (selectedRow >= 0) { VitalSign vs = (VitalSign) tblVS.getValueAt(selectedRow, 0); DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue("Respiratory Rate", new Float(vs.getRespiratoryRate())); pieDataset.setValue("Heart Rate", new Float(vs.getHeartRate())); pieDataset.setValue("Blood Pressure", new Float(vs.getSystolicBloodPressure())); pieDataset.setValue("Weight", new Float(vs.getWeight())); JFreeChart chart = ChartFactory.createPieChart("Pie chart", pieDataset, true, true, true); PiePlot P = (PiePlot) chart.getPlot(); ChartFrame frame = new ChartFrame("Pie Charrt", chart); frame.setVisible(true);//from www . j a va 2s.c o m frame.setSize(450, 500); } else { JOptionPane.showMessageDialog(null, "Please select a Vital Sign row to see the Pie Chart!"); } } else { JOptionPane.showMessageDialog(null, "There's no Vital Sign reported for this patient"); return; } }
From source file:UserInterface.ViewPatientJPanel.java
private void btnViewPieChartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewPieChartActionPerformed String weight = txtWeight.getText(); String hrtRate = txtHeartRate.getText(); String bp = txtSystolicBloodPressure.getText(); String respiRate = txtRespiratoryRate.getText(); DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue("Respiratory Rate", new Float(respiRate)); pieDataset.setValue("Heart Rate", new Float(hrtRate)); pieDataset.setValue("Blood Pressure", new Float(bp)); pieDataset.setValue("Weight", new Float(weight)); JFreeChart chart = ChartFactory.createPieChart("Pie chart", pieDataset, true, true, true); PiePlot P = (PiePlot) chart.getPlot(); ChartFrame frame = new ChartFrame("Pie Charrt", chart); frame.setVisible(true);//ww w . ja v a 2s . c om frame.setSize(450, 500); }
From source file:Interface.FoodDistributionWorkArea.FoodDistributionWorkArea.java
private void btnCalculate1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCalculate1ActionPerformed // TODO add your handling code here: Date toDate1 = jDateChooser3.getDate(); Date toDate2 = jDateChooser4.getDate(); if ((toDate1 == null) || (toDate2 == null)) { JOptionPane.showMessageDialog(null, "Invalid date..Kindly enter valid date."); return;/*from w w w . jav a 2s .c om*/ } long fromDate = (jDateChooser3.getDate().getTime()) / (1000 * 60 * 60 * 24); long toDate = (jDateChooser4.getDate().getTime()) / (1000 * 60 * 60 * 24); int priorityFive = 1; int priorityFour = 1; int priorityThree = 1; int priorityTwo = 1; int priorityOne = 1; //int i = 0; for (WorkRequest request : organization.getWorkQueue().getWorkRequestList()) { long requestDate = (request.getRequestDate().getTime()) / (1000 * 60 * 60 * 24); if ((requestDate >= fromDate) && (requestDate <= toDate)) { if (((FoodDistributionWorkRequest) request).getFood().getFoodPriority().equalsIgnoreCase("5")) { priorityFive++; } else if (((FoodDistributionWorkRequest) request).getFood().getFoodPriority() .equalsIgnoreCase("4")) { priorityFour++; } else if (((FoodDistributionWorkRequest) request).getFood().getFoodPriority() .equalsIgnoreCase("3")) { priorityThree++; } else if (((FoodDistributionWorkRequest) request).getFood().getFoodPriority() .equalsIgnoreCase("2")) { priorityTwo++; } else if (((FoodDistributionWorkRequest) request).getFood().getFoodPriority() .equalsIgnoreCase("1")) { priorityOne++; } else { JOptionPane.showMessageDialog(null, "There are no records for this search criteria."); } } else { JOptionPane.showMessageDialog(null, "There are no records for this search criteria."); } } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(priorityFive, "Number of food collected", "Priority 5"); dataset.setValue(priorityFour, "Number of food collected", "Priority 4"); dataset.setValue(priorityThree, "Number of food collected", "Priority 3"); dataset.setValue(priorityTwo, "Number of food collected", "Priority 2"); dataset.setValue(priorityOne, "Number of food collected", "Priority 1"); JFreeChart chart = ChartFactory.createBarChart("Number of beneficiary", "Types of food donated to bebeficiary", "Number of food collected", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeGridlinePaint(Color.BLUE); ChartFrame frame = new ChartFrame("Bar Chart for Number of beneficiary", chart); frame.setVisible(true); frame.setSize(450, 350); }
From source file:UserInterface.ViewPatientJPanel.java
private void btnViewBarsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewBarsActionPerformed String legend = null;/*from w ww .j a v a2s. co m*/ DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (VitalSign vs : patient.vitalSignHistory.getVitalSignHistory()) { if (vs.getState().equalsIgnoreCase("ABNORMAL")) legend = vs.getTimestamp().concat(" (" + vs.getState() + ")"); else legend = vs.getTimestamp(); dataset.addValue(vs.getRespiratoryRate(), legend, "Respiratory Rate"); dataset.addValue(vs.getHeartRate(), legend, "Heart Rate"); dataset.addValue(vs.getSystolicBloodPressure(), legend, "Blood Pressure"); dataset.addValue(vs.getWeight(), legend, "Weight"); } JFreeChart chart = ChartFactory.createBarChart3D("Vital Signs", "Vital Signs", "Values", dataset, PlotOrientation.VERTICAL, true, true, true); CategoryPlot P = chart.getCategoryPlot(); P.setRangeGridlinePaint(Color.BLACK); ChartFrame frame = new ChartFrame("Bar Charts", chart); frame.setVisible(true); frame.setSize(650, 550); }
From source file:whitebox.stats.Kriging.java
/** * Draw Semivariogram surface map and also draw the search are if * Anisotropic//from w w w .j a va 2s . co m * * @param Radius * @param AnIsotropic */ public void DrawSemivariogramSurface(double Radius, boolean AnIsotropic) { double[][] data = new double[3][BinSurface.length * BinSurface[0].length]; int n = 0; double max = Double.MIN_VALUE; for (int i = 0; i < BinSurface.length; i++) { for (int j = 0; j < BinSurface[i].length; j++) { data[0][n] = BinSurface[i][j].GridHorDistance; data[1][n] = BinSurface[i][j].GridVerDistance; if ((Math.pow(data[0][n], 2) + Math.pow(data[1][n], 2)) <= Radius * Radius && !Double.isNaN(BinSurface[i][j].Value)) { data[2][n] = BinSurface[i][j].Value; if (max < data[2][n]) { max = data[2][n]; } } else { data[2][n] = -1; } n++; } } DefaultXYZDataset dataset = new DefaultXYZDataset(); dataset.addSeries("Value", data); NumberAxis xAxis = new NumberAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setLowerMargin(0.0); yAxis.setUpperMargin(0.0); XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setBlockWidth(LagSize); renderer.setBlockHeight(LagSize); renderer.setBlockAnchor(RectangleAnchor.CENTER); LookupPaintScale paintScale = new LookupPaintScale(0, max, Color.white); double colorRange = max / 6; //double colorRange = 23013; paintScale.add(0.0, Color.blue); paintScale.add(1 * colorRange, Color.green); paintScale.add(2 * colorRange, Color.cyan); paintScale.add(3 * colorRange, Color.yellow); paintScale.add(4 * colorRange, Color.ORANGE); paintScale.add(5 * colorRange, Color.red); renderer.setPaintScale(paintScale); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinePaint(Color.white); if (AnIsotropic) { CombinedRangeXYPlot combinedrangexyplot = new CombinedRangeXYPlot(); XYSeries seriesT1 = new XYSeries("1"); XYSeriesCollection AngleCollct = new XYSeriesCollection(); double bw = BandWidth; double r = bw / Math.sin(Tolerance); if (r > Radius) { bw = Radius * Math.sin(Tolerance); r = Radius; } seriesT1.add(r * Math.cos(Angle + Tolerance), r * Math.sin(Angle + Tolerance)); if ((double) Math.round(Math.sin(Angle) * 10000) / 10000 != 0) { if ((double) Math.round(Math.cos(Angle) * 10000) / 10000 != 0) { double a = (1 + Math.pow(Math.tan(Angle), 2)); double b = 2 * bw / Math.sin(Angle) * Math.pow(Math.tan(Angle), 2); double c = Math.pow(Math.tan(Angle), 2) * Math.pow(bw / Math.sin(Angle), 2) - Math.pow(Radius, 2); double x1 = (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); double y1 = Math.tan(Angle) * (x1 + bw / Math.sin(Angle)); double x2 = (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); double y2 = Math.tan(Angle) * (x2 + bw / Math.sin(Angle)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2)) + (Math.pow((Radius * Math.sin(Angle) - y2), 2))); if (d1 < d2) { seriesT1.add(x1, y1); } else { seriesT1.add(x2, y2); } } else { double x1 = -bw * Math.sin(Angle); double y1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2)); double y2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y2), 2))); if (d1 < d2) { seriesT1.add(x1, y1); } else { seriesT1.add(x1, y2); } } } else { double y1 = bw * Math.cos(Angle); double x1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2)); double x2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); if (d1 < d2) { seriesT1.add(x1, y1); } else { seriesT1.add(x2, y1); } } AngleCollct.addSeries(seriesT1); XYSeries seriesT2 = new XYSeries("2"); seriesT2.add(r * Math.cos(Angle + Tolerance), r * Math.sin(Angle + Tolerance)); seriesT2.add(0.0, 0.0); AngleCollct.addSeries(seriesT2); XYSeries seriesT3 = new XYSeries("3"); seriesT3.add(Radius * Math.cos(Angle), Radius * Math.sin(Angle)); seriesT3.add(0, 0); AngleCollct.addSeries(seriesT3); XYSeries seriesT4 = new XYSeries("4"); seriesT4.add(r * Math.cos(Angle - Tolerance), r * Math.sin(Angle - Tolerance)); seriesT4.add(0, 0); AngleCollct.addSeries(seriesT4); XYSeries seriesT5 = new XYSeries("5"); seriesT5.add(r * Math.cos(Angle - Tolerance), r * Math.sin(Angle - Tolerance)); if ((double) Math.round(Math.sin(Angle) * 10000) / 10000 != 0) { if ((double) Math.round(Math.cos(Angle) * 10000) / 10000 != 0) { double a = (1 + Math.pow(Math.tan(Angle), 2)); double b = -2 * bw / Math.sin(Angle) * Math.pow(Math.tan(Angle), 2); double c = Math.pow(Math.tan(Angle), 2) * Math.pow(bw / Math.sin(Angle), 2) - Math.pow(Radius, 2); double x1 = (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); double y1 = Math.tan(Angle) * (x1 - bw / Math.sin(Angle)); double x2 = (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); double y2 = Math.tan(Angle) * (x2 - bw / Math.sin(Angle)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2)) + (Math.pow((Radius * Math.sin(Angle) - y2), 2))); if (d1 < d2) { seriesT5.add(x1, y1); } else { seriesT5.add(x2, y2); } } else { double x1 = bw * Math.sin(Angle); double y1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2)); double y2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y2), 2))); if (d1 < d2) { seriesT5.add(x1, y1); } else { seriesT5.add(x1, y2); } } } else { double y1 = -bw * Math.cos(Angle); double x1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2)); double x2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); if (d1 < d2) { seriesT5.add(x1, y1); } else { seriesT5.add(x2, y1); } } AngleCollct.addSeries(seriesT5); plot.setDataset(1, AngleCollct); XYLineAndShapeRenderer lineshapRend = new XYLineAndShapeRenderer(true, false); for (int i = 0; i < AngleCollct.getSeriesCount(); i++) { //plot.getRenderer().setSeriesPaint(i , Color.BLUE); lineshapRend.setSeriesPaint(i, Color.BLACK); } plot.setRenderer(1, lineshapRend); combinedrangexyplot.add(plot); } plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); JFreeChart chart = new JFreeChart("Semivariogram Surface", plot); chart.removeLegend(); chart.setBackgroundPaint(Color.white); // create and display a frame... ChartFrame frame = new ChartFrame("", chart); frame.pack(); //frame.setSize(100, 50); frame.setVisible(true); }
From source file:vinci.project2.pkg1.View.java
/** * Initializes the chart// www . ja v a 2s. co m */ private void setChart() { final JFreeChart chart = createChart(gd.createDataset(xySeries1, xySeries2, xySeries3)); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setSize(400, 300); ChartFrame chartFrame = new ChartFrame("Taxes", chart); chartFrame.setSize(400, 300); chartFrame.add(chartPanel); chartFrame.pack(); chartFrame.setVisible(false); chartFrame1.add(chartPanel); chartFrame1.setSize(400, 300); chartFrame1.repaint(); chartFrame1.revalidate(); }
From source file:techtonic.Onview.java
private void maxBtnActionPerformed(java.awt.event.ActionEvent evt) { ChartFrame frame = new ChartFrame("XY graph using JFreeChart", chart); frame.pack();/*w w w .ja v a 2 s. c o m*/ frame.setVisible(true); }
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);//from ww w . ja v a 2s.c o m cframe.setSize(450, 500); 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) { } }