Example usage for org.jfree.data.jdbc JDBCCategoryDataset getValue

List of usage examples for org.jfree.data.jdbc JDBCCategoryDataset getValue

Introduction

In this page you can find the example usage for org.jfree.data.jdbc JDBCCategoryDataset getValue.

Prototype

@Override
public Number getValue(int row, int column) 

Source Link

Document

Returns a value from the table.

Usage

From source file:org.opennms.netmgt.charts.ChartUtils.java

/**
 * @param chartConfig/*from ww w. j a  va2  s  .com*/
 * @param baseDataSet
 * @throws SQLException
 */
private static DefaultCategoryDataset buildCategoryDataSet(BarChart chartConfig) throws SQLException {
    DefaultCategoryDataset baseDataSet = new DefaultCategoryDataset();
    /*
     * Configuration can contain more than one series.  This loop adds
     * single series data sets returned from sql query to a base data set
     * to be displayed in a the chart. 
     */
    Connection conn = null;
    try {
        conn = DataSourceFactory.getInstance().getConnection();
        Iterator<SeriesDef> it = chartConfig.getSeriesDefCollection().iterator();
        while (it.hasNext()) {
            SeriesDef def = it.next();
            JDBCCategoryDataset dataSet = new JDBCCategoryDataset(conn, def.getJdbcDataSet().getSql());

            for (int i = 0; i < dataSet.getRowCount(); i++) {
                for (int j = 0; j < dataSet.getColumnCount(); j++) {
                    baseDataSet.addValue(dataSet.getValue(i, j), def.getSeriesName(), dataSet.getColumnKey(j));
                }
            }
        }
    } finally {
        if (conn != null) {
            conn.close();
        }
    }
    return baseDataSet;
}