From batikjenniferbrown@example.org Mon Oct 01 07:30:26 2001 Return-Path: <batikjenniferbrown@example.org> Delivered-To: jenniferbrown@example.org Received: (qmail 7404 invoked by uid 500); 1 Oct 2001 07:30:26 -0000 Mailing-List: contact jenniferbrown@example.org; run by ezmlm Precedence: bulk List-Post: <mailto:jenniferbrown@example.org> List-Help: <mailto:jenniferbrown@example.org> List-Unsubscribe: <mailto:jenniferbrown@example.org> List-Subscribe: <mailto:jenniferbrown@example.org> Reply-To: jenniferbrown@example.org Delivered-To: mailing list jenniferbrown@example.org Received: (qmail 7392 invoked from network); 1 Oct 2001 07:30:25 -0000 Message-ID: <jenniferbrown@example.org> Date: Mon, 01 Oct 2001 09:28:06 +0200 From: Vincent Hardy <jenniferbrown@example.org> X-Mailer: Mozilla 4.73 [en]C-{C-UDP; EBM-SONY1} (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: jenniferbrown@example.org Subject: Re: SVGTransform does not handle identity transforms correctly References: <jenniferbrown@example.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Paul, Thanks a lot for your detailed bug report. I will look at it in details and commit your patch shortly. Regards, Vincent. "Evenblij, Paul" wrote: > > Hi there, > > I have found another issue with SVGTransform. > Perform the following sequence of calls on SVGGraphics2D instance g2d: > > g2d.translate(10,10); > g2d.scale(2, 2); > g2d.scale(0.5, 0.5); > g2d.translate(20,40); > g2d.rotate(0); > g2d.translate(-30,-50); > > g2d.fillRect(10,10, 100,80); > > Attentive readers will note that the series of transformations should have > no net effect whatsoever. Still, Batik generates the following SVG: > > <rect x="10" y="10" transform="translate(10,10) translate(20,40) > translate(-30,-50)" width="100" style="fill:black; stroke:none;" height="80" > /> > > Obviously, the transform string is not optimized. This is due to the "scale" > transforms (which, taken together, form an identity) and the "rotate" (which > is also an identity). Identity transforms are not converted to SVG (note the > double spaces between the "translate"s). This is correct. However, the first > "translate" is by then already converted, and can no longer be concatenated > to the next. > > I have created a patch which addresses this issue. It adds an "isIdentity()" > method to the TransformStackElement class, and reconstructs the public > "toSVGTransform()" method in SVGTransform, so that identities do not keep > similar transforms from being concatenated, not even if they are "hidden", > like the paired scale transforms above. It also removes the "isIdentity()" > implementation from SVGTransform itself, since this is now handled > generically by TransformStackElement. > > Generated output of the patched code reads: > > <rect x="10" y="10" width="100" style="fill:black; stroke:none;" height="80" > /> > > I have created bug 3871 for this, and attached the proposed patch. > > Cheers, > Paul > > --------------------------------------------------------------------- > To unsubscribe, e-mail: jenniferbrown@example.org > For additional commands, e-mail: jenniferbrown@example.org --------------------------------------------------------------------- To unsubscribe, e-mail: jenniferbrown@example.org For additional commands, e-mail: jenniferbrown@example.org From batikjenniferbrown@example.org Mon Oct 01 10:52:19 2001 Return-Path: <batikjenniferbrown@example.org> Delivered-To: jenniferbrown@example.org Received: (qmail 69038 invoked by uid 500); 1 Oct 2001 10:52:18 -0000 Mailing-List: contact jenniferbrown@example.org; run by ezmlm Precedence: bulk List-Post: <mailto:jenniferbrown@example.org> List-Help: <mailto:jenniferbrown@example.org> List-Unsubscribe: <mailto:jenniferbrown@example.org> List-Subscribe: <mailto:jenniferbrown@example.org> Reply-To: jenniferbrown@example.org Delivered-To: mailing list jenniferbrown@example.org Delivered-To: moderator for jenniferbrown@example.org Received: (qmail 90379 invoked from network); 1 Oct 2001 09:21:56 -0000 Date: Mon, 1 Oct 2001 11:21:46 +0200 From: Keiron Liddle <jenniferbrown@example.org> To: jenniferbrown@example.org Subject: cdata text Message-Id: <jenniferbrown@example.org> Reply-To: jenniferbrown@example.org References: <jenniferbrown@example.org> MIME-Version: 1.0 In-Reply-To: <jenniferbrown@example.org>; from jenniferbrown@example.org on Fri, Sep 28, 2001 at 12:28:26 +0200 X-Mailer: Balsa 1.1.7 Lines: 18 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Is there any particular reason that text inside CDATA sections is not handled or ignored. I removed the createCDATASection from the SAXDocumentFactory (so it just creates a TextNode) and the text appeared. This probably is not the solution, just a test to see what happens. It seems that the bridge ignores the CDATASection class because the node type is not an ELEMENT_NODE. Do I need to remove the cdata sections (and replace "<" with "&lt;" etc.) because this is the expected behaviour or is it not handling the cdata properly. Keiron ps. I'm sending this again, the first one seems to have disappeared --------------------------------------------------------------------- To unsubscribe, e-mail: jenniferbrown@example.org For additional commands, e-mail: jenniferbrown@example.org From batikjenniferbrown@example.org Mon Oct 01 11:56:49 2001 Return-Path: <batikjenniferbrown@example.org> Delivered-To: jenniferbrown@example.org Received: (qmail 31616 invoked by uid 500); 1 Oct 2001 11:56:49 -0000 Mailing-List: contact jenniferbrown@example.org; run by ezmlm Precedence: bulk List-Post: <mailto:jenniferbrown@example.org> List-Help: <mailto:jenniferbrown@example.org> List-Unsubscribe: <mailto:jenniferbrown@example.org> List-Subscribe: <mailto:jenniferbrown@example.org> Reply-To: jenniferbrown@example.org Delivered-To: mailing list jenniferbrown@example.org Received: (qmail 31585 invoked by uid 500); 1 Oct 2001 11:56:49 -0000 Delivered-To: jenniferbrown@example.org Date: 1 Oct 2001 11:54:52 -0000 Message-ID: <jenniferbrown@example.org> From: jenniferbrown@example.org To: jenniferbrown@example.org Subject: cvs commit: xml-batik/sources/org/apache/batik/bridge SVGTextElementBridge.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N vhardy 01/10/01 04:54:52 Modified: sources/org/apache/batik/bridge SVGTextElementBridge.java Log: Fixed problem reported by Keiron Liddle: http://koala.ilog.fr/batik/mlists/batik-dev/archives/msg01601.html. See samples/tests/textPCDATA.svg for test case. Revision Changes Path 1.37 +2 -1 xml-batik/sources/org/apache/batik/bridge/SVGTextElementBridge.java Index: SVGTextElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGTextElementBridge.java,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- SVGTextElementBridge.java 2001/09/19 15:09:29 1.36 +++ SVGTextElementBridge.java 2001/10/01 11:54:52 1.37 @@ -56,7 +56,7 @@ * Bridge class for the &lt;text> element. * * @author <a href="jenniferbrown@example.org>Bill Haneman</a> - * @version $Id: SVGTextElementBridge.java,v 1.36 2001/09/19 15:09:29 tkormann Exp $ + * @version $Id: SVGTextElementBridge.java,v 1.37 2001/10/01 11:54:52 vhardy Exp $ */ public class SVGTextElementBridge extends AbstractSVGBridge implements GraphicsNodeBridge, ErrorConstants { @@ -375,6 +375,7 @@ } break; case Node.TEXT_NODE: + case Node.CDATA_SECTION_NODE: s = n.getNodeValue(); int[] indexMap = new int[s.length()]; as = createAttributedString --------------------------------------------------------------------- To unsubscribe, e-mail: jenniferbrown@example.org For additional commands, e-mail: jenniferbrown@example.org From batikjenniferbrown@example.org Mon Oct 01 11:57:56 2001 Return-Path: <batikjenniferbrown@example.org> Delivered-To: jenniferbrown@example.org Received: (qmail 33702 invoked by uid 500); 1 Oct 2001 11:57:56 -0000 Mailing-List: contact jenniferbrown@example.org; run by ezmlm Precedence: bulk List-Post: <mailto:jenniferbrown@example.org> List-Help: <mailto:jenniferbrown@example.org> List-Unsubscribe: <mailto:jenniferbrown@example.org> List-Subscribe: <mailto:jenniferbrown@example.org> Reply-To: jenniferbrown@example.org Delivered-To: mailing list jenniferbrown@example.org Received: (qmail 33689 invoked by uid 500); 1 Oct 2001 11:57:56 -0000 Delivered-To: jenniferbrown@example.org Date: 1 Oct 2001 11:55:59 -0000 Message-ID: <jenniferbrown@example.org> From: jenniferbrown@example.org To: jenniferbrown@example.org Subject: cvs commit: xml-batik/samples/tests textPCDATA.svg X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N vhardy 01/10/01 04:55:59 Added: samples/tests textPCDATA.svg Log: Exercises bug reported by Keiron Liddle: http://koala.ilog.fr/batik/mlists/batik-dev/archives/msg01601.html and shows it has been fixed. Revision Changes Path 1.1 xml-batik/samples/tests/textPCDATA.svg Index: textPCDATA.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. --> <!-- ========================================================================= --> <!-- ========================================================================= --> <!-- Validates that CDATA sections in &lt;text&gt; elements are supported. --> <!-- --> <!-- @author jenniferbrown@example.org --> <!-- @version $Id: textPCDATA.svg,v 1.1 2001/10/01 11:55:59 vhardy Exp $ --> <!-- ========================================================================= --> <?xml-stylesheet type="text/css" href="test.css" ?> <svg width="450" height="500" viewBox="0 0 450 500"> <g id="content"> <text class="title" x="50%" y="30">Character Data on &lt;text&gt;</text> <!-- Simple case: CDATA only --> <g class="label" text-anchor="middle" transform="translate(225, 120)"> <text>CDATA only</text> <text fill="crimson" y="20"><![CDATA[<text> with a CDATA section]]></text> </g> <!-- text, CDATA, text --> <g class="label" text-anchor="middle" transform="translate(225, 180)"> <text>text, CDATA, text</text> <text fill="crimson" y="20" >Text first, then <![CDATA[CDATA section in <text>]]>, text again</text> </g> <!-- text, CDATA, tspan, CDATA, text --> <g class="label" text-anchor="middle" transform="translate(225, 240)"> <text>text, CDATA, tspan, CDATA, text</text> <text fill="crimson" y="20">text, <![CDATA[CDATA section in <text>]]>, <tspan fill="gold">tspan w/<![CDATA[CDATA section in <tspan>]]></tspan>, text again</text> </g> </g> </svg> --------------------------------------------------------------------- To unsubscribe, e-mail: jenniferbrown@example.org For additional commands, e-mail: jenniferbrown@example.org From batikjenniferbrown@example.org Mon Oct 01 12:02:02 2001 Return-Path: <batikjenniferbrown@example.org> Delivered-To: jenniferbrown@example.org Received: (qmail 36334 invoked by uid 500); 1 Oct 2001 12:02:02 -0000 Mailing-List: contact jenniferbrown@example.org; run by ezmlm Precedence: bulk List-Post: <mailto:jenniferbrown@example.org> List-Help: <mailto:jenniferbrown@example.org> List-Unsubscribe: <mailto:jenniferbrown@example.org> List-Subscribe: <mailto:jenniferbrown@example.org> Reply-To: jenniferbrown@example.org Delivered-To: mailing list jenniferbrown@example.org Received: (qmail 36323 invoked by uid 500); 1 Oct 2001 12:02:02 -0000 Delivered-To: jenniferbrown@example.org Date: 1 Oct 2001 12:00:06 -0000 Message-ID: <jenniferbrown@example.org> From: jenniferbrown@example.org To: jenniferbrown@example.org Subject: cvs commit: xml-batik/test-references/samples/tests textPCDATA.png X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N vhardy 01/10/01 05:00:06 Modified: test-resources/org/apache/batik/test samplesRendering.xml Added: test-references/samples/tests textPCDATA.png Log: Integrated new test (textPCDATA) in test suite infrastructure. Revision Changes Path 1.24 +8 -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.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- samplesRendering.xml 2001/10/01 06:48:38 1.23 +++ samplesRendering.xml 2001/10/01 12:00:06 1.24 @@ -8,7 +8,7 @@ <!-- ========================================================================= --> <!-- @author jenniferbrown@example.org --> -<!-- @version $Id: samplesRendering.xml,v 1.23 2001/10/01 06:48:38 vhardy Exp $ --> +<!-- @version $Id: samplesRendering.xml,v 1.24 2001/10/01 12:00:06 vhardy Exp $ --> <!-- ========================================================================= --> <testSuite name="samples and samples/test Rendering"> <!-- ========================================================================== --> @@ -265,6 +265,13 @@ <arg class="java.lang.String" value="test-references/samples/tests/textOnPathSpaces.png" /> <property name="VariationURL" class="java.lang.String" value="test-references/samples/tests/accepted-variation/textOnPathSpaces.png" /> <property name="SaveVariation" class="java.io.File" value="test-references/samples/tests/candidate-variation/textOnPathSpaces.png" /> + </test> + + <test class="org.apache.batik.test.svg.SVGRenderingAccuracyTest"> + <arg class="java.lang.String" value="samples/tests/textPCDATA.svg" /> + <arg class="java.lang.String" value="test-references/samples/tests/textPCDATA.png" /> + <property name="VariationURL" class="java.lang.String" value="test-references/samples/tests/accepted-variation/textPCDATA.png" /> + <property name="SaveVariation" class="java.io.File" value="test-references/samples/tests/candidate-variation/textPCDATA.png" /> </test> <test class="org.apache.batik.test.svg.SVGRenderingAccuracyTest"> 1.1 xml-batik/test-references/samples/tests/textPCDATA.png <<Binary file>> --------------------------------------------------------------------- To unsubscribe, e-mail: jenniferbrown@example.org For additional commands, e-mail: jenniferbrown@example.org From batikjenniferbrown@example.org Mon Oct 01 12:06:54 2001 Return-Path: <batikjenniferbrown@example.org> Delivered-To: jenniferbrown@example.org Received: (qmail 40701 invoked by uid 500); 1 Oct 2001 12:06:53 -0000 Mailing-List: contact jenniferbrown@example.org; run by ezmlm Precedence: bulk List-Post: <mailto:jenniferbrown@example.org> List-Help: <mailto:jenniferbrown@example.org> List-Unsubscribe: <mailto:jenniferbrown@example.org> List-Subscribe: <mailto:jenniferbrown@example.org> Reply-To: jenniferbrown@example.org Delivered-To: mailing list jenniferbrown@example.org Received: (qmail 40690 invoked from network); 1 Oct 2001 12:06:52 -0000 Message-ID: <jenniferbrown@example.org> Date: Mon, 01 Oct 2001 13:36:10 +0200 From: Vincent Hardy <jenniferbrown@example.org> X-Mailer: Mozilla 4.73 [en]C-{C-UDP; EBM-SONY1} (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: jenniferbrown@example.org Subject: Re: cdata text References: <jenniferbrown@example.org> <jenniferbrown@example.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Keiron, Double checking the XML spec.: + <text> has a "mixed content" as defined in the XML spec. section 3.2.2. It means that a <text> element can contain both character data (PCDATA) and children elements. + Still in the XML spec. section 2.7 says that CDATA can appear anywhere character data may occur. So this means that it is legal SVG to have a CDATA section in your <text> element and we do have a bug as we do not support it. Actually, if you look at the <style> or <script> elements, their content model is character data (PCDATA) as well and the most common use is with a CDATA section... I am going to add a test case for this to the Batik test suite, add a bug in Bugzilla and we will fix it. Thanks, Vincent. Keiron Liddle wrote: > > Is there any particular reason that text inside CDATA sections is not > handled or ignored. > > I removed the createCDATASection from the SAXDocumentFactory (so it just > creates a TextNode) and the text appeared. This probably is not the > solution, just a test to see what happens. > It seems that the bridge ignores the CDATASection class because the node > type is not an ELEMENT_NODE. > > Do I need to remove the cdata sections (and replace "<" with "&lt;" etc.) > because this is the expected behaviour or is it not handling the cdata > properly. > > Keiron > > ps. I'm sending this again, the first one seems to have disappeared > > --------------------------------------------------------------------- > To unsubscribe, e-mail: jenniferbrown@example.org > For additional commands, e-mail: jenniferbrown@example.org --------------------------------------------------------------------- To unsubscribe, e-mail: jenniferbrown@example.org For additional commands, e-mail: jenniferbrown@example.org From batikjenniferbrown@example.org Mon Oct 01 12:39:07 2001 Return-Path: <batikjenniferbrown@example.org> Delivered-To: jenniferbrown@example.org Received: (qmail 66365 invoked by uid 500); 1 Oct 2001 12:39:07 -0000 Mailing-List: contact jenniferbrown@example.org; run by ezmlm Precedence: bulk List-Post: <mailto:jenniferbrown@example.org> List-Help: <mailto:jenniferbrown@example.org> List-Unsubscribe: <mailto:jenniferbrown@example.org> List-Subscribe: <mailto:jenniferbrown@example.org> Reply-To: jenniferbrown@example.org Delivered-To: mailing list jenniferbrown@example.org Received: (qmail 66353 invoked by uid 500); 1 Oct 2001 12:39:06 -0000 Delivered-To: jenniferbrown@example.org Date: 1 Oct 2001 12:37:10 -0000 Message-ID: <jenniferbrown@example.org> From: jenniferbrown@example.org To: jenniferbrown@example.org Subject: cvs commit: xml-batik/test-references/org/apache/batik/svggen IdentityTest.svg X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N vhardy 01/10/01 05:37:10 Modified: sources/org/apache/batik/ext/awt/g2d TransformStackElement.java sources/org/apache/batik/svggen SVGTransform.java test-resources/org/apache/batik/svggen regsvggen.xml Added: test-sources/org/apache/batik/svggen IdentityTest.java test-references/org/apache/batik/svggen IdentityTest.svg Log: Fixed bug #3871. Added test case exercising bug and validating fix. No regression found in other SVGGraphics2D regression tests. Revision Changes Path 1.2 +52 -8 xml-batik/sources/org/apache/batik/ext/awt/g2d/TransformStackElement.java Index: TransformStackElement.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/g2d/TransformStackElement.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TransformStackElement.java 2001/03/14 01:36:09 1.1 +++ TransformStackElement.java 2001/10/01 12:37:10 1.2 @@ -16,9 +16,10 @@ * type and a value, which is an array of double values.<br> * * @author <a href="mailto:jenniferbrown@example.org">Vincent Hardy</a> - * @version $Id: TransformStackElement.java,v 1.1 2001/03/14 01:36:09 vhardy Exp $ + * @author <a href="mailto:jenniferbrown@example.org">Paul Evenblij</a> + * @version $Id: TransformStackElement.java,v 1.2 2001/10/01 12:37:10 vhardy Exp $ */ -public class TransformStackElement implements Cloneable{ +abstract public class TransformStackElement implements Cloneable{ /** * Transform type */ @@ -43,9 +44,18 @@ * @return an object which is a deep copy of this one */ public Object clone() { + TransformStackElement newElement = null; + + // start with a shallow copy to get our implementations right + try { + newElement = (TransformStackElement) super.clone(); + } catch(java.lang.CloneNotSupportedException ex) {} + + // now deep copy the parameter array double transformParameters[] = new double[this.transformParameters.length]; System.arraycopy(this.transformParameters, 0, transformParameters, 0, transformParameters.length); - return new TransformStackElement(type, transformParameters); + newElement.transformParameters = transformParameters; + return newElement; } /** @@ -61,25 +71,59 @@ */ public static TransformStackElement createTranslateElement(double tx, double ty){ - return new TransformStackElement(TransformType.TRANSLATE, new double[]{ tx, ty }); + return new TransformStackElement(TransformType.TRANSLATE, new double[]{ tx, ty }) { + boolean isIdentity(double[] parameters) { + return parameters[0] == 0 && parameters[1] == 0; + } + }; } public static TransformStackElement createRotateElement(double theta){ - return new TransformStackElement(TransformType.ROTATE, new double[]{ theta }); + return new TransformStackElement(TransformType.ROTATE, new double[]{ theta }) { + boolean isIdentity(double[] parameters) { + return Math.cos(parameters[0]) == 1; + } + }; } public static TransformStackElement createScaleElement(double scaleX, double scaleY){ - return new TransformStackElement(TransformType.SCALE, new double[]{ scaleX, scaleY }); + return new TransformStackElement(TransformType.SCALE, new double[]{ scaleX, scaleY }) { + boolean isIdentity(double[] parameters) { + return parameters[0] == 1 && parameters[1] == 1; + } + }; } public static TransformStackElement createShearElement(double shearX, double shearY){ - return new TransformStackElement(TransformType.SHEAR, new double[]{ shearX, shearY }); + return new TransformStackElement(TransformType.SHEAR, new double[]{ shearX, shearY }) { + boolean isIdentity(double[] parameters) { + return parameters[0] == 0 && parameters[1] == 0; + } + }; } public static TransformStackElement createGeneralTransformElement(AffineTransform txf){ double matrix[] = new double[6]; txf.getMatrix(matrix); - return new TransformStackElement(TransformType.GENERAL, matrix); + return new TransformStackElement(TransformType.GENERAL, matrix) { + boolean isIdentity(double[] m) { + return (m[0] == 1 && m[2] == 0 && m[4] == 0 && + m[1] == 0 && m[3] == 1 && m[5] == 0); + } + }; + } + + /** + * Implementation should determine if the parameter list represents + * an identity transform, for the instance transform type. + */ + abstract boolean isIdentity(double[] parameters); + + /** + * @return true iff this transform is the identity transform + */ + public boolean isIdentity() { + return isIdentity(transformParameters); } /** 1.4 +103 -42 xml-batik/sources/org/apache/batik/svggen/SVGTransform.java Index: SVGTransform.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/svggen/SVGTransform.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- SVGTransform.java 2001/03/19 09:26:25 1.3 +++ SVGTransform.java 2001/10/01 12:37:10 1.4 @@ -12,6 +12,7 @@ import java.awt.GradientPaint; import java.awt.geom.Point2D; import java.awt.geom.AffineTransform; +import java.util.Stack; import org.apache.batik.ext.awt.g2d.GraphicContext; import org.apache.batik.ext.awt.g2d.TransformType; @@ -22,7 +23,8 @@ * into an SVG transform attribute. * * @author <a href="mailto:jenniferbrown@example.org">Vincent Hardy</a> - * @version $Id: SVGTransform.java,v 1.3 2001/03/19 09:26:25 cjolif Exp $ + * @author <a href="mailto:jenniferbrown@example.org">Paul Evenblij</a> + * @version $Id: SVGTransform.java,v 1.4 2001/10/01 12:37:10 vhardy Exp $ */ public class SVGTransform extends AbstractSVGConverter{ /** @@ -57,32 +59,101 @@ * This method tries to collapse the transform stack into an SVG * string as compact as possible while still conveying the semantic * of the stack. Successive stack elements of the same kind (e.g., two - * successive transforms or scales) are collasped into a single element. + * successive transforms or scales) are collapsed into a single element. * * @param transformStack sequence of transform that should * be converted to an SVG transform attribute equivalent */ public static String toSVGTransform(TransformStackElement transformStack[]){ StringBuffer transformStackBuffer = new StringBuffer(); - + int nTransforms = transformStack.length; // - // Append transforms in the stack + // Append transforms in the presentation stack // - int nTransforms = transformStack.length; + Stack presentation = new Stack() { + /** + * Adapted push implementation + */ + public Object push(Object o) { + Object element; + if(((TransformStackElement)o).isIdentity()) { + // identity transform: don't push, + // and try to return top of stack + element = pop(); + } else { + // non-identity: push, + // and return null + super.push(o); + element = null; + } + return element; + } + + /** + * Adapted pop implementation + */ + public Object pop() { + Object element = null; + if(!super.empty()) { + element = super.pop(); + } + return element; + } + }; boolean canConcatenate = false; - int i = 0, j = 0; - while(i<nTransforms){ - // Clone current element and try to concatenate - // elements on top of it - TransformStackElement element = (TransformStackElement)transformStack[i].clone(); + int i = 0, j = 0, next = 0; + TransformStackElement element = null; + + // We keep a separate 'presentation' stack, which contains + // all concatenated elements. The top of this stack is the + // element we try to concatenate onto. If this element + // becomes an identity transform, we discard it and look at + // the element underneath it instead. + // The presentation stack is guaranteed not to contain + // identity transforms. + + while(i < nTransforms) { + + // If we do not have an element to concatenate onto, + // we grab one here. + next = i; + if(element == null) { + element = (TransformStackElement) transformStack[i].clone(); + next++; + } + + // try to concatenate as much as possible canConcatenate = true; - for(j= (i+1); j < nTransforms; j++){ + for(j = next; j < nTransforms; j++) { canConcatenate = element.concatenate(transformStack[j]); if(!canConcatenate) break; } + // loop variable assertion: + // If "i" does not increment during this iteration, it is guaranteed + // to do so in the next, since "i" can only keep the same value as a + // result of "element" having a non-null value on starting this + // iteration, which can only be the case if it was popped from the + // stack during the previous one. The stack does not contain + // identities, and since "i" has not grown, "element" has remained + // unchanged and will be pushed onto the stack again. "element" will + // then become null, so "i" will eventually increment. i = j; - transformStackBuffer.append(convertTransform(element)); + + // Get rid of identity transforms within the stack. + // If an identity is pushed, it is immediately removed, and + // the current top of stack will be returned to concatenate onto. + // Otherwise, null will be returned. + element = (TransformStackElement) presentation.push(element); + } + + // + // Transform presentation stack to SVG + // + int nPresentations = presentation.size(); + + for(i = 0; i < nPresentations; i++) { + transformStackBuffer.append(convertTransform((TransformStackElement) presentation.elementAt(i))); transformStackBuffer.append(SPACE); } @@ -98,7 +169,7 @@ double transformParameters[] = transformElement.getTransformParameters(); switch(transformElement.getType().toInt()){ case TransformType.TRANSFORM_TRANSLATE: - if(transformParameters[0] != 0 || transformParameters[1] != 0){ + if(!transformElement.isIdentity()) { transformString.append(TRANSFORM_TRANSLATE); transformString.append(OPEN_PARENTHESIS); transformString.append(doubleString(transformParameters[0])); @@ -108,7 +179,7 @@ } break; case TransformType.TRANSFORM_ROTATE: - if(transformParameters[0] != 0){ + if(!transformElement.isIdentity()) { transformString.append(TRANSFORM_ROTATE); transformString.append(OPEN_PARENTHESIS); transformString.append(doubleString(radiansToDegrees*transformParameters[0])); @@ -116,7 +187,7 @@ } break; case TransformType.TRANSFORM_SCALE: - if(transformParameters[0] != 1 || transformParameters[1] != 1){ + if(!transformElement.isIdentity()) { transformString.append(TRANSFORM_SCALE); transformString.append(OPEN_PARENTHESIS); transformString.append(doubleString(transformParameters[0])); @@ -126,23 +197,25 @@ } break; case TransformType.TRANSFORM_SHEAR: - transformString.append(TRANSFORM_MATRIX); - transformString.append(OPEN_PARENTHESIS); - transformString.append(1); - transformString.append(COMMA); - transformString.append(doubleString(transformParameters[1])); - transformString.append(COMMA); - transformString.append(doubleString(transformParameters[0])); - transformString.append(COMMA); - transformString.append(1); - transformString.append(COMMA); - transformString.append(0); - transformString.append(COMMA); - transformString.append(0); - transformString.append(CLOSE_PARENTHESIS); + if(!transformElement.isIdentity()) { + transformString.append(TRANSFORM_MATRIX); + transformString.append(OPEN_PARENTHESIS); + transformString.append(1); + transformString.append(COMMA); + transformString.append(doubleString(transformParameters[1])); + transformString.append(COMMA); + transformString.append(doubleString(transformParameters[0])); + transformString.append(COMMA); + transformString.append(1); + transformString.append(COMMA); + transformString.append(0); + transformString.append(COMMA); + transformString.append(0); + transformString.append(CLOSE_PARENTHESIS); + } break; case TransformType.TRANSFORM_GENERAL: - if(!isIdentity(transformParameters)){ + if(!transformElement.isIdentity()) { transformString.append(TRANSFORM_MATRIX); transformString.append(OPEN_PARENTHESIS); transformString.append(doubleString(transformParameters[0])); @@ -166,17 +239,5 @@ } return transformString.toString(); - } - - /** - * Examines the input array to find if it represents an - * identity transform. - */ - private static boolean isIdentity(double matrix[]){ - if(matrix.length != 6) - throw new Error(); - - return (matrix[0] == 1 && matrix[2] == 0 && matrix[4] == 0 && - matrix[1] == 0 && matrix[3] == 1 && matrix[5] == 0); } } 1.1 xml-batik/test-sources/org/apache/batik/svggen/IdentityTest.java Index: IdentityTest.java =================================================================== /***************************************************************************** * 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. * *****************************************************************************/ package org.apache.batik.svggen; import java.awt.*; import java.awt.geom.*; /** * This test validates the convertion of Java 2D AffineTransform into SVG * Shapes. * * @author <a href="mailto:jenniferbrown@example.org">Vincent Hardy</a> * @version $Id: IdentityTest.java,v 1.1 2001/10/01 12:37:10 vhardy Exp $ */ public class IdentityTest implements Painter { public void paint(Graphics2D g) { g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setPaint(Color.black); // new Color(102, 102, 144)); g.translate(10,10); g.scale(2, 2); g.scale(0.5, 0.5); g.translate(20,40); g.rotate(0); g.translate(-30,-50); g.fillRect(10,10, 100,80); } } 1.8 +51 -37 xml-batik/test-resources/org/apache/batik/svggen/regsvggen.xml Index: regsvggen.xml =================================================================== RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/svggen/regsvggen.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- regsvggen.xml 2001/09/28 13:11:33 1.7 +++ regsvggen.xml 2001/10/01 12:37:10 1.8 @@ -8,7 +8,7 @@ <!-- ========================================================================= --> <!-- @author jenniferbrown@example.org --> -<!-- @version $Id: regsvggen.xml,v 1.7 2001/09/28 13:11:33 vhardy Exp $ --> +<!-- @version $Id: regsvggen.xml,v 1.8 2001/10/01 12:37:10 vhardy Exp $ --> <!-- ========================================================================= --> <testSuite name="SVGGraphics2D Accuracy Testing"> <test class="org.apache.batik.svggen.SVGAccuracyTest"> @@ -18,81 +18,88 @@ </test> <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.BasicShapes2" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/BasicShapes2.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/BasicShapes2.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/BasicShapes2.svg" /> </test> <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.ATransform" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ATransform.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ATransform.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ATransform.svg" /> </test> <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.AttributedCharacterIterator" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/AttributedCharacterIterator.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/AttributedCharacterIterator.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/AttributedCharacterIterator.svg" /> </test> <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.BEExample" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/BEExample.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/BEExample.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/BEExample.svg" /> </test> <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.BStroke" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/BStroke.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/BStroke.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/BStroke.svg" /> </test> <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.Clip" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Clip.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Clip.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/Clip.svg" /> </test> <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.Color1" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Color1.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Color1.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/Color1.svg" /> </test> <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.Color2" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Color2.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Color2.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/Color2.svg" /> </test> <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.DrawImage" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/DrawImage.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/DrawImage.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/DrawImage.svg" /> </test> <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.Font1" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Font1.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Font1.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/Font1.svg" /> </test> <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.Font2" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Font2.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Font2.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/Font2.svg" /> </test> <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.GVector" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/GVector.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/GVector.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/GVector.svg" /> </test> <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.Gradient" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Gradient.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Gradient.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/Gradient.svg" /> </test> + <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.GraphicObjects" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/GraphicObjects.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/GraphicObjects.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/GraphicObjects.svg" /> </test> <test class="org.apache.batik.svggen.SVGAccuracyTest"> + <arg class="org.apache.batik.svggen.IdentityTest" /> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/IdentityTest.svg"/> + <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/IdentityTest.svg" /> + </test> + + <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.Lookup" /> <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Lookup.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/Lookup.svg" /> @@ -107,22 +114,22 @@ <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.Paints" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Paints.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Paints.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/Paints.svg" /> </test> <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.RHints" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/RHints.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/RHints.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/RHints.svg" /> </test> <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.Rescale" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Rescale.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Rescale.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/Rescale.svg" /> </test> <test class="org.apache.batik.svggen.SVGAccuracyTest"> <arg class="org.apache.batik.svggen.ShearTest" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ShearTest.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ShearTest.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ShearTest.svg" /> </test> @@ -148,80 +155,87 @@ </test> <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.BasicShapes2" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextBasicShapes2.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextBasicShapes2.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextBasicShapes2.svg" /> </test> <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.ATransform" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextATransform.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextATransform.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextATransform.svg" /> </test> <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.AttributedCharacterIterator" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextAttributedCharacterIterator.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextAttributedCharacterIterator.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextAttributedCharacterIterator.svg" /> </test> <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.BEExample" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextBEExample.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextBEExample.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextBEExample.svg" /> </test> <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.BStroke" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextBStroke.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextBStroke.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextBStroke.svg" /> </test> <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.Clip" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextClip.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextClip.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextClip.svg" /> </test> <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.Color1" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextColor1.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextColor1.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextColor1.svg" /> </test> <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.Color2" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextColor2.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextColor2.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextColor2.svg" /> </test> <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.DrawImage" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextDrawImage.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextDrawImage.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextDrawImage.svg" /> </test> <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.Font1" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextFont1.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextFont1.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextFont1.svg" /> </test> <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.Font2" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextFont2.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextFont2.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextFont2.svg" /> </test> <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.GVector" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextGVector.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextGVector.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextGVector.svg" /> </test> <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.Gradient" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextGradient.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextGradient.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextGradient.svg" /> </test> + <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.GraphicObjects" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextGraphicObjects.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextGraphicObjects.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextGraphicObjects.svg" /> </test> <test class="org.apache.batik.svggen.GeneratorContext"> + <arg class="org.apache.batik.svggen.IdentityTest" /> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextIdentityTest.svg"/> + <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextIdentityTest.svg" /> + </test> + + <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.Lookup" /> <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextLookup.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextLookup.svg" /> @@ -235,22 +249,22 @@ <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.Paints" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextPaints.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextPaints.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextPaints.svg" /> </test> <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.RHints" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextRHints.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextRHints.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextRHints.svg" /> </test> <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.Rescale" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextRescale.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextRescale.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextRescale.svg" /> </test> <test class="org.apache.batik.svggen.GeneratorContext"> <arg class="org.apache.batik.svggen.ShearTest" /> - <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextShearTest.svg"/> + <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextShearTest.svg"/> <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextShearTest.svg" /> </test> 1.1 xml-batik/test-references/org/apache/batik/svggen/IdentityTest.svg Index: IdentityTest.svg =================================================================== <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN' 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'> <svg stroke-dasharray="none" shape-rendering="auto" xmlns="http://www.w3.org/2000/svg" font-family="&apos;Arial&apos;" width="300" text-rendering="auto" fill-opacity="1" contentScriptType="text/ecmascript" color-rendering="auto" color-interpolation="auto" preserveAspectRatio="xMidYMid meet" font-size="12" fill="black" stroke="black" image-rendering="auto" stroke-miterlimit="10" zoomAndPan="magnify" version="1.0" stroke-linecap="square" stroke-linejoin="miter" contentStyleType="text/css" font-style="normal" height="400" stroke-width="1" stroke-dashoffset="0" font-weight="normal" stroke-opacity="1"> <!--Generated by the Batik Graphics2D SVG Generator--> <defs id="genericDefs" /> <g> <g text-rendering="optimizeLegibility" shape-rendering="geometricPrecision"> <rect width="100" x="10" height="80" y="10" stroke="none" /> </g> </g> </svg> --------------------------------------------------------------------- To unsubscribe, e-mail: jenniferbrown@example.org For additional commands, e-mail: jenniferbrown@example.org From batikjenniferbrown@example.org Mon Oct 01 12:43:36 2001 Return-Path: <batikjenniferbrown@example.org> Delivered-To: jenniferbrown@example.org Received: (qmail 68995 invoked by uid 500); 1 Oct 2001 12:43:35 -0000 Mailing-List: contact jenniferbrown@example.org; run by ezmlm Precedence: bulk List-Post: <mailto:jenniferbrown@example.org> List-Help: <mailto:jenniferbrown@example.org> List-Unsubscribe: <mailto:jenniferbrown@example.org> List-Subscribe: <mailto:jenniferbrown@example.org> Reply-To: jenniferbrown@example.org Delivered-To: mailing list jenniferbrown@example.org Received: (qmail 68977 invoked from network); 1 Oct 2001 12:43:34 -0000 Message-ID: <jenniferbrown@example.org> Date: Mon, 01 Oct 2001 14:40:57 +0200 From: Vincent Hardy <jenniferbrown@example.org> X-Mailer: Mozilla 4.73 [en]C-{C-UDP; EBM-SONY1} (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: jenniferbrown@example.org Subject: More on: Re: cdata text References: <jenniferbrown@example.org> <jenniferbrown@example.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Keiron, I just commited a fix for the problem you reported and added a new sample which exercises that problem (samples/tests/textPCDATA.svg). Thanks for your feedback! Vincent. Keiron Liddle wrote: > > Is there any particular reason that text inside CDATA sections is not > handled or ignored. > > I removed the createCDATASection from the SAXDocumentFactory (so it just > creates a TextNode) and the text appeared. This probably is not the > solution, just a test to see what happens. > It seems that the bridge ignores the CDATASection class because the node > type is not an ELEMENT_NODE. > > Do I need to remove the cdata sections (and replace "<" with "&lt;" etc.) > because this is the expected behaviour or is it not handling the cdata > properly. > > Keiron > > ps. I'm sending this again, the first one seems to have disappeared > > --------------------------------------------------------------------- > To unsubscribe, e-mail: jenniferbrown@example.org > For additional commands, e-mail: jenniferbrown@example.org --------------------------------------------------------------------- To unsubscribe, e-mail: jenniferbrown@example.org For additional commands, e-mail: jenniferbrown@example.org From batikjenniferbrown@example.org Wed Oct 03 16:10:48 2001 Return-Path: <batikjenniferbrown@example.org> Delivered-To: jenniferbrown@example.org Received: (qmail 53212 invoked by uid 500); 3 Oct 2001 16:10:48 -0000 Mailing-List: contact jenniferbrown@example.org; run by ezmlm Precedence: bulk List-Post: <mailto:jenniferbrown@example.org> List-Help: <mailto:jenniferbrown@example.org> List-Unsubscribe: <mailto:jenniferbrown@example.org> List-Subscribe: <mailto:jenniferbrown@example.org> Reply-To: jenniferbrown@example.org Delivered-To: mailing list jenniferbrown@example.org Received: (qmail 53159 invoked by uid 500); 3 Oct 2001 16:10:47 -0000 Delivered-To: jenniferbrown@example.org Date: 3 Oct 2001 16:08:20 -0000 Message-ID: <jenniferbrown@example.org> From: jenniferbrown@example.org To: jenniferbrown@example.org Subject: cvs commit: xml-batik/sources/org/apache/batik/swing/gvt JGVTComponent.java TextSelectionManager.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N tkormann 01/10/03 09:08:20 Modified: resources/org/apache/batik/apps/svgbrowser/resources FindDialog.properties GUI.properties sources/org/apache/batik/apps/svgbrowser FindDialog.java sources/org/apache/batik/gvt TextPainter.java sources/org/apache/batik/swing/gvt JGVTComponent.java TextSelectionManager.java Log: commit the text search. Selection is now working. Zoom is disable at this time. Revision Changes Path 1.3 +14 -11 xml-batik/resources/org/apache/batik/apps/svgbrowser/resources/FindDialog.properties Index: FindDialog.properties =================================================================== RCS file: /home/cvs/xml-batik/resources/org/apache/batik/apps/svgbrowser/resources/FindDialog.properties,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- FindDialog.properties 2001/05/07 23:49:51 1.2 +++ FindDialog.properties 2001/10/03 16:08:19 1.3 @@ -9,10 +9,10 @@ # FindDialog properties file # # Author: jenniferbrown@example.org -# $Id: FindDialog.properties,v 1.2 2001/05/07 23:49:51 tkormann Exp $ +# $Id: FindDialog.properties,v 1.3 2001/10/03 16:08:19 tkormann Exp $ # -Dialog.title = Find... +Dialog.title = Batik: Find Panel.title = Search for text FindLabel.text = Find : @@ -23,19 +23,22 @@ EnableZoomCheckBox.text = Enable zoom EnableZoomCheckBox.mnemonic = A -NextButton.text = Next -NextButton.mnemonic = N -NextButton.action = NextButtonAction - -PreviousButton.text = Previous -PreviousButton.mnemonic = P -PreviousButton.action = PreviousButtonAction +FindButton.text = Find +FindButton.mnemonic = F +FindButton.action = FindButtonAction + +ClearButton.text = Clear +ClearButton.mnemonic = C +ClearButton.action = ClearButtonAction -CloseButton.text = Close -CloseButton.mnemonic = C +CloseButton.text = Closec +CloseButton.mnemonic = X CloseButton.action = CloseButtonAction +End.text = End of document reached; continue from beginning. +End.title = Batik: Find wrap + 1.32 +3 -3 xml-batik/resources/org/apache/batik/apps/svgbrowser/resources/GUI.properties Index: GUI.properties =================================================================== RCS file: /home/cvs/xml-batik/resources/org/apache/batik/apps/svgbrowser/resources/GUI.properties,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- GUI.properties 2001/09/28 15:40:08 1.31 +++ GUI.properties 2001/10/03 16:08:19 1.32 @@ -9,7 +9,7 @@ # The viewer's GUI resources. # # Author: jenniferbrown@example.org -# $Id: GUI.properties,v 1.31 2001/09/28 15:40:08 hillion Exp $ +# $Id: GUI.properties,v 1.32 2001/10/03 16:08:19 tkormann Exp $ # ViewSource.width = 750 @@ -129,9 +129,9 @@ # Edit menu ################ -#Edit = FindDialog - Preferences +Edit = FindDialog - Preferences #Edit = Preferences Flush -Edit = Preferences +#Edit = Preferences Edit.type = MENU Edit.text = Edit 1.4 +68 -91 xml-batik/sources/org/apache/batik/apps/svgbrowser/FindDialog.java Index: FindDialog.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/apps/svgbrowser/FindDialog.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- FindDialog.java 2001/09/17 13:37:30 1.3 +++ FindDialog.java 2001/10/03 16:08:19 1.4 @@ -18,6 +18,8 @@ import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; +import java.text.AttributedCharacterIterator; + import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -34,6 +36,7 @@ import javax.swing.JCheckBox; import javax.swing.JDialog; import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; @@ -45,7 +48,10 @@ import org.apache.batik.gvt.GraphicsNode; import org.apache.batik.gvt.TextNode; +import org.apache.batik.gvt.text.Mark; + import org.apache.batik.swing.JSVGCanvas; +import org.apache.batik.swing.gvt.TextSelectionManager; import org.apache.batik.util.gui.ExtendedGridBagConstraints; import org.apache.batik.util.gui.resource.ActionMap; @@ -58,7 +64,7 @@ * an SVG document. * * @author <a href="mailto:jenniferbrown@example.org">Thierry Kormann</a> - * @version $Id: FindDialog.java,v 1.3 2001/09/17 13:37:30 tkormann Exp $ + * @version $Id: FindDialog.java,v 1.4 2001/10/03 16:08:19 tkormann Exp $ */ public class FindDialog extends JDialog implements ActionMap { @@ -69,8 +75,8 @@ "org.apache.batik.apps.svgbrowser.resources.FindDialog"; // action names - public final static String NEXT_ACTION = "NextButtonAction"; - public final static String PREVIOUS_ACTION = "PreviousButtonAction"; + public final static String FIND_ACTION = "FindButtonAction"; + public final static String CLEAR_ACTION = "ClearButtonAction"; public final static String CLOSE_ACTION = "CloseButtonAction"; /** @@ -101,13 +107,13 @@ protected JTextField search; /** The next button. */ - protected JButton next; + protected JButton findButton; /** The next button. */ - protected JButton previous; + protected JButton clearButton; /** The cancel button. */ - protected JButton close; + protected JButton closeButton; /** The case sensitive button. */ protected JCheckBox caseSensitive; @@ -134,8 +140,8 @@ buttonFactory = new ButtonFactory(bundle, this); - listeners.put(NEXT_ACTION, new NextButtonAction()); - listeners.put(PREVIOUS_ACTION, new PreviousButtonAction()); + listeners.put(FIND_ACTION, new FindButtonAction()); + listeners.put(CLEAR_ACTION, new ClearButtonAction()); listeners.put(CLOSE_ACTION, new CloseButtonAction()); getContentPane().add(createFindPanel(), BorderLayout.CENTER); @@ -165,7 +171,6 @@ gbc.setWeight(1.0, 0); gbc.setGridBounds(1, 0, 2, 1); panel.add(search = new JTextField(20), gbc); - search.getDocument().addDocumentListener(new TextTracker()); gbc.fill = ExtendedGridBagConstraints.NONE; gbc.anchor = ExtendedGridBagConstraints.WEST; @@ -179,7 +184,7 @@ gbc.setWeight(0, 0); gbc.setGridBounds(2, 1, 1, 1); enableZoom = buttonFactory.createJCheckBox("EnableZoomCheckBox"); - panel.add(enableZoom, gbc); + //panel.add(enableZoom, gbc); return panel; } @@ -189,12 +194,9 @@ */ protected JPanel createButtonsPanel() { JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - panel.add(next = buttonFactory.createJButton("NextButton")); - panel.add(previous = buttonFactory.createJButton("PreviousButton")); - panel.add(close = buttonFactory.createJButton("CloseButton")); - - updateButtonState(); - + panel.add(findButton = buttonFactory.createJButton("FindButton")); + panel.add(clearButton = buttonFactory.createJButton("ClearButton")); + panel.add(closeButton = buttonFactory.createJButton("CloseButton")); return panel; } @@ -210,7 +212,6 @@ } else { this.walker = null; } - updateButtonState(); } /** @@ -220,6 +221,9 @@ * @param text the text to match */ protected GraphicsNode getNext(String text) { + if (walker == null && gvtRoot != null) { + walker = new GVTTreeWalker(gvtRoot); + } GraphicsNode gn = walker.nextGraphicsNode(); while (gn != null && !match(gn, text)) { gn = walker.nextGraphicsNode(); @@ -234,6 +238,9 @@ * @param text the text to match */ protected GraphicsNode getPrevious(String text) { + if (walker == null && gvtRoot != null) { + walker = new GVTTreeWalker(gvtRoot); + } GraphicsNode gn = walker.previousGraphicsNode(); while (gn != null && !match(gn, text)) { gn = walker.previousGraphicsNode(); @@ -242,11 +249,11 @@ } /** - * Returns true if the specified node matches the following text, false - * otherwise. + * Returns the index inside the specified TextNode of the specified text, or + * -1 if not found. * * @param node the graphics node to check - * @param text the text use to match + * @param text the text use to match */ protected boolean match(GraphicsNode node, String text) { if (!(node instanceof TextNode) @@ -254,29 +261,14 @@ || text == null || text.length() == 0) { return false; } - String s = ((TextNode)node).getText(); if (!caseSensitive.isSelected()) { s = s.toLowerCase(); text = text.toLowerCase(); } - return s.startsWith(text); - } - - /** - * Updates the state of the 'next', 'previous' buttons and 'search' text - * field. - */ - private void updateButtonState() { - boolean b1 = (gvtRoot != null); - String text = search.getText(); - boolean b2 = (text != null && text.length() > 0); - next.setEnabled(b1 && b2); - previous.setEnabled(b1 && b2); - search.setEnabled(b1); + return (s.indexOf(text) >= 0); } - /** * Shows the current selected <tt>TextNode</tt>. */ @@ -285,7 +277,24 @@ if (!(gn instanceof TextNode)) { return; } - System.out.println(((TextNode)gn).getText()); + TextNode textNode = (TextNode)gn; + // mark the selection of the substring found + String text = textNode.getText(); + String pattern = search.getText(); + AttributedCharacterIterator aci = + textNode.getAttributedCharacterIterator(); + aci.first(); + for (int i=0; i < text.indexOf(pattern); ++i) { + aci.next(); + } + Mark startMark = textNode.getMarkerForChar(aci.getIndex(), true); + for (int i = 0; i < pattern.length()-1; ++i) { + aci.next(); + } + Mark endMark = textNode.getMarkerForChar(aci.getIndex(), false); + svgCanvas.select(startMark, endMark); + + // zoom on the TextNode if needed if (enableZoom.isSelected()) { Rectangle2D bounds = gn.getBounds(); bounds = gn.getGlobalTransform().createTransformedShape @@ -300,7 +309,6 @@ } } - // ActionMap implementation /** @@ -323,32 +331,35 @@ ////////////////////////////////////////////////////////////////////////// /** - * The action associated to the 'next' button. + * The action associated to the 'find' button. */ - protected class NextButtonAction extends AbstractAction { + protected class FindButtonAction extends AbstractAction { public void actionPerformed(ActionEvent e) { - GraphicsNode gn = getNext(search.getText()); - if (gn != null) { - previous.setEnabled(true); - showSelectedGraphicsNode(); - } else { - next.setEnabled(false); - } - } + String text = search.getText(); + if (text == null || text.length() == 0) { + return; + } + GraphicsNode gn = getNext(text); + if (gn != null) { + showSelectedGraphicsNode(); + } else { + // end of document reached + walker = null; + JOptionPane.showMessageDialog(FindDialog.this, + resources.getString("End.text"), + resources.getString("End.title"), + JOptionPane.INFORMATION_MESSAGE); + } + } } /** - * The action associated to the 'previous' button. + * The action associated to the 'clear' button. */ - protected class PreviousButtonAction extends AbstractAction { + protected class ClearButtonAction extends AbstractAction { public void actionPerformed(ActionEvent e) { - GraphicsNode gn = getPrevious(search.getText()); - if (gn != null) { - next.setEnabled(true); - showSelectedGraphicsNode(); - } else { - previous.setEnabled(false); - } + search.setText(null); + walker = null; } } @@ -358,40 +369,6 @@ protected class CloseButtonAction extends AbstractAction { public void actionPerformed(ActionEvent e) { dispose(); - } - } - - /** - * This class is used to track all modifications of the search TextField. - */ - protected class TextTracker implements DocumentListener { - - public void changedUpdate(DocumentEvent e) { } - - public void insertUpdate(DocumentEvent e) { - updateButtonState(); - String text = search.getText(); - // go to next only if the current node does not match the text - if (!match(walker.getCurrentGraphicsNode(), text)) { - GraphicsNode gn = getNext(text); - if (gn != null) { - previous.setEnabled(true); - showSelectedGraphicsNode(); - } else { - next.setEnabled(false); - } - } - } - - public void removeUpdate(DocumentEvent e) { - updateButtonState(); - GraphicsNode gn = getPrevious(search.getText()); - if (gn != null) { - next.setEnabled(true); - showSelectedGraphicsNode(); - } else { - previous.setEnabled(false); - } } } } 1.15 +2 -3 xml-batik/sources/org/apache/batik/gvt/TextPainter.java Index: TextPainter.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/TextPainter.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- TextPainter.java 2001/09/27 20:09:10 1.14 +++ TextPainter.java 2001/10/03 16:08:19 1.15 @@ -21,7 +21,7 @@ * Renders the attributed character iterator of a <tt>TextNode</tt>. * * @author <a href="mailto:jenniferbrown@example.org">Thierry Kormann</a> - * @version $Id: TextPainter.java,v 1.14 2001/09/27 20:09:10 deweese Exp $ + * @version $Id: TextPainter.java,v 1.15 2001/10/03 16:08:19 tkormann Exp $ */ public interface TextPainter { @@ -33,8 +33,7 @@ * @param g2d the Graphics2D to use * @param context the rendering context. */ - void paint(TextNode node, - Graphics2D g2d); + void paint(TextNode node, Graphics2D g2d); /** * Initiates a text selection on a particular AttributedCharacterIterator, 1.18 +32 -1 xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java Index: JGVTComponent.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- JGVTComponent.java 2001/09/18 21:19:01 1.17 +++ JGVTComponent.java 2001/10/03 16:08:19 1.18 @@ -47,11 +47,13 @@ import org.apache.batik.gvt.renderer.ImageRenderer; import org.apache.batik.gvt.renderer.ImageRendererFactory; +import org.apache.batik.gvt.text.Mark; + /** * This class represents a component which can display a GVT tree. * * @author <a href="mailto:jenniferbrown@example.org">Stephane Hillion</a> - * @version $Id: JGVTComponent.java,v 1.17 2001/09/18 21:19:01 deweese Exp $ + * @version $Id: JGVTComponent.java,v 1.18 2001/10/03 16:08:19 tkormann Exp $ */ public class JGVTComponent extends JComponent { @@ -288,6 +290,35 @@ } } } + + //////////////////////////////////////////////////////////////////////// + // Selection methods + //////////////////////////////////////////////////////////////////////// + + /** + * Sets the selection to the specified start and end mark. + * + * @param start the mark used to define where the selection starts + * @param end the mark used to define where the selection ends + */ + public void select(Mark start, Mark end) { + if (textSelectionManager != null) { + textSelectionManager.setSelection(start, end); + } + } + + /** + * Deselects all. + */ + public void deselectAll() { + if (textSelectionManager != null) { + textSelectionManager.clearSelection(); + } + } + + //////////////////////////////////////////////////////////////////////// + // Painting methods + //////////////////////////////////////////////////////////////////////// /** * Whether to enable the progressive paint. 1.10 +8 -1 xml-batik/sources/org/apache/batik/swing/gvt/TextSelectionManager.java Index: TextSelectionManager.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/gvt/TextSelectionManager.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- TextSelectionManager.java 2001/09/27 21:19:44 1.9 +++ TextSelectionManager.java 2001/10/03 16:08:19 1.10 @@ -36,7 +36,7 @@ * This class represents an object which manage GVT text nodes selection. * * @author <a href="mailto:jenniferbrown@example.org">Stephane Hillion</a> - * @version $Id: TextSelectionManager.java,v 1.9 2001/09/27 21:19:44 deweese Exp $ + * @version $Id: TextSelectionManager.java,v 1.10 2001/10/03 16:08:19 tkormann Exp $ */ public class TextSelectionManager { @@ -113,6 +113,13 @@ */ public void setSelection(Mark start, Mark end) { textSelector.setSelection(start, end); + } + + /** + * Clears the selection. + */ + public void clearSelection() { + textSelector.clearSelection(); } /** --------------------------------------------------------------------- To unsubscribe, e-mail: jenniferbrown@example.org For additional commands, e-mail: jenniferbrown@example.org From batikjenniferbrown@example.org Wed Oct 03 17:59:07 2001 Return-Path: <batikjenniferbrown@example.org> Delivered-To: jenniferbrown@example.org Received: (qmail 32663 invoked by uid 500); 3 Oct 2001 17:59:07 -0000 Mailing-List: contact jenniferbrown@example.org; run by ezmlm Precedence: bulk List-Post: <mailto:jenniferbrown@example.org> List-Help: <mailto:jenniferbrown@example.org> List-Unsubscribe: <mailto:jenniferbrown@example.org> List-Subscribe: <mailto:jenniferbrown@example.org> Reply-To: jenniferbrown@example.org Delivered-To: mailing list jenniferbrown@example.org Received: (qmail 32643 invoked from network); 3 Oct 2001 17:59:07 -0000 X-Originating-IP: [83.161.120.155] From: "r d" <jenniferbrown@example.org> To: jenniferbrown@example.org Bcc: Subject: Question about CVS...vendor branch? Date: Wed, 03 Oct 2001 17:58:45 +0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: <jenniferbrown@example.org> X-OriginalArrivalTime: 03 Oct 2001 17:58:45.0360 (UTC) FILETIME=[0B892700:01C14C35] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hello Batikers, I have been playing in the CVS Repository....and I have run into something that I do not understand....if someone would be so kind as to education me on this issue: In the CVS Reopository for Batik on the Revision line....it sometimes says: Revision 83.161.120.155 /download- annotate-[select for diffs](vendor branch) What does "(vendor branch)" mean......and how come when I click on annotate I get an the error message: Python Exception Occurred I am looking at the CVS from the Batik web site.....any help would be nice.... We all learn by sharing what we know Robert A. DiBlasi _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp --------------------------------------------------------------------- To unsubscribe, e-mail: jenniferbrown@example.org For additional commands, e-mail: jenniferbrown@example.org From batikjenniferbrown@example.org Thu Oct 04 06:58:24 2001 Return-Path: <batikjenniferbrown@example.org> Delivered-To: jenniferbrown@example.org Received: (qmail 25318 invoked by uid 500); 4 Oct 2001 06:58:24 -0000 Mailing-List: contact jenniferbrown@example.org; run by ezmlm Precedence: bulk List-Post: <mailto:jenniferbrown@example.org> List-Help: <mailto:jenniferbrown@example.org> List-Unsubscribe: <mailto:jenniferbrown@example.org> List-Subscribe: <mailto:jenniferbrown@example.org> Reply-To: jenniferbrown@example.org Delivered-To: mailing list jenniferbrown@example.org Received: (qmail 25274 invoked from network); 4 Oct 2001 06:58:23 -0000 Message-ID: <jenniferbrown@example.org> Date: Thu, 04 Oct 2001 08:42:58 +0200 From: Vincent Hardy <jenniferbrown@example.org> X-Mailer: Mozilla 4.73 [en]C-{C-UDP; EBM-SONY1} (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: jenniferbrown@example.org Subject: Re: Question about CVS...vendor branch? References: <jenniferbrown@example.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Robert, I am not a CVS expert, so I am not sure what this is about... May be the other commiters will have an idea. Vincent. r d wrote: > > Hello Batikers, > > I have been playing in the CVS Repository....and I have run into something > that I do not understand....if someone would be so kind as to education me > on this issue: > > In the CVS Reopository for Batik on the Revision line....it sometimes says: > Revision 83.161.120.155 /download- annotate-[select for diffs](vendor branch) > > What does "(vendor branch)" mean......and how come when I click on annotate > I get an the error message: > > Python Exception Occurred > > I am looking at the CVS from the Batik web site.....any help would be > nice.... > > We all learn by sharing what we know > Robert A. DiBlasi > > _________________________________________________________________ > Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp > > --------------------------------------------------------------------- > To unsubscribe, e-mail: jenniferbrown@example.org > For additional commands, e-mail: jenniferbrown@example.org --------------------------------------------------------------------- To unsubscribe, e-mail: jenniferbrown@example.org For additional commands, e-mail: jenniferbrown@example.org From batikjenniferbrown@example.org Thu Oct 04 08:28:17 2001 Return-Path: <batikjenniferbrown@example.org> Delivered-To: jenniferbrown@example.org Received: (qmail 27575 invoked by uid 500); 4 Oct 2001 08:28:16 -0000 Mailing-List: contact jenniferbrown@example.org; run by ezmlm Precedence: bulk List-Post: <mailto:jenniferbrown@example.org> List-Help: <mailto:jenniferbrown@example.org> List-Unsubscribe: <mailto:jenniferbrown@example.org> List-Subscribe: <mailto:jenniferbrown@example.org> Reply-To: jenniferbrown@example.org Delivered-To: mailing list jenniferbrown@example.org Received: (qmail 27562 invoked by uid 500); 4 Oct 2001 08:28:15 -0000 Delivered-To: jenniferbrown@example.org Date: 4 Oct 2001 08:25:47 -0000 Message-ID: <jenniferbrown@example.org> From: jenniferbrown@example.org To: jenniferbrown@example.org Subject: cvs commit: xml-batik/sources/org/apache/batik/swing/gvt JGVTComponent.java TextSelectionManager.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N tkormann 01/10/04 01:25:47 Modified: sources/org/apache/batik/swing/gvt JGVTComponent.java TextSelectionManager.java Log: Add few methods to control the color and the XOR mode of the selection overlay. Revision Changes Path 1.19 +52 -1 xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java Index: JGVTComponent.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- JGVTComponent.java 2001/10/03 16:08:19 1.18 +++ JGVTComponent.java 2001/10/04 08:25:47 1.19 @@ -53,7 +53,7 @@ * This class represents a component which can display a GVT tree. * * @author <a href="mailto:jenniferbrown@example.org">Stephane Hillion</a> - * @version $Id: JGVTComponent.java,v 1.18 2001/10/03 16:08:19 tkormann Exp $ + * @version $Id: JGVTComponent.java,v 1.19 2001/10/04 08:25:47 tkormann Exp $ */ public class JGVTComponent extends JComponent { @@ -294,6 +294,57 @@ //////////////////////////////////////////////////////////////////////// // Selection methods //////////////////////////////////////////////////////////////////////// + + /** + * Sets the color of the selection overlay to the specified color. + * + * @param color the new color of the selection overlay + */ + public void setSelectionOverlayColor(Color color) { + textSelectionManager.setSelectionOverlayColor(color); + } + + /** + * Returns the color of the selection overlay. + */ + public Color getSelectionOverlayColor() { + return textSelectionManager.getSelectionOverlayColor(); + } + + /** + * Sets the color of the outline of the selection overlay to the specified + * color. + * + * @param color the new color of the outline of the selection overlay + */ + public void setSelectionOverlayStrokeColor(Color color) { + textSelectionManager.setSelectionOverlayStrokeColor(color); + } + + /** + * Returns the color of the outline of the selection overlay. + */ + public Color getSelectionOverlayStrokeColor() { + return textSelectionManager.getSelectionOverlayStrokeColor(); + } + + /** + * Sets whether or not the selection overlay will be painted in XOR mode, + * depending on the specified parameter. + * + * @param state true implies the selection overlay will be in XOR mode + */ + public void setSelectionOverlayXORMode(boolean state) { + textSelectionManager.setSelectionOverlayXORMode(state); + } + + /** + * Returns true if the selection overlay is painted in XOR mode, false + * otherwise. + */ + public boolean isSelectionOverlayXORMode() { + return textSelectionManager.isSelectionOverlayXORMode(); + } /** * Sets the selection to the specified start and end mark. 1.11 +81 -12 xml-batik/sources/org/apache/batik/swing/gvt/TextSelectionManager.java Index: TextSelectionManager.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/gvt/TextSelectionManager.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- TextSelectionManager.java 2001/10/03 16:08:19 1.10 +++ TextSelectionManager.java 2001/10/04 08:25:47 1.11 @@ -36,7 +36,7 @@ * This class represents an object which manage GVT text nodes selection. * * @author <a href="mailto:jenniferbrown@example.org">Stephane Hillion</a> - * @version $Id: TextSelectionManager.java,v 1.10 2001/10/03 16:08:19 tkormann Exp $ + * @version $Id: TextSelectionManager.java,v 1.11 2001/10/04 08:25:47 tkormann Exp $ */ public class TextSelectionManager { @@ -86,6 +86,22 @@ protected SelectionListener textSelectionListener; /** + * The color of the selection overlay. + */ + protected Color selectionOverlayColor = new Color(200, 200, 255, 100); + + /** + * The color of the outline of the selection overlay. + */ + protected Color selectionOverlayStrokeColor = new Color(255, 255, 255, 255); + + /** + * A flag bit that indicates whether or not the selection overlay is painted + * in XOR mode. + */ + protected boolean xorMode = true; + + /** * Creates a new TextSelectionManager. */ public TextSelectionManager(JGVTComponent comp, @@ -102,6 +118,57 @@ } /** + * Sets the color of the selection overlay to the specified color. + * + * @param color the new color of the selection overlay + */ + public void setSelectionOverlayColor(Color color) { + this.selectionOverlayColor = color; + } + + /** + * Returns the color of the selection overlay. + */ + public Color getSelectionOverlayColor() { + return selectionOverlayColor; + } + + /** + * Sets the color of the outline of the selection overlay to the specified + * color. + * + * @param color the new color of the outline of the selection overlay + */ + public void setSelectionOverlayStrokeColor(Color color) { + this.selectionOverlayStrokeColor = color; + } + + /** + * Returns the color of the outline of the selection overlay. + */ + public Color getSelectionOverlayStrokeColor() { + return selectionOverlayStrokeColor; + } + + /** + * Sets whether or not the selection overlay will be painted in XOR mode, + * depending on the specified parameter. + * + * @param state true implies the selection overlay will be in XOR mode + */ + public void setSelectionOverlayXORMode(boolean state) { + this.xorMode = state; + } + + /** + * Returns true if the selection overlay is painted in XOR mode, false + * otherwise. + */ + public boolean isSelectionOverlayXORMode() { + return xorMode; + } + + /** * Returns the selection overlay. */ public Overlay getSelectionOverlay() { @@ -239,9 +306,6 @@ return outset(s.getBounds(), 1); } - static final Color fillColor = new Color(200, 200, 255, 100); - static final Color strokeColor = new Color(255, 255, 255, 255); - /** * The selection overlay. */ @@ -256,15 +320,20 @@ Shape s = at.createTransformedShape(selectionHighlight); Graphics2D g2d = (Graphics2D)g; - - // g2d.setXORMode(Color.white); - // g2d.setColor(Color.black); - g2d.setColor(fillColor); + if (xorMode) { + int red = 255 - selectionOverlayColor.getRed(); + int green = 255 - selectionOverlayColor.getGreen(); + int blue = 255 - selectionOverlayColor.getBlue(); + g2d.setXORMode(new Color(red, green, blue)); + } + g2d.setColor(selectionOverlayColor); g2d.fill(s); - - g2d.setStroke(new java.awt.BasicStroke(1.0f)); - g2d.setColor(strokeColor); - g2d.draw(s); + + if (selectionOverlayStrokeColor != null) { + g2d.setStroke(new java.awt.BasicStroke(1.0f)); + g2d.setColor(selectionOverlayStrokeColor); + g2d.draw(s); + } } } } --------------------------------------------------------------------- To unsubscribe, e-mail: jenniferbrown@example.org For additional commands, e-mail: jenniferbrown@example.org From batikjenniferbrown@example.org Thu Oct 04 08:37:58 2001 Return-Path: <batikjenniferbrown@example.org> Delivered-To: jenniferbrown@example.org Received: (qmail 39365 invoked by uid 500); 4 Oct 2001 08:37:57 -0000 Mailing-List: contact jenniferbrown@example.org; run by ezmlm Precedence: bulk List-Post: <mailto:jenniferbrown@example.org> List-Help: <mailto:jenniferbrown@example.org> List-Unsubscribe: <mailto:jenniferbrown@example.org> List-Subscribe: <mailto:jenniferbrown@example.org> Reply-To: jenniferbrown@example.org Delivered-To: mailing list jenniferbrown@example.org Received: (qmail 39354 invoked from network); 4 Oct 2001 08:37:57 -0000 X-Originating-IP: [83.161.120.155] From: "sudhir hs" <jenniferbrown@example.org> To: jenniferbrown@example.org Bcc: Subject: Please help Date: Thu, 04 Oct 2001 08:37:44 +0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: <jenniferbrown@example.org> X-OriginalArrivalTime: 04 Oct 2001 08:37:44.0539 (UTC) FILETIME=[D6893AB0:01C14CAF] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Dear all, I am having xml-batik and all the necessary steps taken regarding setting environment variable. I am working on Windows NT .
{'source': 'Apache Software Foundation Public Mail Archives'}