|
From: <ki...@us...> - 2003-08-27 04:38:02
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart/axis
In directory sc8-pr-cvs1:/tmp/cvs-serv23576/axisChart/axis
Modified Files:
Axis.java YAxis.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: Axis.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart/axis/Axis.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Axis.java 22 Jun 2003 14:12:02 -0000 1.2
--- Axis.java 27 Aug 2003 04:37:44 -0000 1.3
***************
*** 80,83 ****
--- 80,88 ----
private TextTagGroup axisLabelsGroup;
+ // Dual Y axis changes integrated CMC 25Aug03
+ // Variable to use to display the labels of the right Y axis
+ // the corresponding methods are also implemented
+ private TextTagGroup axisLabelsGroupRight;
+
//---this number of items to plot on the Axis. Note, if no labels are displayed, axisLabelsGroup will be NULL so we can not depend on that.
private int numberOfScaleItems;
***************
*** 138,142 ****
! public final float getTitleWidth()
{
return this.titleWidth;
--- 143,158 ----
! // Dual Y axis changes integrated CMC 25Aug03
! public TextTagGroup getAxisLabelsGroupRight()
! {
! return axisLabelsGroupRight;
! }
!
! public void setAxisLabelsGroupRight( TextTagGroup axisLabelsGroupRight )
! {
! this.axisLabelsGroupRight = axisLabelsGroupRight;
! }
!
! public final float getTitleWidth()
{
return this.titleWidth;
Index: YAxis.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart/axis/YAxis.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** YAxis.java 22 Jun 2003 14:12:02 -0000 1.3
--- YAxis.java 27 Aug 2003 04:37:44 -0000 1.4
***************
*** 97,102 ****
if( axisTypeProperties.showAxisLabels() )
{
! widthNeeded+= super.getAxisLabelsGroup().getWidestLabel();
! }
--- 97,118 ----
if( axisTypeProperties.showAxisLabels() )
{
! // Dual Y axis changes integrated CMC 25Aug03
! //widthNeeded+= super.getAxisLabelsGroup().getWidestLabel();
! if ( axisTypeProperties.getShowRightAxis() )
! {
! if ( super.getAxisLabelsGroupRight().getWidestLabel()>super.getAxisLabelsGroup().getWidestLabel())
! {
! widthNeeded+= super.getAxisLabelsGroupRight().getWidestLabel();
! }
! else
! {
! widthNeeded+= super.getAxisLabelsGroup().getWidestLabel();
! }
! }
! else
! {
! widthNeeded+= super.getAxisLabelsGroup().getWidestLabel();
! }
! }
***************
*** 316,319 ****
--- 332,385 ----
}
}
+
+ // Dual Y axis changes integrated CMC 25Aug03
+ //---if AXIS at the right----------------------------------------------------------------------
+
+ if (axisTypeProperties.getShowRightAxis())
+ {
+
+ line2D.x1 = super.getAxisChart().getXAxis().getOrigin() + super.getAxisChart().getXAxis().getPixelLength();
+ line2D.x2 = line2D.x1;
+ line2D.y1 = super.getOrigin() - super.getPixelLength() - 10 ;
+ line2D.y2 = super.getOrigin();
+ axisTypeProperties.getAxisStroke().draw( graphics2D, line2D );
+
+ float tickRightX1 = super.getAxisChart().getXAxis().getOrigin() + super.getAxisChart().getXAxis().getPixelLength();
+ float tickRightX2 = tickRightX1 + axisTypeProperties.getAxisTickMarkPixelLength();
+ line2D.y1 = super.getOrigin();
+ line2D.y2 = line2D.y1;
+
+ stringY = super.getOrigin() + ( super.getAxisLabelsGroupRight().getTallestLabel() / 4 );
+ stringX = super.getAxisChart().getXAxis().getOrigin() + axisTypeProperties.getAxisTickMarkPixelLength()
+ + super.getAxisChart().getXAxis().getPixelLength();
+
+ stringX+= axisTypeProperties.getPaddingBetweenLabelsAndTicks();
+
+ for( int i = 0; i < super.getNumberOfScaleItems(); i++ )
+ {
+ //---TICK MARKS at the right
+ if( axisTypeProperties.getShowTicks() != AxisTypeProperties.TICKS_NONE )
+ {
+ line2D.x1 = tickRightX1;
+ line2D.x2 = tickRightX2;
+ axisTypeProperties.getTickChartStroke().draw( graphics2D, line2D );
+ }
+
+ line2D.y1 -= super.getScalePixelWidth();
+ line2D.y2 = line2D.y1;
+
+
+ //---AXIS LABEL at the right
+ if( axisTypeProperties.showAxisLabels() )
+ {
+
+ // Font and Paint set in TextTagGroup object in 1.0 it seems CMC 25Aug03
+ //graphics2D.setFont( axisTypeProperties.getScaleChartFontRight().getFont());
+ //graphics2D.setPaint( axisTypeProperties.getScaleChartFontRight().getPaint() );
+ super.getAxisLabelsGroupRight().render( i, graphics2D, stringX , stringY );
+ }
+ stringY -= super.getScalePixelWidth();
+ }
+ }
}
|