edu.sdsc.inca.consumer
Class DistributionBean

java.lang.Object
  extended by org.jfree.data.general.AbstractDataset
      extended by org.jfree.data.category.DefaultCategoryDataset
          extended by edu.sdsc.inca.consumer.DistributionBean
All Implemented Interfaces:
de.laures.cewolf.DatasetProducer, de.laures.cewolf.tooltips.CategoryToolTipGenerator, de.laures.cewolf.tooltips.ToolTipGenerator, java.io.ObjectInputValidation, java.io.Serializable, java.lang.Cloneable, org.jfree.data.category.CategoryDataset, org.jfree.data.general.Dataset, org.jfree.data.KeyedValues2D, org.jfree.data.Values2D

public class DistributionBean
extends org.jfree.data.category.DefaultCategoryDataset
implements de.laures.cewolf.DatasetProducer, de.laures.cewolf.tooltips.CategoryToolTipGenerator

A dataset producer for graphing distribution data based on an xpath values in a xml document. This is implemented by extending the category dataset using the xpath values for the xaxis and their count for the yaxis. Multiple rows (or series) can be added to create a stacked bar graph.

Author:
Shava Smallen <ssmallen@sdsc.edu>
See Also:
Serialized Form

Field Summary
static java.lang.String NAMESPACE_DECLS
           
 
Fields inherited from interface de.laures.cewolf.DatasetProducer
PRODUCER_ATTRIBUTE_NAME
 
Constructor Summary
DistributionBean(java.lang.String id, java.lang.String xml)
          Create a new distribution dataset which will pull data from the provided xml document
 
Method Summary
 void add(java.lang.String xpath, java.lang.String rowKey)
          Add a new row to the dataset.
 java.lang.String generateToolTip(org.jfree.data.category.CategoryDataset data, int row, int column)
          Text to display when a bar is moused over
 int getColKeyIndex(java.lang.String colValue)
          Return the index of the column key value
 java.util.Vector<java.lang.String> getColKeys()
          Return the vector of column keys (or unique values found in the xpath)
 java.lang.String getProducerId()
          Returns a unique id for this dataset
 int getRowKeyIndex(java.lang.String rowValue)
          Return the index of the row key value
 java.util.Vector<java.lang.String> getRowKeys()
          Return the vector of row keys (or series)
 boolean hasExpired(java.util.Map params, java.util.Date since)
          This method influences Cewolf's caching behaviour.
 java.lang.Object produceDataset(java.util.Map params)
          Return this object as the dataset
 
Methods inherited from class org.jfree.data.category.DefaultCategoryDataset
addValue, addValue, clear, clone, equals, getColumnCount, getColumnIndex, getColumnKey, getColumnKeys, getRowCount, getRowIndex, getRowKey, getValue, getValue, hashCode, incrementValue, removeColumn, removeColumn, removeRow, removeRow, removeValue, setValue, setValue
 
Methods inherited from class org.jfree.data.general.AbstractDataset
addChangeListener, fireDatasetChanged, getGroup, hasListener, notifyListeners, removeChangeListener, setGroup, validateObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jfree.data.general.Dataset
addChangeListener, getGroup, removeChangeListener, setGroup
 

Field Detail

NAMESPACE_DECLS

public static final java.lang.String NAMESPACE_DECLS
See Also:
Constant Field Values
Constructor Detail

DistributionBean

public DistributionBean(java.lang.String id,
                        java.lang.String xml)
                 throws org.apache.xmlbeans.XmlException
Create a new distribution dataset which will pull data from the provided xml document

Parameters:
id - A unique id that can be used for a graph id
xml - An string containing an xml document following the query results schema: http://inca.sdsc.edu/dataModel/queryResults_2.0
Throws:
org.apache.xmlbeans.XmlException - if problem parsing xml
Method Detail

add

public void add(java.lang.String xpath,
                java.lang.String rowKey)
Add a new row to the dataset. Will then run the xpath expression over the xml and add values to the distribution.

Parameters:
xpath - the values that will be calculated into the distribution
rowKey - an identifier to use for the row (or series)

generateToolTip

public java.lang.String generateToolTip(org.jfree.data.category.CategoryDataset data,
                                        int row,
                                        int column)
Text to display when a bar is moused over

Specified by:
generateToolTip in interface de.laures.cewolf.tooltips.CategoryToolTipGenerator
Parameters:
data - Jfree CategoryDataset object to add mouseover text to.
row - The row value that was moused over
column - The column value that was moused over
Returns:
Mouseover text string

getColKeyIndex

public int getColKeyIndex(java.lang.String colValue)
Return the index of the column key value

Parameters:
colValue - A value in the the column keys
Returns:
An index in the column key vector

getColKeys

public java.util.Vector<java.lang.String> getColKeys()
Return the vector of column keys (or unique values found in the xpath)

Returns:
A vector of column keys.

getProducerId

public java.lang.String getProducerId()
Returns a unique id for this dataset

Specified by:
getProducerId in interface de.laures.cewolf.DatasetProducer

getRowKeyIndex

public int getRowKeyIndex(java.lang.String rowValue)
Return the index of the row key value

Parameters:
rowValue - A value in the the row keys
Returns:
An index in the row key vector

getRowKeys

public java.util.Vector<java.lang.String> getRowKeys()
Return the vector of row keys (or series)

Specified by:
getRowKeys in interface org.jfree.data.KeyedValues2D
Overrides:
getRowKeys in class org.jfree.data.category.DefaultCategoryDataset
Returns:
A vector of row keys

hasExpired

public boolean hasExpired(java.util.Map params,
                          java.util.Date since)
This method influences Cewolf's caching behaviour. Example of invalid data after a day (86,400 seconds): log.debug(getClass().getName() + "hasExpired()"); return (System.currentTimeMillis() - since.getTime()) > 86400000;

Specified by:
hasExpired in interface de.laures.cewolf.DatasetProducer

produceDataset

public java.lang.Object produceDataset(java.util.Map params)
                                throws de.laures.cewolf.DatasetProduceException
Return this object as the dataset

Specified by:
produceDataset in interface de.laures.cewolf.DatasetProducer
Parameters:
params - Additional params for the dataset production.
Returns:
A CategoryDataset object containing a distribution dataset
Throws:
de.laures.cewolf.DatasetProduceException