Busy week, but managed to find some time yesterday to look at this problem again...
I was able to get the java2DToValue and valueToJava2D methods to work properly. Along with the autoAdjustRange methods. So the data are now displayed on the screen properly. To achieve this with minimum impact on the rest of the class, I wrote 2 mehods:
Code: Select all
protected double reverseCalcLog10( double val ) {
return Math.exp( val / 10.0 * LOG10 );
}
protected double calcLog10( double val ) {
return 10.0d * ( Math.log( val ) / LOG10 );
}
These methods are called whenever the class needs to manipulate a value. They essentially fool the axis into thinking that it is dealing with the dB value ( 10*Log(value) )rather than the actual value. For example, I call the method calcLog10(value) whenever the class has called getRange() and convert the values prior to the code doing anything with those values. This all seems to work now, including allowing me to place range markers on the plot in the proper locations.
However, I still cannot get the ticks to display properly. I am having a hard time understanding why it is that if the default tick unit size is set to 1.0, that at some point, it is set automatically to 1.0E-7 prior to the plot being displayed. The causes the number of ticks to be ridiculously large, and then no ticks get displayed.
To give some perspective, the data I am testing has a range value of approximately Range = [0.000123, 0.009] (on the Y-axis - the axis in question). When translated to dB, this data range is from [-39.1, -10.5] (roughly).
refreshTickVertical is calculating my lowest tick value properly ( it gives me -39.05 ) however, despite the DEFAULT_TICK_UNIT being set to 1.0 at the top of the class, in the
calculateVisibleTickCount method, the TickUnit is returned at 1.0E-7??? This causes the number of ticks to be high, and I'm assuming that this is why they are not drawn.
Another thing I tried was setting the tickUnit when I instantiate the Axis by using the following code:
Code: Select all
magLogAxis = new DbAxis( "Amplitude [dB]" );
magLogAxis.setAutoRange( true );
magLogAxis.setAutoRangeIncludesZero( false );
magLogAxis.setUpperMargin( 0.05 );
magLogAxis.setLowerMargin( 0.05 );
magLogAxis.setTickUnit( new NumberTickUnit( 1.0 ) );
By doing this, the tickUnit does indeed start off at 1.0 (overriding the presumed default of 1.0E-7) and the tickLabelSize seems to be affected, because the plot now draws the Axis label away from the edge of the plot (seemingly leaving room for tick labels). But there are no lables or ticks drawn beside the plot. Instead, they are drawn all on top of one another in the upper left corner of my plot panel. ??? This seems to be perhaps a symptom of a different problem...
Anyhow, I'm continuing to work on the problem, but would really appreciate any advice or tips anyone can throw at me. I am confident that I am likely missing some very minute detail that will solve my problem.
I am happy to share this class (once it works) to anyone needing to display data easily with a dB axis.
Cheers,
dave