deweese 02/05/29 11:53:05 Modified: sources/org/apache/batik/gvt AbstractGraphicsNode.java ShapeNode.java sources/org/apache/batik/swing/gvt GVTTreeRenderer.java test-references/samples/extensions flowText.png test-resources/org/apache/batik/test samplesRendering.xml Added: samples/tests/spec/paints gradientPoint.svg Log: 1) Put in a fix for gradients on lines/points (really any geometry with zero size in x or y). 2) Put in a fix for IndexOutOfBounds exceptions from fireFailedEvent (It seems that interupting a thread that is in the middle of loading a class does bad things on Solaris. This seems to limit the damage.) 3) New reference image for flowText 4) New test for gradients, applying them to points. Revision Changes Path 1.1 xml-batik/samples/tests/spec/paints/gradientPoint.svg Index: gradientPoint.svg =================================================================== <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <!-- ====================================================================== --> <!-- Copyright (C) The Apache Software Foundation. All rights reserved. --> <!-- --> <!-- This software is published under the terms of the Apache Software --> <!-- License version 1.1, a copy of which has been included with this --> <!-- distribution in the LICENSE file. --> <!-- ====================================================================== --> <!-- ====================================================================== --> <!-- Gradients on Points. --> <!-- --> <!-- @author [EMAIL PROTECTED] --> <!-- @version $Id: gradientPoint.svg,v 1.1 2002/05/29 18:53:05 deweese Exp $ --> <!-- ====================================================================== --> <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> <svg id="body" width="450" height="500" viewBox="0 0 450 500" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" > <title>Gradients on Points</title> <text x="50%" y="45" class="title">Gradients on Points</text> <g id="testContent"> <defs> <linearGradient id="hGrad" x1="0" y1="0" x2="1" y2="0"> <stop offset="0" style="stop-color:crimson" /> <stop offset="1" style="stop-color:gold" /> </linearGradient> <linearGradient id="vGrad" x1="0" y1="0" x2="0" y2="1"> <stop offset="0" style="stop-color:crimson" /> <stop offset="1" style="stop-color:gold" /> </linearGradient> <linearGradient id="hvGrad" x1="0" y1="0" x2="1" y2="1"> <stop offset="0" style="stop-color:crimson" /> <stop offset="1" style="stop-color:gold" /> </linearGradient> <radialGradient id="rGrad" cx=".5" cy=".5" r="1"> <stop offset="0" style="stop-color:crimson" /> <stop offset="1" style="stop-color:gold" /> </radialGradient> </defs> <g style="fill:#eee;stroke:black"> <rect x="75" y="100" width="300" height="20" /> <rect x="55" y="120" width="20" height="300" /> </g> <g style="fill:none;stroke:black"> <rect x="75" y="120" width="300" height="300" /> <line x1="150" y1="100" x2="150" y2="420" /> <line x1="225" y1="100" x2="225" y2="420" /> <line x1="300" y1="100" x2="300" y2="420" /> <line x1="55" y1="220" x2="375" y2="220" /> <line x1="55" y1="320" x2="375" y2="320" /> </g> <g style="text-anchor:middle; fill:black; stroke:none"> <text x="112" y="115">hLinGrad</text> <text x="187" y="115">vLinGrad</text> <text x="262" y="115">hvLinGrad</text> <text x="337" y="115">radGrad</text> <text transform="translate(70 170)rotate(-90)">No Scale</text> <text transform="translate(70 270)rotate(-90)">Scale Up</text> <text transform="translate(70 370)rotate(-90)">Scale Down</text> </g> <g stroke-linecap="round"> <g stroke-width="50"> <line transform="translate(112,170)" stroke="url(#hGrad)" /> <line transform="translate(187,170)" stroke="url(#vGrad)" /> <line transform="translate(262,170)" stroke="url(#hvGrad)"/> <line transform="translate(337,170)" stroke="url(#rGrad)" /> </g> <!-- Note that I wanted to scale this even more agressively But it appears that very narrow stroke-widths just get clamped to something like '0.0001' - Odd! --> <g stroke-width=".005"> <line transform="translate(112,270) scale(10000)" stroke="url(#hGrad)" /> <line transform="translate(187,270) scale(10000)" stroke="url(#vGrad)" /> <line transform="translate(262,270) scale(10000)" stroke="url(#hvGrad)" /> <line transform="translate(337,270) scale(10000)" stroke="url(#rGrad)" /> </g> <g stroke-width="50000000"> <line transform="translate(112,370) scale(.000001)" stroke="url(#hGrad)" /> <line transform="translate(187,370) scale(.000001)" stroke="url(#vGrad)" /> <line transform="translate(262,370) scale(.000001)" stroke="url(#hvGrad)" /> <line transform="translate(337,370) scale(.000001)" stroke="url(#rGrad)" /> </g> </g> </g> <!-- ============================================================= --> <!-- Batik sample mark --> <!-- ============================================================= --> <use xlink:href="../../../batikLogo.svg#Batik_Tag_Box" /> </svg> 1.41 +37 -1 xml-batik/sources/org/apache/batik/gvt/AbstractGraphicsNode.java Index: AbstractGraphicsNode.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/AbstractGraphicsNode.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- AbstractGraphicsNode.java 3 Apr 2002 04:58:21 -0000 1.40 +++ AbstractGraphicsNode.java 29 May 2002 18:53:05 -0000 1.41 @@ -54,7 +54,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> * @author <a href="mailto:[EMAIL PROTECTED]">Emmanuel Tissandier</a> * @author <a href="mailto:[EMAIL PROTECTED]">Thomas DeWeese</a> - * @version $Id: AbstractGraphicsNode.java,v 1.40 2002/04/03 04:58:21 deweese Exp $ + * @version $Id: AbstractGraphicsNode.java,v 1.41 2002/05/29 18:53:05 deweese Exp $ */ public abstract class AbstractGraphicsNode implements GraphicsNode { @@ -743,6 +743,8 @@ } } + bounds = normalizeRectangle(bounds); + // Make sure we haven't been interrupted if (Thread.currentThread().isInterrupted()) { // The Thread has been interrupted. Invalidate @@ -888,4 +890,38 @@ public GraphicsNode nodeHitAt(Point2D p) { return (contains(p) ? this : null); } + + static double EPSILON = 1e-6; + + /** + * This method makes sure that neither the width nor height of the + * rectangle is zero. But it tries to make them very small + * relatively speaking. + */ + protected Rectangle2D normalizeRectangle(Rectangle2D bounds) { + if ((bounds.getWidth() < EPSILON)) { + if (bounds.getHeight() < EPSILON) { + AffineTransform gt = getGlobalTransform(); + double det = Math.sqrt(gt.getDeterminant()); + return new Rectangle2D.Double + (bounds.getX(), bounds.getY(), EPSILON/det, EPSILON/det); + } else { + double tmpW = bounds.getHeight()*EPSILON; + if (tmpW < bounds.getWidth()) + tmpW = bounds.getWidth(); + return new Rectangle2D.Double + (bounds.getX(), bounds.getY(), + tmpW, bounds.getHeight()); + } + } else if (bounds.getHeight() < EPSILON) { + double tmpH = bounds.getWidth()*EPSILON; + if (tmpH < bounds.getHeight()) + tmpH = bounds.getHeight(); + return new Rectangle2D.Double + (bounds.getX(), bounds.getY(), + bounds.getWidth(), tmpH); + } + return bounds; + } + } 1.18 +2 -2 xml-batik/sources/org/apache/batik/gvt/ShapeNode.java Index: ShapeNode.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/ShapeNode.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- ShapeNode.java 7 May 2002 16:19:37 -0000 1.17 +++ ShapeNode.java 29 May 2002 18:53:05 -0000 1.18 @@ -20,7 +20,7 @@ * A graphics node that represents a shape. * * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> - * @version $Id: ShapeNode.java,v 1.17 2002/05/07 16:19:37 tkormann Exp $ + * @version $Id: ShapeNode.java,v 1.18 2002/05/29 18:53:05 deweese Exp $ */ public class ShapeNode extends AbstractGraphicsNode { @@ -299,7 +299,7 @@ if (shape == null) { return null; } - geometryBounds = shape.getBounds2D(); + geometryBounds = normalizeRectangle(shape.getBounds2D()); } return geometryBounds; } 1.7 +24 -16 xml-batik/sources/org/apache/batik/swing/gvt/GVTTreeRenderer.java Index: GVTTreeRenderer.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/gvt/GVTTreeRenderer.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- GVTTreeRenderer.java 8 Mar 2002 08:45:27 -0000 1.6 +++ GVTTreeRenderer.java 29 May 2002 18:53:05 -0000 1.7 @@ -29,7 +29,7 @@ * a GVT tree. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: GVTTreeRenderer.java,v 1.6 2002/03/08 08:45:27 hillion Exp $ + * @version $Id: GVTTreeRenderer.java,v 1.7 2002/05/29 18:53:05 deweese Exp $ */ public class GVTTreeRenderer extends Thread { @@ -277,26 +277,34 @@ * Fires a GVTTreeRendererEvent when failed. */ protected void fireFailedEvent() { - final Object[] dll = listeners.toArray(); - - if (dll.length > 0) { - final GVTTreeRendererEvent ev = - new GVTTreeRendererEvent(this, null); + int count=10; + while(--count != 0) { + try { + final Object[] dll = listeners.toArray(); + + if (dll.length > 0) { + final GVTTreeRendererEvent ev = + new GVTTreeRendererEvent(this, null); - if (EventQueue.isDispatchThread()) { - for (int i = 0; i < dll.length; i++) { - ((GVTTreeRendererListener)dll[i]).gvtRenderingFailed(ev); - } - } else { - EventQueue.invokeLater(new Runnable() { - public void run() { + if (EventQueue.isDispatchThread()) { for (int i = 0; i < dll.length; i++) { - ((GVTTreeRendererListener)dll[i]). - gvtRenderingFailed(ev); + ((GVTTreeRendererListener)dll[i]).gvtRenderingFailed(ev); } + } else { + EventQueue.invokeLater(new Runnable() { + public void run() { + for (int i = 0; i < dll.length; i++) { + ((GVTTreeRendererListener)dll[i]). + gvtRenderingFailed(ev); + } + } + }); } - }); + } + } catch (Throwable t) { + continue; } + return; } } } 1.2 +336 -345 xml-batik/test-references/samples/extensions/flowText.png <<Binary file>> 1.74 +2 -1 xml-batik/test-resources/org/apache/batik/test/samplesRendering.xml Index: samplesRendering.xml =================================================================== RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/test/samplesRendering.xml,v retrieving revision 1.73 retrieving revision 1.74 diff -u -r1.73 -r1.74 --- samplesRendering.xml 29 May 2002 13:12:21 -0000 1.73 +++ samplesRendering.xml 29 May 2002 18:53:05 -0000 1.74 @@ -8,7 +8,7 @@ <!-- ========================================================================= --> <!-- @author [EMAIL PROTECTED] --> -<!-- @version $Id: samplesRendering.xml,v 1.73 2002/05/29 13:12:21 tkormann Exp $ --> +<!-- @version $Id: samplesRendering.xml,v 1.74 2002/05/29 18:53:05 deweese Exp $ --> <!-- ========================================================================= --> <testSuite id="samplesRendering" name="samples and samples/test Rendering" class="org.apache.batik.test.svg.SamplesRenderingTest"> @@ -168,6 +168,7 @@ <test id="samples/tests/spec/paints/linearGradientOrientation.svg" /> <test id="samples/tests/spec/paints/linearGradientLine.svg" /> <test id="samples/tests/spec/paints/radialGradientLine.svg" /> + <test id="samples/tests/spec/paints/gradientPoint.svg" /> <test id="samples/tests/spec/paints/patternPreserveAspectRatioA.svg" /> <test id="samples/tests/spec/paints/patternRegionA.svg" /> <test id="samples/tests/spec/paints/patternRegionB.svg" />
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]