krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart BarChart.java,1.2,1.3

"Nathaniel G. Auvil" <[email protected]> Thu, 27 May 2004 02:15:22 +0000
Newsgroups gmane.comp.krysalis.jcharts.cvs
Message-ID <[email protected]>
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15023/src/java/org/krysalis/jcharts/axisChart

Modified Files:
	BarChart.java 
Log Message:


Index: BarChart.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart/BarChart.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** BarChart.java	26 May 2004 01:57:19 -0000	1.2
--- BarChart.java	27 May 2004 02:15:19 -0000	1.3
***************
*** 44,48 ****
  import org.krysalis.jcharts.imageMap.RectMapArea;
  import org.krysalis.jcharts.properties.BarChartProperties;
- import org.krysalis.jcharts.properties.DataAxisProperties;
  
  
--- 44,47 ----
***************
*** 64,69 ****
  		Graphics2D g2d = axisChart.getGraphics2D();
  		BarChartProperties barChartProperties = (BarChartProperties) iAxisChartDataSet.getChartTypeProperties();
- 
- 		DataAxisProperties dataAxisProperties;
  		float barWidth;
  
--- 63,66 ----
***************
*** 76,82 ****
  		if( axisChart.getAxisProperties().isPlotHorizontal() )
  		{
- 			dataAxisProperties = (DataAxisProperties) axisChart.getAxisProperties().getXAxisProperties();
  			barWidth = axisChart.getYAxis().getScalePixelWidth() * barChartProperties.getPercentage();
- 
  			startingX = axisChart.getXAxis().getZeroLineCoordinate();
  			startingY = axisChart.getYAxis().getLastTickY() - (barWidth / 2);
--- 73,77 ----
***************
*** 86,101 ****
  
  			BarChart.horizontalPlot(	axisChart,
! 																iAxisChartDataSet,
! 																barChartProperties,
! 																dataAxisProperties,
! 																g2d,
! 																rectangle,
! 																startingX );
  		}
  		else
  		{
- 			dataAxisProperties = (DataAxisProperties) axisChart.getAxisProperties().getYAxisProperties();
  			barWidth = axisChart.getXAxis().getScalePixelWidth() * barChartProperties.getPercentage();
- 
  			startingX = axisChart.getXAxis().getTickStart() - (barWidth / 2);
  			startingY = axisChart.getYAxis().getZeroLineCoordinate();
--- 81,93 ----
  
  			BarChart.horizontalPlot(	axisChart,
! 												iAxisChartDataSet,
! 												barChartProperties,
! 												g2d,
! 												rectangle,
! 												startingX );
  		}
  		else
  		{
  			barWidth = axisChart.getXAxis().getScalePixelWidth() * barChartProperties.getPercentage();
  			startingX = axisChart.getXAxis().getTickStart() - (barWidth / 2);
  			startingY = axisChart.getYAxis().getZeroLineCoordinate();
***************
*** 105,114 ****
  
  			BarChart.verticalPlot(	axisChart,
! 															iAxisChartDataSet,
! 															barChartProperties,
! 															dataAxisProperties,
! 															g2d,
! 															rectangle,
! 															startingY );
  		}
  	}
--- 97,105 ----
  
  			BarChart.verticalPlot(	axisChart,
! 											iAxisChartDataSet,
! 											barChartProperties,
! 											g2d,
! 											rectangle,
! 											startingY );
  		}
  	}
***************
*** 119,123 ****
  	 * @param iAxisChartDataSet
  	 * @param barChartProperties
- 	 * @param dataAxisProperties
  	 * @param g2d
  	 * @param rectangle
--- 110,113 ----
***************
*** 125,134 ****
  	 **************************************************************************************/
  	private static void horizontalPlot( AxisChart axisChart,
! 																			IAxisChartDataSet iAxisChartDataSet,
! 																			BarChartProperties barChartProperties,
! 																			DataAxisProperties dataAxisProperties,
! 																			Graphics2D g2d,
! 																			Rectangle2D.Float rectangle,
! 																			float startingX )
  	{
  		int imageMapLabelIndex = axisChart.getYAxis().getNumberOfScaleItems() - 1;
--- 115,123 ----
  	 **************************************************************************************/
  	private static void horizontalPlot( AxisChart axisChart,
! 													IAxisChartDataSet iAxisChartDataSet,
! 													BarChartProperties barChartProperties,
! 													Graphics2D g2d,
! 													Rectangle2D.Float rectangle,
! 													float startingX )
  	{
  		int imageMapLabelIndex = axisChart.getYAxis().getNumberOfScaleItems() - 1;
***************
*** 143,150 ****
  		//---reuse the same Object for pre and post render events.
  		AxisValueRenderEvent axisValueRenderEvent = new AxisValueRenderEvent( axisChart,
! 																																					iAxisChartDataSet,
! 																																					g2d,
! 																																					totalItemArea,
! 																																					axisChart.getXAxis().getZeroLineCoordinate() );
  
  		//---there is only ever one data set for a regular bar chart
--- 132,139 ----
  		//---reuse the same Object for pre and post render events.
  		AxisValueRenderEvent axisValueRenderEvent = new AxisValueRenderEvent( axisChart,
! 																									iAxisChartDataSet,
! 																									g2d,
! 																									totalItemArea,
! 																									axisChart.getXAxis().getZeroLineCoordinate() );
  
  		//---there is only ever one data set for a regular bar chart
***************
*** 171,178 ****
  				{
  					rectangle.x = axisChart.getXAxis().computeAxisCoordinate( axisChart.getXAxis().getOrigin(),
! 																																		iAxisChartDataSet.getValue( 0, i ),
! 																																		axisChart	.getXAxis()
! 																																							.getScaleCalculator()
! 																																							.getMinValue() );
  					rectangle.width = startingX - rectangle.x;
  
--- 160,165 ----
  				{
  					rectangle.x = axisChart.getXAxis().computeAxisCoordinate( axisChart.getXAxis().getOrigin(),
! 																									iAxisChartDataSet.getValue( 0, i ),
! 																									axisChart.getXAxis().getScaleCalculator().getMinValue() );
  					rectangle.width = startingX - rectangle.x;
  
***************
*** 184,188 ****
  					rectangle.x = startingX;
  					rectangle.width = BarChart.computeScaleHeightOfValue( iAxisChartDataSet.getValue( 0, i ),
! 																																axisChart.getXAxis().getOneUnitPixelSize() );
  
  					//---set values for the postRender event
--- 171,175 ----
  					rectangle.x = startingX;
  					rectangle.width = BarChart.computeScaleHeightOfValue( iAxisChartDataSet.getValue( 0, i ),
! 																							axisChart.getXAxis().getOneUnitPixelSize() );
  
  					//---set values for the postRender event
***************
*** 190,204 ****
  				}
  
! 				//---with a user defined scale, we could have non-zero data points with a height
! 				// of zero.
  				if( rectangle.width != 0 )
  				{
- 
- 					/*
- 					 * System.out.println( "rectangle.x= " + rectangle.x ); System.out.println(
- 					 * "rectangle.y= " + rectangle.y ); System.out.println( "rectangle.width= " +
- 					 * rectangle.width ); System.out.println( "rectangle.height= " +
- 					 * rectangle.height );
- 					 */
  					g2d.fill( rectangle );
  
--- 177,183 ----
  				}
  
! 				//---with a user defined scale, we could have non-zero data points with a height of zero.
  				if( rectangle.width != 0 )
  				{
  					g2d.fill( rectangle );
  
***************
*** 211,231 ****
  					if( axisChart.getGenerateImageMapFlag() )
  					{
! 						String label;
! 						if( axisChart.getYAxis().getAxisLabelsGroup() != null )
! 						{
! 							label = axisChart.getYAxis().getAxisLabelsGroup().getTextTag( imageMapLabelIndex ).getText();
! 						}
! 						else
! 						{
! 							label = null;
! 						}
  
! 						axisChart.getImageMap().addImageMapArea( new RectMapArea( rectangle,
! 																																			iAxisChartDataSet.getValue( 0, i ),
! 																																			label,
! 																																			iAxisChartDataSet.getLegendLabel( 0 ) ) );
  
! 						imageMapLabelIndex--;
  					}
  				}
  			}
--- 190,230 ----
  					if( axisChart.getGenerateImageMapFlag() )
  					{
! 						RectMapArea rectMapArea= createImageMapArea( axisChart.getYAxis().getAxisLabelsGroup(),
! 																					imageMapLabelIndex,
! 																					rectangle,
! 																					iAxisChartDataSet.getValue( 0, i ),
! 																					iAxisChartDataSet.getLegendLabel( 0 ) );
! 						axisChart.getImageMap().addImageMapArea( rectMapArea );
! 						
! 						imageMapLabelIndex--;
! 					}
! 				}
! 			}
! 			else
! 			{
! 				//---else, value is zero.
  
! 				//---if we are generating an ImageMap, store the image coordinates
! 				if( axisChart.getGenerateImageMapFlag() )
! 				{
! 					//---check if zero scale line is visible
! 					//---make sure zero is even visible on the scale. 
! 					//---If zero is not visible on scale nothing will be clickable for that item
! 					if( axisChart.getXAxis().getScaleCalculator().getMaxValue() >= 0
! 							&& axisChart.getXAxis().getScaleCalculator().getMinValue() <= 0 )
! 					{
! 						rectangle.x = startingX;
! 						rectangle.width = 1;
! 							
! 						RectMapArea rectMapArea = createImageMapArea( axisChart.getYAxis().getAxisLabelsGroup(),
! 																						imageMapLabelIndex,
! 																						rectangle,
! 																						iAxisChartDataSet.getValue( 0, i ),
! 																						iAxisChartDataSet.getLegendLabel( 0 ) );
  
! 						axisChart.getImageMap().addImageMapArea( rectMapArea );						
  					}
+ 					
+ 					imageMapLabelIndex--;
  				}
  			}
***************
*** 244,248 ****
  	 * @param iAxisChartDataSet
  	 * @param barChartProperties
- 	 * @param dataAxisProperties
  	 * @param g2d
  	 * @param rectangle
--- 243,246 ----
***************
*** 252,256 ****
  													IAxisChartDataSet iAxisChartDataSet,
  													BarChartProperties barChartProperties,
- 													DataAxisProperties dataAxisProperties,
  													Graphics2D g2d,
  													Rectangle2D.Float rectangle,
--- 250,253 ----
***************
*** 308,312 ****
  				}
  
! //TODO not sure this makes sense.  How could this be zero?				
  				//---with a user defined scale, we could have non-zero data points with a height of zero.
  				if( rectangle.height != 0 )
--- 305,309 ----
  				}
  
! 				
  				//---with a user defined scale, we could have non-zero data points with a height of zero.
  				if( rectangle.height != 0 )
***************
*** 335,350 ****
  			else
  			{
! //				System.out.println( "value was zero" );
! 
! 				//---make sure zero is even visible on the scale
! 				if( axisChart.getYAxis().getScaleCalculator().getMaxValue() >= 0
! 						&& axisChart.getYAxis().getScaleCalculator().getMinValue() <= 0 )
  				{
! 					rectangle.y = startingY;
! 					rectangle.height = 1;
! 
! 					//---if we are generating an ImageMap, store the image coordinates
! 					if( axisChart.getGenerateImageMapFlag() )
  					{
  						RectMapArea rectMapArea = createImageMapArea( axisChart.getXAxis().getAxisLabelsGroup(),
  																						i,
--- 332,346 ----
  			else
  			{
! 				//---if we are generating an ImageMap, store the image coordinates
! 				if( axisChart.getGenerateImageMapFlag() )
  				{
! 					//---make sure zero is even visible on the scale. 
! 					//---If zero is not visible on scale nothing will be clickable for that item
! 					if( axisChart.getYAxis().getScaleCalculator().getMaxValue() >= 0
! 							&& axisChart.getYAxis().getScaleCalculator().getMinValue() <= 0 )
  					{
+ 						rectangle.y = startingY;
+ 						rectangle.height = 1;
+ 							
  						RectMapArea rectMapArea = createImageMapArea( axisChart.getXAxis().getAxisLabelsGroup(),
  																						i,
***************
*** 353,364 ****
  																						iAxisChartDataSet.getLegendLabel( 0 ) );
  
! 						axisChart.getImageMap().addImageMapArea( rectMapArea );
  					}
  				}
! /*				else
! 				{
! 					System.out.println( "Not in scale range so skip." );
! 				}
! */			}
  
  			//---notify everyone we just rendered
--- 349,356 ----
  																						iAxisChartDataSet.getLegendLabel( 0 ) );
  
! 						axisChart.getImageMap().addImageMapArea( rectMapArea );						
  					}
  				}
! 			}
  
  			//---notify everyone we just rendered
***************
*** 388,399 ****
  	/***************************************************************************************
  	 * @param axisLabelsGroup
! 	 * @param index
  	 * @param rectangle
  	 * @param value
  	 * @param legendLabel
! 	 * @return
  	 **************************************************************************************/
  	private static RectMapArea createImageMapArea( TextTagGroup axisLabelsGroup,
! 																	int index,
  																	Rectangle2D.Float rectangle,
  																	double value,
--- 380,391 ----
  	/***************************************************************************************
  	 * @param axisLabelsGroup
! 	 * @param labelIndex
  	 * @param rectangle
  	 * @param value
  	 * @param legendLabel
! 	 * @return RectMapArea
  	 **************************************************************************************/
  	private static RectMapArea createImageMapArea( TextTagGroup axisLabelsGroup,
! 																   int labelIndex,
  																	Rectangle2D.Float rectangle,
  																	double value,
***************
*** 403,411 ****
  		if( axisLabelsGroup != null )
  		{
! 			label = axisLabelsGroup.getTextTag( index ).getText();
  		}
  		else
  		{
! 			label = null;
  		}
  
--- 395,403 ----
  		if( axisLabelsGroup != null )
  		{
! 			label = axisLabelsGroup.getTextTag( labelIndex ).getText();
  		}
  		else
  		{
! 			label = "";
  		}
  



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click