krysalis-jcharts/src/java/org/krysalis/jcharts Legend.java,1.13,1.14

"Nathaniel G. Auvil" <[email protected]> Fri, 22 Oct 2004 00:31:29 +0000
Newsgroups gmane.comp.krysalis.jcharts.cvs
Message-ID <[email protected]>
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19052/src/java/org/krysalis/jcharts

Modified Files:
	Legend.java 
Log Message:
fixing the icon problems. Still needs more work

Index: Legend.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/Legend.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** Legend.java	20 Oct 2004 13:34:50 -0000	1.13
--- Legend.java	22 Oct 2004 00:31:26 -0000	1.14
***************
*** 229,234 ****
  
  	/***************************************************************************************
! 	 * Method for processing data for AxisPlot datasets; try to minimize looping. 1)
! 	 * calculate the maximum height of labels 2) find the maximum label width
  	 * 
  	 * @param iAxisPlotDataSet
--- 229,236 ----
  
  	/***************************************************************************************
! 	 * Method for processing data for AxisPlot datasets; try to minimize looping. 
! 	 * 	1) calculate the maximum height of labels 
! 	 *  2) find the maximum label width
! 	 *  3
  	 * 
  	 * @param iAxisPlotDataSet
***************
*** 241,247 ****
  			if( iAxisPlotDataSet.getLegendLabel( i ) != null )
  			{
! 				this.textProcessor.addLabel(	iAxisPlotDataSet.getLegendLabel( i ),
! 												this.legendProperties.getChartFont().getFont(),
! 												this.chart.getGraphics2D().getFontRenderContext() );
  
  				//---pair labels with paints to get around ugly piechart vs axischart data structure mess
--- 243,249 ----
  			if( iAxisPlotDataSet.getLegendLabel( i ) != null )
  			{
! 				this.textProcessor.addLabel( iAxisPlotDataSet.getLegendLabel( i ),
! 											 this.legendProperties.getChartFont().getFont(), 
! 											 this.chart.getGraphics2D().getFontRenderContext() );
  
  				//---pair labels with paints to get around ugly piechart vs axischart data structure mess
***************
*** 293,302 ****
  			if( iPieChartDataSet.getLegendLabel( i ) != null )
  			{
! 				this.textProcessor.addLabel(	iPieChartDataSet.getLegendLabel( i ),
! 																			this.legendProperties.getChartFont().getFont(),
! 																			this.chart.getGraphics2D().getFontRenderContext() );
  
! 				//---pair labels with paints to get around ugly piechart vs axischart data
! 				// structure mess
  				this.labels.add( iPieChartDataSet.getLegendLabel( i ) );
  				this.paints.add( iPieChartDataSet.getPaint( i ) );
--- 295,303 ----
  			if( iPieChartDataSet.getLegendLabel( i ) != null )
  			{
! 				this.textProcessor.addLabel( iPieChartDataSet.getLegendLabel( i ),
! 											 this.legendProperties.getChartFont().getFont(),
! 											 this.chart.getGraphics2D().getFontRenderContext() );
  
! 				//---pair labels with paints to get around ugly piechart vs axischart data structure mess
  				this.labels.add( iPieChartDataSet.getLegendLabel( i ) );
  				this.paints.add( iPieChartDataSet.getPaint( i ) );
***************
*** 452,458 ****
  
  		//---account for lineStrokes for LINE charts
  		if( chartType == ChartType.LINE )
  		{
! 			width += this.legendProperties.getIconLineStrokeLength() * 2 * this.numColumns;
  		}
  
--- 453,461 ----
  
  		//---account for lineStrokes for LINE charts
+ 		//TODO this is NOT correct.
  		if( chartType == ChartType.LINE )
  		{
! 			//width += this.legendProperties.getIconLineStrokeLength() * 2 * this.numColumns;
! 			width += this.legendProperties.getIconLineStrokeLength() * this.numColumns;
  		}
  
***************
*** 490,495 ****
  
  		//---dont think we want this so text will be clean but leave commented out.
! 		//g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING,
! 		// RenderingHints.VALUE_ANTIALIAS_OFF );
  
  		//---set the font and text color.
--- 493,497 ----
  
  		//---dont think we want this so text will be clean but leave commented out.
! 		//g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
  
  		//---set the font and text color.
***************
*** 512,515 ****
--- 514,521 ----
  		Shape shape = (Shape) this.shapes.get( labelIndex );
  
+ 		//---get the original transform so can reset it
+ 		AffineTransform affineTransform = g2d.getTransform();
+ 		
+ 		
  		//LOOP
  		for( int j = 0; j < this.numRows; j++ )
***************
*** 530,539 ****
  				if( this.shapes.size() > 0 && this.shapes.size() > labelIndex && !shape.equals( barShape ) )
  				{
- 					//---get the original transform so can reset it
- 					AffineTransform affineTransform = g2d.getTransform();
- 
  					//---translate the Shape into position
  					g2d.translate( rectangle.x, rectangle.y );
! 
  					if( this.fillPointsFlags.size() > 0 )
  					{
--- 536,542 ----
  				if( this.shapes.size() > 0 && this.shapes.size() > labelIndex && !shape.equals( barShape ) )
  				{
  					//---translate the Shape into position
  					g2d.translate( rectangle.x, rectangle.y );
! 					
  					if( this.fillPointsFlags.size() > 0 )
  					{
***************
*** 553,600 ****
  					else
  					{
! 						// for Point Charts, only draw shape
! 						if( chartType == ChartType.POINT )
! 						{
! 							g2d.draw( shape );
! 						}
! 						else
! 						// chartType == ChartType.LINE
! 						// for Line Charts, fill the shape
! 						{
! 							//---get the bounds of the shape
! 							Rectangle2D shapeBounds = shape.getBounds2D();
! 							double xOffset = shapeBounds.getWidth() / 2;
! 							double yOffset = shapeBounds.getHeight() / 2;
! 							g2d.setStroke( (Stroke) this.strokes.get( labelIndex ) );
! 							Line2D.Double line = new Line2D.Double( 0,
! 																	yOffset,
! 																	this.legendProperties.getIconLineStrokeLength(),
! 																	yOffset );
! 							g2d.draw( line );
! 							// move posX to account for the lineStroke before the shape. for example: ---o
! 							posX += this.legendProperties.getIconLineStrokeLength();
! 							//---translate the Shape to adjust for the IconLineStrokeLength
! 							g2d.translate( this.legendProperties.getIconLineStrokeLength() - xOffset, 0 );
! 
! 							line.x1 = xOffset;
! 							g2d.draw( line );
  
! 							g2d.fill( (Shape) this.shapes.get( labelIndex ) );
  
! 							//---border around icon
! 							if( this.legendProperties.getIconBorderStroke() != null && this.pointOutlinePaints.size() != 0 )
  							{
! 								if( this.pointOutlinePaints != null )
! 								{
! 									g2d.setStroke( this.legendProperties.getIconBorderStroke() );
! 									g2d.setPaint( (Paint) this.pointOutlinePaints.get( labelIndex ) );
! 									g2d.draw( shape );
! 								}
  							}
- 
- 							//---move posX to account for the lineStroke after the shape. for example: o---
- 							posX += this.legendProperties.getIconLineStrokeLength();
  						}
  					}
  					//---reset original transform
  					g2d.setTransform( affineTransform );
--- 556,599 ----
  					else
  					{
! 						//---get the bounds of the shape
! 						Rectangle2D shapeBounds = shape.getBounds2D();
! 						double xOffset = shapeBounds.getWidth() / 2;
! 						double yOffset = shapeBounds.getHeight() / 2;
! 						g2d.setStroke( (Stroke) this.strokes.get( labelIndex ) );
! 						
! 						Line2D.Double line = new Line2D.Double( 0,
! 																yOffset,
! 																this.legendProperties.getIconLineStrokeLength(),
! 																yOffset );
! 						g2d.draw( line );
! 						
! 						// move posX to account for the lineStroke before the shape. for example: ---o
! 						//posX += this.legendProperties.getIconLineStrokeLength();
! 						
! 						//---translate the Shape to adjust for the IconLineStrokeLength
! 						//g2d.translate( this.legendProperties.getIconLineStrokeLength() - xOffset, 0 );
! 						g2d.translate( xOffset, 0 );
! 						
! 						//line.x1 = xOffset;
! 						//g2d.draw( line );
  
! 						//---Line Charts fill with the same Paint as the lines are drawn with
! 						g2d.fill( (Shape) this.shapes.get( labelIndex ) );
  
! 						//---border around icon
! 						if( this.legendProperties.getIconBorderStroke() != null && this.pointOutlinePaints.size() != 0 )
! 						{
! 							if( this.pointOutlinePaints != null )
  							{
! 								g2d.setStroke( this.legendProperties.getIconBorderStroke() );
! 								g2d.setPaint( (Paint) this.pointOutlinePaints.get( labelIndex ) );
! 								g2d.draw( shape );
  							}
  						}
+ 
+ 						//---move posX to account for the lineStroke after the shape. for example: o---
+ 						posX += this.legendProperties.getIconLineStrokeLength();						
  					}
+ 					
  					//---reset original transform
  					g2d.setTransform( affineTransform );
***************
*** 655,658 ****
--- 654,661 ----
  		htmlGenerator.legendTableStart();
  
+ 		htmlGenerator.addTableRow( "X", Float.toString( this.x ) );
+ 		htmlGenerator.addTableRow( "Y", Float.toString( this.y ) );
+ 		htmlGenerator.addTableRow( "numColumns", Integer.toString( this.numColumns ) );
+ 		htmlGenerator.addTableRow( "numRows", Integer.toString( this.numRows ) );
  		htmlGenerator.addTableRow( "Width", Float.toString( this.width ) );
  		htmlGenerator.addTableRow( "Height", Float.toString( this.height ) );



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl