From: David G. <mu...@us...> - 2006-10-24 14:05:08
|
Update of /cvsroot/jfreechart/jfreechart/source/org/jfree/chart/annotations In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv18563/source/org/jfree/chart/annotations Modified Files: Tag: STABLE_1-0-0 XYShapeAnnotation.java Log Message: 2006-10-24 David Gilbert <dav...@ob...> * source/org/jfree/chart/annotations/XYShapeAnnotation.java (draw): Calculate transform on shape bounds. Index: XYShapeAnnotation.java =================================================================== RCS file: /cvsroot/jfreechart/jfreechart/source/org/jfree/chart/annotations/XYShapeAnnotation.java,v retrieving revision 1.8.2.2 retrieving revision 1.8.2.3 diff -C2 -d -r1.8.2.2 -r1.8.2.3 *** XYShapeAnnotation.java 25 Oct 2005 16:51:15 -0000 1.8.2.2 --- XYShapeAnnotation.java 24 Oct 2006 14:05:02 -0000 1.8.2.3 *************** *** 3,7 **** * =========================================================== * ! * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html --- 3,7 ---- * =========================================================== * ! * (C) Copyright 2000-2006, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html *************** *** 28,32 **** * XYShapeAnnotation.java * ---------------------- ! * (C) Copyright 2003-2005, by Ondax, Inc. and Contributors. * * Original Author: Greg Steckman (for Ondax, Inc.); --- 28,32 ---- * XYShapeAnnotation.java * ---------------------- ! * (C) Copyright 2003-2006, by Ondax, Inc. and Contributors. * * Original Author: Greg Steckman (for Ondax, Inc.); *************** *** 47,50 **** --- 47,53 ---- * constructors (DG); * 06-Jun-2005 : Fixed equals() method to handle GradientPaint (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 24-Oct-2006 : Calculate AffineTransform on shape's bounding rectangle + * rather than sample points (0, 0) and (1, 1) (DG); * */ *************** *** 79,84 **** * A simple <code>Shape</code> annotation that can be placed on an * {@link XYPlot}. The shape coordinates are specified in data space. - * - * @author Greg Steckman */ public class XYShapeAnnotation extends AbstractXYAnnotation --- 82,85 ---- *************** *** 105,109 **** * with a black outline). * ! * @param shape the shape (coordinates in data space). */ public XYShapeAnnotation(Shape shape) { --- 106,111 ---- * with a black outline). * ! * @param shape the shape (coordinates in data space, <code>null</code> ! * not permitted). */ public XYShapeAnnotation(Shape shape) { *************** *** 162,191 **** PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( ! plot.getDomainAxisLocation(), orientation ! ); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( ! plot.getRangeAxisLocation(), orientation ! ); ! //compute transform matrix elements via sample points. Assume no // rotation or shear. ! // x-axis translation ! double m02 = domainAxis.valueToJava2D(0, dataArea, domainEdge); ! // y-axis translation ! double m12 = rangeAxis.valueToJava2D(0, dataArea, rangeEdge); ! // x-axis scale ! double m00 = domainAxis.valueToJava2D(1, dataArea, domainEdge) - m02; ! // y-axis scale ! double m11 = rangeAxis.valueToJava2D(1, dataArea, rangeEdge) - m12; ! //create transform & transform shape Shape s = null; if (orientation == PlotOrientation.HORIZONTAL) { ! AffineTransform t1 = new AffineTransform( ! 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f ! ); ! AffineTransform t2 = new AffineTransform( ! m11, 0.0f, 0.0f, m00, m12, m02 ! ); s = t1.createTransformedShape(this.shape); s = t2.createTransformedShape(s); --- 164,195 ---- PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( ! plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( ! plot.getRangeAxisLocation(), orientation); ! // compute transform matrix elements via sample points. Assume no // rotation or shear. ! Rectangle2D bounds = this.shape.getBounds2D(); ! double x0 = bounds.getMinX(); ! double x1 = bounds.getMaxX(); ! double xx0 = domainAxis.valueToJava2D(x0, dataArea, domainEdge); ! double xx1 = domainAxis.valueToJava2D(x1, dataArea, domainEdge); ! double m00 = (xx1 - xx0) / (x1 - x0); ! double m02 = xx0 - x0 * m00; ! ! double y0 = bounds.getMaxY(); ! double y1 = bounds.getMinY(); ! double yy0 = rangeAxis.valueToJava2D(y0, dataArea, rangeEdge); ! double yy1 = rangeAxis.valueToJava2D(y1, dataArea, rangeEdge); ! double m11 = (yy1 - yy0) / (y1 - y0); ! double m12 = yy0 - m11 * y0; ! // create transform & transform shape Shape s = null; if (orientation == PlotOrientation.HORIZONTAL) { ! AffineTransform t1 = new AffineTransform(0.0f, 1.0f, 1.0f, 0.0f, ! 0.0f, 0.0f); ! AffineTransform t2 = new AffineTransform(m11, 0.0f, 0.0f, m00, ! m12, m02); s = t1.createTransformedShape(this.shape); s = t2.createTransformedShape(s); |