Example usage for org.jfree.chart ChartFactory createBarChart3D

List of usage examples for org.jfree.chart ChartFactory createBarChart3D

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory createBarChart3D.

Prototype

public static JFreeChart createBarChart3D(String title, String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) 

Source Link

Document

Creates a bar chart with a 3D effect.

Usage

From source file:keel.GraphInterKeel.datacf.visualizeData.VisualizePanelAttribute.java

private void infoAttribute() {
    this.enabledTable(true);
    // Extended info about selected attribute
    if (((VisualizePanel) this.getParent().getParent()).getData()
            .getAttributeTypeIndex(this.tableInfojTable.getSelectedRow()).equals("nominal")) {
        this.valuesjScrollPane.setEnabled(true);
        this.valuesjScrollPane.setVisible(true);
        this.valuesjTextPane.setEnabled(true);
        this.valuesjTextPane.setVisible(true);

        Vector r = ((VisualizePanel) this.getParent().getParent()).getData()
                .getRangesVar(((VisualizePanel) this.getParent().getParent()).getData()
                        .getAttributeIndex(this.tableInfojTable.getSelectedRow()));

        this.valuesjTextPane.setText("");
        this.valueAveragejLabel.setText("");
        this.valueVariancejLabel.setText("");
        this.valueRankjLabelIzdo.setText("  ");
        this.valueRankjLabelDcho.setText("  ");

        String cadena = new String();
        for (int i = 0; i < r.size(); i++) {
            if (i == 0) {
                cadena = r.elementAt(i).toString() + "";
                this.valuesjTextPane.setText(cadena);
            } else {
                cadena = this.valuesjTextPane.getText() + "\n" + r.elementAt(i).toString();
            }/*from  ww w .  j  a v  a 2  s .  c  o  m*/
            this.valuesjTextPane.setText(cadena);
        }
        boolean legend = false;
        // Draw bar chart
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        try {
            for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) {
                String column = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                        this.tableInfojTable.getSelectedRow());
                String row = "";
                if (((VisualizePanel) this.getParent().getParent()).getOutAttribute() != -1
                        && this.tableInfojTable
                                .getSelectedRow() != ((VisualizePanel) this.getParent().getParent())
                                        .getOutAttribute()) {
                    row = "Class " + ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                            ((VisualizePanel) this.getParent().getParent()).getOutAttribute());
                    legend = true;
                }

                if (column != null) {
                    if (dataset.getRowIndex(row) == -1 || ((dataset.getColumnIndex(column) == -1))) {
                        dataset.addValue(1.0, row, column);
                    } else {
                        dataset.incrementValue(1.0, row, column);
                    }
                }
            }
        } catch (ArrayIndexOutOfBoundsException exp) {
            JOptionPane.showMessageDialog(this,
                    "The data set contains some errors. This attribute can not be visualized", "Error", 2);
        }

        this.chart = ChartFactory.createBarChart3D("", "", "", dataset, PlotOrientation.VERTICAL, legend, false,
                false);

        this.chart.setBackgroundPaint(new Color(0xFFFFFF));
        //BufferedImage image = this.chart.createBufferedImage(210, 140);
        BufferedImage image = this.chart.createBufferedImage(400, 240);
        this.imagejLabel.setIcon(new ImageIcon(image));
        this.clickToExpandjLabel.setVisible(true);
    } else {
        this.valuesjScrollPane.setEnabled(false);
        this.valuesjScrollPane.setVisible(false);
        this.valuesjTextPane.setEnabled(false);
        this.valuesjTextPane.setVisible(false);
        Vector r = ((VisualizePanel) this.getParent().getParent()).getData()
                .getRangesVar(((VisualizePanel) this.getParent().getParent()).getData()
                        .getAttributeIndex(this.tableInfojTable.getSelectedRow()));
        this.valueRankjLabelIzdo.setText(r.elementAt(0).toString());
        this.valueRankjLabelDcho.setText(r.elementAt(1).toString());

        // Average
        double m = 0.0;
        for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) {
            String valor = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                    this.tableInfojTable.getSelectedRow());
            if (valor != null) {
                m += Double.valueOf(valor).doubleValue();
            }
        }
        m = m / ((VisualizePanel) this.getParent().getParent()).getData().getNData();
        DecimalFormat df = new DecimalFormat();
        df.setMaximumFractionDigits(3);
        this.valueAveragejLabel.setText(df.format(m));
        // Variance
        double v = 0.0;
        for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) {
            String valor = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                    this.tableInfojTable.getSelectedRow());
            if (valor != null) {
                v += Math.pow(Double.valueOf(valor).doubleValue() - m, 2);
            }
        }
        v = v / (((VisualizePanel) this.getParent().getParent()).getData().getNData() - 1);
        this.valueVariancejLabel.setText(df.format(v));

        // Draw scatter plot
        XYSeriesCollection juegoDatos = new XYSeriesCollection();
        boolean legend = false;
        if (((VisualizePanel) this.getParent().getParent()).getOutAttribute() != -1) {
            Vector outputRang = ((VisualizePanel) this.getParent().getParent()).getData()
                    .getRange(((VisualizePanel) this.getParent().getParent()).getOutAttribute());
            XYSeries series[] = new XYSeries[outputRang.size()];
            for (int i = 0; i < outputRang.size(); i++) {
                series[i] = new XYSeries("Class " + outputRang.elementAt(i));
                juegoDatos.addSeries(series[i]);
            }
            for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) {
                int clase = outputRang.indexOf(((VisualizePanel) this.getParent().getParent()).getData()
                        .getDataIndex(i, ((VisualizePanel) this.getParent().getParent()).getOutAttribute()));
                String valor = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                        this.tableInfojTable.getSelectedRow());
                if (valor != null) {
                    series[clase].add(Double.parseDouble(Integer.toString(i)),
                            Double.valueOf(valor).doubleValue());
                }
            }
            legend = true;
        } else {
            XYSeries series = new XYSeries("Regresin");
            juegoDatos.addSeries(series);
            for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) {
                String valor = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                        this.tableInfojTable.getSelectedRow());
                if (valor != null) {
                    series.add(Double.parseDouble(Integer.toString(i)), Double.valueOf(valor).doubleValue());
                }
            }

        }

        chart = ChartFactory.createScatterPlot("", "", "", juegoDatos, PlotOrientation.VERTICAL, legend, false,
                false);
        chart.setBackgroundPaint(new Color(0xFFFFFF));
        //BufferedImage image = chart.createBufferedImage(210, 140);
        BufferedImage image = chart.createBufferedImage(400, 240);
        this.imagejLabel.setIcon(new ImageIcon(image));
        this.clickToExpandjLabel.setVisible(true);
    }
}

From source file:hudson.plugins.plot.Plot.java

/**
 * Creates a Chart of the style indicated by getEffStyle() using the given
 * dataset. Defaults to using createLineChart.
 *//*w  ww  .  j ava2  s .  c  om*/
private JFreeChart createChart(PlotCategoryDataset dataset) {
    String s = getUrlStyle();
    if ("area".equalsIgnoreCase(s)) {
        return ChartFactory.createAreaChart(getURLTitle(), /*
                                                            * categoryAxisLabel=
                                                            */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("bar".equalsIgnoreCase(s)) {
        return ChartFactory.createBarChart(getURLTitle(), /*
                                                           * categoryAxisLabel=
                                                           */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("bar3d".equalsIgnoreCase(s)) {
        return ChartFactory.createBarChart3D(getURLTitle(), /*
                                                             * categoryAxisLabel
                                                             * =
                                                             */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("line3d".equalsIgnoreCase(s)) {
        return ChartFactory.createLineChart3D(getURLTitle(), /*
                                                              * categoryAxisLabel
                                                              * =
                                                              */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("lineSimple".equalsIgnoreCase(s)) {
        return ChartFactory.createLineChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }

    if ("stackedarea".equalsIgnoreCase(s)) {
        return ChartFactory.createStackedAreaChart(getURLTitle(), /*
                                                                   * categoryAxisLabel
                                                                   * =
                                                                   */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("stackedbar".equalsIgnoreCase(s)) {
        return ChartFactory.createStackedBarChart(getURLTitle(), /*
                                                                  * categoryAxisLabel
                                                                  * =
                                                                  */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("stackedbar3d".equalsIgnoreCase(s)) {
        return ChartFactory.createStackedBarChart3D(getURLTitle(), /*
                                                                    * categoryAxisLabel
                                                                    * =
                                                                    */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("waterfall".equalsIgnoreCase(s)) {
        return ChartFactory.createWaterfallChart(getURLTitle(), /*
                                                                 * categoryAxisLabel
                                                                 * =
                                                                 */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    return ChartFactory.createLineChart(getURLTitle(), /* categoryAxisLabel= */
            null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /* tooltips= */true,
            /* url= */false);
}

From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java

protected JFreeChart createBar3DChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createBarChart3D(
            evaluateTextExpression(getChart().getTitleExpression()),
            evaluateTextExpression(((JRBar3DPlot) getPlot()).getCategoryAxisLabelExpression()),
            evaluateTextExpression(((JRBar3DPlot) getPlot()).getValueAxisLabelExpression()),
            (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(),
            true, false);/* w w w .j  ava  2 s  .  c  o m*/

    configureChart(jfreeChart);

    CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot();
    JRBar3DPlot bar3DPlot = (JRBar3DPlot) getPlot();

    BarRenderer3D barRenderer3D = new BarRenderer3D(
            bar3DPlot.getXOffsetDouble() == null ? BarRenderer3D.DEFAULT_X_OFFSET
                    : bar3DPlot.getXOffsetDouble(),
            bar3DPlot.getYOffsetDouble() == null ? BarRenderer3D.DEFAULT_Y_OFFSET
                    : bar3DPlot.getYOffsetDouble());

    boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels();
    barRenderer3D.setBaseItemLabelsVisible(isShowLabels);
    if (isShowLabels) {
        JRItemLabel itemLabel = bar3DPlot.getItemLabel();

        barRenderer3D.setBaseItemLabelFont(
                fontUtil.getAwtFont(getFont(itemLabel == null ? null : itemLabel.getFont()), getLocale()));

        if (itemLabel != null) {
            if (itemLabel.getColor() != null) {
                barRenderer3D.setBaseItemLabelPaint(itemLabel.getColor());
            } else {
                barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor());
            }
            //            categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor());
            //            if (itemLabel.getMask() != null)
            //            {
            //               barRenderer3D.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
            //                     StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, 
            //                     new DecimalFormat(itemLabel.getMask())));
            //            }
            //            else
            //            {
            barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator());
            //            }
        } else {
            barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator());
            barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor());
        }
    }

    categoryPlot.setRenderer(barRenderer3D);

    // Handle the axis formating for the category axis
    configureAxis(categoryPlot.getDomainAxis(), bar3DPlot.getCategoryAxisLabelFont(),
            bar3DPlot.getCategoryAxisLabelColor(), bar3DPlot.getCategoryAxisTickLabelFont(),
            bar3DPlot.getCategoryAxisTickLabelColor(), bar3DPlot.getCategoryAxisTickLabelMask(),
            bar3DPlot.getCategoryAxisVerticalTickLabels(), bar3DPlot.getCategoryAxisLineColor(), false,
            (Comparable<?>) evaluateExpression(bar3DPlot.getDomainAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(bar3DPlot.getDomainAxisMaxValueExpression()));

    // Handle the axis formating for the value axis
    configureAxis(categoryPlot.getRangeAxis(), bar3DPlot.getValueAxisLabelFont(),
            bar3DPlot.getValueAxisLabelColor(), bar3DPlot.getValueAxisTickLabelFont(),
            bar3DPlot.getValueAxisTickLabelColor(), bar3DPlot.getValueAxisTickLabelMask(),
            bar3DPlot.getValueAxisVerticalTickLabels(), bar3DPlot.getValueAxisLineColor(), true,
            (Comparable<?>) evaluateExpression(bar3DPlot.getRangeAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(bar3DPlot.getRangeAxisMaxValueExpression()));

    return jfreeChart;
}

From source file:UserInterface.FinanceRole.DonateToPoorPeopleJPanel.java

private void populateTransactionTable(Person objPerson) {

    //Chart/*w  ww  .  j a  va 2s .  c o  m*/
    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();

    //Table
    DefaultTableModel dtm = (DefaultTableModel) donationHistoryJTable.getModel();
    dtm.setRowCount(0);

    if (objPerson != null) {
        for (Transaction objTransaction : objPerson.getObjPoorPeopleTransactionDirectory()
                .getTransactionList()) {

            if (objTransaction.getTransactionSource()
                    .equals(Transaction.TransactionSourceType.FromWorldEnterprise.getValue())) {

                Object row[] = new Object[3];
                row[0] = objTransaction;
                row[1] = "$ " + objTransaction.getTransactionBDAmount();
                row[2] = objTransaction.getTransactionDateToDisplay();

                dtm.addRow(row);

                dataSet.setValue(objTransaction.getTransactionBDAmount(), "Amount",
                        objTransaction.getTransactionDateToDisplay());
            }
        }

        JFreeChart chart = ChartFactory.createBarChart3D("Overview of entire Transaction", "Transaction Date",
                "Amount in USD $", dataSet, PlotOrientation.VERTICAL, false, true, false);

        CategoryPlot plot = chart.getCategoryPlot();
        plot.setRangeGridlinePaint(Color.black);

        ChartPanel myChart = new ChartPanel(chart);
        transferDetailsJPanel.setLayout(new java.awt.BorderLayout());
        transferDetailsJPanel.add(myChart, BorderLayout.CENTER);
        transferDetailsJPanel.validate();

        transferDetailsJPanel.setVisible(true);
    } else {

        transferDetailsJPanel.setVisible(false);

    }
}

From source file:org.apache.jmeter.visualizers.CreateReport.java

/**
 * Creates a table; widths are set with setWidths().
 * @return a PdfPTable//from ww  w .  j a  v  a 2s.  c o  m
 * @throws DocumentException
 */

//createGraphs("Average Response Time of samples for each Request","Average(ms)",2);
public Image createGraphs(String chartName, String colName, int colNo) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (int i = 0; i < model.getRowCount(); i++)
        dataset.setValue((long) model.getValueAt(i, colNo), "Average", model.getValueAt(i, 0).toString());
    ChartFactory.setChartTheme(StandardChartTheme.createDarknessTheme());

    final JFreeChart chart = ChartFactory.createBarChart3D(chartName, // chart title
            "Requests", // domain axis label

            "Average (ms)", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    final CategoryPlot plot = chart.getCategoryPlot();
    final CategoryAxis axis = plot.getDomainAxis();
    axis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 8.0));
    final BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setMaximumBarWidth(0.05);

    try {
        //java.io.OutputStream out= new OutputStream(new FileOutputStream(BASEPATH+"//MyFile.jpg"));
        ChartUtilities.saveChartAsJPEG(new File(BASEPATH + "//MyFile.jpg"), chart, 500, 400);
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    Image img = null;
    try {
        img = Image.getInstance(BASEPATH + "//MyFile.jpg");
    } catch (BadElementException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return img;
}

From source file:userinterface.PatientRole.PatientWorkAreaJPanel.java

private void btnViewBarsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewBarsActionPerformed

    if (patient.vitalSignHistory.getVitalSignHistory().size() > 0) {

        String legend = null;/*from   w w  w .j  av a 2s  .co m*/
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        for (VitalSign vs : patient.vitalSignHistory.getVitalSignHistory()) {

            /*if(vs.getState().equalsIgnoreCase("ABNORMAL"))
            legend=vs.getTimestamp().concat(" (" +vs.getState()+")");
            else*/
            legend = vs.getTimestamp();

            dataset.addValue(vs.getRespiratoryRate(), legend, "Respiratory Rate");
            dataset.addValue(vs.getHeartRate(), legend, "Heart Rate");
            dataset.addValue(vs.getSystolicBloodPressure(), legend, "Blood Pressure");
            dataset.addValue(vs.getWeight(), legend, "Weight");

        }

        JFreeChart chart = ChartFactory.createBarChart3D("Vital Signs", "Vital Signs", "Values", dataset,
                PlotOrientation.VERTICAL, true, true, true);
        CategoryPlot P = chart.getCategoryPlot();
        P.setRangeGridlinePaint(Color.BLACK);

        ChartFrame frame = new ChartFrame("Bar Charts", chart);
        frame.setVisible(true);
        frame.setSize(650, 550);

    } else {
        JOptionPane.showMessageDialog(null, "There's no Vital Sign reported for this patient");
        return;
    }

}

From source file:msi.gama.outputs.layers.ChartLayerStatement.java

private void createChart(final IScope scope) {
    switch (type) {
    case SERIES_CHART: {
        chart = ChartFactory.createXYLineChart(getName(), "time", "", null, PlotOrientation.VERTICAL, true,
                false, false);// w  w w . j  a  va  2 s  .  co  m
        break;
    }
    case PIE_CHART: {
        if (style.equals(IKeyword.THREE_D)) {
            chart = ChartFactory.createPieChart3D(getName(), null, false, true, false);
        } else if (style.equals(IKeyword.RING)) {
            chart = ChartFactory.createRingChart(getName(), null, false, true, false);
        } else if (style.equals(IKeyword.EXPLODED)) {
            chart = ChartFactory.createPieChart(getName(), null, false, true, false);
            exploded = true;
        } else {
            chart = ChartFactory.createPieChart(getName(), null, false, true, false);
        }
        break;
    }
    case HISTOGRAM_CHART: {
        if (style.equals(IKeyword.THREE_D)) {
            chart = ChartFactory.createBarChart3D(getName(), null, null, null, PlotOrientation.VERTICAL, true,
                    true, false);
        } else if (style.equals(IKeyword.STACK)) {
            chart = ChartFactory.createStackedBarChart(getName(), null, null, null, PlotOrientation.VERTICAL,
                    true, true, false);
        } else {
            chart = ChartFactory.createBarChart(getName(), null, null, null, PlotOrientation.VERTICAL, true,
                    true, false);
        }
        break;
    }
    case XY_CHART:
        chart = ChartFactory.createXYLineChart(getName(), "", "", null, PlotOrientation.VERTICAL, true, false,
                false);
        break;
    case SCATTER_CHART:
        chart = ChartFactory.createXYLineChart(getName(), "", "", null, PlotOrientation.VERTICAL, true, false,
                false);
        break;
    case BOX_WHISKER_CHART: {
        chart = ChartFactory.createBoxAndWhiskerChart(getName(), "Time", "Value",
                (BoxAndWhiskerCategoryDataset) dataset, true);
        chart.setBackgroundPaint(new Color(249, 231, 236));

        break;
    }
    }
    Plot plot = chart.getPlot();
    chart.getTitle().setFont(getTitleFont());
    if (backgroundColor == null) {
        plot.setBackgroundPaint(null);
        chart.setBackgroundPaint(null);
        chart.setBorderPaint(null);
        if (chart.getLegend() != null) {
            chart.getLegend().setBackgroundPaint(null);
        }
    } else {
        Color bg = backgroundColor;
        chart.setBackgroundPaint(bg);
        plot.setBackgroundPaint(bg);
        chart.setBorderPaint(bg);
        if (chart.getLegend() != null) {
            chart.getLegend().setBackgroundPaint(bg);
        }
    }
    // chart.getLegend().setItemPaint(axesColor);
    // chart.getLegend().setBackgroundPaint(null);

    if (plot instanceof CategoryPlot) {
        final CategoryPlot pp = (CategoryPlot) chart.getPlot();
        pp.setDomainGridlinePaint(axesColor);
        pp.setRangeGridlinePaint(axesColor);
        // plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
        // plot.setDomainCrosshairVisible(true);
        pp.setRangeCrosshairVisible(true);
    } else if (plot instanceof XYPlot) {
        final XYPlot pp = (XYPlot) chart.getPlot();
        pp.setDomainGridlinePaint(axesColor);
        pp.setRangeGridlinePaint(axesColor);
        pp.setDomainCrosshairPaint(axesColor);
        pp.setRangeCrosshairPaint(axesColor);
        pp.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
        pp.setDomainCrosshairVisible(true);
        pp.setRangeCrosshairVisible(true);
    }
}

From source file:userInteface.Patient.ManageVitalSignsJPanel.java

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

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

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

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

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

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

}

From source file:UserInterface.DonorRole.DonorWorkAreaJPanel.java

private void generateOverallAnalysis() {

    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();

    objWorldEnterprise.getObjTransactionDirectory().updateTransactionAccount();
    dataSet.setValue(objWorldEnterprise.getObjTransactionDirectory().getAvailableVirtualBalance(),
            "Amount left", "Donation left");
    dataSet.setValue(objWorldEnterprise.getObjTransactionDirectory().getTotalVirtualDebitAmount(),
            "Amount donated", "Donation given");

    JFreeChart chart = ChartFactory.createBarChart3D("Overview of Donation received and delivered", "Donation",
            "Amount in USD $", dataSet, PlotOrientation.VERTICAL, false, true, false);

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setRangeGridlinePaint(Color.black);

    ChartPanel myChart = new ChartPanel(chart);
    donationOverviewJPanel.setLayout(new java.awt.BorderLayout());
    donationOverviewJPanel.add(myChart, BorderLayout.CENTER);
    donationOverviewJPanel.validate();// ww w.  j a v a 2s.c o  m
}

From source file:edu.ku.brc.specify.utilapps.RegisterApp.java

/**
 * @param chartTitle//from ww w  .  j a va2s  .c  o  m
 * @param xTitle
 * @param values
 */
private void createBarChart(final String chartTitle, final String xTitle,
        final Vector<Pair<String, Integer>> values) {
    String cat = ""; //$NON-NLS-1$
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    for (Pair<String, Integer> p : values) {
        //System.out.println("["+p.second+"]  ["+p.first+"]");
        //System.out.println("            values.add(new Pair<String, Integer>(\""+p.first+"\", "+p.second+"));");
        dataset.addValue(p.second, p.first, cat);
    }

    // create the chart... 
    JFreeChart chart = ChartFactory.createBarChart3D(chartTitle, // chart title 
            xTitle, // domain axis label 
            "Occurrence", // range axis label 
            dataset, // data 
            PlotOrientation.VERTICAL, true, //maxStrLen > 4 || values.size() > 15,       // include legend 
            true, // tooltips? 
            false // URLs? 
    );
    chart.setAntiAlias(true);
    chart.setTextAntiAlias(true);

    // create and display a frame... 
    ChartPanel panel = new ChartPanel(chart, true, true, true, true, true);

    boolean wasVisible = false;
    boolean wasCreated = false;
    if (chartFrame == null) {
        panel.setPreferredSize(new Dimension(800, 600));
        chartFrame = new CustomFrame("Statistics", CustomFrame.OK_BTN, null);
        chartFrame.setOkLabel("Close");
        chartFrame.createUI();
        wasCreated = true;
    } else {
        wasVisible = chartFrame.isVisible();
    }

    chartFrame.setContentPane(panel);

    // Can't believe I have to do this
    Rectangle r = chartFrame.getBounds();
    r.height++;
    chartFrame.setBounds(r);
    r.height--;
    //----
    chartFrame.setBounds(r);

    if (wasCreated) {
        chartFrame.pack();
    }

    if (!wasVisible) {
        UIHelper.centerAndShow(chartFrame);
    }
}