Example usage for java.awt Color magenta

List of usage examples for java.awt Color magenta

Introduction

In this page you can find the example usage for java.awt Color magenta.

Prototype

Color magenta

To view the source code for java.awt Color magenta.

Click Source Link

Document

The color magenta.

Usage

From source file:edu.harvard.mcz.imagecapture.PositionTemplateEditor.java

/**
 * This method initializes jPanel   //  w  ww. ja v  a 2 s  .c  o  m
 *    
 * @return javax.swing.JPanel   
 */
private JPanel getJPanel() {
    if (jPanel == null) {
        GridBagConstraints gridBagConstraints24 = new GridBagConstraints();
        gridBagConstraints24.fill = GridBagConstraints.BOTH;
        gridBagConstraints24.gridy = 10;
        gridBagConstraints24.weightx = 1.0;
        gridBagConstraints24.anchor = GridBagConstraints.WEST;
        gridBagConstraints24.gridx = 1;
        GridBagConstraints gridBagConstraints113 = new GridBagConstraints();
        gridBagConstraints113.gridx = 0;
        gridBagConstraints113.anchor = GridBagConstraints.EAST;
        gridBagConstraints113.gridy = 10;
        jLabel9 = new JLabel();
        jLabel9.setText("Taxon Name Barcode");
        GridBagConstraints gridBagConstraints23 = new GridBagConstraints();
        gridBagConstraints23.fill = GridBagConstraints.BOTH;
        gridBagConstraints23.gridy = 13;
        gridBagConstraints23.weightx = 1.0;
        gridBagConstraints23.anchor = GridBagConstraints.WEST;
        gridBagConstraints23.gridx = 1;
        GridBagConstraints gridBagConstraints112 = new GridBagConstraints();
        gridBagConstraints112.gridx = 0;
        gridBagConstraints112.gridy = 13;
        GridBagConstraints gridBagConstraints22 = new GridBagConstraints();
        gridBagConstraints22.fill = GridBagConstraints.BOTH;
        gridBagConstraints22.gridy = 12;
        gridBagConstraints22.weightx = 1.0;
        gridBagConstraints22.anchor = GridBagConstraints.WEST;
        gridBagConstraints22.gridx = 1;
        GridBagConstraints gridBagConstraints111 = new GridBagConstraints();
        gridBagConstraints111.gridx = 0;
        gridBagConstraints111.gridy = 12;
        GridBagConstraints gridBagConstraints110 = new GridBagConstraints();
        gridBagConstraints110.gridx = 1;
        gridBagConstraints110.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints110.gridwidth = 1;
        gridBagConstraints110.anchor = GridBagConstraints.NORTH;
        gridBagConstraints110.gridy = 14;
        jLabelFeedback = new JLabel();
        jLabelFeedback.setText(" ");
        GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
        gridBagConstraints21.fill = GridBagConstraints.BOTH;
        gridBagConstraints21.gridy = 0;
        gridBagConstraints21.weightx = 2.0;
        gridBagConstraints21.anchor = GridBagConstraints.NORTHWEST;
        gridBagConstraints21.gridx = 1;
        GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
        gridBagConstraints13.gridx = 0;
        gridBagConstraints13.anchor = GridBagConstraints.NORTHEAST;
        gridBagConstraints13.gridy = 0;
        jLabel8 = new JLabel();
        jLabel8.setText("ImageFile");
        GridBagConstraints gridBagConstraints18 = new GridBagConstraints();
        gridBagConstraints18.fill = GridBagConstraints.BOTH;
        gridBagConstraints18.gridy = 9;
        gridBagConstraints18.weightx = 1.0;
        gridBagConstraints18.anchor = GridBagConstraints.WEST;
        gridBagConstraints18.gridx = 1;
        GridBagConstraints gridBagConstraints17 = new GridBagConstraints();
        gridBagConstraints17.fill = GridBagConstraints.BOTH;
        gridBagConstraints17.gridy = 8;
        gridBagConstraints17.weightx = 1.0;
        gridBagConstraints17.anchor = GridBagConstraints.WEST;
        gridBagConstraints17.gridx = 1;
        GridBagConstraints gridBagConstraints16 = new GridBagConstraints();
        gridBagConstraints16.fill = GridBagConstraints.BOTH;
        gridBagConstraints16.gridy = 7;
        gridBagConstraints16.weightx = 1.0;
        gridBagConstraints16.anchor = GridBagConstraints.WEST;
        gridBagConstraints16.gridx = 1;
        GridBagConstraints gridBagConstraints15 = new GridBagConstraints();
        gridBagConstraints15.fill = GridBagConstraints.BOTH;
        gridBagConstraints15.gridy = 6;
        gridBagConstraints15.weightx = 1.0;
        gridBagConstraints15.anchor = GridBagConstraints.WEST;
        gridBagConstraints15.gridx = 1;
        GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
        gridBagConstraints14.fill = GridBagConstraints.BOTH;
        gridBagConstraints14.gridy = 5;
        gridBagConstraints14.weightx = 1.0;
        gridBagConstraints14.anchor = GridBagConstraints.WEST;
        gridBagConstraints14.gridx = 1;
        GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
        gridBagConstraints12.fill = GridBagConstraints.BOTH;
        gridBagConstraints12.gridy = 3;
        gridBagConstraints12.weightx = 1.0;
        gridBagConstraints12.anchor = GridBagConstraints.WEST;
        gridBagConstraints12.gridx = 1;
        GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
        gridBagConstraints11.gridx = 0;
        gridBagConstraints11.anchor = GridBagConstraints.EAST;
        gridBagConstraints11.gridy = 9;
        jLabel7 = new JLabel();
        jLabel7.setText("Specimen");
        jLabel7.setForeground(Color.ORANGE);
        GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
        gridBagConstraints10.gridx = 0;
        gridBagConstraints10.anchor = GridBagConstraints.EAST;
        gridBagConstraints10.gridy = 8;
        jLabel6 = new JLabel();
        jLabel6.setText("Tray Labels");
        jLabel6.setForeground(Color.CYAN);
        GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
        gridBagConstraints9.gridx = 0;
        gridBagConstraints9.anchor = GridBagConstraints.EAST;
        gridBagConstraints9.gridy = 7;
        jLabel5 = new JLabel();
        jLabel5.setText("Pin Labels");
        jLabel5.setForeground(Color.MAGENTA);
        GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
        gridBagConstraints8.gridx = 0;
        gridBagConstraints8.anchor = GridBagConstraints.EAST;
        gridBagConstraints8.insets = new Insets(0, 3, 0, 0);
        gridBagConstraints8.gridy = 6;
        jLabel4 = new JLabel();
        jLabel4.setText("Taxon Name Label");
        jLabel4.setForeground(Color.BLUE);
        GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
        gridBagConstraints7.gridx = 0;
        gridBagConstraints7.anchor = GridBagConstraints.EAST;
        gridBagConstraints7.gridy = 5;
        jLabel3 = new JLabel();
        jLabel3.setText("Barcode");
        jLabel3.setForeground(Color.RED);
        GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
        gridBagConstraints6.gridx = 0;
        gridBagConstraints6.anchor = GridBagConstraints.EAST;
        gridBagConstraints6.gridy = 3;
        jLabel2 = new JLabel();
        jLabel2.setText("Image Size");
        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
        gridBagConstraints5.fill = GridBagConstraints.BOTH;
        gridBagConstraints5.gridy = 2;
        gridBagConstraints5.weightx = 1.0;
        gridBagConstraints5.anchor = GridBagConstraints.WEST;
        gridBagConstraints5.gridx = 1;
        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
        gridBagConstraints4.fill = GridBagConstraints.BOTH;
        gridBagConstraints4.gridy = 1;
        gridBagConstraints4.weightx = 1.0;
        gridBagConstraints4.anchor = GridBagConstraints.WEST;
        gridBagConstraints4.gridx = 1;
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.gridx = 0;
        gridBagConstraints2.anchor = GridBagConstraints.EAST;
        gridBagConstraints2.gridy = 2;
        jLabel1 = new JLabel();
        jLabel1.setText("Name");
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.gridx = 0;
        gridBagConstraints1.anchor = GridBagConstraints.EAST;
        gridBagConstraints1.gridy = 1;
        jLabel = new JLabel();
        jLabel.setText("Template ID");
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 11;
        jPanel = new JPanel();
        jPanel.setLayout(new GridBagLayout());
        jPanel.add(getJButtonSave(), gridBagConstraints);
        jPanel.add(jLabel, gridBagConstraints1);
        jPanel.add(jLabel1, gridBagConstraints2);
        jPanel.add(getJTextFieldTemplateId(), gridBagConstraints4);
        jPanel.add(getJTextFieldName(), gridBagConstraints5);
        jPanel.add(jLabel2, gridBagConstraints6);
        jPanel.add(jLabel3, gridBagConstraints7);
        jPanel.add(jLabel4, gridBagConstraints8);
        jPanel.add(jLabel5, gridBagConstraints9);
        jPanel.add(jLabel6, gridBagConstraints10);
        jPanel.add(jLabel7, gridBagConstraints11);
        jPanel.add(getJTextField2(), gridBagConstraints12);
        jPanel.add(getJTextField3(), gridBagConstraints14);
        jPanel.add(getJTextField4(), gridBagConstraints15);
        jPanel.add(getJTextField5(), gridBagConstraints16);
        jPanel.add(getJTextField6(), gridBagConstraints17);
        jPanel.add(getJTextField7(), gridBagConstraints18);
        jPanel.add(jLabel8, gridBagConstraints13);
        jPanel.add(getJTextField8(), gridBagConstraints21);
        jPanel.add(jLabelFeedback, gridBagConstraints110);
        jPanel.add(getJButton(), gridBagConstraints111);
        jPanel.add(getJTextFieldBarcodeScan(), gridBagConstraints22);
        jPanel.add(getJButton1(), gridBagConstraints112);
        jPanel.add(getJTextField(), gridBagConstraints23);
        jPanel.add(jLabel9, gridBagConstraints113);
        jPanel.add(getJTextField9(), gridBagConstraints24);
    }
    return jPanel;
}

From source file:org.owasp.benchmark.score.report.ScatterHome.java

private void makeLegend(Set<Report> toolResults, double x, double y, XYSeriesCollection dataset,
        XYPlot xyplot) {/*w w  w . j av a 2 s  .co  m*/
    char ch = INITIAL_LABEL; // This is the first label in the Key with all the tools processed by this scorecard
    int i = -2; // Used to keep track of which row in the key were are processing. Helps calculate the Y axis
                // location where to put the Key entry

    boolean printedNonCommercialLabel = false;

    //non-commercial results
    for (Report r : toolResults) {
        OverallResults or = r.getOverallResults();
        if (!r.isCommercial()) {
            // print non-commercial label if there is at least one non-commercial tool
            if (!printedNonCommercialLabel) {
                XYTextAnnotation stroketext1 = new XYTextAnnotation("Non-Commercial", x, y + i * -3.3);
                stroketext1.setTextAnchor(TextAnchor.CENTER_LEFT);
                stroketext1.setBackgroundPaint(Color.white);
                stroketext1.setPaint(Color.black);
                stroketext1.setFont(theme.getRegularFont());
                xyplot.addAnnotation(stroketext1);
                i++;
                printedNonCommercialLabel = true;
            }

            // Special hack to make it line up better if the letter is an 'I' or 'i'
            String label = (ch == 'I' || ch == 'i' ? ch + ":  " : "" + ch + ": ");
            double score = or.getScore() * 100;
            String msg = "\u25A0 " + label + r.getToolNameAndVersion() + " (" + Math.round(score) + "%)";
            XYTextAnnotation stroketext3 = new XYTextAnnotation(msg, x, y + i * -3.3);
            stroketext3.setTextAnchor(TextAnchor.CENTER_LEFT);
            stroketext3.setBackgroundPaint(Color.white);
            stroketext3.setPaint(Color.blue);
            stroketext3.setFont(theme.getRegularFont());
            xyplot.addAnnotation(stroketext3);
            i++;
            // Weak hack if there are more than 26 tools scored. This will only get us to 52.
            if (ch == 'Z')
                ch = 'a';
            else
                ch++;
        }
    }

    //commercial tools
    double totalScore = 0;
    boolean printedCommercialLabel = false;
    int commercialToolCount = 0;

    for (Report r : toolResults) {

        OverallResults or = r.getOverallResults();
        if (r.isCommercial()) {

            // print commercial label if there is at least one commercial tool
            if (!printedCommercialLabel) {
                XYTextAnnotation stroketext = new XYTextAnnotation("Commercial", x, y + i * -3.3);
                stroketext.setTextAnchor(TextAnchor.CENTER_LEFT);
                stroketext.setBackgroundPaint(Color.white);
                stroketext.setPaint(Color.black);
                stroketext.setFont(theme.getRegularFont());
                xyplot.addAnnotation(stroketext);
                i++;
                printedCommercialLabel = true;
            }

            commercialToolCount++;
            // Special hack to make it line up better if the letter is an 'I' or 'i'
            String label = (ch == 'I' || ch == 'i' ? ch + ":  " : "" + ch + ": ");
            double score = or.getScore() * 100;
            if (!BenchmarkScore.showAveOnlyMode) {
                String msg = "\u25A0 " + label + r.getToolNameAndVersion() + " (" + Math.round(score) + "%)";
                XYTextAnnotation stroketext4 = new XYTextAnnotation(msg, x, y + i * -3.3);
                stroketext4.setTextAnchor(TextAnchor.CENTER_LEFT);
                stroketext4.setBackgroundPaint(Color.white);
                stroketext4.setPaint(Color.blue);
                stroketext4.setFont(theme.getRegularFont());
                xyplot.addAnnotation(stroketext4);
                i++;
                // Weak hack if there are more than 26 tools scored. This will only get us to 52.
                if (ch == 'Z')
                    ch = 'a';
                else
                    ch++;
            }
            totalScore += score;
        }
        if (r.getToolName().replace(' ', '_').equalsIgnoreCase(focus)) {
            OverallResults orc = r.getOverallResults();
            Point2D focusPoint = new Point2D.Double(orc.getFalsePositiveRate() * 100,
                    orc.getTruePositiveRate() * 100);
            Color green = new Color(0, 1, 0, 0.5f);
            makePoint(xyplot, focusPoint, 3, green);
        }
    }

    //commercial average
    if (commercialToolCount > 1 || (BenchmarkScore.showAveOnlyMode && commercialToolCount == 1)) {
        double averageScore = totalScore / commercialToolCount;
        XYTextAnnotation stroketext2 = new XYTextAnnotation(
                "\u25A0 " + ch + ": Commercial Average" + " (" + Math.round(averageScore) + "%)", x,
                y + i * -3.3);
        stroketext2.setTextAnchor(TextAnchor.CENTER_LEFT);
        stroketext2.setBackgroundPaint(Color.white);
        stroketext2.setPaint(Color.magenta);
        stroketext2.setFont(theme.getRegularFont());
        xyplot.addAnnotation(stroketext2);

        Point2D averagePoint = new Point2D.Double(afr * 100, atr * 100);
        makePoint(xyplot, averagePoint, 3, Color.magenta);
    }
}

From source file:mil.tatrc.physiology.utilities.csv.plots.MultiPlotter.java

protected void formatMultiPlot(PlotJob job, JFreeChart chart, XYSeriesCollection dataSet1,
        XYSeriesCollection dataSet2) {//  w  w w .  j  a  v  a  2  s. c o m
    Color[] blueColors = { Color.blue, Color.cyan, new Color(0, 160, 255), new Color(0, 100, 255),
            new Color(0, 160, 255), new Color(14, 0, 145), new Color(70, 105, 150) };
    Color[] redColors = { Color.red, Color.magenta, new Color(255, 0, 100), new Color(255, 0, 160), Color.pink,
            new Color(145, 0, 0), new Color(132, 58, 58) };
    Color[] variedColors = { Color.red, Color.blue, Color.green, Color.orange, Color.magenta, Color.cyan,
            Color.gray, new Color(255, 165, 0), new Color(42, 183, 136), new Color(87, 158, 186) };
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer1 = (XYLineAndShapeRenderer) plot.getRenderer();
    BasicStroke wideLine = new BasicStroke(2.0f);

    //For Scientific notation
    NumberFormat formatter = new DecimalFormat("0.######E0");

    for (int i = 0; i < plot.getDomainAxisCount(); i++) {
        plot.getDomainAxis(i).setLabelFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
        plot.getDomainAxis(i).setTickLabelFont(new Font("SansSerif", Font.PLAIN, 15));
        plot.getDomainAxis(i).setLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        plot.getDomainAxis(i).setTickLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
    }
    for (int i = 0; i < plot.getRangeAxisCount(); i++) {
        plot.getRangeAxis(i).setLabelFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
        plot.getRangeAxis(i).setTickLabelFont(new Font("SansSerif", Font.PLAIN, 15));
        plot.getRangeAxis(i).setLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        plot.getRangeAxis(i).setTickLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(i);
        rangeAxis.setNumberFormatOverride(formatter);
    }

    //White background outside of plottable area
    chart.setBackgroundPaint(job.bgColor);

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);

    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 15));
    chart.getTitle().setFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
    chart.getTitle().setPaint(job.bgColor == Color.red ? Color.white : Color.black);

    //If there is only one Y axis, we just need to color the data series differently
    if (job.Y2headers == null || job.Y2headers.isEmpty()) {
        for (int i = 0, cIndex = 0; i < dataSet1.getSeriesCount(); i++, cIndex++) {
            renderer1.setSeriesStroke(i, wideLine);
            renderer1.setBaseShapesVisible(false);
            if (cIndex > 9)
                cIndex = 0;
            renderer1.setSeriesFillPaint(i, variedColors[cIndex]);
            renderer1.setSeriesPaint(i, variedColors[cIndex]);
        }
    }
    //If there are 2 Y axes, we should color the axes to correspond with the data so it isn't (as) confusing
    else {
        StandardXYItemRenderer renderer2 = new StandardXYItemRenderer();
        plot.setRenderer(1, renderer2);

        for (int i = 0, cIndex = 0; i < dataSet1.getSeriesCount(); i++, cIndex++) {
            renderer1.setSeriesStroke(i, wideLine);
            renderer1.setBaseShapesVisible(false);
            if (cIndex > 6)
                cIndex = 0;
            renderer1.setSeriesFillPaint(i, redColors[cIndex]);
            renderer1.setSeriesPaint(i, redColors[cIndex]);
        }
        for (int i = 0, cIndex = 0; i < dataSet2.getSeriesCount(); i++, cIndex++) {
            renderer2.setSeriesStroke(i, wideLine);
            renderer2.setBaseShapesVisible(false);
            if (cIndex > 6)
                cIndex = 0;
            renderer2.setSeriesFillPaint(i, blueColors[cIndex]);
            renderer2.setSeriesPaint(i, blueColors[cIndex]);
        }
        plot.getRangeAxis(0).setLabelPaint(redColors[0]);
        plot.getRangeAxis(0).setTickLabelPaint(redColors[0]);
        plot.getRangeAxis(1).setLabelPaint(blueColors[0]);
        plot.getRangeAxis(1).setTickLabelPaint(blueColors[0]);
    }
}

From source file:hr.restart.util.chart.ChartXY.java

/**
 * Creates a BAR CHART//from w ww.ja  v a  2s  .  co m
 * @param dataset The org.jfree.data.CategoryDataset
 * @param title The title
 * @return org.jfree.chart.JFreeChart
 */
private JFreeChart createBarChart(final CategoryDataset dataset, String title, PlotOrientation orientation) {

    final JFreeChart chart = ChartFactory.createBarChart(title, // chart title
            "", // domain axis label
            "", // range axis label
            dataset, // data
            orientation, // the plot orientation
            false, // include legend
            true, false);

    chart.setBackgroundPaint(Color.white);

    // the subtitle from the combobox        
    if (jcb != null)
        chart.addSubtitle(new TextTitle(jcb.getSelectedItem().toString()));

    //subtitles setted by the user.
    if (getSubtitles() != null)
        for (int i = 0; i < getSubtitles().size(); i++) {
            chart.addSubtitle(new TextTitle(getSubtitles().get(i).toString()));
        }

    final Plot plot = chart.getPlot();

    // get a reference to the plot for further customisation...
    final CategoryPlot categoryPlot = (CategoryPlot) plot;

    categoryPlot.setNoDataMessage("NO DATA!");

    categoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    final CategoryItemRenderer renderer = new CustomRenderer(new Paint[] { Color.red, Color.blue, Color.green,
            Color.yellow, Color.orange, Color.cyan, Color.magenta, Color.blue });
    categoryPlot.setRenderer(renderer);

    renderer.setLabelGenerator(new StandardCategoryLabelGenerator());
    renderer.setItemLabelsVisible(true);

    // inside
    //renderer.setBaseItemLabelPaint(Color.white);
    Font font = new Font("SansSerif", Font.PLAIN, 7);
    Font derive = font.deriveFont(Font.BOLD);
    renderer.setBaseItemLabelFont(derive);

    // margin
    final CategoryAxis domainAxis = categoryPlot.getDomainAxis();
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    //domainAxis.setBottomCategoryLabelPosition(new CategoryLabelPosition(RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_CENTER));
    domainAxis.setCategoryLabelPositions(new CategoryLabelPositions(
            new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.TOP_CENTER), // TOP
            new CategoryLabelPosition(RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_CENTER), // BOTTOM
            new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT,
                    CategoryLabelWidthType.RANGE, 0.30f), // LEFT
            new CategoryLabelPosition(RectangleAnchor.RIGHT, TextBlockAnchor.CENTER_RIGHT,
                    CategoryLabelWidthType.RANGE, 0.30f) // RIGHT) 
    ));

    final ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER,
            TextAnchor.CENTER, 0.0);
    renderer.setPositiveItemLabelPosition(p);

    if (comboBoxOrientation != null) {
        if (comboBoxOrientation.getSelectedItem() == "Vertikalni") {

            domainAxis.setCategoryLabelPositions(
                    CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4.0));
        }
    }

    return chart;

}

From source file:org.owasp.benchmark.score.report.ScatterVulns.java

private void makeLegend(String category, Set<Report> toolResults, double x, double y,
        XYSeriesCollection dataset, XYPlot xyplot) {

    char ch = ScatterHome.INITIAL_LABEL;
    int i = -2;/*from   w w  w  .ja va  2 s.  c o m*/

    // non-commercial results
    boolean printedNonCommercialLabel = false;

    for (Report r : toolResults) {
        if (!r.isCommercial()) {
            // print non commercial label if there is at least one
            // non-commercial tool
            if (!printedNonCommercialLabel) {
                XYTextAnnotation stroketext1 = new XYTextAnnotation("Non-Commercial", x, y + i * -3.3);
                stroketext1.setTextAnchor(TextAnchor.CENTER_LEFT);
                stroketext1.setBackgroundPaint(Color.white);
                stroketext1.setPaint(Color.black);
                stroketext1.setFont(theme.getRegularFont());
                xyplot.addAnnotation(stroketext1);
                i++;
                printedNonCommercialLabel = true;
            }

            OverallResults or = r.getOverallResults();
            // Special hack to make it line up better if the letter is an 'I' or 'i'
            String label = (ch == 'I' || ch == 'i' ? ch + ":  " : "" + ch + ": ");
            double score = or.getResults(category).score * 100;
            String msg = "\u25A0 " + label + r.getToolNameAndVersion() + " (" + Math.round(score) + "%)";
            XYTextAnnotation stroketext3 = new XYTextAnnotation(msg, x, y + i * -3.3);
            stroketext3.setTextAnchor(TextAnchor.CENTER_LEFT);
            stroketext3.setBackgroundPaint(Color.white);
            stroketext3.setPaint(
                    r.getToolName().replace(' ', '_').equalsIgnoreCase(focus) ? Color.green : Color.blue);
            stroketext3.setFont(theme.getRegularFont());
            xyplot.addAnnotation(stroketext3);
            i++;
            // Weak hack if there are more than 26 tools scored. This will only get us to 52.
            if (ch == 'Z')
                ch = 'a';
            else
                ch++;
        }
    }

    // commercial tools
    boolean printedCommercialLabel = false;
    double commercialTotal = 0;

    for (Report r : toolResults) {
        OverallResults or = r.getOverallResults();
        if (r.isCommercial()) {

            // print commercial label if there is at least one commercial
            // tool
            if (!printedCommercialLabel) {
                XYTextAnnotation stroketext4 = new XYTextAnnotation("Commercial", x, y + i * -3.3);
                stroketext4.setTextAnchor(TextAnchor.CENTER_LEFT);
                stroketext4.setBackgroundPaint(Color.white);
                stroketext4.setPaint(Color.black);
                stroketext4.setFont(theme.getRegularFont());
                xyplot.addAnnotation(stroketext4);
                i++;
                printedCommercialLabel = true;
            }

            commercialToolCount++;
            double score = or.getResults(category).score * 100;
            // don't show the commercial tool results if in 'show ave only mode'
            if (!BenchmarkScore.showAveOnlyMode) {
                // Special hack to make it line up better if the letter is an 'I' or 'i'
                String label = (ch == 'I' || ch == 'i' ? ch + ":  " : "" + ch + ": ");
                String msg = "\u25A0 " + label + r.getToolNameAndVersion() + " (" + Math.round(score) + "%)";
                XYTextAnnotation stroketext4 = new XYTextAnnotation(msg, x, y + i * -3.3);
                stroketext4.setTextAnchor(TextAnchor.CENTER_LEFT);
                stroketext4.setBackgroundPaint(Color.white);
                stroketext4.setPaint(Color.blue);
                stroketext4.setFont(theme.getRegularFont());
                xyplot.addAnnotation(stroketext4);
                i++; // increment the location of the label
                // Weak hack if there are more than 26 tools scored. This will only get us to 52.
                if (ch == 'Z')
                    ch = 'a';
                else
                    ch++;
            }
            commercialTotal += score;

            if (score < commercialLow) {
                commercialLow = score;
                commercialLowToolType = r.getToolType();
            }
            if (score > commercialHigh) {
                commercialHigh = score;
                commercialHighToolType = r.getToolType();
            }
        }

        // Add color emphasis to the tool of focus
        if (r.getToolName().replace(' ', '_').equalsIgnoreCase(focus)) {
            OverallResult orc = r.getOverallResults().getResults(category);
            Point2D focusPoint = new Point2D.Double(orc.falsePositiveRate * 100, orc.truePositiveRate * 100);
            Color green = new Color(0, 1, 0, 0.5f);
            makePoint(xyplot, focusPoint, 3, green);
        }
    }

    // commercial average
    if (commercialToolCount > 1 || (BenchmarkScore.showAveOnlyMode && commercialToolCount == 1)) {
        commercialAve = commercialTotal / commercialToolCount;
        XYTextAnnotation stroketext2 = new XYTextAnnotation(
                "\u25A0 " + ch + ": Commercial Average" + " (" + Math.round(commercialAve) + "%)", x,
                y + i * -3.3);
        stroketext2.setTextAnchor(TextAnchor.CENTER_LEFT);
        stroketext2.setBackgroundPaint(Color.white);
        stroketext2.setPaint(Color.magenta);
        stroketext2.setFont(theme.getRegularFont());
        xyplot.addAnnotation(stroketext2);

        Point2D averagePoint = new Point2D.Double(afr * 100, atr * 100);
        Color red = new Color(1, 0, 0, 0.5f);
        makePoint(xyplot, averagePoint, 3, red);
    }
}

From source file:edu.fullerton.ldvservlet.SrcList.java

private PageItem makePlots(ArrayList<ChanSourceData> csdList, String name, Database db, Page vpage,
        ViewUser vuser, String contextPath) throws WebUtilException, LdvTableException {
    PageItemList ret = new PageItemList();
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Date/Time (UTC)"));
    plot.setGap(10.0);/*ww  w . j  av  a2s .  c o  m*/

    String baseName = "";
    StringBuilder errors = new StringBuilder();
    int plotNum = 0;
    Color[] colors = { Color.RED, Color.BLUE, Color.MAGENTA, Color.ORANGE, Color.DARK_GRAY, Color.GREEN };
    boolean gotData = false;
    TimeInterval timeRange = null;
    for (ChanSourceData csd : csdList) {
        TimeInterval ti = csd.getTimeRange();
        if (ti != null) {
            if (timeRange == null) {
                timeRange = ti;
            } else if (timeRange.overlaps(ti)) {
                timeRange = timeRange.mergeIntervals(ti);
            } else if (ti.getStartGps() < timeRange.getStartGps()) {
                timeRange.setStartGps(ti.getStartGps());
            } else if (ti.getStopGps() > timeRange.getStopGps()) {
                timeRange.setStopGps(ti.getStopGps());
            }
        }
    }
    if (timeRange != null) {
        for (ChanSourceData csd : csdList) {
            baseName = csd.getChanInfo().getBaseName();
            TimeSeriesCollection mtds = new TimeSeriesCollection();
            String server = csd.getChanInfo().getServer().replace(".caltech.edu", "");
            String legend = String.format("Type: %1$s at %2$s", csd.getChanInfo().getcType(), server);
            TimeSeries ts;
            double[][] data = csd.getGraphData();
            if (data == null) {
                data = new double[2][2];
                data[0][0] = timeRange.getStartGps();
                data[1][0] = timeRange.getStopGps();
                data[0][1] = data[1][1] = 0;
                errors.append("Error getting data for: ").append(legend).append("<br>");
            } else {
                gotData = true;
            }
            for (double[] d : data) {
                d[1] = d[1] <= 1 ? 1 : d[1];
            }
            ts = getTimeSeries(data, legend);

            mtds.addSeries(ts);
            XYAreaRenderer renderer = new XYAreaRenderer(XYAreaRenderer.AREA);

            BasicStroke str = new BasicStroke(2);
            int colorIdx = plotNum % colors.length;
            Color color = colors[colorIdx];
            NumberAxis yAxis = new NumberAxis("% Avail");
            yAxis.setRange(0, 100);
            renderer.setBaseFillPaint(color);
            renderer.setSeriesFillPaint(0, Color.WHITE);
            renderer.setBaseStroke(str);
            renderer.setUseFillPaint(true);
            XYPlot subplot = new XYPlot(mtds, null, yAxis, renderer);
            plot.add(subplot);

            plotNum++;
        }

        ChartPanel cpnl;
        JFreeChart chart;
        String gtitle = String.format("Available data for %1$s ", baseName);
        String subTitleTxt = String.format("From %1$s to %2$s",
                TimeAndDate.gpsAsUtcString(timeRange.getStartGps()),
                TimeAndDate.gpsAsUtcString(timeRange.getStopGps()));

        plot.setOrientation(PlotOrientation.VERTICAL);

        chart = new JFreeChart(gtitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true);

        chart.addSubtitle(new TextTitle(subTitleTxt));
        cpnl = new ChartPanel(chart, false, false, false, false, false);

        PluginSupport psupport = new PluginSupport();
        psupport.setup(db, vpage, vuser);
        int imgId;
        PageItemImage img = null;
        try {
            psupport.setSize(800, 600);
            imgId = psupport.saveImageAsPNG(cpnl);
            String url = String.format("%1$s/view?act=getImg&amp;imgId=%2$d", contextPath, imgId);

            img = new PageItemImage(url, "availability", baseName);

        } catch (SQLException | IOException | NoSuchAlgorithmException ex) {
            String ermsg = String.format("Error creating or saving image: %1$s - $2$s",
                    ex.getClass().getSimpleName(), ex.getLocalizedMessage());
            errors.append(ermsg);

        }
        if (errors.length() > 0) {
            ret.add(errors.toString());
        }
        if (img != null) {
            ret.add(img);
        }
    } else {
        ret.add("No data to plot.");
    }
    return ret;
}

From source file:edu.unibonn.kmeans.mapreduce.plotting.TimeSeriesPlotter_KMeans.java

private Paint getColor(int color_number) {
    Color curr_color = null;/*from  w ww.  j  a  v  a  2 s.c  o  m*/

    switch (color_number) {
    case 0:
        curr_color = Color.BLUE;
        break;
    case 1:
        curr_color = Color.GREEN;
        break;
    case 2:
        curr_color = Color.RED;
        break;
    case 3:
        curr_color = Color.PINK;
        break;
    case 4:
        curr_color = Color.MAGENTA;
        break;
    case 5:
        curr_color = Color.CYAN;
        break;
    case 6:
        curr_color = Color.DARK_GRAY;
        break;
    case 7:
        curr_color = Color.LIGHT_GRAY;
        break;
    case 8:
        curr_color = Color.YELLOW;
        break;
    case 9:
        curr_color = Color.ORANGE;
        break;
    case 10:
        curr_color = Color.BLACK;
        break;
    //           case 11: curr_color = Color.YELLOW;
    //                    break;
    //           case 12: curr_color = Color.BLACK;
    //                    break;
    //           case 13: curr_color = Color.BLACK;
    //                  break;
    //           case 14: curr_color = Color.BLACK;
    //                  break;
    //           case 15: curr_color = Color.BLACK;
    //                break;
    //           case 16: curr_color = Color.BLACK;
    //                break;
    //           case 17: curr_color = Color.BLACK;
    //                break;
    //           case 18: curr_color = Color.BLACK;
    //                break;
    //           case 20: curr_color = Color.BLACK;
    //                break;
    //           case 21: curr_color = Color.BLACK;
    //                break;
    //           case 22: curr_color = Color.BLACK;
    //                break;
    //           case 23: curr_color = Color.BLACK;
    //                break;
    default:
        curr_color = Color.WHITE;
        break;
    }

    return curr_color;
}

From source file:edu.ku.brc.specify.extras.ViewToSchemaReview.java

/**
 * // w  ww . ja v a2s  . c o  m
 */
public void checkSchemaAndViews() {

    Hashtable<String, HashSet<String>> viewFieldHash = new Hashtable<String, HashSet<String>>();

    SpecifyAppContextMgr sacm = (SpecifyAppContextMgr) AppContextMgr.getInstance();

    for (ViewIFace view : sacm.getEntirelyAllViews()) {
        //System.err.println(view.getName() + " ----------------------");
        for (AltViewIFace av : view.getAltViews()) {
            ViewDefIFace vd = av.getViewDef();
            if (vd.getType() == ViewType.form) {
                DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(vd.getClassName());
                if (ti != null) {
                    HashSet<String> tiHash = viewFieldHash.get(ti.getName());
                    if (tiHash == null) {
                        tiHash = new HashSet<String>();
                        viewFieldHash.put(ti.getName(), tiHash);
                    }

                    FormViewDef fvd = (FormViewDef) vd;
                    for (FormRowIFace row : fvd.getRows()) {
                        for (FormCellIFace cell : row.getCells()) {
                            if (cell.getType() == FormCellIFace.CellType.panel) {
                                FormCellPanelIFace panelCell = (FormCellPanelIFace) cell;
                                for (String fieldName : panelCell.getFieldNames()) {
                                    tiHash.add(fieldName);
                                }

                            } else if (cell.getType() == FormCellIFace.CellType.field
                                    || cell.getType() == FormCellIFace.CellType.subview) {
                                String fieldName = cell.getName();
                                if (!cell.isIgnoreSetGet() && !fieldName.equals("this")) {
                                    DBFieldInfo fi = ti.getFieldByName(fieldName);
                                    if (fi != null) {
                                        //System.err.println("Form Field["+fieldName+"] is in schema.");
                                        tiHash.add(fieldName);
                                    } else {
                                        DBRelationshipInfo ri = ti.getRelationshipByName(fieldName);
                                        if (ri == null) {
                                            //System.err.println("Form Field["+fieldName+"] not in table.");
                                        } else {
                                            tiHash.add(fieldName);
                                        }
                                    }
                                } else if (cell instanceof FormCellFieldIFace) {
                                    FormCellFieldIFace fcf = (FormCellFieldIFace) cell;
                                    if (fcf.getUiType() == FormCellFieldIFace.FieldType.plugin) {
                                        String pluginName = fcf.getProperty("name");
                                        if (StringUtils.isNotEmpty(pluginName)) {
                                            checkPluginForNames(fcf, pluginName, tiHash);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    for (DBTableInfo ti : DBTableIdMgr.getInstance().getTables()) {
        int cnt = 0;

        HashSet<String> tiHash = viewFieldHash.get(ti.getName());
        if (tiHash != null) {
            tblTitle2Name.put(ti.getTitle(), ti.getName());

            //System.err.println(ti.getName() + " ----------------------");
            for (DBFieldInfo fi : ti.getFields()) {
                Boolean isInForm = tiHash.contains(fi.getName());
                modelList.add(
                        createRow(ti.getTitle(), fi.getName(), fi.getTitle(), isInForm, fi.isHidden(), cnt++));
            }

            for (DBRelationshipInfo ri : ti.getRelationships()) {
                Boolean isInForm = tiHash.contains(ri.getName());
                modelList.add(
                        createRow(ti.getTitle(), ri.getName(), ri.getTitle(), isInForm, ri.isHidden(), cnt++));
            }
        }
    }

    viewModel = new ViewModel();
    JTable table = new JTable(viewModel);

    sorter = new TableRowSorter<TableModel>(viewModel);
    searchTF = new JAutoCompTextField(20);

    table.setRowSorter(sorter);

    CellConstraints cc = new CellConstraints();
    PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,4px,f:p:g,2px,p:g"));
    SearchBox searchBox = new SearchBox(searchTF, null);

    filterCBX = UIHelper.createComboBox(new String[] { "None", "Not On Form, Not Hidden", "On Form, Hidden" });

    PanelBuilder searchPB = new PanelBuilder(new FormLayout("p,2px,p, f:p:g, p,2px,p", "p"));
    searchPB.add(UIHelper.createI18NFormLabel("SEARCH"), cc.xy(1, 1));
    searchPB.add(searchBox, cc.xy(3, 1));
    searchPB.add(UIHelper.createI18NFormLabel("Filter"), cc.xy(5, 1));
    searchPB.add(filterCBX, cc.xy(7, 1));

    JLabel legend = UIHelper.createLabel(
            "<HTML><li><font color=\"red\">Red</font> - Not on form and not hidden</li><li><font color=\"magenta\">Magenta</font> - On the form , but is hidden</li><li>Black - Correct</li>");
    legend.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    PanelBuilder legPB = new PanelBuilder(new FormLayout("p,f:p:g", "p"));
    legPB.add(legend, cc.xy(1, 1));

    pb.add(searchPB.getPanel(), cc.xy(1, 1));
    pb.add(UIHelper.createScrollPane(table), cc.xy(1, 3));
    pb.add(legPB.getPanel(), cc.xy(1, 5));
    pb.setDefaultDialogBorder();

    sorter.setRowFilter(null);

    searchTF.getDocument().addDocumentListener(new DocumentAdaptor() {
        @Override
        protected void changed(DocumentEvent e) {
            SwingUtilities.invokeLater(new Runnable() {

                /* (non-Javadoc)
                 * @see java.lang.Runnable#run()
                 */
                @Override
                public void run() {
                    if (filterCBX.getSelectedIndex() > 0) {
                        blockCBXUpdate = true;
                        filterCBX.setSelectedIndex(-1);
                        blockCBXUpdate = false;
                    }
                    String text = searchTF.getText();
                    sorter.setRowFilter(text.isEmpty() ? null : RowFilter.regexFilter("^(?i)" + text, 0, 1));
                }
            });
        }
    });

    filterCBX.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    if (!blockCBXUpdate) {
                        RowFilter<TableModel, Integer> filter = null;
                        int inx = filterCBX.getSelectedIndex();
                        if (inx > 0) {
                            filter = filterCBX.getSelectedIndex() == 1 ? new NotOnFormNotHiddenRowFilter()
                                    : new OnFormIsHiddenRowFilter();
                        }
                        sorter.setRowFilter(filter);
                    }
                }
            });
        }
    });

    table.setDefaultRenderer(String.class, new BiColorTableCellRenderer(false));
    table.setDefaultRenderer(Boolean.class, new BiColorBooleanTableCellRenderer());
    table.getColumnModel().getColumn(0).setCellRenderer(new TitleCellFadeRenderer());
    table.getColumnModel().getColumn(3).setCellRenderer(new BiColorTableCellRenderer(true));
    table.getColumnModel().getColumn(2).setCellRenderer(new BiColorTableCellRenderer(false) {
        @SuppressWarnings("unchecked")
        @Override
        public Component getTableCellRendererComponent(JTable tableArg, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            JLabel lbl = (JLabel) super.getTableCellRendererComponent(tableArg, value, isSelected, hasFocus,
                    row, column);

            /*if (sorter.getRowFilter() != null)
            {
            System.out.println(" getRowCount:"+sorter.getModel().getRowCount());
            Pair<String, Integer> col1Pair = (Pair<String, Integer>)sorter.getModel().getValueAt(row, 0);
            rowData = modelList.get(col1Pair.second);
                    
            } else
            {
            rowData = modelList.get(row);
            }*/

            //System.out.println(" R2:"+row+"  "+rowData[0]+"/"+rowData[1]+" - "+rowData[3]+"|"+rowData[4]);
            if (value instanceof TableInfo) {
                TableInfo pair = (TableInfo) value;
                Object[] rowData = modelList.get(pair.getSecond());
                lbl.setText(rowData[0].toString());

            } else if (value instanceof Pair<?, ?>) {
                Pair<String, Integer> pair = (Pair<String, Integer>) value;
                Object[] rowData = modelList.get(pair.getSecond());

                boolean isOnForm = rowData[3] instanceof Boolean ? (Boolean) rowData[3]
                        : ((String) rowData[3]).equals("Yes");
                boolean isHidden = rowData[4] instanceof Boolean ? (Boolean) rowData[4]
                        : ((String) rowData[4]).equals("true");

                if (!isOnForm && !isHidden) {
                    lbl.setForeground(Color.RED);

                } else if (isOnForm && isHidden) {
                    lbl.setForeground(Color.MAGENTA);
                } else {
                    lbl.setForeground(Color.BLACK);
                }
                lbl.setText(pair.getFirst());
            } else {
                lbl.setText(value.toString());
            }
            return lbl;
        }

    });

    //UIHelper.makeTableHeadersCentered(table, false);
    UIHelper.calcColumnWidths(table, null);

    //Removing fix all button because fix() method is broken (bug #8087)...

    /*CustomDialog dlg = new CustomDialog((Frame)UIRegistry.getTopWindow(), "", true, CustomDialog.OKCANCELAPPLY, pb.getPanel()) 
    {
    @Override
    protected void applyButtonPressed()
    {
        fix(this);
    }
    };
    dlg.setApplyLabel("Fix All");*/

    CustomDialog dlg = new CustomDialog((Frame) UIRegistry.getTopWindow(), "", true, CustomDialog.OKCANCEL,
            pb.getPanel());

    //... end removing fix all button

    dlg.setVisible(true);

    if (!dlg.isCancelled()) {
        updateSchema();
    }
}

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//from   ww w.  j  a  v a2 s . c o 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:mil.tatrc.physiology.utilities.csv.plots.RespiratoryPFTPlotter.java

public void createGraph(PlotJob job, Map<String, List<Double>> PFTData, Map<String, List<Double>> data,
        List<LogEvent> events, List<SEAction> actions) {
    CSVPlotTool plotTool = new CSVPlotTool(); //to leverage existing functions
    String title = job.name + "_";
    XYSeriesCollection dataSet = new XYSeriesCollection();
    double maxY = 0;
    double minY = Double.MAX_VALUE;
    for (int i = 0; i < job.headers.size(); i++) {
        title = title + job.headers.get(i) + "_";
        XYSeries dataSeries;//from   w ww  .  j  a v  a 2 s . c  o m
        dataSeries = plotTool.createXYSeries(job.headers.get(i), data.get("Time(s)"),
                data.get(job.headers.get(i)));
        dataSet.addSeries(dataSeries);
        maxY = maxY < dataSeries.getMaxY() ? dataSeries.getMaxY() : maxY;
        minY = minY > dataSeries.getMinY() ? dataSeries.getMinY() : minY;
    }

    //Now make a data series for PFT data and check its max and min
    XYSeries dataSeries = plotTool.createXYSeries("PFT Total Lung Volume (mL)", PFTData.get("Time"),
            PFTData.get("Volume"));
    dataSet.addSeries(dataSeries);
    maxY = maxY < dataSeries.getMaxY() ? dataSeries.getMaxY() : maxY;
    minY = minY > dataSeries.getMinY() ? dataSeries.getMinY() : minY;

    title = title + "vs_Time";

    //Override the constructed title if desired
    if (job.titleOverride != null && !job.titleOverride.isEmpty()
            && !job.titleOverride.equalsIgnoreCase("None"))
        title = job.titleOverride;

    double rangeLength = maxY - minY;
    if (Math.abs(rangeLength) < 1e-6) {
        rangeLength = .01;
    }

    class AEEntry implements Comparable<AEEntry> {
        public String name;
        public List<Double> times = new ArrayList<Double>();
        public List<Double> YVals = new ArrayList<Double>();
        public String type = "";

        public int compareTo(AEEntry entry) {
            return times.get(0) < entry.times.get(0) ? -1 : times.get(0) > entry.times.get(0) ? 1 : 0;
        }
    }

    List<AEEntry> allActionsAndEvents = new ArrayList<AEEntry>();

    if (!job.skipAllEvents) {
        //Make points for each event
        //Treat each event like two points on the same vertical line
        for (LogEvent event : events) {
            boolean skip = false;

            for (String eventToSkip : job.eventOmissions) {
                if (event.text.contains(eventToSkip))
                    skip = true;
            }
            if (skip)
                continue;
            AEEntry entry = new AEEntry();

            entry.times.add(event.time.getValue());
            if (job.logAxis)
                entry.YVals.add(maxY);
            else if (job.forceZeroYAxisBound && maxY < 0)
                entry.YVals.add(-.01);
            else
                entry.YVals.add(maxY + 0.15 * rangeLength);

            entry.times.add(event.time.getValue());
            if (job.logAxis)
                entry.YVals.add(minY);
            else if (job.forceZeroYAxisBound && minY > 0)
                entry.YVals.add(-.01);
            else
                entry.YVals.add(minY - 0.15 * rangeLength);

            entry.name = event.text + "\r\nt=" + event.time.getValue();
            entry.type = "EVENT:";

            allActionsAndEvents.add(entry);
        }
    }

    if (!job.skipAllActions) {
        //Make similar entries for actions
        for (SEAction action : actions) {
            boolean skip = false;

            for (String actionToSkip : job.actionOmissions) {
                if (action.toString().contains(actionToSkip))
                    skip = true;
            }
            if (skip)
                continue;

            if (action.toString().contains("Advance Time"))
                continue;

            AEEntry entry = new AEEntry();

            entry.times.add(action.getScenarioTime().getValue());
            if (job.logAxis)
                entry.YVals.add(maxY);
            else if (job.forceZeroYAxisBound && maxY < 0)
                entry.YVals.add(-.01);
            else
                entry.YVals.add(maxY + 0.15 * rangeLength);

            entry.times.add(action.getScenarioTime().getValue());
            if (job.logAxis)
                entry.YVals.add(minY);
            else if (job.forceZeroYAxisBound && minY > 0)
                entry.YVals.add(-.01);
            else
                entry.YVals.add(minY - 0.15 * rangeLength);

            entry.name = action.toString() + "\r\nt=" + action.getScenarioTime().getValue();
            entry.type = "ACTION:";

            allActionsAndEvents.add(entry);
        }
    }

    //Sort the list
    Collections.sort(allActionsAndEvents);

    //Add a series for each entry
    for (AEEntry entry : allActionsAndEvents) {
        dataSet.addSeries(plotTool.createXYSeries(entry.type + entry.name, entry.times, entry.YVals));
    }

    //set labels
    String XAxisLabel = "Time(s)";
    String YAxisLabel = job.headers.get(0);

    JFreeChart chart = ChartFactory.createXYLineChart(
            job.titleOverride != null && job.titleOverride.equalsIgnoreCase("None") ? "" : title, // chart title
            XAxisLabel, // x axis label
            YAxisLabel, // y axis label
            dataSet, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    Log.info("Creating Graph " + title);
    XYPlot plot = (XYPlot) chart.getPlot();

    if (!job.logAxis) {
        // Determine Y range
        double resMax0 = maxY;
        double resMin0 = minY;
        if (Double.isNaN(resMax0) || Double.isNaN(resMin0))
            plot.getDomainAxis().setLabel("Range is NaN");
        if (DoubleUtils.isZero(resMin0))
            resMin0 = -0.000001;
        if (DoubleUtils.isZero(resMax0))
            resMax0 = 0.000001;
        if (job.forceZeroYAxisBound && resMin0 >= 0)
            resMin0 = -.000001;
        if (job.forceZeroYAxisBound && resMax0 <= 0)
            resMax0 = .000001;
        rangeLength = resMax0 - resMin0;
        ValueAxis yAxis = plot.getRangeAxis();
        if (rangeLength != 0)
            yAxis.setRange(resMin0 - 0.15 * rangeLength, resMax0 + 0.15 * rangeLength);//15% buffer so we can see top and bottom clearly           

        //Add another Y axis to the right side for easier reading
        ValueAxis rightYAxis = new NumberAxis();
        rightYAxis.setRange(resMin0 - 0.15 * rangeLength, resMax0 + 0.15 * rangeLength);
        rightYAxis.setLabel("");

        //Override the bounds if desired
        try {
            if (job.Y1LowerBound != null) {
                yAxis.setLowerBound(job.Y1LowerBound);
                rightYAxis.setLowerBound(job.Y1LowerBound);
            }
            if (job.Y1UpperBound != null) {
                yAxis.setUpperBound(job.Y1UpperBound);
                rightYAxis.setUpperBound(job.Y1UpperBound);
            }
        } catch (Exception e) {
            Log.error(
                    "Couldn't set Y bounds. You probably tried to set a bound on an axis that doesn't exist.");
        }
        plot.setRangeAxis(0, yAxis);
        plot.setRangeAxis(1, rightYAxis);

    } else {
        double resMin = minY;
        double resMax = maxY;
        if (resMin <= 0.0)
            resMin = .00001;
        LogarithmicAxis yAxis = new LogarithmicAxis("Log(" + YAxisLabel + ")");
        LogarithmicAxis rightYAxis = new LogarithmicAxis("");
        yAxis.setLowerBound(resMin);
        rightYAxis.setLowerBound(resMin);
        yAxis.setUpperBound(resMax);
        rightYAxis.setUpperBound(resMax);

        //Override the bounds if desired
        try {
            if (job.Y1LowerBound != null) {
                yAxis.setLowerBound(job.Y1LowerBound);
                rightYAxis.setLowerBound(job.Y1LowerBound);
            }
            if (job.Y1UpperBound != null) {
                yAxis.setUpperBound(job.Y1UpperBound);
                rightYAxis.setUpperBound(job.Y1UpperBound);
            }
        } catch (Exception e) {
            Log.error(
                    "Couldn't set Y bounds. You probably tried to set a bound on an axis that doesn't exist.");
        }
        plot.setRangeAxis(0, yAxis);
        plot.setRangeAxis(1, rightYAxis);
    }

    //Override X bounds if desired
    try {
        if (job.X1LowerBound != null)
            plot.getDomainAxis(0).setLowerBound(job.X1LowerBound);
        if (job.X1UpperBound != null)
            plot.getDomainAxis(0).setUpperBound(job.X1UpperBound);
    } catch (Exception e) {
        Log.error("Couldn't set X bounds. You probably tried to set a bound on an axis that doesn't exist.");
    }

    //Override labels if desired
    if (job.X1Label != null && !plot.getDomainAxis(0).getLabel().contains("NaN"))
        plot.getDomainAxis(0).setLabel(job.X1Label.equalsIgnoreCase("None") ? "" : job.X1Label);
    if (job.Y1Label != null)
        plot.getRangeAxis(0).setLabel(job.Y1Label.equalsIgnoreCase("None") ? "" : job.Y1Label);

    formatRPFTPlot(job, chart);
    plot.setDomainGridlinesVisible(job.showGridLines);
    plot.setRangeGridlinesVisible(job.showGridLines);

    //Changing line widths and colors
    XYItemRenderer r = plot.getRenderer();
    BasicStroke wideLine = new BasicStroke(2.0f);
    Color[] AEcolors = { Color.red, Color.green, Color.black, Color.magenta, Color.orange };
    Color[] dataColors = { Color.blue, Color.cyan, Color.gray, Color.black, Color.red };
    for (int i = 0, cIndex = 0; i < dataSet.getSeriesCount(); i++, cIndex++) {
        r.setSeriesStroke(i, wideLine);
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
        renderer.setBaseShapesVisible(false);
        if (cIndex > 4)
            cIndex = 0;
        if (i < job.headers.size()) //Our actual data
        {
            renderer.setSeriesFillPaint(i, dataColors[cIndex]);
            renderer.setSeriesPaint(i, dataColors[cIndex]);
        } else //actions and events in procession of other colors
        {
            renderer.setSeriesFillPaint(i, AEcolors[cIndex]);
            renderer.setSeriesPaint(i, AEcolors[cIndex]);
        }
    }

    //Split the auto-generated legend into two legends, one for data and one for actions and events
    LegendItemCollection originalLegendCollection = plot.getLegendItems();
    final LegendItemCollection dataLegendCollection = new LegendItemCollection();
    int i;
    for (i = 0; i < job.headers.size() && i < originalLegendCollection.getItemCount(); i++) {
        if (originalLegendCollection.get(i).getLabel().startsWith("ACTION")
                || originalLegendCollection.get(i).getLabel().startsWith("EVENT"))
            break;
        dataLegendCollection.add(originalLegendCollection.get(i));
    }
    final LegendItemCollection remainingLegendCollection = new LegendItemCollection();
    for (; i < originalLegendCollection.getItemCount(); i++) {
        remainingLegendCollection.add(originalLegendCollection.get(i));
    }
    chart.removeLegend();
    LegendItemSource source = new LegendItemSource() {
        LegendItemCollection lic = new LegendItemCollection();
        {
            lic.addAll(dataLegendCollection);
        }

        public LegendItemCollection getLegendItems() {
            return lic;
        }
    };
    LegendTitle dataLegend = new LegendTitle(source);
    dataLegend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    dataLegend.setBorder(2, 2, 2, 2);
    dataLegend.setBackgroundPaint(Color.white);
    dataLegend.setPosition(RectangleEdge.TOP);
    dataLegend.setItemFont(new Font("SansSerif", Font.PLAIN, 22));
    chart.addLegend(dataLegend);

    source = new LegendItemSource() {
        LegendItemCollection lic = new LegendItemCollection();
        {
            lic.addAll(remainingLegendCollection);
        }

        public LegendItemCollection getLegendItems() {
            return lic;
        }
    };
    LegendTitle actionEventsLegend = new LegendTitle(source);
    actionEventsLegend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    actionEventsLegend.setBorder(2, 2, 2, 2);
    actionEventsLegend.setBackgroundPaint(Color.white);
    actionEventsLegend.setPosition(RectangleEdge.BOTTOM);
    actionEventsLegend.setItemFont(new Font("SansSerif", Font.PLAIN, 22));
    if (!job.hideAELegend && !job.removeAllLegends)
        chart.addLegend(actionEventsLegend);

    if (job.removeAllLegends)
        chart.removeLegend();

    int verticalPixels = 800 + 170 * (allActionsAndEvents.size() / 5);

    try {
        FileUtils.createDirectory(job.outputDir);
        String filename = job.outputFilename == null
                ? job.outputDir + "/" + plotTool.MakeFileName(title) + ".jpg"
                : job.outputDir + "/" + job.outputFilename;
        if (!filename.endsWith(".jpg"))
            filename = filename + ".jpg";
        File JPGFile = new File(filename);
        if (job.imageHeight != null && job.imageWidth != null)
            ChartUtilities.saveChartAsJPEG(JPGFile, chart, job.imageWidth, job.imageHeight);
        else if (!job.hideAELegend && !job.removeAllLegends)
            ChartUtilities.saveChartAsJPEG(JPGFile, chart, 1600, verticalPixels);
        else
            ChartUtilities.saveChartAsJPEG(JPGFile, chart, 1600, 800);
    } catch (IOException e) {
        Log.error(e.getMessage());
    }
}