List of usage examples for org.jfree.chart ChartFactory createPieChart3D
public static JFreeChart createPieChart3D(String title, PieDataset dataset, boolean legend, boolean tooltips, boolean urls)
From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java
/** * *//*from w w w .j ava 2 s.c om*/ protected JFreeChart createPie3DChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createPieChart3D( evaluateTextExpression(getChart().getTitleExpression()), (PieDataset) getDataset(), isShowLegend(), true, false); configureChart(jfreeChart); PiePlot3D piePlot3D = (PiePlot3D) jfreeChart.getPlot(); //plot.setStartAngle(290); //plot.setDirection(Rotation.CLOCKWISE); //plot.setNoDataMessage("No data to display"); JRPie3DPlot jrPie3DPlot = (JRPie3DPlot) getPlot(); double depthFactor = jrPie3DPlot.getDepthFactorDouble() == null ? JRPie3DPlot.DEPTH_FACTOR_DEFAULT : jrPie3DPlot.getDepthFactorDouble(); boolean isCircular = jrPie3DPlot.getCircular() == null ? false : jrPie3DPlot.getCircular(); piePlot3D.setDepthFactor(depthFactor); piePlot3D.setCircular(isCircular); boolean isShowLabels = jrPie3DPlot.getShowLabels() == null ? true : jrPie3DPlot.getShowLabels(); if (isShowLabels) { PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator(); JRItemLabel itemLabel = jrPie3DPlot.getItemLabel(); if (labelGenerator != null) { piePlot3D.setLabelGenerator(labelGenerator); } else if (jrPie3DPlot.getLabelFormat() != null) { piePlot3D.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPie3DPlot.getLabelFormat(), NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale()))); } // the default section label is just the key, so there's no need to set localized number formats // else if (itemLabel != null && itemLabel.getMask() != null) // { // piePlot3D.setLabelGenerator( // new StandardPieSectionLabelGenerator(itemLabel.getMask()) // ); // } piePlot3D.setLabelFont( fontUtil.getAwtFont(getFont(itemLabel == null ? null : itemLabel.getFont()), getLocale())); if (itemLabel != null && itemLabel.getColor() != null) { piePlot3D.setLabelPaint(itemLabel.getColor()); } else { piePlot3D.setLabelPaint(getChart().getForecolor()); } if (itemLabel != null && itemLabel.getBackgroundColor() != null) { piePlot3D.setLabelBackgroundPaint(itemLabel.getBackgroundColor()); } else { piePlot3D.setLabelBackgroundPaint(getChart().getBackcolor()); } } else { piePlot3D.setLabelGenerator(null); } if (jrPie3DPlot.getLegendLabelFormat() != null) { piePlot3D.setLegendLabelGenerator(new StandardPieSectionLabelGenerator( jrPie3DPlot.getLegendLabelFormat(), NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale()))); } // the default legend label is just the key, so there's no need to set localized number formats return jfreeChart; }
From source file:pi.bestdeal.gui.InterfacePrincipale.java
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed int idd = (int) jTable3.getModel().getValueAt(jTable3.getSelectedRow(), 0); ChoixStat1 chStat = new ChoixStat1(); ChoixStat2 chStat2 = new ChoixStat2(); Object[] options = { "BACK", "NEXT" }; int a = JOptionPane.showOptionDialog(null, chStat, "", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); int b = 0;//from w w w. j a va2 s . c om if (chStat.jRadiosexe.isSelected() && chStat.jRadioconsult.isSelected()) { b = 0; } if (chStat.jRadiosexe.isSelected() && chStat.jRadiores.isSelected()) { b = 1; } if (chStat.jRadiooperation.isSelected() && chStat.jRadioconsult.isSelected()) { b = 2; } if (chStat.jRadiooperation.isSelected() && chStat.jRadiores.isSelected()) { b = 3; } if (a == 1 && b == 2) { chStat.setVisible(false); Object[] options2 = { "Annuler", "Afficher la Statistique" }; int c = JOptionPane.showOptionDialog(null, chStat2, "", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options2, options[0]); if (c == 1) { java.util.Date d1 = chStat2.jDateDebut.getCalendar().getTime(); java.sql.Date sqlDate = new java.sql.Date(d1.getTime()); java.util.Date d2 = chStat2.jDatefin.getCalendar().getTime(); java.sql.Date sqlDate2 = new java.sql.Date(d2.getTime()); Charts charts = new Charts(); XYSeriesCollection dataxy = charts.createDataset(sqlDate.toString(), sqlDate2.toString(), idd); final JFreeChart chart = ChartFactory.createXYLineChart( "Evolution des Consultation par rapport au temps", "Jours", "Nombre des Consultations", // dataxy, // Dataset PlotOrientation.VERTICAL, // true, true, false); XYItemRenderer rend = chart.getXYPlot().getRenderer(); ChartPanel crepart = new ChartPanel(chart); Plot plot = chart.getPlot(); JPanel jpan = new JPanel(); JButton button = new JButton("Sauvegarder"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { JFileChooser chooser = new JFileChooser(); chooser.showSaveDialog(jPanel3); String path = chooser.getSelectedFile().getPath(); if ((!path.contains("jpg")) || (!path.contains("png")) || (!path.contains("jpeg"))) { path = path + ".png"; } File f = new File(path); ChartUtilities.saveChartAsPNG(new File(path), chart, 800, 600); if (f.exists() && !f.isDirectory()) { JOptionPane.showMessageDialog(null, "Sauvegarde Effectue"); Desktop.getDesktop().open(f); } } catch (IOException ex) { Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex); } } }); jpan.add(crepart); jpan.add(button); JOptionPane.showConfirmDialog(null, jpan, "Chart d'volution des consultations", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); } } if (a == 1 && (b == 3)) { Object[] options2 = { "Annuler", "Afficher la Statistique" }; int c = JOptionPane.showOptionDialog(null, chStat2, "", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options2, options[0]); if (c == 1) { java.util.Date d1 = chStat2.jDateDebut.getCalendar().getTime(); java.sql.Date sqlDate = new java.sql.Date(d1.getTime()); java.util.Date d2 = chStat2.jDatefin.getCalendar().getTime(); java.sql.Date sqlDate2 = new java.sql.Date(d2.getTime()); Charts charts = new Charts(); // JFreeChart chrt = ChartFactory.createXYStepAreaChart(null, null, null, null, PlotOrientation.HORIZONTAL, rootPaneCheckingEnabled, rootPaneCheckingEnabled, rootPaneCheckingEnabled) XYSeriesCollection dataxy = charts.createDatasetRes(sqlDate.toString(), sqlDate2.toString(), idd); final JFreeChart chart = ChartFactory.createXYLineChart( "Evolution des Consultation par rapport au temps", "Jours", "Nombre des Reservations", dataxy, PlotOrientation.VERTICAL, true, true, false); XYItemRenderer rend = chart.getXYPlot().getRenderer(); ChartPanel crepart = new ChartPanel(chart); Plot plot = chart.getPlot(); JPanel jpan = new JPanel(); jpan.setLayout(new FlowLayout(FlowLayout.LEADING)); JButton button = new JButton(); button.setText("Sauvegarder"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { JFileChooser chooser = new JFileChooser(); chooser.showSaveDialog(jPanel3); String path = chooser.getSelectedFile().getPath(); if ((!path.contains("jpg")) || (!path.contains("png")) || (!path.contains("jpeg"))) { path = path + ".png"; } File f = new File(path); ChartUtilities.saveChartAsPNG(new File(path), chart, 800, 600); if (f.exists() && !f.isDirectory()) { JOptionPane.showMessageDialog(null, "Sauvegarde Effectue"); Desktop.getDesktop().open(f); } } catch (IOException ex) { Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex); } } }); jpan.add(crepart); jpan.add(button); JOptionPane.showConfirmDialog(null, jpan, "Test", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); } } if (a == 1 && b == 0) { ConsultationDAO cdao = ConsultationDAO.getInstance(); DefaultPieDataset union = new DefaultPieDataset(); union.setValue("Homme", cdao.consultationCounterByGender(false, idd)); union.setValue("Femme", cdao.consultationCounterByGender(true, idd)); final JFreeChart repart = ChartFactory.createPieChart3D("Rpartition par Sexe", union, true, true, false); ChartPanel crepart = new ChartPanel(repart); Plot plot = repart.getPlot(); JPanel jpan = new JPanel(); JButton button = new JButton("Sauvegarder"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { JFileChooser chooser = new JFileChooser(); chooser.showSaveDialog(jPanel3); String path = chooser.getSelectedFile().getPath(); if ((!path.contains("jpg")) || (!path.contains("png")) || (!path.contains("jpeg"))) { path = path + ".png"; } File f = new File(path); ChartUtilities.saveChartAsPNG(new File(path), repart, 800, 600); if (f.exists() && !f.isDirectory()) { JOptionPane.showMessageDialog(null, "Sauvegarde Effectue"); Desktop.getDesktop().open(f); } } catch (IOException ex) { Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex); } } }); jpan.add(crepart); jpan.add(button); JOptionPane.showConfirmDialog(null, jpan, "", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); } if (a == 1 && b == 1) { DefaultPieDataset union = new DefaultPieDataset(); ReservationDAO dAO = ReservationDAO.getInstance(); union.setValue("Homme", dAO.reservationCounterByGender(false, idd)); union.setValue("Femme", dAO.reservationCounterByGender(true, idd)); final JFreeChart repart = ChartFactory.createPieChart3D("Rpartition par Sexe", union, true, true, false); ChartPanel crepart = new ChartPanel(repart); Plot plot = repart.getPlot(); JPanel jpan = new JPanel(); JButton button = new JButton("Sauvegarder"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { JFileChooser chooser = new JFileChooser(); chooser.showSaveDialog(jPanel3); String path = chooser.getSelectedFile().getPath(); if ((!path.contains("jpg")) || (!path.contains("png")) || (!path.contains("jpeg"))) { path = path + ".png"; } File f = new File(path); ChartUtilities.saveChartAsPNG(new File(path), repart, 800, 600); if (f.exists() && !f.isDirectory()) { JOptionPane.showMessageDialog(null, "Sauvegarde Effectue"); Desktop.getDesktop().open(f); } } catch (IOException ex) { Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex); } } }); jpan.add(crepart); jpan.add(button); JOptionPane.showConfirmDialog(null, jpan, "Chart de la rpartition des achat par sexe", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); } }
From source file:gui.Trabajadores.java
public void GPNosin() { ChartPanel panel;/*from w w w. j a v a 2s . c o m*/ JFreeChart chart = null; String m = ""; String f = ""; DefaultPieDataset datos = new DefaultPieDataset(); dtm2 = (DefaultTableModel) tablaNoSin.getModel(); f = tablaNoSin.getValueAt(0, 1).toString(); m = tablaNoSin.getValueAt(1, 1).toString(); datos.setValue("Masculino", Integer.parseInt(m)); datos.setValue("Femenino", Integer.parseInt(f)); chart = ChartFactory.createPieChart3D("Grafico No Sindicalizados", datos, true, true, true); panel = new ChartPanel(chart); panel.setBounds(5, 5, 350, 350); PastelNosin.setVisible(true); capas.setLayer(PastelNosin, 0, 0); PastelNosin.add(panel); PastelNosin.repaint(); }
From source file:controller.ChartAndGraphServlet.java
/** * Creates the appropriate chart for the patient history page or the * statistics page. Line charts are created to display a longitudinal view * of patient results on the history page. The statistics page includes pie * charts, bar charts, histograms, and box and whisker charts. * * @param request servlet request// w w w. jav a 2 s .co m * @param response servlet response * @throws IOException */ public void getChart(HttpServletRequest request, HttpServletResponse response) throws IOException { HttpSession session = request.getSession(); response.setContentType("image/png"); OutputStream outputStream = response.getOutputStream(); final int widthIncreaseThreshold = 18; final int incrementalIncreaseThreshold = 22; final int incrementalIncreaseInPixels = 45; final int treatmentClassUnknownIndex = 6; int width = 640; int height = 450; int bigWidth = 780; ReferenceContainer rc = (ReferenceContainer) session.getServletContext().getAttribute("references"); HealthyTargetReference htr = rc.getHealthyTargets(); String action = request.getParameter("action"); switch (action) { case "a1c": { ArrayList<A1cResult> a1cHistory = (ArrayList<A1cResult>) session .getAttribute(SessionObjectUtility.A1C_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = a1cHistory.size() - 1; i > -1; i--) { dataset.addValue(a1cHistory.get(i).getValue(), "A1C", a1cHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.A1C_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("A1C History", "dates", "A1C", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); /* show the healthy target boundaries */ BigDecimal upper = htr.getA1c().getUpperBound(); BigDecimal lower = htr.getA1c().getLowerBound(); if (upper != null) { ValueMarker marker = new ValueMarker(upper.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (lower != null) { ValueMarker marker = new ValueMarker(lower.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (a1cHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (a1cHistory.size() > incrementalIncreaseThreshold) { int increments = a1cHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "psa": { ArrayList<ContinuousResult> psaHistory = (ArrayList<ContinuousResult>) session .getAttribute(SessionObjectUtility.PSA_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = psaHistory.size() - 1; i > -1; i--) { dataset.addValue(psaHistory.get(i).getValue(), "PSA", psaHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.PSA_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("PSA History", "dates", "PSA", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); /* show the healthy target boundaries */ BigDecimal upper = htr.getPsa().getUpperBound(); BigDecimal lower = htr.getPsa().getLowerBound(); if (upper != null) { ValueMarker marker = new ValueMarker(upper.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (lower != null) { ValueMarker marker = new ValueMarker(lower.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (psaHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (psaHistory.size() > incrementalIncreaseThreshold) { int increments = psaHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "alt": { ArrayList<ContinuousResult> altHistory = (ArrayList<ContinuousResult>) session .getAttribute(SessionObjectUtility.ALT_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = altHistory.size() - 1; i > -1; i--) { dataset.addValue(altHistory.get(i).getValue(), "ALT", altHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.ALT_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("ALT History", "dates", "ALT", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); /* show the healthy target boundaries */ BigDecimal upper = htr.getAlt().getUpperBound(); BigDecimal lower = htr.getAlt().getLowerBound(); if (upper != null) { ValueMarker marker = new ValueMarker(upper.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (lower != null) { ValueMarker marker = new ValueMarker(lower.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (altHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (altHistory.size() > incrementalIncreaseThreshold) { int increments = altHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "ast": { ArrayList<ContinuousResult> astHistory = (ArrayList<ContinuousResult>) session .getAttribute(SessionObjectUtility.AST_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = astHistory.size() - 1; i > -1; i--) { dataset.addValue(astHistory.get(i).getValue(), "AST", astHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.AST_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("AST History", "dates", "AST", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); /* show the healthy target boundaries */ BigDecimal upper = htr.getAst().getUpperBound(); BigDecimal lower = htr.getAst().getLowerBound(); if (upper != null) { ValueMarker marker = new ValueMarker(upper.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (lower != null) { ValueMarker marker = new ValueMarker(lower.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (astHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (astHistory.size() > incrementalIncreaseThreshold) { int increments = astHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "bp": { ArrayList<BloodPressureResult> bpHistory = (ArrayList<BloodPressureResult>) session .getAttribute(SessionObjectUtility.BP_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = bpHistory.size() - 1; i > -1; i--) { dataset.addValue(bpHistory.get(i).getSystolicValue(), "systolic", bpHistory.get(i).getDate()); dataset.addValue(bpHistory.get(i).getDiastolicValue(), "diastolic", bpHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.BP_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("Blood Pressure History", "dates", "blood pressure", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); /* show the healthy target boundaries */ BigDecimal upperSystole = htr.getBloodPressureSystole().getUpperBound(); BigDecimal upperDiastole = htr.getBloodPressureDiastole().getUpperBound(); if (upperSystole != null) { ValueMarker marker = new ValueMarker(upperSystole.doubleValue()); marker.setPaint(Color.MAGENTA); plot.addRangeMarker(marker); } if (upperDiastole != null) { ValueMarker marker = new ValueMarker(upperDiastole.doubleValue()); marker.setPaint(Color.BLUE); plot.addRangeMarker(marker); } if (bpHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (bpHistory.size() > incrementalIncreaseThreshold) { int increments = bpHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "bmi": { ArrayList<ContinuousResult> bmiHistory = (ArrayList<ContinuousResult>) session .getAttribute(SessionObjectUtility.BMI_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = bmiHistory.size() - 1; i > -1; i--) { dataset.addValue(bmiHistory.get(i).getValue(), "BMI", bmiHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.BMI_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("BMI History", "dates", "BMI", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); /* show the healthy target boundaries */ BigDecimal upper = htr.getBmi().getUpperBound(); BigDecimal lower = htr.getBmi().getLowerBound(); if (upper != null) { ValueMarker marker = new ValueMarker(upper.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (lower != null) { ValueMarker marker = new ValueMarker(lower.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (bmiHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (bmiHistory.size() > incrementalIncreaseThreshold) { int increments = bmiHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "creatinine": { ArrayList<ContinuousResult> creatinineHistory = (ArrayList<ContinuousResult>) session .getAttribute(SessionObjectUtility.CREATININE_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = creatinineHistory.size() - 1; i > -1; i--) { dataset.addValue(creatinineHistory.get(i).getValue(), "creatinine", creatinineHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.CREATININE_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("Creatinine History", "dates", "creatinine", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); /* show the healthy target boundaries */ BigDecimal upper = htr.getCreatinine().getUpperBound(); BigDecimal lower = htr.getCreatinine().getLowerBound(); if (upper != null) { ValueMarker marker = new ValueMarker(upper.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (lower != null) { ValueMarker marker = new ValueMarker(lower.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (creatinineHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (creatinineHistory.size() > incrementalIncreaseThreshold) { int increments = creatinineHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "egfr": { ArrayList<ContinuousResult> egfrHistory = (ArrayList<ContinuousResult>) session .getAttribute(SessionObjectUtility.EGFR_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = egfrHistory.size() - 1; i > -1; i--) { dataset.addValue(egfrHistory.get(i).getValue(), "eGFR", egfrHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.EGFR_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("eGFR History", "dates", "eGFR", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); /* show the healthy target boundaries */ BigDecimal upper = htr.getEgfr().getUpperBound(); BigDecimal lower = htr.getEgfr().getLowerBound(); if (upper != null) { ValueMarker marker = new ValueMarker(upper.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (lower != null) { ValueMarker marker = new ValueMarker(lower.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (egfrHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (egfrHistory.size() > incrementalIncreaseThreshold) { int increments = egfrHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "glucose": { ArrayList<ContinuousResult> glucoseHistory = (ArrayList<ContinuousResult>) session .getAttribute(SessionObjectUtility.GLUCOSE_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = glucoseHistory.size() - 1; i > -1; i--) { dataset.addValue(glucoseHistory.get(i).getValue(), "glucose", glucoseHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.GLUCOSE_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("Glucose History", "dates", "glucose", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); /* show the healthy target boundaries */ BigDecimal upper = htr.getGlucoseAc().getUpperBound(); BigDecimal lower = htr.getGlucoseAc().getLowerBound(); if (upper != null) { ValueMarker marker = new ValueMarker(upper.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (lower != null) { ValueMarker marker = new ValueMarker(lower.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (glucoseHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (glucoseHistory.size() > incrementalIncreaseThreshold) { int increments = glucoseHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "hdl": { ArrayList<ContinuousResult> hdlHistory = (ArrayList<ContinuousResult>) session .getAttribute(SessionObjectUtility.HDL_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = hdlHistory.size() - 1; i > -1; i--) { dataset.addValue(hdlHistory.get(i).getValue(), "HDL", hdlHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.HDL_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /*get the chart */ JFreeChart chart = ChartFactory.createLineChart("HDL History", "dates", "HDL", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); /* show the healthy target boundaries */ BigDecimal upperFemale = htr.getHdlFemale().getUpperBound(); BigDecimal lowerFemale = htr.getHdlFemale().getLowerBound(); BigDecimal upperMale = htr.getHdlMale().getUpperBound(); BigDecimal lowerMale = htr.getHdlMale().getLowerBound(); if (upperFemale != null) { ValueMarker marker = new ValueMarker(upperFemale.doubleValue()); marker.setPaint(Color.MAGENTA); plot.addRangeMarker(marker); } if (lowerFemale != null) { ValueMarker marker = new ValueMarker(lowerFemale.doubleValue()); marker.setPaint(Color.MAGENTA); plot.addRangeMarker(marker); } if (upperMale != null) { ValueMarker marker = new ValueMarker(upperMale.doubleValue()); marker.setPaint(Color.BLUE); plot.addRangeMarker(marker); } if (lowerMale != null) { ValueMarker marker = new ValueMarker(lowerMale.doubleValue()); marker.setPaint(Color.BLUE); plot.addRangeMarker(marker); } if (hdlHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (hdlHistory.size() > incrementalIncreaseThreshold) { int increments = hdlHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "ldl": { ArrayList<LdlResult> ldlHistory = (ArrayList<LdlResult>) session .getAttribute(SessionObjectUtility.LDL_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = ldlHistory.size() - 1; i > -1; i--) { dataset.addValue(ldlHistory.get(i).getValue(), "LDL", ldlHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.LDL_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("LDL History", "dates", "LDL", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); /* show the healthy target boundaries */ BigDecimal upper = htr.getLdl().getUpperBound(); BigDecimal lower = htr.getLdl().getLowerBound(); if (upper != null) { ValueMarker marker = new ValueMarker(upper.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (lower != null) { ValueMarker marker = new ValueMarker(lower.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (ldlHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (ldlHistory.size() > incrementalIncreaseThreshold) { int increments = ldlHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "compliance": { ArrayList<ContinuousResult> complianceHistory = (ArrayList<ContinuousResult>) session .getAttribute(SessionObjectUtility.COMPLIANCE_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = complianceHistory.size() - 1; i > -1; i--) { dataset.addValue(complianceHistory.get(i).getValue(), "compliance", complianceHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.COMPLIANCE_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("Compliance History", "dates", "compliance", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); if (complianceHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (complianceHistory.size() > incrementalIncreaseThreshold) { int increments = complianceHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "physicalActivity": { ArrayList<DiscreteResult> physicalActivityHistory = (ArrayList<DiscreteResult>) session .getAttribute(SessionObjectUtility.PHYSICAL_ACTIVITY_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = physicalActivityHistory.size() - 1; i > -1; i--) { dataset.addValue(physicalActivityHistory.get(i).getValue(), "physical activity", physicalActivityHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.PHYSICAL_ACTIVITY_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("Physical Activity History", "dates", "min per wk", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); /* show the healthy target boundaries */ BigDecimal upper = htr.getPhysicalActivity().getUpperBound(); BigDecimal lower = htr.getPhysicalActivity().getLowerBound(); if (upper != null) { ValueMarker marker = new ValueMarker(upper.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (lower != null) { ValueMarker marker = new ValueMarker(lower.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (physicalActivityHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (physicalActivityHistory.size() > incrementalIncreaseThreshold) { int increments = physicalActivityHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "psychological": { ArrayList<PsychologicalScreeningResult> psychologicalHistory = (ArrayList<PsychologicalScreeningResult>) session .getAttribute(SessionObjectUtility.PSYCHOLOGICAL_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = psychologicalHistory.size() - 1; i > -1; i--) { dataset.addValue(psychologicalHistory.get(i).getScore(), "PHQ9 score", psychologicalHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.PSYCHOLOGICAL_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("Psychological Screening History", "dates", "score", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); if (psychologicalHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (psychologicalHistory.size() > incrementalIncreaseThreshold) { int increments = psychologicalHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "t4": { ArrayList<ContinuousResult> t4History = (ArrayList<ContinuousResult>) session .getAttribute(SessionObjectUtility.T4_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = t4History.size() - 1; i > -1; i--) { dataset.addValue(t4History.get(i).getValue(), "T4", t4History.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.T4_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("T4 History", "dates", "T4", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); /* show the healthy target boundaries */ BigDecimal upper = htr.getT4().getUpperBound(); BigDecimal lower = htr.getT4().getLowerBound(); if (upper != null) { ValueMarker marker = new ValueMarker(upper.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (lower != null) { ValueMarker marker = new ValueMarker(lower.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (t4History.size() > widthIncreaseThreshold) { width = bigWidth; } if (t4History.size() > incrementalIncreaseThreshold) { int increments = t4History.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "triglycerides": { ArrayList<ContinuousResult> triglyceridesHistory = (ArrayList<ContinuousResult>) session .getAttribute(SessionObjectUtility.TRIGLYCERIDES_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = triglyceridesHistory.size() - 1; i > -1; i--) { dataset.addValue(triglyceridesHistory.get(i).getValue(), "triglycerides", triglyceridesHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.TRIGLYCERIDES_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("Triglycerides History", "dates", "triglycerides", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); /* show the healthy target boundaries */ BigDecimal upper = htr.getTriglycerides().getUpperBound(); BigDecimal lower = htr.getTriglycerides().getLowerBound(); if (upper != null) { ValueMarker marker = new ValueMarker(upper.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (lower != null) { ValueMarker marker = new ValueMarker(lower.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (triglyceridesHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (triglyceridesHistory.size() > incrementalIncreaseThreshold) { int increments = triglyceridesHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "tsh": { ArrayList<TshResult> tshHistory = (ArrayList<TshResult>) session .getAttribute(SessionObjectUtility.TSH_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = tshHistory.size() - 1; i > -1; i--) { dataset.addValue(tshHistory.get(i).getValue(), "TSH", tshHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.TSH_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("TSH History", "dates", "TSH", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); /* show the healthy target boundaries */ BigDecimal upper = htr.getTsh().getUpperBound(); BigDecimal lower = htr.getTsh().getLowerBound(); if (upper != null) { ValueMarker marker = new ValueMarker(upper.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (lower != null) { ValueMarker marker = new ValueMarker(lower.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (tshHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (tshHistory.size() > incrementalIncreaseThreshold) { int increments = tshHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "uacr": { ArrayList<ContinuousResult> uacrHistory = (ArrayList<ContinuousResult>) session .getAttribute(SessionObjectUtility.UACR_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = uacrHistory.size() - 1; i > -1; i--) { dataset.addValue(uacrHistory.get(i).getValue(), "UACR", uacrHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.UACR_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("UACR History", "dates", "UACR", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); /* show the healthy target boundaries */ BigDecimal upper = htr.getUacr().getUpperBound(); BigDecimal lower = htr.getUacr().getLowerBound(); if (upper != null) { ValueMarker marker = new ValueMarker(upper.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (lower != null) { ValueMarker marker = new ValueMarker(lower.doubleValue()); marker.setPaint(Color.YELLOW); plot.addRangeMarker(marker); } if (uacrHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (uacrHistory.size() > incrementalIncreaseThreshold) { int increments = uacrHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "waist": { ArrayList<ContinuousResult> waistHistory = (ArrayList<ContinuousResult>) session .getAttribute(SessionObjectUtility.WAIST_GRAPH_POINTS); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); /* add the data */ for (int i = waistHistory.size() - 1; i > -1; i--) { dataset.addValue(waistHistory.get(i).getValue(), "waist", waistHistory.get(i).getDate()); } /* remove reference */ session.setAttribute(SessionObjectUtility.WAIST_GRAPH_POINTS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createLineChart("Waist History", "dates", "waist", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); /* angle the x-axis labels */ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); /* show the healthy target boundaries */ BigDecimal upperFemale = htr.getWaistFemale().getUpperBound(); BigDecimal lowerFemale = htr.getWaistFemale().getLowerBound(); BigDecimal upperMale = htr.getWaistMale().getUpperBound(); BigDecimal lowerMale = htr.getWaistMale().getLowerBound(); if (upperFemale != null) { ValueMarker marker = new ValueMarker(upperFemale.doubleValue()); marker.setPaint(Color.MAGENTA); plot.addRangeMarker(marker); } if (lowerFemale != null) { ValueMarker marker = new ValueMarker(lowerFemale.doubleValue()); marker.setPaint(Color.MAGENTA); plot.addRangeMarker(marker); } if (upperMale != null) { ValueMarker marker = new ValueMarker(upperMale.doubleValue()); marker.setPaint(Color.BLUE); plot.addRangeMarker(marker); } if (lowerMale != null) { ValueMarker marker = new ValueMarker(lowerMale.doubleValue()); marker.setPaint(Color.BLUE); plot.addRangeMarker(marker); } if (waistHistory.size() > widthIncreaseThreshold) { width = bigWidth; } if (waistHistory.size() > incrementalIncreaseThreshold) { int increments = waistHistory.size() % incrementalIncreaseThreshold; for (int i = 0; i < increments; i++) { width += incrementalIncreaseInPixels; } } ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "agedemographics": { DemographicData demographicData = (DemographicData) session .getAttribute(SessionObjectUtility.AGE_DEMOGRAPHICS_GRAPH_DATA); HistogramDataset dataset = new HistogramDataset(); ArrayList<Integer> ages = demographicData.getAges(); if (ages.size() > 0) { double[] vector = new double[ages.size()]; for (int i = 0; i < vector.length; i++) { vector[i] = ages.get(i); } /* add the data */ dataset.addSeries("number of patients", vector, 10); /* remove reference */ session.setAttribute(SessionObjectUtility.AGE_DEMOGRAPHICS_GRAPH_DATA, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createHistogram("Age Distribution", "age", "number of patients", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); XYPlot plot = chart.getXYPlot(); final XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); /* creating a shadow */ renderer.setShadowXOffset(4.0); renderer.setShadowYOffset(1.5); renderer.setShadowVisible(true); ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); } break; } case "genderdemographics": { DemographicData demographicData = (DemographicData) session .getAttribute(SessionObjectUtility.GENDER_DEMOGRAPHICS_GRAPH_DATA); DefaultPieDataset dataset = new DefaultPieDataset(); /* add the data */ dataset.setValue("female", demographicData.getPercentFemale()); dataset.setValue("male", demographicData.getPercentMale()); /* remove reference */ session.setAttribute(SessionObjectUtility.GENDER_DEMOGRAPHICS_GRAPH_DATA, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createPieChart3D("Gender", dataset, legend, tooltips, urls); final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(90); plot.setForegroundAlpha(0.60f); plot.setInteriorGap(0.02); PieSectionLabelGenerator labels = new StandardPieSectionLabelGenerator("{0}: ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); plot.setLabelGenerator(labels); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "racedemographics": { DemographicData demographicData = (DemographicData) session .getAttribute(SessionObjectUtility.RACE_DEMOGRAPHICS_GRAPH_DATA); DefaultPieDataset dataset = new DefaultPieDataset(); /* add the data */ dataset.setValue("White", demographicData.getPercentWhite()); dataset.setValue("African American", demographicData.getPercentAfricanAmerican()); dataset.setValue("Asian/Pacific Islander", demographicData.getPercentAsian()); dataset.setValue("American Indian/Alaska Native", demographicData.getPercentIndian()); dataset.setValue("Hispanic", demographicData.getPercentHispanic()); dataset.setValue("Middle Eastern", demographicData.getPercentMiddleEastern()); dataset.setValue("Other", demographicData.getPercentOther()); /* remove reference */ session.setAttribute(SessionObjectUtility.RACE_DEMOGRAPHICS_GRAPH_DATA, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createPieChart3D("Race", dataset, legend, tooltips, urls); final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(90); plot.setForegroundAlpha(0.60f); plot.setInteriorGap(0.02); PieSectionLabelGenerator labels = new StandardPieSectionLabelGenerator("{0}: ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); plot.setLabelGenerator(labels); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "lasta1c": { Stats glycemicStats = (Stats) session.getAttribute(SessionObjectUtility.LAST_A1C_DATA); HistogramDataset dataset = new HistogramDataset(); ArrayList<CategoricalValue> lastA1cValues = new ArrayList<>(); if (glycemicStats.getGroups() != null) { int i; for (i = 0; i < glycemicStats.getGroups().size(); i++) { if (glycemicStats.getGroups().get(i) != null) { lastA1cValues.addAll(glycemicStats.getGroups().get(i)); } } } if (lastA1cValues.size() > 0) { double[] vector = new double[lastA1cValues.size()]; for (int i = 0; i < vector.length; i++) { vector[i] = lastA1cValues.get(i).getValue().doubleValue(); } /* add the data */ dataset.addSeries("number of patients", vector, 15); /* remove reference */ session.setAttribute(SessionObjectUtility.LAST_A1C_DATA, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createHistogram("Most Recent A1C Values", "last A1C(%)", "number of patients", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); XYPlot plot = chart.getXYPlot(); final XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); /* creating a shadow */ renderer.setShadowXOffset(4.0); renderer.setShadowYOffset(1.5); renderer.setShadowVisible(true); ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); } break; } case "lasta1cbyclassattendance": { final int topGroupIndex = 4; Stats glycemicStats = (Stats) session.getAttribute(SessionObjectUtility.LAST_A1C_BY_CLASS_DATA); DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); if (glycemicStats.getGroups() != null) { for (int i = 0; i < glycemicStats.getGroups().size(); i++) { if ((glycemicStats.getGroups().get(i) != null) && (!glycemicStats.getGroups().get(i).isEmpty())) { List values = new ArrayList(); for (CategoricalValue cv : glycemicStats.getGroups().get(i)) { values.add(cv.getValue()); } if (i == topGroupIndex) { dataset.add(BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(values), "last A1C(%)", "5 or more"); } else { dataset.add(BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(values), "last A1C(%)", i + 1); } } } } /* remove reference */ session.setAttribute(SessionObjectUtility.LAST_A1C_BY_CLASS_DATA, null); CategoryAxis domainAxis = new CategoryAxis("number of classes attended"); NumberAxis rangeAxis = new NumberAxis("last A1C(%)"); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); JFreeChart chart = new JFreeChart("Most Recent A1C by Classes Attended", plot); renderer.setMeanVisible(false); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "lastbmimales": { Stats bmiMalesStats = (Stats) session.getAttribute(SessionObjectUtility.LAST_BMI_MALES_DATA); HistogramDataset dataset = new HistogramDataset(); ArrayList<CategoricalValue> lastBmiMalesValues = new ArrayList<>(); if ((bmiMalesStats.getGroups() != null) && (!bmiMalesStats.getGroups().isEmpty())) { for (int i = 0; i < bmiMalesStats.getGroups().size(); i++) { if (bmiMalesStats.getGroups().get(i) != null) { lastBmiMalesValues.addAll(bmiMalesStats.getGroups().get(i)); } } } if (lastBmiMalesValues.size() > 0) { double[] vector = new double[lastBmiMalesValues.size()]; for (int i = 0; i < vector.length; i++) { vector[i] = lastBmiMalesValues.get(i).getValue().doubleValue(); } /* add the data */ dataset.addSeries("number of patients", vector, 15); /* remove reference */ session.setAttribute(SessionObjectUtility.LAST_BMI_MALES_DATA, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createHistogram("Most Recent BMI Values for Males", "last BMI", "number of patients", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); XYPlot plot = chart.getXYPlot(); final XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); /* creating a shadow */ renderer.setShadowXOffset(4.0); renderer.setShadowYOffset(1.5); renderer.setShadowVisible(true); ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); } break; } case "lastbmifemales": { Stats bmiFemalesStats = (Stats) session.getAttribute(SessionObjectUtility.LAST_BMI_FEMALES_DATA); HistogramDataset dataset = new HistogramDataset(); ArrayList<CategoricalValue> lastBmiFemalesValues = new ArrayList<>(); if ((bmiFemalesStats.getGroups() != null) && (!bmiFemalesStats.getGroups().isEmpty())) { for (int i = 0; i < bmiFemalesStats.getGroups().size(); i++) { if (bmiFemalesStats.getGroups().get(i) != null) { lastBmiFemalesValues.addAll(bmiFemalesStats.getGroups().get(i)); } } } if (lastBmiFemalesValues.size() > 0) { double[] vector = new double[lastBmiFemalesValues.size()]; for (int i = 0; i < vector.length; i++) { vector[i] = lastBmiFemalesValues.get(i).getValue().doubleValue(); } /* add the data */ dataset.addSeries("number of patients", vector, 15); /* remove reference */ session.setAttribute(SessionObjectUtility.LAST_BMI_FEMALES_DATA, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createHistogram("Most Recent BMI Values for Females", "last BMI", "number of patients", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); XYPlot plot = chart.getXYPlot(); final XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); /* creating a shadow */ renderer.setShadowXOffset(4.0); renderer.setShadowYOffset(1.5); renderer.setShadowVisible(true); ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); } break; } case "lastbmimalesbyclassattendance": { final int topGroupIndex = 4; Stats bmiMalesStats = (Stats) session.getAttribute(SessionObjectUtility.LAST_BMI_MALES_BY_CLASS_DATA); DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); if (bmiMalesStats.getGroups() != null) { for (int i = 0; i < bmiMalesStats.getGroups().size(); i++) { if ((bmiMalesStats.getGroups().get(i) != null) && (!bmiMalesStats.getGroups().get(i).isEmpty())) { List values = new ArrayList(); for (CategoricalValue cv : bmiMalesStats.getGroups().get(i)) { values.add(cv.getValue()); } if (i == topGroupIndex) { dataset.add(BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(values), "last BMI (males)", "5 or more"); } else { dataset.add(BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(values), "last BMI (males)", i + 1); } } } } /* remove reference */ session.setAttribute(SessionObjectUtility.LAST_BMI_MALES_BY_CLASS_DATA, null); CategoryAxis domainAxis = new CategoryAxis("number of classes attended"); NumberAxis rangeAxis = new NumberAxis("last BMI (males)"); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); JFreeChart chart = new JFreeChart("Most Recent BMI for Males by Classes Attended", plot); renderer.setMeanVisible(false); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "lastbmifemalesbyclassattendance": { final int topGroupIndex = 4; Stats bmiFemalesStats = (Stats) session .getAttribute(SessionObjectUtility.LAST_BMI_FEMALES_BY_CLASS_DATA); DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); if (bmiFemalesStats.getGroups() != null) { for (int i = 0; i < bmiFemalesStats.getGroups().size(); i++) { if ((bmiFemalesStats.getGroups().get(i) != null) && (!bmiFemalesStats.getGroups().get(i).isEmpty())) { List values = new ArrayList(); for (CategoricalValue cv : bmiFemalesStats.getGroups().get(i)) { values.add(cv.getValue()); } if (i == topGroupIndex) { dataset.add(BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(values), "last BMI (females)", "5 or more"); } else { dataset.add(BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(values), "last BMI (females)", i + 1); } } } } /* remove reference */ session.setAttribute(SessionObjectUtility.LAST_BMI_FEMALES_BY_CLASS_DATA, null); CategoryAxis domainAxis = new CategoryAxis("number of classes attended"); NumberAxis rangeAxis = new NumberAxis("last BMI (females)"); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); JFreeChart chart = new JFreeChart("Most Recent BMI for Females by Classes Attended", plot); renderer.setMeanVisible(false); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "lasta1cbytreatment": { final int firstIndex = 0; Stats glycemicStats = (Stats) session.getAttribute(SessionObjectUtility.LAST_A1C_BY_TREATMENT); DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); if (glycemicStats.getGroups() != null) { for (int i = 0; i < glycemicStats.getGroups().size(); i++) { if ((glycemicStats.getGroups().get(i) != null) && (!glycemicStats.getGroups().get(i).isEmpty())) { String category = glycemicStats.getGroups().get(i).get(firstIndex) != null ? glycemicStats.getGroups().get(i).get(firstIndex).getCategory() : ""; List values = new ArrayList(); for (CategoricalValue cv : glycemicStats.getGroups().get(i)) { values.add(cv.getValue()); } dataset.add(BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(values), "last A1C(%)", category); } } } /* remove reference */ session.setAttribute(SessionObjectUtility.LAST_A1C_BY_TREATMENT, null); CategoryAxis domainAxis = new CategoryAxis("treatment class"); NumberAxis rangeAxis = new NumberAxis("last A1C(%)"); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); JFreeChart chart = new JFreeChart("Most Recent A1C by Treatment Class", plot); renderer.setMeanVisible(false); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "treatmentclasscounts": { int treatmentClassCountsIndex = 1; Stats treatmentData = (Stats) session.getAttribute(SessionObjectUtility.CLASS_COUNTS_TREATMENT_STATS); DefaultPieDataset dataset = new DefaultPieDataset(); /* add the treatment data to the dataset */ for (int i = 0; i < treatmentClassUnknownIndex + 1; i++) { dataset.setValue(treatmentData.getGroups().get(treatmentClassCountsIndex).get(i).getCategory(), treatmentData.getGroups().get(treatmentClassCountsIndex).get(i).getValue()); } /* remove reference */ session.setAttribute(SessionObjectUtility.CLASS_COUNTS_TREATMENT_STATS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; /* get the chart */ JFreeChart chart = ChartFactory.createPieChart3D("Treatment Class", dataset, legend, tooltips, urls); final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(90); plot.setForegroundAlpha(0.60f); plot.setInteriorGap(0.02); PieSectionLabelGenerator labels = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); plot.setLabelGenerator(labels); chart.setBorderPaint(Color.GREEN); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); break; } case "treatmentgenderclasscounts": { int maleClassCountsIndex = 2; int femaleClassCountsIndex = 3; Stats treatmentData = (Stats) session .getAttribute(SessionObjectUtility.GENDER_CLASS_COUNTS_TREATMENT_STATS); final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); HashMap<Integer, String> genderMap = new HashMap<>(); genderMap.put(maleClassCountsIndex, "Male"); genderMap.put(femaleClassCountsIndex, "Female"); /* load data for males and females into the dataset */ for (int i = femaleClassCountsIndex; i > maleClassCountsIndex - 1; i--) { for (int j = 0; j < treatmentClassUnknownIndex + 1; j++) { dataset.addValue(treatmentData.getGroups().get(i).get(j).getValue(), genderMap.get(i), treatmentData.getGroups().get(i).get(j).getCategory()); } } /* remove reference */ session.setAttribute(SessionObjectUtility.GENDER_CLASS_COUNTS_TREATMENT_STATS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; JFreeChart barChart = ChartFactory.createBarChart("Treatment Class by Gender", "Treatment Class", "Number of Patients", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); barChart.setBorderPaint(Color.GREEN); barChart.setBorderStroke(new BasicStroke(5.0f)); barChart.setBorderVisible(true); CategoryPlot plot = barChart.getCategoryPlot(); final BarRenderer renderer = (BarRenderer) plot.getRenderer(); /* creating a shadow */ renderer.setShadowXOffset(4.0); renderer.setShadowYOffset(1.5); renderer.setShadowVisible(true); ChartUtilities.writeChartAsPNG(outputStream, barChart, width, height); break; } case "treatmentraceclasscounts": { int whiteClassCountsIndex = 4; int africanAmericanClassCountsIndex = 5; int asianPacificIslanderClassCountsIndex = 6; int americanIndianAlaskaNativeClassCountsIndex = 7; int hispanicClassCountsIndex = 8; int middleEasternClassCountsIndex = 9; int otherClassCountsIndex = 10; Stats treatmentData = (Stats) session .getAttribute(SessionObjectUtility.RACE_CLASS_COUNTS_TREATMENT_STATS); final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); HashMap<Integer, String> raceMap = new HashMap<>(); raceMap.put(whiteClassCountsIndex, "White"); raceMap.put(africanAmericanClassCountsIndex, "African American"); raceMap.put(asianPacificIslanderClassCountsIndex, "Asian/Pacific Islander"); raceMap.put(americanIndianAlaskaNativeClassCountsIndex, "American Indian/Alaska Native"); raceMap.put(hispanicClassCountsIndex, "Hispanic"); raceMap.put(middleEasternClassCountsIndex, "Middle Eastern"); raceMap.put(otherClassCountsIndex, "Other"); /* load data for each race into the dataset */ for (int i = whiteClassCountsIndex; i < otherClassCountsIndex + 1; i++) { for (int j = 0; j < treatmentClassUnknownIndex + 1; j++) { dataset.addValue(treatmentData.getGroups().get(i).get(j).getValue(), raceMap.get(i), treatmentData.getGroups().get(i).get(j).getCategory()); } } /* remove reference */ session.setAttribute(SessionObjectUtility.RACE_CLASS_COUNTS_TREATMENT_STATS, null); boolean legend = true; boolean tooltips = false; boolean urls = false; JFreeChart barChart = ChartFactory.createStackedBarChart("Treatment Class by Race", "Treatment Class", "Number of Patients", dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); barChart.setBorderPaint(Color.GREEN); barChart.setBorderStroke(new BasicStroke(5.0f)); barChart.setBorderVisible(true); CategoryPlot plot = barChart.getCategoryPlot(); final BarRenderer renderer = (BarRenderer) plot.getRenderer(); /* creating a shadow */ renderer.setShadowXOffset(4.0); renderer.setShadowYOffset(1.5); renderer.setShadowVisible(true); ChartUtilities.writeChartAsPNG(outputStream, barChart, width, height); break; } default: break; } }
From source file:UserInterface.SystemAdmin.ReportsJPanel.java
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed int total = 0; // for(Network network : system.getNetworkList()){ // for(Enterprise enterprise : network.getEnterpriseDirectory().getEnterpriseList()){ // 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 . ja va 2 s.c om // } // } for (Network network : system.getNetworkList()) { for (Enterprise enterprise : network.getEnterpriseDirectory().getEnterpriseList()) { if (enterprise instanceof WaterEnterprise) { for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) { if (organization instanceof CustomerOrganization) { for (Employee employee : organization.getEmployeeDirectory().getEmployeeList()) { Customer customer = (Customer) employee; total += customer.getTotalUsageVolume(); } } } } } } if (total == 0) { JOptionPane.showMessageDialog(null, "No Customer has used water yet"); return; } DefaultPieDataset dataset = new DefaultPieDataset(); for (Network network : system.getNetworkList()) { for (Enterprise enterprise : network.getEnterpriseDirectory().getEnterpriseList()) { 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:gui.images.ImageHubExplorer.java
/** * This method sets the image of the specified index as the currently * selected image and updates all the views. * * @param index Integer that is the index of the image to select as the * current image./* w w w . j av a 2 s. com*/ */ private synchronized void setSelectedImageForIndex(int index) { try { // Update the selected image panels. BufferedImage photo = getPhoto(index); selectedImagePanelClassNeighborMain.setImage(photo); selectedImagePanelClassNeighbor.setImage(photo); selectedImagePanelClass.setImage(photo); selectedImagePanelSearch.setImage(photo); String shortPath = imgPaths.get(index).substring(workspace.getPath().length(), imgPaths.get(index).length()); // Update the labels with the new name. selectedImagePathLabelClassNeighborMain.setText(shortPath); selectedImagePathLabelClassNeighbor.setText(shortPath); selectedImagePathLabelClass.setText(shortPath); selectedImagePathLabelSearch.setText(shortPath); // Update the class colors. selectedImageLabelClassNeighborMain .setBackground(classColors[quantizedRepresentation.getLabelOf(index)]); selectedImageLabelClassNeighbor.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]); selectedImageLabelClass.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]); selectedImageLabelSearch.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]); // Refresh the display. selectedImageLabelClassNeighborMain.setOpaque(true); selectedImageLabelClassNeighbor.setOpaque(true); selectedImageLabelClass.setOpaque(true); selectedImageLabelSearch.setOpaque(true); selectedImageLabelClassNeighborMain.repaint(); selectedImageLabelClassNeighbor.repaint(); selectedImageLabelClass.repaint(); selectedImageLabelSearch.repaint(); // Update the history. if (selectedImageHistory == null) { selectedImageHistory = new ArrayList<>(200); selectedImageIndexInHistory = -1; } // Discard the future history. if (selectedImageIndexInHistory < selectedImageHistory.size() - 1) { for (int i = selectedImageHistory.size() - 1; i > selectedImageIndexInHistory; i--) { selectedImageHistory.remove(i); } } selectedImageHistory.add(index); selectedImageIndexInHistory = selectedImageHistory.size() - 1; // Update the nearest neighbors and the reverse nearest neighbors. NeighborSetFinder nsf = getNSF(); nnPanel.removeAll(); rnnPanel.removeAll(); nnPanel.revalidate(); nnPanel.repaint(); rnnPanel.revalidate(); rnnPanel.repaint(); int[][] kneighbors = nsf.getKNeighbors(); for (int neighborIndex = 0; neighborIndex < neighborhoodSize; neighborIndex++) { // Insert all the nearest neighbors to their panel. BufferedImage thumb = thumbnails.get(kneighbors[index][neighborIndex]); try { Thread t = new Thread(new SetImageNeighborsHelper(nnPanel, thumb, quantizedRepresentation.getLabelOf(kneighbors[index][neighborIndex]), kneighbors[index][neighborIndex])); t.start(); t.join(500); if (t.isAlive()) { t.interrupt(); } } catch (Throwable thr) { System.err.println(thr.getMessage()); } } // Insert all the reverse nearest neighbors to their panel. ArrayList<Integer>[] rrns = null; if (rnnSetsAllK != null) { rrns = rnnSetsAllK[neighborhoodSize - 1]; } if (rrns != null && rrns[index] != null && rrns[index].size() > 0) { for (int i = 0; i < rrns[index].size(); i++) { BufferedImage thumb = thumbnails.get(rrns[index].get(i)); try { Thread t = new Thread(new SetImageNeighborsHelper(rnnPanel, thumb, quantizedRepresentation.getLabelOf(rrns[index].get(i)), rrns[index].get(i))); t.start(); t.join(500); if (t.isAlive()) { t.interrupt(); } } catch (Throwable thr) { System.err.println(thr.getMessage()); } } } // Refresh the neighbor and reverse neighbor panels. nnPanel.revalidate(); nnPanel.repaint(); rnnPanel.revalidate(); rnnPanel.repaint(); // Visualize the neighbor occurrence profile of the selected image. DefaultPieDataset pieData = new DefaultPieDataset(); for (int c = 0; c < numClasses; c++) { pieData.setValue(classNames[c], occurrenceProfilesAllK[neighborhoodSize - 1][index][c]); } JFreeChart chart = ChartFactory.createPieChart3D("occurrence " + "profile", pieData, true, true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); PieRenderer prend = new PieRenderer(classColors); prend.setColor(plot, pieData); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(240, 200)); occProfileChartHolder.removeAll(); occProfileChartHolder.add(chartPanel); occProfileChartHolder.revalidate(); occProfileChartHolder.repaint(); } catch (Exception e) { System.err.println(e.getMessage()); } }
From source file:edu.ucla.stat.SOCR.chart.ChartGenerator_JTable.java
private JFreeChart createPieChart(String titleLabel, PieDataset dataset) { // System.out.println("rotation="+rotation); if (dimension.equalsIgnoreCase("3D")) { JFreeChart chart = ChartFactory.createPieChart3D(titleLabel, // chart title dataset, // data true, // include legend true, false);/*www .j a v a2 s . c o m*/ PiePlot3D plot = (PiePlot3D) chart.getPlot(); if (rotation.equalsIgnoreCase("clockwise")) { plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); Rotator rotator = new Rotator(plot); rotator.start(); } else if (rotation.equalsIgnoreCase("counter_clockwise")) { plot.setStartAngle(290); plot.setDirection(Rotation.ANTICLOCKWISE); Rotator rotator = new Rotator(plot); rotator.start(); } plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); return chart; } //end of 3D //2D ring if (rotation.equalsIgnoreCase("ring")) { JFreeChart chart = ChartFactory.createRingChart(titleLabel, // chart title dataset, // data false, // include legend true, false); RingPlot plot = (RingPlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; } //2D JFreeChart chart = ChartFactory.createPieChart(titleLabel, // chart title dataset, // data true, // include legend true, false); TextTitle title = chart.getTitle(); title.setToolTipText("A title tooltip!"); PiePlot plot = (PiePlot) chart.getPlot(); if (rotation.equalsIgnoreCase("clockwise")) { plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); Rotator rotator = new Rotator(plot); rotator.start(); } else if (rotation.equalsIgnoreCase("counter_clockwise")) { plot.setStartAngle(290); plot.setDirection(Rotation.ANTICLOCKWISE); Rotator rotator = new Rotator(plot); rotator.start(); } plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; }
From source file:gui.images.ImageHubExplorer.java
/** * This method sets the image of the specified history index as the * currently selected image and updates all the views. * * @param index Integer that is the history index of the image to select as * the current image.//from w w w .j a va 2s . co m */ private synchronized void setSelectedImageForHistoryIndex(int historyIndex) { // Update the selected image panels. BufferedImage photo = getPhoto(selectedImageHistory.get(historyIndex)); selectedImagePanelClassNeighborMain.setImage(photo); selectedImagePanelClassNeighbor.setImage(photo); selectedImagePanelClass.setImage(photo); selectedImagePanelSearch.setImage(photo); int index = selectedImageHistory.get(historyIndex); // Update the labels with the new name. String shortPath = imgPaths.get(index).substring(workspace.getPath().length(), imgPaths.get(index).length()); selectedImagePathLabelClassNeighborMain.setText(shortPath); selectedImagePathLabelClassNeighbor.setText(shortPath); selectedImagePathLabelClass.setText(shortPath); selectedImagePathLabelSearch.setText(shortPath); // Update the class colors. selectedImageLabelClassNeighborMain.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]); selectedImageLabelClassNeighbor.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]); selectedImageLabelClass.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]); selectedImageLabelSearch.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]); // Refresh the display. selectedImageLabelClassNeighborMain.setOpaque(true); selectedImageLabelClassNeighbor.setOpaque(true); selectedImageLabelClass.setOpaque(true); selectedImageLabelSearch.setOpaque(true); selectedImageLabelClassNeighborMain.repaint(); selectedImageLabelClassNeighbor.repaint(); selectedImageLabelClass.repaint(); selectedImageLabelSearch.repaint(); // Update the nearest neighbors and the reverse nearest neighbors. NeighborSetFinder nsf = getNSF(); nnPanel.removeAll(); rnnPanel.removeAll(); nnPanel.revalidate(); nnPanel.repaint(); rnnPanel.revalidate(); rnnPanel.repaint(); int[][] kneighbors = nsf.getKNeighbors(); for (int neighborIndex = 0; neighborIndex < neighborhoodSize; neighborIndex++) { BufferedImage thumb = thumbnails.get(kneighbors[index][neighborIndex]); try { Thread t = new Thread(new SetImageNeighborsHelper(nnPanel, thumb, quantizedRepresentation.getLabelOf(kneighbors[index][neighborIndex]), kneighbors[index][neighborIndex])); t.start(); t.join(500); if (t.isAlive()) { t.interrupt(); } } catch (Throwable thr) { System.err.println(thr.getMessage()); } } ArrayList<Integer>[] rrns = rnnSetsAllK[neighborhoodSize - 1]; if (rrns[index] != null && rrns[index].size() > 0) { for (int i = 0; i < rrns[index].size(); i++) { BufferedImage thumb = thumbnails.get(rrns[index].get(i)); try { Thread t = new Thread(new SetImageNeighborsHelper(rnnPanel, thumb, quantizedRepresentation.getLabelOf(rrns[index].get(i)), rrns[index].get(i))); t.start(); t.join(500); if (t.isAlive()) { t.interrupt(); } } catch (Throwable thr) { System.err.println(thr.getMessage()); } } } // Refresh the neighbor and reverse neighbor panels. nnPanel.revalidate(); nnPanel.repaint(); rnnPanel.revalidate(); rnnPanel.repaint(); // Visualize the neighbor occurrence profile of the selected image. DefaultPieDataset pieData = new DefaultPieDataset(); for (int c = 0; c < numClasses; c++) { pieData.setValue(classNames[c], occurrenceProfilesAllK[neighborhoodSize - 1][index][c]); } JFreeChart chart = ChartFactory.createPieChart3D("occurrence profile", pieData, true, true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); PieRenderer prend = new PieRenderer(classColors); prend.setColor(plot, pieData); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(240, 200)); occProfileChartHolder.removeAll(); occProfileChartHolder.add(chartPanel); occProfileChartHolder.revalidate(); occProfileChartHolder.repaint(); }