if( selectedFieldsData.size() > 0 )
{
// load data from multi browser
tableModelClass tableDataModel = dataBrowser.tableModel;
int rowCount = tableDataModel.getRowCount();
// formatter
SimpleDateFormat dateFormatter = null;
if( configuration.getField( "databaseType" ).equals( "oracle" ) ){
dateFormatter = new SimpleDateFormat ("MM/dd/yyyy");
}else if(configuration.getField( "databaseType" ).equals( "mssql" ) ){
dateFormatter = new SimpleDateFormat ("yyyy-MM-dd");
}else{
throw new KExceptionClass( "databaseType not recognized " + configuration.getField( "databaseType" ), null );
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// JFREE stuff begins here
// ++++++++++++++++++++++++++++++++++++++++++++++++
// Make a vector with date units for the date axis
log.log( this, "Figure dates" );
Vector< Day > dateColumn = new Vector< Day >();
for( int rowIndex = 0; rowIndex < rowCount; rowIndex++ ){
try{
String dateString = (String) tableDataModel.getValueAt( rowIndex, 0 );
Date rowDate = dateFormatter.parse( dateString );
dateColumn.add( new Day( rowDate ) );
log.log( this, "Adding " + dateString );
}catch( ParseException parseError ){
throw new KExceptionClass( parseError.toString() , null );
}
}
// +++++++++++++++++++++++++++++
// create a data set, keeps the series
TimeSeriesCollection mainDataset = new TimeSeriesCollection();
// +++++++++++++++++++++++++++++
// make data series
// read data, a serie per column
log.log( this, "Adding data" );
for( int columnIndex = 1; columnIndex < tableDataModel.getColumnCount(); columnIndex++ ){
// make a serie
TimeSeries dataByDateSerie = new TimeSeries( tableDataModel.getColumnName(columnIndex), Day.class );
// read data
for( int rowIndex = 0; rowIndex < tableDataModel.getRowCount(); rowIndex++ ){
try{
// read value
String rowValue = (String) tableDataModel.getValueAt( rowIndex, columnIndex );
// parse value string
StringTokenizer tokenizer = new StringTokenizer( rowValue );
String decodedValue = new String();
if( tokenizer.hasMoreTokens() ){
decodedValue = tokenizer.nextToken();
if( decodedValue.equals( "<" ) && tokenizer.hasMoreTokens() ){
String valueToken = tokenizer.nextToken();
try{
decodedValue = "" + ( KMetaUtilsClass.getDecimalNumericValueFromString( valueToken ) / 2 );
}catch( Exception error ){
decodedValue = valueToken;
}
}
}
// data raw
double currentRecordValue = KMetaUtilsClass.getDecimalNumericValueFromString( decodedValue );
// make serie
dataByDateSerie.add( dateColumn.get(rowIndex), currentRecordValue );
log.log( this, "Adding " + currentRecordValue );
log.log( this, tableDataModel.getColumnName( columnIndex ) + " --> " + ((String) tableDataModel.getValueAt( rowIndex, columnIndex )).trim() );
}catch( Exception parseError ){
log.log( this, parseError.toString() + "|" + tableDataModel.getColumnName( columnIndex ) + " !!!!!! --> " + ((String) tableDataModel.getValueAt( rowIndex, columnIndex )).trim() );
}
}