|
From: <ki...@us...> - 2003-08-27 04:38:02
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart
In directory sc8-pr-cvs1:/tmp/cvs-serv23576/axisChart
Modified Files:
AxisChart.java LineChart.java
Log Message:
Integration of the Dual Y axis code that was submitted to Nathaniel by
Romain SEGUY.
These are new properties added to the AxisTypeProperties class
ChartFont AxisTypeProperties.getScaleChartFontRight()
void AxisTypeProperties.setScaleChartFontRight( ChartFont scaleChartFontRight )
void AxisTypeProperties.setShowRightAxis( boolean showRightAxis )
float AxisTypeProperties.getSecondScaleRight()
void AxisTypeProperties.setSecondScaleRight(float secondScaleRight)
double AxisTypeProperties.getMinRightAxis()
void AxisTypeProperties.setMinRightAxis(double minRightAxis)
double AxisTypeProperties.getMaxRightAxis()
void AxisTypeProperties.setMaxRightAxis(double maxRightAxis)
Added to Axis class
TextTagGroup Axis.getAxisLabelsGroupRight()
void Axis.setAxisLabelsGroupRight( TextTagGroup axisLabelsGroupRight )
There is a demonstration servlet in org\krysalis\jcharts\demo\simpleservlet
called DualYAxis.java
Index: AxisChart.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart/AxisChart.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** AxisChart.java 22 Jun 2003 14:14:24 -0000 1.3
--- AxisChart.java 27 Aug 2003 04:37:44 -0000 1.4
***************
*** 70,73 ****
--- 70,78 ----
import java.awt.geom.Rectangle2D;
+ // Dual Y axis changes integrated CMC 25Aug03
+ import java.lang.Math.*;
+ import java.lang.Float.*;
+
+
/*************************************************************************************
***************
*** 156,171 ****
{
s = new AutomaticScaleCalculator();
! s.setMaxValue( axisChartDataProcessor.getMaxValue() );
! s.setMinValue( axisChartDataProcessor.getMinValue() );
! }
! axis.setScaleCalculator( s );
}
else
{
axis.setScaleCalculator( dataAxisProperties.getScaleCalculator() );
! axis.getScaleCalculator().setMaxValue( axisChartDataProcessor.getMaxValue() );
! axis.getScaleCalculator().setMinValue( axisChartDataProcessor.getMinValue() );
! }
axis.getScaleCalculator().setRoundingPowerOfTen( dataAxisProperties.getRoundToNearest() );
--- 161,212 ----
{
s = new AutomaticScaleCalculator();
! // Dual Y axis changes integrated CMC 25Aug03
! // s.setMaxValue( axisChartDataProcessor.getMaxValue() );
! // s.setMinValue( axisChartDataProcessor.getMinValue() );
! if (this.axisProperties.getYAxisProperties().getMaxRightAxis()>0)
! {
! s.setMaxValue( this.axisProperties.getYAxisProperties().getMaxRightAxis() );
! }
! else
! {
! s.setMaxValue( axisChartDataProcessor.getMaxValue() );
! }
! if (this.axisProperties.getYAxisProperties().getMinRightAxis()<0)
! {
! s.setMinValue( this.axisProperties.getYAxisProperties().getMinRightAxis() );
! }
! else
! {
! s.setMinValue( axisChartDataProcessor.getMinValue() );
! }
! }
! axis.setScaleCalculator( s );
}
else
{
axis.setScaleCalculator( dataAxisProperties.getScaleCalculator() );
! // Dual Y axis changes integrated CMC 25Aug03
! // axis.getScaleCalculator().setMaxValue( axisChartDataProcessor.getMaxValue() );
! // axis.getScaleCalculator().setMinValue( axisChartDataProcessor.getMinValue() );
!
! if (this.axisProperties.getYAxisProperties().getMaxRightAxis()>0)
! {
! axis.getScaleCalculator().setMaxValue( this.axisProperties.getYAxisProperties().getMaxRightAxis() );
! }
! else
! {
! axis.getScaleCalculator().setMaxValue( axisChartDataProcessor.getMaxValue() );
! }
!
! if (this.axisProperties.getYAxisProperties().getMinRightAxis()<0)
! {
! axis.getScaleCalculator().setMinValue( this.axisProperties.getYAxisProperties().getMinRightAxis() );
! }
! else
! {
! axis.getScaleCalculator().setMinValue( axisChartDataProcessor.getMinValue() );
! }
! }
axis.getScaleCalculator().setRoundingPowerOfTen( dataAxisProperties.getRoundToNearest() );
***************
*** 264,267 ****
--- 305,331 ----
NumericTagGroup numericTagGroup= setupDataAxisProperties( this.yAxis, dataAxisProperties, axisChartDataProcessor, fontRenderContext );
this.yAxis.setAxisLabelsGroup( numericTagGroup );
+ // Dual Y axis changes integrated CMC 25Aug03
+ // compute the labels of the right axis if necessary
+ if ( this.axisProperties.getYAxisProperties().getSecondScaleRight()!=1 )
+ {
+ NumericTagGroup numericTagGroup2 = new NumericTagGroup( dataAxisProperties.getScaleChartFontRight(),
+ fontRenderContext,
+ dataAxisProperties.useDollarSigns(),
+ dataAxisProperties.usePercentSigns(),
+ dataAxisProperties.useCommas(),
+ dataAxisProperties.getRoundToNearest() );
+ int j=0;
+ while (j<this.getYAxis().getNumberOfScaleItems())
+ {
+ Float myFloat = new Float (this.yAxis.getAxisLabelsGroup().getTextTag(j).getText());
+ float temp = myFloat.floatValue();
+ Integer myInteger = new Integer ( Math.round(Math.round((float)(temp / this.axisProperties.getYAxisProperties().getSecondScaleRight()))/10)*10 );
+ String myString = new String ("");
+ myString = myInteger.toString();
+ numericTagGroup2.addLabel(myString);
+ j++;
+ }
+ this.yAxis.setAxisLabelsGroupRight(numericTagGroup2);
+ }
}
***************
*** 283,288 ****
{
//---SUBTRACT space for axis titles, labels, ticks...
! xAxisWidth -= this.yAxis.getMinimumWidthNeeded();
! yAxisHeight -= this.xAxis.getMinimumHeightNeeded();
//---SET THE PIXEL LENGTH OF THE AXIS
--- 347,358 ----
{
//---SUBTRACT space for axis titles, labels, ticks...
! // Dual Y axis changes integrated CMC 25Aug03
! // if there is a right axis to render we subtract twice the minimum width needed
! if (this.axisProperties.getYAxisProperties().getShowRightAxis())
! xAxisWidth -= 2*this.yAxis.getMinimumWidthNeeded();
! else
! xAxisWidth -= this.yAxis.getMinimumWidthNeeded();
!
! yAxisHeight -= this.xAxis.getMinimumHeightNeeded();
//---SET THE PIXEL LENGTH OF THE AXIS
Index: LineChart.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart/LineChart.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** LineChart.java 17 May 2003 16:56:57 -0000 1.1
--- LineChart.java 27 Aug 2003 04:37:44 -0000 1.2
***************
*** 85,91 ****
if( iAxisChartDataSet.getValue( i, j ) != Double.NaN )
{
! yAxisCoordinates[ i ][ j ]= axisChart.getYAxis().computeAxisCoordinate( axisChart.getYAxis().getOrigin(),
! iAxisChartDataSet.getValue( i, j ),
! axisChart.getYAxis().getScaleCalculator().getMinValue() );
//---if we are generating an ImageMap, store the image coordinates
--- 85,99 ----
if( iAxisChartDataSet.getValue( i, j ) != Double.NaN )
{
! // Dual Y axis changes integrated CMC 25Aug03
! //yAxisCoordinates[ i ][ j ]= axisChart.getYAxis().computeAxisCoordinate( axisChart.getYAxis().getOrigin(),
! // iAxisChartDataSet.getValue( i, j ),
! // axisChart.getYAxis().getScaleCalculator().getMinValue() );
!
! // The coordinates of the line charts are drawn with the default scale and
! // multiplicate with the second scale for the right axis (by default equal 1)
! // if the second scale at the right is unchanged then there will be no impact
! yAxisCoordinates[ i ][ j ]= axisChart.getYAxis().computeAxisCoordinate( axisChart.getYAxis().getOrigin(),
! iAxisChartDataSet.getValue( i, j )*axisChart.axisProperties.getYAxisProperties().getSecondScaleRight(),
! axisChart.getYAxis().getScaleCalculator().getMinValue() );
//---if we are generating an ImageMap, store the image coordinates
|