com.jrefinery.data
Class JdbcXYDataset

java.lang.Object
  extended by com.jrefinery.data.AbstractDataset
      extended by com.jrefinery.data.JdbcXYDataset
All Implemented Interfaces:
Dataset, RangeInfo, SeriesDataset, XYDataset

public class JdbcXYDataset
extends AbstractDataset
implements XYDataset, RangeInfo

Description of the Class This class provides an chart XYDataset implementation over a database JDBC result set. The dataset is populated via a call to executeQuery with the string sql query. The sql query must return at least two columns. The first column will be the x-axis and remaining columns y-axis values. executeQuery can be called a number of times. The database connection is read-only and no write back facility exists.


Field Summary
 boolean isTimeSeries
           
protected  double maxValue
          The maximum y value of the returned result set
protected  double minValue
          The minimum y value of the returned result set
 
Fields inherited from class com.jrefinery.data.AbstractDataset
listeners
 
Constructor Summary
JdbcXYDataset(java.sql.Connection con)
          Constructor Create a new JDBCChartAdapter using the specificied database connection.
JdbcXYDataset(java.sql.Connection con, java.lang.String query)
           
JdbcXYDataset(java.lang.String url, java.lang.String driverName, java.lang.String user, java.lang.String passwd)
          Constructor Create a new JDBCChartAdapter and establish a new database connection.
 
Method Summary
 void close()
          Close the database connection
 void executeQuery(java.lang.String query)
          ExecuteQuery will attempt execute the query passed to it against the existing database connection.
 int getItemCount(int seriesIndex)
          Returns the number of items in the specified series.
 int getLegendItemCount()
          Returns the number of items that should be displayed in the legend.
 java.lang.String[] getLegendItemLabels()
          Returns the legend item labels.
 java.lang.Number getMaximumRangeValue()
          Returns the maximum data value.
 java.lang.Number getMinimumRangeValue()
          Returns the minimum data value.
 int getSeriesCount()
          Returns the number of series in the data source;
 java.lang.String getSeriesName(int seriesIndex)
          Returns the name of the specified series.
 Range getValueRange()
          Returns the range of the values in this dataset's range.
 java.lang.Number getXValue(int seriesIndex, int itemIndex)
          Returns the x-value for the specified series and item.
 java.lang.Number getYValue(int seriesIndex, int itemIndex)
          Returns the y-value for the specified series and item.
 
Methods inherited from class com.jrefinery.data.AbstractDataset
addChangeListener, fireDatasetChanged, notifyListeners, removeChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jrefinery.data.Dataset
addChangeListener, removeChangeListener
 

Field Detail

maxValue

protected double maxValue
The maximum y value of the returned result set


minValue

protected double minValue
The minimum y value of the returned result set


isTimeSeries

public boolean isTimeSeries
Constructor Detail

JdbcXYDataset

public JdbcXYDataset(java.lang.String url,
                     java.lang.String driverName,
                     java.lang.String user,
                     java.lang.String passwd)
Constructor Create a new JDBCChartAdapter and establish a new database connection.

Parameters:
url - URL of the database connection
driverName - The database driver class name
user - The database user
passwd - The database users password.

JdbcXYDataset

public JdbcXYDataset(java.sql.Connection con)
Constructor Create a new JDBCChartAdapter using the specificied database connection.

Parameters:
con - The database connection to use

JdbcXYDataset

public JdbcXYDataset(java.sql.Connection con,
                     java.lang.String query)
Method Detail

executeQuery

public void executeQuery(java.lang.String query)
ExecuteQuery will attempt execute the query passed to it against the existing database connection. If no connection exists then no action is taken. The results from the query are extracted and cached locally, thus applying an upper limit on how many rows can be retrieved successfully.

Parameters:
query - The query to be executed

getXValue

public java.lang.Number getXValue(int seriesIndex,
                                  int itemIndex)
Returns the x-value for the specified series and item. The implementation is responsible for ensuring that the x-values are presented in ascending order.

Specified by:
getXValue in interface XYDataset
Parameters:
seriesIndex - The index of the series of interest (zero-based);
itemIndex - The index of the item of interest (zero-based).
Returns:
The xValue value
See Also:
XYDataset

getYValue

public java.lang.Number getYValue(int seriesIndex,
                                  int itemIndex)
Returns the y-value for the specified series and item.

Specified by:
getYValue in interface XYDataset
Parameters:
seriesIndex - The index of the series of interest (zero-based);
itemIndex - The index of the item of interest (zero-based).
Returns:
The yValue value
See Also:
XYDataset

getItemCount

public int getItemCount(int seriesIndex)
Returns the number of items in the specified series.

Specified by:
getItemCount in interface XYDataset
Parameters:
seriesIndex - The index of the series of interest (zero-based).
Returns:
The itemCount value
See Also:
XYDataset

getSeriesCount

public int getSeriesCount()
Returns the number of series in the data source;

Specified by:
getSeriesCount in interface SeriesDataset
Returns:
The seriesCount value
See Also:
XYDataset, DataSource

getSeriesName

public java.lang.String getSeriesName(int seriesIndex)
Returns the name of the specified series.

Specified by:
getSeriesName in interface SeriesDataset
Parameters:
seriesIndex - The index of the required series (zero-based);
Returns:
The seriesName value
See Also:
XYDataset, Dataset

getLegendItemCount

public int getLegendItemCount()
Returns the number of items that should be displayed in the legend.

Returns:
The legendItemCount value

getLegendItemLabels

public java.lang.String[] getLegendItemLabels()
Returns the legend item labels.

Returns:
The legend item labels.

getMinimumRangeValue

public java.lang.Number getMinimumRangeValue()
Returns the minimum data value.

Specified by:
getMinimumRangeValue in interface RangeInfo
Returns:
The minimumRangeValue value
See Also:
RangeInfo

getMaximumRangeValue

public java.lang.Number getMaximumRangeValue()
Returns the maximum data value.

Specified by:
getMaximumRangeValue in interface RangeInfo
Returns:
The maximumRangeValue value
See Also:
RangeInfo

close

public void close()
Close the database connection


getValueRange

public Range getValueRange()
Returns the range of the values in this dataset's range.

Specified by:
getValueRange in interface RangeInfo
Returns:
The range.


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.