JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.chart.data
Class JCChartSwingDataSource

java.lang.Object
  |
  +--com.klg.jclass.chart.ChartDataSupport
        |
        +--com.klg.jclass.chart.data.JCChartSwingDataSource
All Implemented Interfaces:
ChartDataManageable, ChartDataManager, ChartDataModel, EditableChartDataModel, EventListener, HoleValueChartDataModel, LabelledChartDataModel, Serializable, TableModelListener

public class JCChartSwingDataSource
extends ChartDataSupport
implements EditableChartDataModel, LabelledChartDataModel, HoleValueChartDataModel, TableModelListener, ChartDataManageable, Serializable

JCChartSwingDataSource provides an intepretive layer between JCChart and data existing in a Swing TableModel format.

The most notable differences between them is the inversion of rows and columns - TableModel's rows are JCChart's columns, and vice versa. Also, TableModel provides no X values, and so these are generated here.

See Also:
Serialized Form

Field Summary
protected  String dsName
           
protected  String[] pLabels
           
protected  TableModel tableModel
          TableModel instance (Swing data source instance).
 
Fields inherited from class com.klg.jclass.chart.ChartDataSupport
source
 
Fields inherited from interface com.klg.jclass.chart.ChartDataModel
ALL
 
Constructor Summary
JCChartSwingDataSource()
          The default constructor.
JCChartSwingDataSource(TableModel model)
          Constructor.
JCChartSwingDataSource(TableModel model, String[] pointLabels, String dataSourceName)
          Constructor.
 
Method Summary
 com.klg.jclass.chart.ChartDataManager getChartDataManager()
          Retrieves the ChartDataManager instance.
 String getDataSourceName()
          Name of data source, used at the top of the legend.
 double getHoleValue()
          Returns the hole value being used for this data source.
 int getNumSeries()
          Retrieves the number of data series.
 String[] getPointLabels()
          Point labels can be set manually if desired.
 String[] getSeriesLabels()
          Gets series labels from TabelModel's column headers.
 double[] getXSeries(int index)
          Retrieves the specified x-value series.
 double[] getYSeries(int index)
          Retrieves the specified y-value series.
 boolean setDataItem(int seriesIndex, int pointIndex, double newValue)
          Sets the value of a single data item in the TableModel.
 void setDataSourceName(String name)
          Name of data source, used at the top of the legend.
 void setPointLabels(String[] labels)
          Point labels can be set manually if desired.
 void tableChanged(TableModelEvent e)
          Implements TableModelListener for changes to TableModel.
 
Methods inherited from class com.klg.jclass.chart.ChartDataSupport
addChartDataListener, fireChartDataEvent, fireChartDataEvent, removeChartDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tableModel

protected TableModel tableModel
TableModel instance (Swing data source instance).


pLabels

protected String[] pLabels

dsName

protected String dsName
Constructor Detail

JCChartSwingDataSource

public JCChartSwingDataSource()
The default constructor. Makes an empty data source.


JCChartSwingDataSource

public JCChartSwingDataSource(TableModel model)
Constructor. Sets the table model to passed object.

Parameters:
model - The table model on which to base this datasource

JCChartSwingDataSource

public JCChartSwingDataSource(TableModel model,
                              String[] pointLabels,
                              String dataSourceName)
Constructor. Sets the table model to passed object, values for point labels, and a data source name.

Parameters:
model - The table model on which to base this datasource
pointLabels - A list of point labels for this data source
dataSourceName - The name of this data source
Method Detail

setDataItem

public boolean setDataItem(int seriesIndex,
                           int pointIndex,
                           double newValue)
Sets the value of a single data item in the TableModel.

Specified by:
setDataItem in interface EditableChartDataModel
Parameters:
newValue - The new data item value
seriesIndex - The series (or column) to change
pointIndex - The point (or row) to change
Returns:
Whether change succeeded

getXSeries

public double[] getXSeries(int index)
Retrieves the specified x-value series.

Specified by:
getXSeries in interface ChartDataModel
Parameters:
index - data series index
Returns:
array of double values representing x-value data

getYSeries

public double[] getYSeries(int index)
Retrieves the specified y-value series.

Specified by:
getYSeries in interface ChartDataModel
Parameters:
index - data series index
Returns:
array of double values representing x-value data

getNumSeries

public int getNumSeries()
Retrieves the number of data series.

Specified by:
getNumSeries in interface ChartDataModel
Returns:
Number of data series

getPointLabels

public String[] getPointLabels()
Point labels can be set manually if desired. There are none in the JTable itself.

Specified by:
getPointLabels in interface LabelledChartDataModel
Returns:
The current list of point labels
See Also:
LabelledChartDataModel.getPointLabels()

setPointLabels

public void setPointLabels(String[] labels)
Point labels can be set manually if desired. There are none in the JTable itself.

Parameters:
labels - A list of point labels
See Also:
LabelledChartDataModel.getPointLabels()

getSeriesLabels

public String[] getSeriesLabels()
Gets series labels from TabelModel's column headers.

Specified by:
getSeriesLabels in interface LabelledChartDataModel
Returns:
A list of series labels gleaned from the column headers
See Also:
LabelledChartDataModel.getSeriesLabels()

getDataSourceName

public String getDataSourceName()
Name of data source, used at the top of the legend. Can be set manually. It is not found in the JTable itself.

Specified by:
getDataSourceName in interface LabelledChartDataModel
Returns:
The current data source name

setDataSourceName

public void setDataSourceName(String name)
Name of data source, used at the top of the legend. Can be set manually. It is not found in the JTable itself.

Parameters:
name - The new data source name

getHoleValue

public double getHoleValue()
Returns the hole value being used for this data source.

Specified by:
getHoleValue in interface HoleValueChartDataModel
Returns:
The current hole value

tableChanged

public void tableChanged(TableModelEvent e)
Implements TableModelListener for changes to TableModel.

Specified by:
tableChanged in interface TableModelListener
Parameters:
e - The event generated by the change

getChartDataManager

public com.klg.jclass.chart.ChartDataManager getChartDataManager()
Retrieves the ChartDataManager instance. Required by the ChartDataManageable interface.

Specified by:
getChartDataManager in interface ChartDataManageable
Returns:

Copyright © 2004 Quest Software Inc..
All rights reserved.