Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25634/src/java/org/krysalis/jcharts
Modified Files:
Legend.java
Log Message:
Fix for Legend for combo charts where legend colors would get out of sync
Index: Legend.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/Legend.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Legend.java 31 May 2004 21:11:51 -0000 1.11
--- Legend.java 1 Jul 2004 00:06:17 -0000 1.12
***************
*** 40,43 ****
--- 40,45 ----
import java.awt.Paint;
import java.awt.Shape;
+ import java.awt.Stroke;
+ import java.awt.BasicStroke;
import java.awt.geom.AffineTransform;
import java.awt.geom.Line2D;
***************
*** 87,91 ****
private float width = 0;
private float height = 0;
!
//---used to extract the legendLabels and paints from the data set and make them easy to loop through
--- 89,96 ----
private float width = 0;
private float height = 0;
!
! // for Bar chart legend shape - size is automatically calculated later on
! private Rectangle2D barShape = new Rectangle2D.Double(0, 0, 0, 0);
! private Stroke barStroke = new BasicStroke();
//---used to extract the legendLabels and paints from the data set and make them easy to loop through
***************
*** 93,96 ****
--- 98,102 ----
private ArrayList paints;
private ArrayList shapes = new ArrayList();
+ private ArrayList strokes = new ArrayList();
private ArrayList fillPointsFlags = new ArrayList();
private ArrayList pointOutlinePaints = new ArrayList();
***************
*** 257,260 ****
--- 263,267 ----
this.chartType = ChartType.LINE;
this.lineChartProperties = (LineChartProperties) iAxisPlotDataSet.getChartTypeProperties();
+ this.strokes.add( lineChartProperties.getLineStrokes()[ i ] );
if( lineChartProperties.getShapes() != null )
{
***************
*** 262,265 ****
--- 269,280 ----
}
}
+ else
+ {
+ // just put place holder shape in as well as stroke so that order is maintained
+ // for combo bar and line charts. If we allow point/line/bar combos then we'll
+ // also have to add fillPointsFlags and Paints
+ this.shapes.add(barShape);
+ this.strokes.add(barStroke);
+ }
}
}
***************
*** 504,508 ****
// only Point and Line Charts will have shapes drawn
! if( this.shapes.size() > 0 && this.shapes.size() > labelIndex )
{
//Shape shape = (Shape)this.shapes.get( labelIndex);
--- 519,525 ----
// only Point and Line Charts will have shapes drawn
! if( this.shapes.size() > 0 && this.shapes.size() > labelIndex &&
! !((Shape)this.shapes.get( labelIndex)).equals(barShape))
!
{
//Shape shape = (Shape)this.shapes.get( labelIndex);
***************
*** 544,548 ****
double YOffset = shapeBounds.getHeight() / 2;
! g2d.setStroke(this.lineChartProperties.getLineStrokes()[ labelIndex]);
Line2D.Double line = new Line2D.Double(0, YOffset, this.legendProperties.getIconLineStrokeLength(), YOffset);
--- 561,566 ----
double YOffset = shapeBounds.getHeight() / 2;
! // g2d.setStroke(this.lineChartProperties.getLineStrokes()[ labelIndex]);
! g2d.setStroke((Stroke)this.strokes.get( labelIndex ));
Line2D.Double line = new Line2D.Double(0, YOffset, this.legendProperties.getIconLineStrokeLength(), YOffset);
|