craftleft.gif (3002 bytes)QuickTable
Home | API | Tutorial | Download | Support | Contact topblack.gif (108 bytes)


QuickTable User Cp  |  Register  |  Members  |  Search  |  Help
    |- QuickTable Discussion Forums > CellEditor/Renderer Post New Topic   Post A Reply
Problems with setPrecision() printer friendly version
next newest post | next oldest post
Author Messages
jamen
Corporal

Gender: Unspecified
Location:
Registered: Sep 2007
Status: Offline
Posts: 22

Click here to see the profile for jamen Send email to jamen Send private message to jamen Find more posts by jamen Edit or delete this message Reply w/Quote
Posted Wednesday, October 10, 2007 @ 09:28:13  

Well as long as I'm on the board I might as well ask all the questions I have :)

I'm trying to use setPrecsion(int ) to set the number of digits displayed in several columns of one table. The column is supposed to be doubles and I'm pretty sure they are because the same table sets the foreground color correctly basesd on double values. The setPrecision() method seems to be ignored and the values display in scientific format. Overridding the MonitorCellProperty doesn't by change also override the mechanisim to set the precision of the display does it?

public Color getForeground(int row, int col) {
// Color the cells red that are reverse polarity
if (col == 1) {
Object cellValue = adaptee.qTable.getTable().getValueAt(row, col);
if (cellValue instanceof Double) {
// Negative (reverse polarity) is colored red
if ( ( (Double) cellValue).doubleValue() < 0.0) {
return Color.red;
}
// out of normal range is colored yellow
if ( ( (Double) cellValue).doubleValue() > adaptee.cellWarningValue) {
return Color.ORANGE;
}
}
}

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Thursday, October 11, 2007 @ 09:17:50  

Please enable debug dbTable.debug=true; and see whether you get any errors.
jamen
Corporal

Gender: Unspecified
Location:
Registered: Sep 2007
Status: Offline
Posts: 22

Click here to see the profile for jamen Send email to jamen Send private message to jamen Find more posts by jamen Edit or delete this message Reply w/Quote
Posted Thursday, October 11, 2007 @ 09:45:09  

This is what it told me:

Unable to automatically create rowcount sql. Optionally you can provide rowcount sql using DBTable.setRowCountSql(String rowCountSql). Refer api for setRowCountSql() for more info.

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Thursday, October 11, 2007 @ 13:12:17  

what is your source of data? is it database?
If database mode, when the data is loaded it will print all the datatype information for every column when debug is enabled. what is the datatype, scale & precison you see for this probelmatic column?
jamen
Corporal

Gender: Unspecified
Location:
Registered: Sep 2007
Status: Offline
Posts: 22

Click here to see the profile for jamen Send email to jamen Send private message to jamen Find more posts by jamen Edit or delete this message Reply w/Quote
Posted Thursday, October 11, 2007 @ 13:51:40  

Its a database. Here is the debug info below but I just had another idea. Is it because the column is the product of a db math function instead of just a pure column itself? Here is the sql:

qTable.setSelectSql(
" SELECT chan, AVG(channel_value - reference_value) as AVERAGE, " +
" MAX(channel_value - reference_value) as MAX, " +
" MIN(channel_value - reference_value) as MIN, " +
" MIN(channel_value) as MIN_CHANNEL, " +
" MAX(channel_value) as MAX_CHANNEL, " +
" MIN(reference_value) as MIN_REF, " +
" MAX(reference_value) as MAX_REF " +
" FROM pyronometer_monitor_data " +
" GROUP BY chan ");

Unable to automatically create rowcount sql. Optionally you can provide rowcount sql using DBTable.setRowCountSql(String rowCountSql). Refer api for setRowCountSql() for more info.

Database meta data information received from jdbc driver

Column 1: Name: chan
ReadOnly: false
Data Type: INTEGER

Precision: 10
Scale: 0
Signed: true

Column 2: Name: average
ReadOnly: false
Data Type: DOUBLE

Precision: 17
Scale: 17
Signed: true

Column 3: Name: max
ReadOnly: false
Data Type: DOUBLE

Precision: 17
Scale: 17
Signed: true

Column 4: Name: min
ReadOnly: false
Data Type: DOUBLE

Precision: 17
Scale: 17
Signed: true

Column 5: Name: min_channel
ReadOnly: false
Data Type: DOUBLE

Precision: 17
Scale: 17
Signed: true

Column 6: Name: max_channel
ReadOnly: false
Data Type: DOUBLE

Precision: 17
Scale: 17
Signed: true

Column 7: Name: min_ref
ReadOnly: false
Data Type: DOUBLE

Precision: 17
Scale: 17
Signed: true

Column 8: Name: max_ref
ReadOnly: false
Data Type: DOUBLE

Precision: 17
Scale: 17
Signed: true

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Thursday, October 11, 2007 @ 16:02:44  

When you try to edit the cell with this data, do you still see the data in scientific format?
jamen
Corporal

Gender: Unspecified
Location:
Registered: Sep 2007
Status: Offline
Posts: 22

Click here to see the profile for jamen Send email to jamen Send private message to jamen Find more posts by jamen Edit or delete this message Reply w/Quote
Posted Friday, October 12, 2007 @ 09:32:46  

I can't edit the cells. They are results of db math functions and the cells are set (by someone other than me, i.e. jdbc or ?Quicktable) as being un-editiable.

This is the total code for that table (wrt QuickTable)

qTable.setSelectSql(
" SELECT chan, AVG(channel_value - reference_value) as AVERAGE, " +
" MAX(channel_value - reference_value) as MAX, " +
" MIN(channel_value - reference_value) as MIN, " +
" MIN(channel_value) as MIN_CHANNEL, " +
" MAX(channel_value) as MAX_CHANNEL, " +
" MIN(reference_value) as MIN_REF, " +
" MAX(reference_value) as MAX_REF " +
" FROM pyronometer_monitor_data " +
" GROUP BY chan ");

try {
qTable.connectDatabase();
}
catch (Exception ex) {
System.out.println(ex.toString());
}

try {
qTable.refresh();
}
catch (SQLException ex) {
System.out.println(ex.toString());
}

qTable.getColumn(0).setReadOnly(true);
qTable.getColumn(1).setReadOnly(true);

qTable.getColumn(0).setHeaderValue("Data DVM Channel");
qTable.getColumn(1).setHeaderValue("Average Delta from Reference");

qTable.getColumn(2).setPrecision(3);
qTable.getColumn(3).setPrecision(3);
qTable.getColumn(4).setPrecision(3);
qTable.getColumn(5).setPrecision(3);
qTable.getColumn(6).setPrecision(3);

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Sunday, October 14, 2007 @ 21:12:11  

The problem is quicktable is using Double's toString() method to convert double to string. This is converted in scientific format by tostring. We need to use NumberFormat class to correctly format as you need. Please use the class ResultSetMap and convert the double value to string as you want see in the cell. Again this is not the best solution, it is just a workaround.

refer api doc for ResultSetMap

Post New Topic   Post A Reply Jump to:
Contact Us | QuickTable - A Java DBGrid | Privacy Policy All times are GMT -5 Hours.
Welcome to QuickTable Forums, Guest!  
Login
Username :
Password :
In order to fully utilize the abilities of this board, you are required to register as a member. Registration is free, and allows you to do lots of things including turning on or off certain features of this board. Register now!
Powered by CuteCast v2.0 BETA 2
Copyright © 2001-2003 ArtsCore Studios