krysalis-jcharts/src/java/org/krysalis/jcharts/legend Legend.java,1.1,1.2 Symbol.java,1.1,1.2 LineSymbol.java,1.1,1.2 Item.java,1.1,1.2

"Nathaniel G. Auvil" <[email protected]> Mon, 25 Oct 2004 02:30:20 +0000
Newsgroups gmane.comp.krysalis.jcharts.cvs
Message-ID <[email protected]>
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/legend
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8136/src/java/org/krysalis/jcharts/legend

Modified Files:
	Legend.java Symbol.java LineSymbol.java Item.java 
Log Message:


Index: Item.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/legend/Item.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Item.java	23 Oct 2004 17:38:36 -0000	1.1
--- Item.java	25 Oct 2004 02:30:18 -0000	1.2
***************
*** 67,74 ****
--- 67,87 ----
  	/**************************************************************************************
  	 * 
+ 	 * @return
+ 	 **************************************************************************************/
+ 	public float getWidth()
+ 	{
+ 		return this.width;
+ 	}
+ 	
+ 	
+ 	/**************************************************************************************
+ 	 * 
  	 * @param g2d
  	 *************************************************************************************/
  	public void render( Graphics2D g2d )
  	{
+ 		this.symbol.render( g2d );
+ 		
+ 		
  		
  	}

Index: Symbol.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/legend/Symbol.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Symbol.java	23 Oct 2004 17:38:59 -0000	1.1
--- Symbol.java	25 Oct 2004 02:30:18 -0000	1.2
***************
*** 48,54 ****
  class Symbol
  {
! 	private Shape shape;
! 	private Paint fillPaint;
! 	private Paint outlinePaint;
  	
  	private float width;
--- 48,54 ----
  class Symbol
  {
! 	Shape shape;
! 	Paint fillPaint;
! 	Paint outlinePaint;
  	
  	private float width;
***************
*** 74,78 ****
  	 ****************************************************************************************/	
  	public void render( Graphics2D g2d )
! 	{
  		
  	}
--- 74,89 ----
  	 ****************************************************************************************/	
  	public void render( Graphics2D g2d )
! 	{		
! 		if( this.fillPaint != null )
! 		{
! 			g2d.setPaint( this.fillPaint );
! 			g2d.fill( shape );
! 		}
! 		
! 		if( this.outlinePaint != null )
! 		{
! 			g2d.setPaint( this.outlinePaint );
! 			g2d.draw( shape );
! 		}
  		
  	}

Index: LineSymbol.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/legend/LineSymbol.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** LineSymbol.java	23 Oct 2004 17:38:50 -0000	1.1
--- LineSymbol.java	25 Oct 2004 02:30:18 -0000	1.2
***************
*** 41,44 ****
--- 41,45 ----
  import java.awt.Stroke;
  import java.awt.geom.Line2D;
+ import java.awt.geom.Rectangle2D;
  
  
***************
*** 51,54 ****
--- 52,56 ----
  {
  	private Stroke stroke;
+ 	private int lineLength;
  	
  	
***************
*** 56,69 ****
  	 * 
  	 * @param shape
  	 * @param lineStroke
  	 *************************************************************************************/
! 	public LineSymbol( Shape shape, Paint fillPaint, Stroke lineStroke )
  	{
  		super( shape, fillPaint, null );
  		this.stroke= lineStroke;
  	}
  	
  	
- 	
  	/*************************************************************************************
  	 * 
--- 58,73 ----
  	 * 
  	 * @param shape
+ 	 * @param fillPaint
  	 * @param lineStroke
+ 	 * @param lineLength
  	 *************************************************************************************/
! 	public LineSymbol( Shape shape, Paint fillPaint, Stroke lineStroke, int lineLength )
  	{
  		super( shape, fillPaint, null );
  		this.stroke= lineStroke;
+ 		this.lineLength= lineLength;
  	}
  	
  	
  	/*************************************************************************************
  	 * 
***************
*** 72,80 ****
  	public void render( Graphics2D g2d )
  	{
! 		Line2D.Double line;
  		
! 		//TODO draw the line
  		
! 		super.render( g2d );
  	}
  	
--- 76,102 ----
  	public void render( Graphics2D g2d )
  	{
! 		Rectangle2D shapeBounds = super.shape.getBounds2D();
! 		double xOffset = shapeBounds.getWidth() / 2;
! 		double yOffset = shapeBounds.getHeight() / 2;
  		
! 		g2d.setStroke( this.stroke );						
! 		g2d.draw( new Line2D.Double( 0, yOffset, this.lineLength, yOffset ) );
  		
! 		//---translate the Shape to adjust for the lineLength
! 		g2d.translate( xOffset, 0 );
! 		
! 		
! 		if( super.fillPaint != null )
! 		{
! 			g2d.setPaint( super.fillPaint );
! 			g2d.fill( super.shape );
! 		}
! 	
! 		if( super.outlinePaint != null )
! 		{
! 			g2d.setPaint( super.outlinePaint );
! 			g2d.draw( super.shape );
! 		}
! 
  	}
  	

Index: Legend.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/legend/Legend.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Legend.java	23 Oct 2004 17:44:48 -0000	1.1
--- Legend.java	25 Oct 2004 02:30:17 -0000	1.2
***************
*** 100,103 ****
--- 100,104 ----
  	ChartType chartType;
  	ArrayList shapes, fillPointsFlags, strokes, pointOutlinePaints, labels, paints;
+ 
  	
  
***************
*** 271,275 ****
  					}
  
! 					LineSymbol lineSymbol= new LineSymbol( shape, iAxisPlotDataSet.getPaint( i ), lineChartProperties.getLineStrokes()[ i ] );					
  					this.items.add( new Item( lineSymbol, iAxisPlotDataSet.getLegendLabel( i ) ) );
  				}
--- 272,279 ----
  					}
  
! 					LineSymbol lineSymbol= new LineSymbol( shape, 
! 																		iAxisPlotDataSet.getPaint( i ), 
! 																		lineChartProperties.getLineStrokes()[ i ],
! 																		this.legendProperties.getIconLineStrokeLength() );					
  					this.items.add( new Item( lineSymbol, iAxisPlotDataSet.getLegendLabel( i ) ) );
  				}
***************
*** 300,306 ****
  			{
  //TODO this probably should be moved into the Item Class.				
! 				this.textProcessor.addLabel( iPieChartDataSet.getLegendLabel( i ),
! 											 this.legendProperties.getChartFont().getFont(),
! 											 this.chart.getGraphics2D().getFontRenderContext() );
  
  				Symbol symbol= new Symbol( PointChartProperties.SHAPE_SQUARE,
--- 304,310 ----
  			{
  //TODO this probably should be moved into the Item Class.				
! 				this.textProcessor.addLabel( iPieChartDataSet.getLegendLabel( i ), 
! 													  this.legendProperties.getChartFont().getFont(), 
! 													  this.chart.getGraphics2D().getFontRenderContext() );
  
  				Symbol symbol= new Symbol( PointChartProperties.SHAPE_SQUARE,
***************
*** 347,352 ****
  		//---make the icon proportional to the Font being used.
  		this.iconSide = (float) .50 * this.textProcessor.getTallestLabel();
  		
! 		
  		//---for POINT and LINE charts, set iconSide to max width of legend shapes
  		if( (chartType == ChartType.POINT) || (chartType == ChartType.LINE) )
--- 351,359 ----
  		//---make the icon proportional to the Font being used.
  		this.iconSide = (float) .50 * this.textProcessor.getTallestLabel();
+ 
+ //TODO we probably do not even need to look at all the shapes because we just need a scale factor for the shape.
+ //TODO do we need to be concerned about the line length?
  		
! /*		
  		//---for POINT and LINE charts, set iconSide to max width of legend shapes
  		if( (chartType == ChartType.POINT) || (chartType == ChartType.LINE) )
***************
*** 367,371 ****
  
  				this.iconSide = Math.max( this.iconSide, (float) shape.getBounds2D().getWidth() );
! 
  
  /*				
--- 374,378 ----
  
  				this.iconSide = Math.max( this.iconSide, (float) shape.getBounds2D().getWidth() );
! */
  
  /*				
***************
*** 384,390 ****
  				  	}
  */				 
! 			}
  		}
! 
  		this.determineWidthAndHeight( numberOfLabels );
  	}
--- 391,397 ----
  				  	}
  */				 
! /*			}
  		}
! */
  		this.determineWidthAndHeight( numberOfLabels );
  	}
***************
*** 522,526 ****
  		int labelIndex = 0;
  
! 		Shape shape = (Shape) this.shapes.get( labelIndex );
  
  		//---get the original transform so can reset it
--- 529,534 ----
  		int labelIndex = 0;
  
! 		Shape shape= null;
! 		Item item;
  
  		//---get the original transform so can reset it
***************
*** 535,544 ****
  			{
  				rectangle.x = posX;
- 				shape = (Shape) this.shapes.get( labelIndex );
  				
! 				//---display icon
! 				g2d.setPaint( (Paint) this.paints.get( labelIndex ) );
  
  				
  //TODO still need to draw a line for Line Charts				
  if( shape != null )
--- 543,561 ----
  			{
  				rectangle.x = posX;
  				
! 				item= (Item) this.items.get( labelIndex );
  
  				
+ 				//---translate the Shape into position
+ 				g2d.translate( rectangle.x, rectangle.y );				
+ 
+ 				
+ 				item.render( g2d );
+ 				
+ 				
+ 				posX+= item.getWidth();
+ 				
+ 				
+ 				
  //TODO still need to draw a line for Line Charts				
  if( shape != null )
***************
*** 548,602 ****
  				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 )
  					{
- 						if( ((Boolean) this.fillPointsFlags.get( labelIndex )).booleanValue() )
- 						{
- 							g2d.fill( shape );
- 
- 							//---if we are filling the points, see if we should outline the Shape
- 							//---applicable only to POINt charts
- 							if( this.pointOutlinePaints.get( labelIndex ) != null )
- 							{
- 								g2d.setPaint( (Paint) this.pointOutlinePaints.get( labelIndex ) );
- 								g2d.draw( shape );
- 							}
- 						}
  					}
  					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 ) );						
- 						g2d.draw( new Line2D.Double( 0, yOffset, this.legendProperties.getIconLineStrokeLength(), yOffset ) );
- 						
- 						// 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---
--- 565,574 ----
***************
*** 610,622 ****
  				else
  				{
! 					g2d.fill( rectangle );
! 
! 					//---border around icon
! 					if( this.legendProperties.getIconBorderStroke() != null )
! 					{
! 						g2d.setStroke( this.legendProperties.getIconBorderStroke() );
! 						g2d.setPaint( this.legendProperties.getIconBorderPaint() );
! 						g2d.draw( rectangle );
! 					}
  					
  					posX += iconAndPaddingWidth;
--- 582,586 ----
  				else
  				{
! 					
  					
  					posX += iconAndPaddingWidth;



-------------------------------------------------------
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