Return-Path: Delivered-To: apmail-xml-batik-dev-archive@www.apache.org Received: (qmail 71071 invoked from network); 10 Sep 2004 00:19:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 10 Sep 2004 00:19:23 -0000 Received: (qmail 65833 invoked by uid 500); 10 Sep 2004 00:19:22 -0000 Delivered-To: apmail-xml-batik-dev-archive@xml.apache.org Received: (qmail 65818 invoked by uid 500); 10 Sep 2004 00:19:22 -0000 Mailing-List: contact batik-dev-help@xml.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: batik-dev@xml.apache.org Delivered-To: mailing list batik-dev@xml.apache.org Received: (qmail 65805 invoked by uid 99); 10 Sep 2004 00:19:22 -0000 X-ASF-Spam-Status: No, hits=1.5 required=10.0 tests=DNS_FROM_RFC_POST,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of herve.girod@club-internet.fr designates 194.158.96.107 as permitted sender) Message-ID: <001901c496cc$6d0d4ee0$89e4c2d4@hppav> Reply-To: =?iso-8859-1?Q?Herv=E9_Girod?= From: =?iso-8859-1?Q?Herv=E9_Girod?= To: Subject: Fw: RFE in svggen Date: Fri, 10 Sep 2004 02:23:41 +0200 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0016_01C496DD.3052FB60" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N ------=_NextPart_000_0016_01C496DD.3052FB60 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Sorry, first I forgot to put the attached files, and then I wasn't aware that zip attachments were not allowed... Hope it is all right now... Herv� Girod Thomas DeWeese wrote: >> My problem is that it is not possible to control the SVG Tree by using >> SVGGraphics2D. I am now able to do it, but in order to do it, I had to >> create a new SVGGraphics2D class, rather than subclassing it, because of >> some private fields and methods. >> >> Would it be possible to make some of these methods and fields protected, >> it would ease the process of controlling the generated SVG Tree. >> > Why don't you make the changes and check? Then if it works well > you could submit the changes as a patch ;) Here is the files containing the patches for this RFE, I made very few modifications (mostly transformations from private to protected for some methods), to the following classes : - AbstractGraphics2D in org.apache.batik.ext.awt.g2d - DOMTreeManager, DOMGroupManager, SVGGraphics2D in org.apache.batik.svggen I rebuilt the whole Batik jars after this change, and after subclassing SVGGraphics2D, DOMTreeManager, and DOMGroupManager in my client application, I was able to control the structure of the generated SVG Tree. As you requested, I provided in SVGGraphics2D a protected setter for DOMGroupManager and DOMTreeManager. Hope it is the good patch format (diff -u), as I'm not a cvs guru at all. In fact, I had much more problem in generating the patch files than for all the rest ;) Herv� Girod ------=_NextPart_000_0016_01C496DD.3052FB60 Content-Type: application/octet-stream; name="DOMTreeManager.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="DOMTreeManager.patch" Index: sources/org/apache/batik/svggen/DOMTreeManager.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /home/cvspublic/xml-batik/sources/org/apache/batik/svggen/DOMTreeManager.= java,v retrieving revision 1.19 diff -u -r1.19 DOMTreeManager.java --- sources/org/apache/batik/svggen/DOMTreeManager.java 18 Aug 2004 = 07:14:59 -0000 1.19 +++ sources/org/apache/batik/svggen/DOMTreeManager.java 9 Sep 2004 = 23:18:26 -0000 @@ -70,13 +70,13 @@ * Set of group managers that build groups for * this manager */ - private Vector groupManagers =3D new Vector(); + protected Vector groupManagers =3D new Vector(); =20 /** * Set of definitions that are to be placed at the top of the * document tree */ - private List genericDefSet =3D new LinkedList(); + protected List genericDefSet =3D new LinkedList(); =20 /** * Default SVG GraphicContext state @@ -86,7 +86,7 @@ /** * Top level group */ - private Element topLevelGroup; + protected Element topLevelGroup; =20 /** * Used to convert the Java 2D API graphic context state @@ -99,18 +99,18 @@ * The context that stores the domFactory, the imageHandler * and the extensionHandler. */ - private SVGGeneratorContext generatorContext; + protected SVGGeneratorContext generatorContext; =20 /** * Converters used bVy this object to translate graphic context * attributes */ - private SVGBufferedImageOp filterConverter; + protected SVGBufferedImageOp filterConverter; =20 /** * Set of definitions which can be used by custom extensions */ - private List otherDefs; + protected List otherDefs; =20 /** * Constructor @@ -306,7 +306,7 @@ * SVGGeneratorContext. * @param new extension handler this object should use */ - void setExtensionHandler(ExtensionHandler extensionHandler) { + public void setExtensionHandler(ExtensionHandler extensionHandler) = { generatorContext.setExtensionHandler(extensionHandler); } =20 @@ -420,15 +420,19 @@ return gcConverter; } =20 - SVGGeneratorContext getGeneratorContext() { + public SVGGeneratorContext getGeneratorContext() { return generatorContext; } + =20 + public SVGGraphicContext getGraphicContext() { + return defaultGC; + } =20 - Document getDOMFactory() { + public Document getDOMFactory() { return generatorContext.domFactory; } =20 - StyleHandler getStyleHandler() { + public StyleHandler getStyleHandler() { return generatorContext.styleHandler; } } ------=_NextPart_000_0016_01C496DD.3052FB60 Content-Type: application/octet-stream; name="DOMGroupManager.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="DOMGroupManager.patch" Index: sources/org/apache/batik/svggen/DOMGroupManager.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /home/cvspublic/xml-batik/sources/org/apache/batik/svggen/DOMGroupManager= .java,v retrieving revision 1.13 diff -u -r1.13 DOMGroupManager.java --- sources/org/apache/batik/svggen/DOMGroupManager.java 18 Aug 2004 = 07:14:59 -0000 1.13 +++ sources/org/apache/batik/svggen/DOMGroupManager.java 9 Sep 2004 = 23:17:07 -0000 @@ -65,22 +65,22 @@ * Reference to the GraphicContext this manager will use to * reflect style attributes in the tree nodes. */ - private GraphicContext gc; + protected GraphicContext gc; =20 /** * DOMTreeManager that this group manager cooperates with */ - private DOMTreeManager domTreeManager; + protected DOMTreeManager domTreeManager; =20 /** * Current group's SVG GraphicContext state */ - private SVGGraphicContext groupGC; + protected SVGGraphicContext groupGC; =20 /** * Current group node */ - private Element currentGroup; + protected Element currentGroup; =20 /** * Constructor @@ -109,7 +109,7 @@ /** * Reset the state of this object to handle a new currentGroup */ - void recycleCurrentGroup() { + public void recycleCurrentGroup() { // Create new initial current group node currentGroup =3D domTreeManager.getDOMFactory(). createElementNS(SVG_NAMESPACE_URI, SVG_G_TAG); @@ -224,7 +224,7 @@ /** * Removes properties that do not apply for a specific element */ - private void trimContextForElement(SVGGraphicContext svgGC, Element = element) { + protected void trimContextForElement(SVGGraphicContext svgGC, = Element element) { String tag =3D element.getTagName(); Map groupAttrMap =3D svgGC.getGroupContext(); if (tag !=3D null) { @@ -246,7 +246,7 @@ * Processes the transform attribute value corresponding to a * given transform stack */ - private void setTransform(Element element, + protected void setTransform(Element element, TransformStackElement transformStack[]) { String transform =3D domTreeManager.gcConverter. toSVG(transformStack).trim(); @@ -259,7 +259,7 @@ * in gc that are different from the values in referenceGc will be * present in the delta. Other values will no. */ - private SVGGraphicContext processDeltaGC(SVGGraphicContext gc, + protected SVGGraphicContext processDeltaGC(SVGGraphicContext gc, SVGGraphicContext = referenceGc) { Map groupDelta =3D processDeltaMap(gc.getGroupContext(), = referenceGc.getGroupContext()); @@ -310,7 +310,7 @@ * are different from values in referenceMap are place in the * returned delta Map. */ - private Map processDeltaMap(Map map, Map referenceMap) { + protected Map processDeltaMap(Map map, Map referenceMap) { // no need to be synch =3D> HashMap Map mapDelta =3D new HashMap(); Iterator iter =3D map.keySet().iterator();* ------=_NextPart_000_0016_01C496DD.3052FB60 Content-Type: application/octet-stream; name="AbstractGraphics2D.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="AbstractGraphics2D.patch" Index: sources/org/apache/batik/ext/awt/g2d/AbstractGraphics2D.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /home/cvspublic/xml-batik/sources/org/apache/batik/ext/awt/g2d/AbstractGr= aphics2D.java,v retrieving revision 1.8 diff -u -r1.8 AbstractGraphics2D.java --- sources/org/apache/batik/ext/awt/g2d/AbstractGraphics2D.java 18 Aug = 2004 07:13:45 -0000 1.8 +++ sources/org/apache/batik/ext/awt/g2d/AbstractGraphics2D.java 9 Sep = 2004 23:11:02 -0000 @@ -1418,4 +1418,11 @@ public FontRenderContext getFontRenderContext(){ return gc.getFontRenderContext(); } + + /** + * @return the {@link GraphicContext} of this = Graphics2D. + */ =20 + public GraphicContext getGraphicContext() { + return gc; + } } ------=_NextPart_000_0016_01C496DD.3052FB60 Content-Type: application/octet-stream; name="SVGGraphics2D.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="SVGGraphics2D.patch" Index: sources/org/apache/batik/svggen/SVGGraphics2D.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /home/cvspublic/xml-batik/sources/org/apache/batik/svggen/SVGGraphics2D.j= ava,v retrieving revision 1.40 diff -u -r1.40 SVGGraphics2D.java --- sources/org/apache/batik/svggen/SVGGraphics2D.java 18 Aug 2004 = 07:15:05 -0000 1.40 +++ sources/org/apache/batik/svggen/SVGGraphics2D.java 9 Sep 2004 = 23:19:28 -0000 @@ -167,6 +167,13 @@ } =20 /** + * @return the SVGShape used by this SVGGraphics2D instance. + */ =20 + public final SVGShape getShapeConverter() { + return shapeConverter; + } + + /** * @return the DOMTreeManager used by this SVGGraphics2D instance */ public final DOMTreeManager getDOMTreeManager(){ @@ -208,7 +215,22 @@ public final ExtensionHandler getExtensionHandler(){ return generatorCtx.extensionHandler; } - + =20 + /**=20 + * @param new DOM Tree manager this SVGGraphics2D should use + */ + protected final void setDOMTreeManager(DOMTreeManager treeMgr) { + this.domTreeManager =3D treeMgr; + = generatorCtx.genericImageHandler.setDOMTreeManager(domTreeManager); + } + + /**=20 + * @param new DOM Group manager this SVGGraphics2D should use + */ + protected final void setDOMGroupManager(DOMGroupManager groupMgr) = { + this.domGroupManager =3D groupMgr; + } =20 + =20 /** * @param new extension handler this SVGGraphics2D should use */ @@ -289,7 +311,7 @@ /** * Sets an non null SVGGeneratorContext. */ - private void setGeneratorContext(SVGGeneratorContext generatorCtx) = { + protected void setGeneratorContext(SVGGeneratorContext = generatorCtx) { this.generatorCtx =3D generatorCtx; =20 this.gc =3D new GraphicContext(new AffineTransform()); ------=_NextPart_000_0016_01C496DD.3052FB60 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org For additional commands, e-mail: batik-dev-help@xml.apache.org ------=_NextPart_000_0016_01C496DD.3052FB60--