From batikpaul24@example.com Mon Jul 01 13:51:20 2002 Return-Path: <batikpaul24@example.com> Delivered-To: paul24@example.com Received: (qmail 78449 invoked by uid 500); 1 Jul 2002 13:51:20 -0000 Mailing-List: contact paul24@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:paul24@example.com> List-Help: <mailto:paul24@example.com> List-Unsubscribe: <mailto:paul24@example.com> List-Subscribe: <mailto:paul24@example.com> Reply-To: paul24@example.com Delivered-To: mailing list paul24@example.com Received: (qmail 78438 invoked from network); 1 Jul 2002 13:51:19 -0000 Sender: paul24@example.com Message-ID: <paul24@example.com> Date: Mon, 01 Jul 2002 15:53:12 +0200 From: Ahmad Morad <paul24@example.com> Reply-To: paul24@example.com Organization: GhK X-Mailer: Mozilla 4.79 [de] (X11; U; Linux 2.4.18-4GB i686) X-Accept-Language: en MIME-Version: 1.0 To: "paul24@example.com" <paul24@example.com> Subject: JSVgCanvas using DOM Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: 83.161.120.155 1.6.2 0/1000/N Hallo all! I'm trying to view a SVG Document which I read from a socket connection in a JSVGCanvas. The DOM I generate is redable and I can print it out in a file and view it in an SVG viewer (also in Batik). But this code: private JSVGCanvas viewport;ling ... viewport.setSVGDocument(svgDoc); with the DOM-Tree produce the following exeception! Exception occurred during event dispatching: java.lang.ClassCastException: paul24@example.com(Unknown Source) at org.apache.batik.swing.svg.JSVGComponent.computeRenderingTransform(Unknown Source) at org.apache.batik.swing.svg.JSVGComponent.updateRenderingTransform(Unknown Source) at org.apache.batik.swing.gvt.JGVTComponent$1.componentResized(Unknown Source) at java.awt.AWTEventMulticaster.componentResized(AWTEventMulticaster.java:100) ... Could any body help me. thanks, Morad. -- Dipl. Math. Morad Ahmad paul24@example.com Universitaet Gh. Kassel www.db.informatik.uni-kassel.de/~morad Heinrich-Plett-Str. 40 Tel.: 610-863-0746 D-34109 Kassel, Germany Fax: 610-863-0746 --------------------------------------------------------------------- To unsubscribe, e-mail: paul24@example.com For additional commands, e-mail: paul24@example.com From batikpaul24@example.com Mon Jul 01 14:55:27 2002 Return-Path: <batikpaul24@example.com> Delivered-To: paul24@example.com Received: (qmail 51112 invoked by uid 500); 1 Jul 2002 14:55:25 -0000 Mailing-List: contact paul24@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:paul24@example.com> List-Help: <mailto:paul24@example.com> List-Unsubscribe: <mailto:paul24@example.com> List-Subscribe: <mailto:paul24@example.com> Reply-To: paul24@example.com Delivered-To: mailing list paul24@example.com Received: (qmail 51101 invoked from network); 1 Jul 2002 14:55:24 -0000 Sender: paul24@example.com Message-ID: <paul24@example.com> Date: Mon, 01 Jul 2002 16:57:21 +0200 From: Ahmad Morad <paul24@example.com> Reply-To: paul24@example.com Organization: GhK X-Mailer: Mozilla 4.79 [de] (X11; U; Linux 2.4.18-4GB i686) X-Accept-Language: en MIME-Version: 1.0 To: "paul24@example.com" <paul24@example.com> Subject: JSVGCanvas Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: 83.161.120.155 1.6.2 0/1000/N What could be the problem if the JSVGCanvas does'nt throw any excception while rendering an SVG. But doesn't really draw the Document. It seema that the canvas reads the currect size and resizes the drw area. But no svg is drawed. Again the same document could be prblemless drawed using the batik-application. Thanks, Morad Ahmad. -- Dipl. Math. Morad Ahmad paul24@example.com Universitaet Gh. Kassel www.db.informatik.uni-kassel.de/~morad Heinrich-Plett-Str. 40 Tel.: 610-863-0746 D-34109 Kassel, Germany Fax: 610-863-0746 --------------------------------------------------------------------- To unsubscribe, e-mail: paul24@example.com For additional commands, e-mail: paul24@example.com From batikpaul24@example.com Tue Jul 02 07:26:48 2002 Return-Path: <batikpaul24@example.com> Delivered-To: paul24@example.com Received: (qmail 48409 invoked by uid 500); 2 Jul 2002 07:24:46 -0000 Mailing-List: contact paul24@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:paul24@example.com> List-Help: <mailto:paul24@example.com> List-Unsubscribe: <mailto:paul24@example.com> List-Subscribe: <mailto:paul24@example.com> Reply-To: paul24@example.com Delivered-To: mailing list paul24@example.com Received: (qmail 48398 invoked from network); 2 Jul 2002 07:24:45 -0000 Subject: pdf transcoding development From: Keiron Liddle <paul24@example.com> To: paul24@example.com Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.7 Date: 02 Jul 2002 09:24:47 +0200 Message-Id: <1025594687.4417.43.camel@fztig938> Mime-Version: 1.0 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi All, Just an update about the svg->pdf transcoder that is developed with FOP. Currently this is in cvs only. - added transparency for shapes and images. It handles most of the samples in batik quite well (although the images sometimes make the document large), my favourite is mapSpain. (need acrobat 5.0 to see this) - releases memory used by adding images immediately. Before it was getting out of memory errors with the textRotateShadows.svg. - started implementation of patterns and gradients Patterns generally work. The gradient coordinates are currently wrong, I'm not sure how to get this right. - text bridge If the text can be inserted directly into pdf then it does not draw the text as shapes. It will be a while before it is ready for a release but it is improved quite a bit. Regards, Keiron Liddle --------------------------------------------------------------------- To unsubscribe, e-mail: paul24@example.com For additional commands, e-mail: paul24@example.com From batikpaul24@example.com Tue Jul 02 11:36:29 2002 Return-Path: <batikpaul24@example.com> Delivered-To: paul24@example.com Received: (qmail 11916 invoked by uid 500); 2 Jul 2002 11:36:28 -0000 Mailing-List: contact paul24@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:paul24@example.com> List-Help: <mailto:paul24@example.com> List-Unsubscribe: <mailto:paul24@example.com> List-Subscribe: <mailto:paul24@example.com> Reply-To: paul24@example.com Delivered-To: mailing list paul24@example.com Received: (qmail 11905 invoked from network); 2 Jul 2002 11:36:28 -0000 X-Authentication-Warning: frog.rl.kodak.com: deweese set sender to paul24@example.com using -f From: Thomas E Deweese <paul24@example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <paul24@example.com> Date: Tue, 2 Jul 2002 07:36:26 -0400 To: paul24@example.com Subject: pdf transcoding development In-Reply-To: <1025594687.4417.43.camel@fztig938> References: <1025594687.4417.43.camel@fztig938> X-Mailer: VM 7.03 under Emacs 20.5.1 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi Keiron, >>>>> "KL" == Keiron Liddle <paul24@example.com> writes: KL> Just an update about the svg->pdf transcoder that is developed KL> with FOP. Currently this is in cvs only. KL> - added transparency for shapes and images. This is _great_ news! KL> - started implementation of patterns and gradients Patterns KL> generally work. The gradient coordinates are currently wrong, I'm KL> not sure how to get this right. Anything we can do to help? Pointers to the suspected problem areas? KL> - text bridge If the text can be inserted directly into pdf then KL> it does not draw the text as shapes. Very nice! KL> It will be a while before it is ready for a release but it is KL> improved quite a bit. I would say, the support for transparenct is really wonderful. Keep up the good work. --------------------------------------------------------------------- To unsubscribe, e-mail: paul24@example.com For additional commands, e-mail: paul24@example.com From batikpaul24@example.com Tue Jul 02 14:36:04 2002 Return-Path: <batikpaul24@example.com> Delivered-To: paul24@example.com Received: (qmail 22249 invoked by uid 500); 2 Jul 2002 14:36:02 -0000 Mailing-List: contact paul24@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:paul24@example.com> List-Help: <mailto:paul24@example.com> List-Unsubscribe: <mailto:paul24@example.com> List-Subscribe: <mailto:paul24@example.com> Reply-To: paul24@example.com Delivered-To: mailing list paul24@example.com Delivered-To: moderator for paul24@example.com Received: (qmail 45925 invoked from network); 2 Jul 2002 13:33:54 -0000 X-Originating-IP: [83.161.120.155] From: "Maybin Muyeba" <paul24@example.com> To: paul24@example.com Bcc: Subject: Forte Running SVG program - not terminating Java program threads Date: Tue, 02 Jul 2002 13:33:55 +0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: <paul24@example.com> X-OriginalArrivalTime: 02 Jul 2002 13:33:55.0692 (UTC) FILETIME=[1CEA3AC0:01C221CD] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N hi, I have written a program in Java that draws Bar GRaphs and Pie graphs using SVG DOM. But when I run the program in Forte IDE, the program thread does not terminate after writing to file the output SVG file. So if I run five times, I have five (java.exe) processes in Task Manager of Windows 2000. What is the fix for this? I know when I use System.exit(0) in my code, it will terminate but my class files are being used in other peoples classes. And I probably do not ant to write my classes as extending the Thread or Runnable class. Help MM> Maybin MM> Software Engineer MM> Manchester, UK _________________________________________________________________ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx --------------------------------------------------------------------- To unsubscribe, e-mail: paul24@example.com For additional commands, e-mail: paul24@example.com From batikpaul24@example.com Wed Jul 03 11:25:35 2002 Return-Path: <batikpaul24@example.com> Delivered-To: paul24@example.com Received: (qmail 40286 invoked by uid 500); 3 Jul 2002 11:25:35 -0000 Mailing-List: contact paul24@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:paul24@example.com> List-Help: <mailto:paul24@example.com> List-Unsubscribe: <mailto:paul24@example.com> List-Subscribe: <mailto:paul24@example.com> Reply-To: paul24@example.com Delivered-To: mailing list paul24@example.com Received: (qmail 40274 invoked from network); 3 Jul 2002 11:25:35 -0000 X-Authentication-Warning: frog.rl.kodak.com: deweese set sender to paul24@example.com using -f From: Thomas E Deweese <paul24@example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <paul24@example.com> Date: Wed, 3 Jul 2002 07:25:33 -0400 To: paul24@example.com Subject: Forte Running SVG program - not terminating Java program threads In-Reply-To: <paul24@example.com> References: <paul24@example.com> X-Mailer: VM 7.03 under Emacs 20.5.1 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N >>>>> "MM" == Maybin Muyeba <paul24@example.com> writes: MM> hi, I have written a program in Java that draws Bar GRaphs and Pie MM> graphs using SVG DOM. But when I run the program in Forte IDE, the MM> program thread does not terminate after writing to file the output MM> SVG file. MM> So if I run five times, I have five (java.exe) processes in Task MM> Manager of Windows 2000. MM> What is the fix for this? I know when I use System.exit(0) in my MM> code, it will terminate but my class files are being used in other MM> peoples classes. And I probably do not ant to write my classes as MM> extending the Thread or Runnable class. I suspect that the issue is the AWT event threads. They should only came into existence when Windows are created. If you are creating windows then I think you have to System.exit() for the program to terminate. All GUI apps have to deal with this. So if your classes are used by another application then you should rely on that other application calling System.exit when the time comes. Otherwise I suggest you print the execution stack for all the active threads and see where they are comming from. --------------------------------------------------------------------- To unsubscribe, e-mail: paul24@example.com For additional commands, e-mail: paul24@example.com From batikpaul24@example.com Thu Jul 04 07:19:01 2002 Return-Path: <batikpaul24@example.com> Delivered-To: paul24@example.com Received: (qmail 69030 invoked by uid 500); 4 Jul 2002 07:19:00 -0000 Mailing-List: contact paul24@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:paul24@example.com> List-Help: <mailto:paul24@example.com> List-Unsubscribe: <mailto:paul24@example.com> List-Subscribe: <mailto:paul24@example.com> Reply-To: paul24@example.com Delivered-To: mailing list paul24@example.com Received: (qmail 69019 invoked by uid 500); 4 Jul 2002 07:18:59 -0000 Delivered-To: paul24@example.com Date: 4 Jul 2002 07:19:02 -0000 Message-ID: <paul24@example.com> From: paul24@example.com To: paul24@example.com Subject: cvs commit: xml-batik/samples/tests/spec/scripting svg2.svg X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N tkormann 2002/07/04 00:19:02 Modified: sources/org/apache/batik/bridge SVGGElementBridge.java SVGSVGElementBridge.java test-resources/org/apache/batik/test samplesRendering.xml Added: samples/tests/spec/scripting svg2.svg Log: - Outermost svg element can now be modified dynamically - Add test that need to be checked manually Revision Changes Path 1.20 +2 -2 xml-batik/sources/org/apache/batik/bridge/SVGGElementBridge.java Index: SVGGElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGGElementBridge.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- SVGGElementBridge.java 18 Jun 2002 12:50:06 -0000 1.19 +++ SVGGElementBridge.java 4 Jul 2002 07:19:01 -0000 1.20 @@ -106,7 +106,7 @@ * Invoked when an MutationEvent of type 'DOMNodeInserted' is fired. */ public void handleElementAdded(CompositeGraphicsNode gn, - Element parent, + Node parent, Element childElt) { // build the graphics node GVTBuilder builder = ctx.getGVTBuilder(); 1.30 +2 -2 xml-batik/sources/org/apache/batik/bridge/SVGSVGElementBridge.java Index: SVGSVGElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGSVGElementBridge.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- SVGSVGElementBridge.java 18 Jun 2002 12:50:06 -0000 1.29 +++ SVGSVGElementBridge.java 4 Jul 2002 07:19:02 -0000 1.30 @@ -217,7 +217,7 @@ gn.remove(node); disposeTree(e); - handleElementAdded(gn, (Element)e.getParentNode(), e); + handleElementAdded(gn, e.getParentNode(), e); } } 1.79 +3 -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.78 retrieving revision 1.79 diff -u -r1.78 -r1.79 --- samplesRendering.xml 21 Jun 2002 14:20:40 -0000 1.78 +++ samplesRendering.xml 4 Jul 2002 07:19:02 -0000 1.79 @@ -322,6 +322,8 @@ <test id="samples/tests/spec/scripting/markerUpdate.svg" /> <test id="samples/tests/spec/scripting/filterPatternUpdate.svg" /> <test id="samples/tests/spec/scripting/use.svg" /> + <test id="samples/tests/spec/scripting/svg.svg" /> + <test id="samples/tests/spec/scripting/svg2.svg" /> </testGroup> </testSuite> 1.1 xml-batik/samples/tests/spec/scripting/svg2.svg Index: svg2.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. --> <!-- ====================================================================== --> <!-- ====================================================================== --> <!-- append child test --> <!-- --> <!-- @author paul24@example.com --> <!-- @version $Id: svg2.svg,v 1.1 2002/07/04 07:19:02 tkormann Exp $ --> <!-- ====================================================================== --> <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" onclick="changeSize(evt)" id="body" width="450" height="500" viewBox="0 0 450 500"> <title>svg viewport modification 'onclick'</title> <text x="50%" y="45" class="title">svg viewport modification 'onclick'</text> <script type="text/ecmascript"> function changeSize(evt) { var e = evt.currentTarget; e.setAttribute("viewBox", "0 0 225 250"); } </script> <g id="test-content"> <rect x="25%" y="25%" width="50%" height="50%" fill="crimson" /> </g> </svg> --------------------------------------------------------------------- To unsubscribe, e-mail: paul24@example.com For additional commands, e-mail: paul24@example.com From batikpaul24@example.com Fri Jul 05 15:16:28 2002 Return-Path: <batikpaul24@example.com> Delivered-To: paul24@example.com Received: (qmail 8440 invoked by uid 500); 5 Jul 2002 15:16:28 -0000 Mailing-List: contact paul24@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:paul24@example.com> List-Help: <mailto:paul24@example.com> List-Unsubscribe: <mailto:paul24@example.com> List-Subscribe: <mailto:paul24@example.com> Reply-To: paul24@example.com Delivered-To: mailing list paul24@example.com Received: (qmail 8429 invoked by uid 500); 5 Jul 2002 15:16:28 -0000 Delivered-To: paul24@example.com Date: 5 Jul 2002 15:16:27 -0000 Message-ID: <paul24@example.com> From: paul24@example.com To: paul24@example.com Subject: cvs commit: xml-batik/xdocs svggen.xml X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N vhardy 2002/07/05 08:16:27 Modified: xdocs svggen.xml Log: Added example showing how to display the generated SVG content in a JSVGCanvas Revision Changes Path 1.13 +51 -1 xml-batik/xdocs/svggen.xml Index: svggen.xml =================================================================== RCS file: /home/cvs/xml-batik/xdocs/svggen.xml,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- svggen.xml 17 Jun 2002 16:28:00 -0000 1.12 +++ svggen.xml 5 Jul 2002 15:16:27 -0000 1.13 @@ -39,6 +39,7 @@ <li><link href="#whatIsIt">What is <code>SVGGraphics2D</code>?</link></li> <li><link href="#howToUse">How to use <code>SVGGraphics2D</code>?</link></li> <li><link href="#custom">How to customize SVG Generation process?</link></li> + <li><link href="#view">How to view the generated SVG document?</link></li> </ul> </s1> @@ -415,5 +416,54 @@ SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);</source> </s2> </s1> + + <anchor id="view"/> + <s1 title="How to view the generated SVG document"> + + <p>The following code example illustrates how to view the SVG content generated + by an <code>SVGGraphics2D</code> object.</p> + +<source> +import org.apache.batik.swing.*; +import org.apache.batik.svggen.*; +import org.apache.batik.dom.svg.SVGDOMImplementation; +import org.w3c.dom.*; +import org.w3c.dom.svg.*; +import javax.swing.*; +import java.awt.*; +import java.awt.geom.*; + +DOMImplementation impl = SVGDOMImplementation.getDOMImplementation(); +String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; +SVGDocument doc = (SVGDocument)impl.createDocument(svgNS, "svg", null); + +SVGGraphics2D g = new SVGGraphics2D(doc); + +// Draw into g. For example: +// +Shape circle = new Ellipse2D.Double(0,0,50,50); +g.setPaint(Color.red); +g.fill(circle); +g.translate(60,0); +g.setPaint(Color.green); +g.fill(circle); +g.translate(60,0); +g.setPaint(Color.blue); +g.fill(circle); +g.setSVGCanvasSize(new Dimension(180,50)); + +// The following populates the document root with the +// generated SVG content. +Element root = doc.getDocumentElement(); +g.getRoot(root); + +// Now, display the document +JSVGCanvas canvas = new JSVGCanvas(); +JFrame f = new JFrame(); +f.getContentPane().add(canvas); +canvas.setSVGDocument(doc); +f.pack(); +f.setVisible(true);</source> + </s1> </body> </document> --------------------------------------------------------------------- To unsubscribe, e-mail: paul24@example.com For additional commands, e-mail: paul24@example.com From batikpaul24@example.com Mon Jul 08 11:54:04 2002 Return-Path: <batikpaul24@example.com> Delivered-To: paul24@example.com Received: (qmail 41239 invoked by uid 500); 8 Jul 2002 11:54:03 -0000 Mailing-List: contact paul24@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:paul24@example.com> List-Help: <mailto:paul24@example.com> List-Unsubscribe: <mailto:paul24@example.com> List-Subscribe: <mailto:paul24@example.com> Reply-To: paul24@example.com Delivered-To: mailing list paul24@example.com Received: (qmail 41228 invoked by uid 500); 8 Jul 2002 11:54:03 -0000 Delivered-To: paul24@example.com Date: 8 Jul 2002 11:54:03 -0000 Message-ID: <paul24@example.com> From: paul24@example.com To: paul24@example.com Subject: cvs commit: xml-batik/test-resources/org/apache/batik/svggen regsvggen.xml X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N vhardy 2002/07/08 04:54:02 Modified: sources/org/apache/batik/script/rhino RhinoClassLoader.java test-resources/org/apache/batik/svggen regsvggen.xml Added: test-sources/org/apache/batik/svggen ShowGraphics2DOutput.java Log: Fixed problem when handling documents with null URL. Problem appeared in RhinoClassLoader Revision Changes Path 1.4 +6 -2 xml-batik/sources/org/apache/batik/script/rhino/RhinoClassLoader.java Index: RhinoClassLoader.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/script/rhino/RhinoClassLoader.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- RhinoClassLoader.java 13 Jun 2002 11:19:38 -0000 1.3 +++ RhinoClassLoader.java 8 Jul 2002 11:54:02 -0000 1.4 @@ -98,7 +98,11 @@ * can be read. */ protected PermissionCollection getPermissions(CodeSource codesource) { - PermissionCollection perms = super.getPermissions(codesource); + PermissionCollection perms = null; + + if (codesource != null) { + perms = super.getPermissions(codesource); + } if (documentURL != null && perms != null) { Permission p = null; 1.1 xml-batik/test-sources/org/apache/batik/svggen/ShowGraphics2DOutput.java Index: ShowGraphics2DOutput.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 org.apache.batik.swing.*; import org.apache.batik.svggen.*; import org.apache.batik.dom.svg.SVGDOMImplementation; import org.w3c.dom.*; import org.w3c.dom.svg.*; import org.apache.batik.dom.svg.*; import javax.swing.*; import java.awt.*; import java.awt.geom.*; import org.apache.batik.bridge.*; import org.apache.batik.test.*; /** * Checks that the content generated from the SVGGraphics2D and to which * an event handler has been added can be processed by Batik. * * @author <a mailto="paul24@example.com">Vincent Hardy</a> * @version $Id: ShowGraphics2DOutput.java,v 1.1 2002/07/08 11:54:02 vhardy Exp $ */ public class ShowGraphics2DOutput extends AbstractTest { public TestReport runImpl() throws Exception { DOMImplementation impl = SVGDOMImplementation.getDOMImplementation(); String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; SVGDocument doc = (SVGDocument)impl.createDocument(svgNS, "svg", null); SVGGraphics2D g = new SVGGraphics2D(doc); Shape circle = new Ellipse2D.Double(0,0,50,50); g.setPaint(Color.red); g.fill(circle); g.translate(60,0); g.setPaint(Color.green); g.fill(circle); g.translate(60,0); g.setPaint(Color.blue); g.fill(circle); g.setSVGCanvasSize(new Dimension(180,50)); Element root = doc.getDocumentElement(); // The following populates the document root with the // generated SVG content. g.getRoot(root); root.setAttribute("onload", "System.out.println('hello')"); // Now that the SVG file has been loaded, build // a GVT Tree from it TestUserAgent userAgent = new TestUserAgent(); GVTBuilder builder = new GVTBuilder(); BridgeContext ctx = new BridgeContext(userAgent); ctx.setDynamic(true); builder.build(ctx, doc); BaseScriptingEnvironment scriptEnvironment = new BaseScriptingEnvironment(ctx); scriptEnvironment.loadScripts(); scriptEnvironment.dispatchSVGLoadEvent(); if (!userAgent.failed) { return reportSuccess(); } else { return reportError("Got exception while processing document"); } } class TestUserAgent extends UserAgentAdapter { boolean failed; public void displayError(Exception e) { failed = true; } } } 1.17 +3 -2 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.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- regsvggen.xml 18 Jun 2002 08:05:23 -0000 1.16 +++ regsvggen.xml 8 Jul 2002 11:54:02 -0000 1.17 @@ -37,7 +37,8 @@ <test id="ShearTest" /> <test id="Texture" /> <test id="TextSpacePreserve" /> - <test id="TransformCollapse" /> + <test id="TransformCollapse" /> + <test id="ShowSVG" class="org.apache.batik.svggen.ShowGraphics2DOutput" /> <test id="GetRootTest" class="org.apache.batik.svggen.GetRootTest" /> </testSuite> --------------------------------------------------------------------- To unsubscribe, e-mail: paul24@example.com For additional commands, e-mail: paul24@example.com From batikpaul24@example.com Mon Jul 08 11:55:19 2002 Return-Path: <batikpaul24@example.com> Delivered-To: paul24@example.com Received: (qmail 42467 invoked by uid 500); 8 Jul 2002 11:55:19 -0000 Mailing-List: contact paul24@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:paul24@example.com> List-Help: <mailto:paul24@example.com> List-Unsubscribe: <mailto:paul24@example.com> List-Subscribe: <mailto:paul24@example.com> Reply-To: paul24@example.com Delivered-To: mailing list paul24@example.com Delivered-To: moderator for paul24@example.com Received: (qmail 33460 invoked from network); 8 Jul 2002 11:37:08 -0000 X-Originating-IP: [83.161.120.155] From: "Maybin Muyeba" <paul24@example.com> To: paul24@example.com Cc: paul24@example.com Bcc: Subject: Java/SVG - Stopping Batik in Java Date: Mon, 08 Jul 2002 11:37:09 +0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: <paul24@example.com> X-OriginalArrivalTime: 08 Jul 2002 11:37:09.0449 (UTC) FILETIME=[CB58E390:01C22673] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Dear sir, I have an SVG program that creates graphs using J2EE and Batik 1.1. But when I execute the program in main() method of the graph.java program, the process still runs when I open Task Manager in Windows 2000. i.e. the program thread continues to run and is not terminated by anything even if all the method calls have been returned. Is there any command that is used to stop SVG Java threads to stop like say .close(), .stop() etc. I would appreciate your help Maybin ---------- Software enginner Granada Learning Manchester 07903495760 _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com --------------------------------------------------------------------- To unsubscribe, e-mail: paul24@example.com For additional commands, e-mail: paul24@example.com From batikpaul24@example.com Tue Jul 09 14:42:09 2002 Return-Path: <batikpaul24@example.com> Delivered-To: paul24@example.com Received: (qmail 93343 invoked by uid 500); 9 Jul 2002 14:42:08 -0000 Mailing-List: contact paul24@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:paul24@example.com> List-Help: <mailto:paul24@example.com> List-Unsubscribe: <mailto:paul24@example.com> List-Subscribe: <mailto:paul24@example.com> Reply-To: paul24@example.com Delivered-To: mailing list paul24@example.com Received: (qmail 93331 invoked from network); 9 Jul 2002 14:42:08 -0000 Subject: Re: pdf transcoding development From: Keiron Liddle <paul24@example.com> To: paul24@example.com In-Reply-To: <paul24@example.com> References: <1025594687.4417.43.camel@fztig938> <paul24@example.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.7 Date: 09 Jul 2002 16:42:07 +0200 Message-Id: <1026225727.15570.58.camel@fztig938> Mime-Version: 1.0 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N On Tue, 2002-07-02 at 13:36, Thomas E Deweese wrote: > KL> - started implementation of patterns and gradients Patterns > KL> generally work. The gradient coordinates are currently wrong, I'm > KL> not sure how to get this right. > > Anything we can do to help? Pointers to the suspected problem > areas? I have worked out what was wrong, I need to apply the gradients transform and the transform for the current pdf state because the coords need to be abolute for pdf. It seems to be working for linear and radial gradients - the asf-logo.svg works, thats the most important thing! Unfortunately it appears that pdf cannot handle all the radial gradients. It only has a single radius whereas in svg rx and ry may be different. Also the center point cannot be outside the circle centered around the focal point with the given radius. There may be ways to handle this but it is too complicated for now. Thanks, Keiron. --------------------------------------------------------------------- To unsubscribe, e-mail: paul24@example.com For additional commands, e-mail: paul24@example.com From batikpaul24@example.com Tue Jul 09 17:17:57 2002 Return-Path: <batikpaul24@example.com> Delivered-To: paul24@example.com Received: (qmail 89305 invoked by uid 500); 9 Jul 2002 17:17:56 -0000 Mailing-List: contact paul24@example.com; run by ezmlm Precedence: bulk List-Post: <mailto:paul24@example.com> List-Help: <mailto:paul24@example.com> List-Unsubscribe: <mailto:paul24@example.com> List-Subscribe: <mailto:paul24@example.com> Reply-To: paul24@example.com Delivered-To: mailing list paul24@example.com Received: (qmail 89294 invoked by uid 500); 9 Jul 2002 17:17:55 -0000 Delivered-To: paul24@example.com Date: 9 Jul 2002 17:17:54 -0000 Message-ID: <paul24@example.com> From: paul24@example.com To: paul24@example.com Subject: cvs commit: xml-batik/test-resources/org/apache/batik/test samplesRendering.xml X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N deweese 2002/07/09 10:17:54 Modified: sources/org/apache/batik/ext/awt/geom ExtendedGeneralPath.java sources/org/apache/batik/gvt MarkerShapePainter.java test-resources/org/apache/batik/test samplesRendering.xml Added: samples/tests/spec/painting markersExt.svg sources/org/apache/batik/ext/awt/geom ExtendedPathIterator.java ExtendedShape.java ShapeExtender.java Log: 1) Created an ExtendedShape class that can give an ExtendedPathIterator that may return SEG_ARCTO. So we can properly implement markers on paths that have elliptical arcs in them. 2) These new interfaces also do not collapse multiple moveTo calls into one moveTo. This allows a path consisting of many 'm' or 'M' commands to place markers on the canvas. This update fixes a long standing bug in the rendering of markersOrientA.svg 3) Updated MarkerShapePainter to take advantage of these interfaces (calculating the tangent at the end of an elliptical arc is a pain). 4) Added a new test 'paints/markersExt.svg' for move paths and elliptical arc paths (it's funny to look at in the old Batik). 5) Added new markers test and the 'filters/feGaussianDefault.svg' to samplesRendering.xml PR: 5806 Revision Changes Path 1.1 xml-batik/samples/tests/spec/painting/markersExt.svg Index: markersExt.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. --> <!-- ====================================================================== --> <!-- ====================================================================== --> <!-- This test validates arcto and multiple move to --> <!-- --> <!-- @author paul24@example.com --> <!-- @version $Id: markersExt.svg,v 1.1 2002/07/09 17:17:53 deweese Exp $ --> <!-- ====================================================================== --> <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> <svg id="body" width="450" height="500" viewBox="0 0 450 500" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" > <title>Marker Test</title> <style type="text/css"><![CDATA[ .markedPath { fill:none; stroke:black; stroke-width:4; } .label { filter:url(#textBG); } ]]></style> <g id="content"> <g transform="translate(0, 40)"> <text class="title" x="50%" y="0">Markers on paths with just moves</text> <text class="title" x="50%" y="1em">and elliptical arcs</text> </g> <defs> <filter id="textBG" x="-5%" y="-5%" width="110%" height="110%" color-interpolation-filters="sRGB"> <feFlood flood-color="lightGrey" result="foo"/> <feComposite in="SourceGraphic" in2="foo" /> </filter> <path id="testPathMoves" d="M 0 0 m 60 0 m 60 0" /> <path id="testPathMoves2" d="M 0 0 m 40 -15 m 40 30 m 40 -15" /> <path id="testPathArcs1" d="M 0 0 a 50 30 30 1 1 60 0 a 50 30 30 1 0 60 0" /> <path id="testPathArcs2" d="M 0 0 a 60 30 0 1 1 60 0 a 60 30 0 1 0 60 0" /> <path id="testPathArcs3" d="M 0 0 a 610-863-0746 a 610-863-0746" /> <path id="testPathArcs4" d="M 0 0 a 60 30 0 0 1 60 0 a 60 30 0 0 0 60 0" /> <path id="testPathArcs5" d="M 0 0 a 60 30 30 0 1 40 -15 a 60 30 30 0 0 40 30 a 60 30 30 0 0 40 -15" /> <g id="crossHair" style="marker:none" stroke="black"> <line y1="-5" x2="0" y2="5" /> <line x1="-5" x2="5" y2="0" /> </g> <g id="startEndCrossHairs"> <use x="0" y="20" xlink:href="#crossHair" /> <use x="30" y="0" xlink:href="#crossHair" /> </g> <g id="startMidEndCrossHairs"> <use x="0" y="20" xlink:href="#crossHair" /> <use x="20" y="0" xlink:href="#crossHair" /> <use x="50" y="10" xlink:href="#crossHair" /> </g> <g id="testPathCrossHairs"> <use xlink:href="#crossHair" /> <use x="60" xlink:href="#crossHair" /> <use x="120" xlink:href="#crossHair" /> </g> <g id="testPathCrossHairs2"> <use xlink:href="#crossHair" /> <use x="40" y="-15" xlink:href="#crossHair" /> <use x="80" y="15" xlink:href="#crossHair" /> <use x="120" xlink:href="#crossHair" /> </g> <!-- ============================= --> <!-- Simple Marker Definition --> <!-- ============================= --> <marker id="markerStart" markerWidth="20" markerHeight="20" viewBox="-1 -1 2 2" orient="auto" refX="0" refY="0" markerUnits="strokeWidth" overflow="visible"> <g opacity="0.5"> <circle r="1.8" stroke="black" fill="blue" stroke-width=".4" /> <path d="M 0 -1.8 L 0.3 -0.3 L 1.8 0 L 0.3 0.3 L 0 1.8 L -.2 0.3 L -1.8 0 L -0.3 -0.3 Z" fill="yellow" stroke="none" /> <circle r="0.2" cx="0" cy="-1.8" fill="gold"/> </g> </marker> <marker id="markerMid" markerWidth="20" markerHeight="20" viewBox="-1 -1 2 2" orient="auto" refX="0" refY="0" markerUnits="strokeWidth" overflow="visible"> <g opacity="0.5"> <circle r="1.8" stroke="black" fill="crimson" stroke-width=".4" /> <path d="M 0 -1.8 L 0.3 -0.3 L 1.8 0 L 0.3 0.3 L 0 1.8 L -.2 0.3 L -1.8 0 L -0.3 -0.3 Z" fill="yellow" stroke="none" /> <circle r="0.2" cx="0" cy="-1.8" fill="gold"/> </g> </marker> <marker id="markerEnd" markerWidth="20" markerHeight="20" viewBox="-1 -1 2 2" orient="auto" refX="0" refY="0" markerUnits="strokeWidth" overflow="visible"> <g opacity="0.5"> <circle r="1.8" stroke="black" fill="green" stroke-width=".4" /> <path d="M 0 -1.8 L 0.3 -0.3 L 1.8 0 L 0.3 0.3 L 0 1.8 L -.2 0.3 L -1.8 0 L -0.3 -0.3 Z" fill="yellow" stroke="none" /> <circle r="0.2" cx="0" cy="-1.8" fill="gold"/> </g> </marker> </defs> <g transform="translate(50, 100)"> <!-- ==================================== --> <!-- Move Tests --> <!-- ==================================== --> <g transform="translate(0, 0)" > <!-- Top reference point --> <use xlink:href="#testPathMoves" marker-start="url(#markerStart)" marker-mid="url(#markerMid)" marker-end="url(#markerEnd)" class="markedPath" style="stroke-width:1"/> <use xlink:href="#testPathCrossHairs" /> <g class="label" transform="translate(60, 35)" text-anchor="middle"> <text y="0">Simple test of multiple moves</text> </g> </g> <!-- ==================================== --> <!-- Move Tests2 --> <!-- ==================================== --> <g transform="translate(230, 0)" > <!-- Top reference point --> <use xlink:href="#testPathMoves2" marker-start="url(#markerStart)" marker-mid="url(#markerMid)" marker-end="url(#markerEnd)" class="markedPath" style="stroke-width:1"/> <use xlink:href="#testPathCrossHairs2" /> <g class="label" transform="translate(60, 50)" text-anchor="middle"> <text y="0">Another test of multiple moves</text> </g> </g> <!-- ==================================== --> <!-- Arc Test 1 --> <!-- ==================================== --> <g transform="translate(0, 110)" > <!-- Top reference point --> <use xlink:href="#testPathArcs1" marker-start="url(#markerStart)" marker-mid="url(#markerMid)" marker-end="url(#markerEnd)" class="markedPath" style="stroke-width:1"/> <use xlink:href="#testPathCrossHairs" /> <g class="label" transform="translate(60, 50)" text-anchor="middle"> <text y="0">Test of rotated arcs</text> </g> </g> <!-- ==================================== --> <!-- Arc Test 2 --> <!-- ==================================== --> <g transform="translate(230, 110)" > <!-- Top reference point --> <use xlink:href="#testPathArcs2" marker-start="url(#markerStart)" marker-mid="url(#markerMid)" marker-end="url(#markerEnd)" class="markedPath" style="stroke-width:1"/> <use xlink:href="#testPathCrossHairs" /> <g class="label" transform="translate(60, 50)" text-anchor="middle"> <text y="0">Test of arcs 2</text> </g> </g> <!-- ==================================== --> <!-- Arc Test 3 --> <!-- ==================================== --> <g transform="translate(0, 220)" > <!-- Top reference point --> <use xlink:href="#testPathArcs3" marker-start="url(#markerStart)" marker-mid="url(#markerMid)" marker-end="url(#markerEnd)" class="markedPath" style="stroke-width:1"/> <use xlink:href="#testPathCrossHairs" /> <g class="label" transform="translate(60, 50)" text-anchor="middle"> <text y="0">Test of arcs 3</text> </g> </g> <!-- ==================================== --> <!-- Arc Test 4 --> <!-- ==================================== --> <g transform="translate(230, 220)" > <!-- Top reference point --> <use xlink:href="#testPathArcs4" marker-start="url(#markerStart)" marker-mid="url(#markerMid)" marker-end="url(#markerEnd)" class="markedPath" style="stroke-width:1"/> <use xlink:href="#testPathCrossHairs" /> <g class="label" transform="translate(60, 50)" text-anchor="middle"> <text y="0">Test of arcs 4</text> </g> </g> <!-- ==================================== --> <!-- Arc Test 5 --> <!-- ==================================== --> <g transform="translate(115, 320)" > <!-- Top reference point --> <use xlink:href="#testPathArcs5" marker-start="url(#markerStart)" marker-mid="url(#markerMid)" marker-end="url(#markerEnd)" class="markedPath" style="stroke-width:1"/> <use xlink:href="#testPathCrossHairs2" /> <g class="label" transform="translate(60, 50)" text-anchor="middle"> <text y="0">Test of arcs 5</text> </g> </g> </g> </g> <!-- ============================================================= --> <!-- Batik sample mark --> <!-- ============================================================= --> <use xlink:href="../../../batikLogo.svg#Batik_Tag_Box" /> </svg> 1.3 +326 -20 xml-batik/sources/org/apache/batik/ext/awt/geom/ExtendedGeneralPath.java Index: ExtendedGeneralPath.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/geom/ExtendedGeneralPath.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ExtendedGeneralPath.java 6 Sep 2001 09:01:26 -0000 1.2 +++ ExtendedGeneralPath.java 9 Jul 2002 17:17:53 -0000 1.3 @@ -8,8 +8,13 @@ package org.apache.batik.ext.awt.geom; -import java.awt.*; -import java.awt.geom.*; +import java.awt.Shape; +import java.awt.geom.AffineTransform; +import java.awt.geom.Arc2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.PathIterator; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; /** * The <code>ExtendedGeneralPath</code> class represents a geometric @@ -24,12 +29,17 @@ * @author <a href="mailto:paul24@example.com">Thierry Kormann</a> * @version $Id$ */ -public class ExtendedGeneralPath implements Shape, Cloneable { +public class ExtendedGeneralPath implements ExtendedShape, Cloneable { /** The enclosed general path. */ protected GeneralPath path; - /** + int numVals = 0; + int numSeg = 0; + double [] values = null; + int [] types = null; + + /** * Constructs a new <code>ExtendedGeneralPath</code>. */ public ExtendedGeneralPath() { @@ -59,7 +69,8 @@ * an arbitrary <code>Shape</code> object. */ public ExtendedGeneralPath(Shape s) { - path = new GeneralPath(s); + this(); + append(s, false); } /** @@ -89,24 +100,62 @@ boolean largeArcFlag, boolean sweepFlag, double x, double y) { - // - // Elliptical arc implementation based on the SVG specification notes - // // Ensure radii are valid if (rx == 0 || ry == 0) { lineTo((float) x, (float) y); return; } + // Get the current (x, y) coordinates of the path Point2D p2d = path.getCurrentPoint(); double x0 = p2d.getX(); double y0 = p2d.getY(); - if (x0 == x && y0 == y) { - // If the endpoints (x, y) and (x0, y0) are identical, then this - // is equivalent to omitting the elliptical arc segment entirely. - return; - } + if (x0 == x && y0 == y) { + // If the endpoints (x, y) and (x0, y0) are identical, then this + // is equivalent to omitting the elliptical arc segment entirely. + return; + } + + Arc2D arc = computeArc(x0, y0, rx, ry, angle, + largeArcFlag, sweepFlag, x, y); + if (arc == null) return; + + AffineTransform t = AffineTransform.getRotateInstance + (Math.toRadians(angle), arc.getCenterX(), arc.getCenterY()); + Shape s = t.createTransformedShape(arc); + path.append(s, true); + + makeRoom(7); + types [numSeg++] = ExtendedPathIterator.SEG_ARCTO; + values[numVals++] = rx; + values[numVals++] = ry; + values[numVals++] = angle; + values[numVals++] = largeArcFlag?1:0; + values[numVals++] = sweepFlag?1:0; + values[numVals++] = x; + values[numVals++] = y; + } + + + /** + * This constructs an unrotated Arc2D from the SVG specification of an + * Elliptical arc. To get the final arc you need to apply a rotation + * transform such as: + * + * AffineTransform.getRotateInstance + * (angle, arc.getX()+arc.getWidth()/2, arc.getY()+arc.getHeight()/2); + */ + public static Arc2D computeArc(double x0, double y0, + double rx, double ry, + double angle, + boolean largeArcFlag, + boolean sweepFlag, + double x, double y) { + // + // Elliptical arc implementation based on the SVG specification notes + // + // Compute the half distance between the current and the final point double dx2 = (x0 - x) / 2.0; double dy2 = (y0 - y) / 2.0; @@ -191,9 +240,8 @@ arc.height = ry * 2.0; arc.start = -angleStart; arc.extent = -angleExtent; - AffineTransform t = AffineTransform.getRotateInstance(angle, cx, cy); - Shape s = t.createTransformedShape(arc); - append(s, true); + + return arc; } /** @@ -201,6 +249,11 @@ */ public synchronized void moveTo(float x, float y) { path.moveTo(x, y); + + makeRoom(2); + types [numSeg++] = PathIterator.SEG_MOVETO; + values[numVals++] = x; + values[numVals++] = y; } /** @@ -208,6 +261,11 @@ */ public synchronized void lineTo(float x, float y) { path.lineTo(x, y); + + makeRoom(2); + types [numSeg++] = PathIterator.SEG_LINETO; + values[numVals++] = x; + values[numVals++] = y; } /** @@ -215,6 +273,13 @@ */ public synchronized void quadTo(float x1, float y1, float x2, float y2) { path.quadTo(x1, y1, x2, y2); + + makeRoom(4); + types [numSeg++] = PathIterator.SEG_QUADTO; + values[numVals++] = x1; + values[numVals++] = y1; + values[numVals++] = x2; + values[numVals++] = y2; } /** @@ -224,6 +289,15 @@ float x2, float y2, float x3, float y3) { path.curveTo(x1, y1, x2, y2, x3, y3); + + makeRoom(6); + types [numSeg++] = PathIterator.SEG_CUBICTO; + values[numVals++] = x1; + values[numVals++] = y1; + values[numVals++] = x2; + values[numVals++] = y2; + values[numVals++] = x3; + values[numVals++] = y3; } /** @@ -231,20 +305,107 @@ */ public synchronized void closePath() { path.closePath(); + + makeRoom(0); + types [numSeg++] = PathIterator.SEG_CLOSE; } /** * Delegates to the enclosed <code>GeneralPath</code>. */ public void append(Shape s, boolean connect) { - path.append(s, connect); + append(s.getPathIterator(new AffineTransform()), connect); } /** * Delegates to the enclosed <code>GeneralPath</code>. */ public void append(PathIterator pi, boolean connect) { - path.append(pi, connect); + + while (!pi.isDone()) { + double [] vals = new double[6]; + int type = pi.currentSegment(vals); + pi.next(); + if (connect && (numVals != 0)) { + if (type == PathIterator.SEG_MOVETO) { + double x = vals[0]; + double y = vals[1]; + if ((x != values[numVals-2]) || + (y != values[numVals-1])) { + // Change MOVETO to LINETO. + type = PathIterator.SEG_LINETO; + } else { + // Redundent segment (move to current loc) drop it... + if (pi.isDone()) break; // Nothing interesting + type = pi.currentSegment(vals); + pi.next(); + } + } + connect = false; + } + + switch(type) { + case PathIterator.SEG_CLOSE: closePath(); break; + case PathIterator.SEG_MOVETO: + moveTo ((float)vals[0], (float)vals[1]); break; + case PathIterator.SEG_LINETO: + lineTo ((float)vals[0], (float)vals[1]); break; + case PathIterator.SEG_QUADTO: + quadTo ((float)vals[0], (float)vals[1], + (float)vals[2], (float)vals[3]); break; + case PathIterator.SEG_CUBICTO: + curveTo((float)vals[0], (float)vals[1], + (float)vals[2], (float)vals[3], + (float)vals[4], (float)vals[5]); break; + } + } + } + + /** + * Delegates to the enclosed <code>GeneralPath</code>. + */ + public void append(ExtendedPathIterator epi, boolean connect) { + while (!epi.isDone()) { + double [] vals = new double[7]; + int type = epi.currentSegment(vals); + epi.next(); + if (connect && (numVals != 0)) { + if (type == PathIterator.SEG_MOVETO) { + double x = vals[0]; + double y = vals[1]; + if ((x != values[numVals-2]) || + (y != values[numVals-1])) { + // Change MOVETO to LINETO. + type = PathIterator.SEG_LINETO; + } else { + // Redundent segment (move to current loc) drop it... + if (epi.isDone()) break; // Nothing interesting + type = epi.currentSegment(vals); + epi.next(); + } + } + connect = false; + } + + switch(type) { + case PathIterator.SEG_CLOSE: closePath(); break; + case PathIterator.SEG_MOVETO: + moveTo ((float)vals[0], (float)vals[1]); break; + case PathIterator.SEG_LINETO: + lineTo ((float)vals[0], (float)vals[1]); break; + case PathIterator.SEG_QUADTO: + quadTo ((float)vals[0], (float)vals[1], + (float)vals[2], (float)vals[3]); break; + case PathIterator.SEG_CUBICTO: + curveTo((float)vals[0], (float)vals[1], + (float)vals[2], (float)vals[3], + (float)vals[4], (float)vals[5]); break; + case ExtendedPathIterator.SEG_ARCTO: + arcTo (vals[0], vals[1], vals[2], + (vals[3]!=0), (vals[4]!=0), + vals[5], vals[6]); break; + } + } } /** @@ -273,13 +434,18 @@ */ public synchronized void reset() { path.reset(); + + numSeg = 0; + numVals = 0; } /** * Delegates to the enclosed <code>GeneralPath</code>. */ public void transform(AffineTransform at) { - path.transform(at); + if (at.getType() != AffineTransform.TYPE_IDENTITY) + throw new IllegalArgumentException + ("ExtendedGeneralPaths can not be transformed"); } /** @@ -362,12 +528,152 @@ /** * Delegates to the enclosed <code>GeneralPath</code>. */ + public ExtendedPathIterator getExtendedPathIterator() { + return new EPI(); + } + + class EPI implements ExtendedPathIterator { + int segNum = 0; + int valsIdx = 0; + + public int currentSegment(double[] coords) { + int ret = types[segNum]; + switch (ret) { + case SEG_CLOSE: break; + case SEG_MOVETO: + case SEG_LINETO: + coords[0] = values[valsIdx]; + coords[1] = values[valsIdx+1]; + break; + case SEG_QUADTO: + coords[0] = values[valsIdx]; + coords[1] = values[valsIdx+1]; + coords[2] = values[valsIdx+2]; + coords[3] = values[valsIdx+3]; + break; + case SEG_CUBICTO: + coords[0] = values[valsIdx]; + coords[1] = values[valsIdx+1]; + coords[2] = values[valsIdx+2]; + coords[3] = values[valsIdx+3]; + coords[4] = values[valsIdx+4]; + coords[5] = values[valsIdx+5]; + break; + case SEG_ARCTO: + coords[0] = values[valsIdx]; + coords[1] = values[valsIdx+1]; + coords[2] = values[valsIdx+2]; + coords[3] = values[valsIdx+3]; + coords[4] = values[valsIdx+4]; + coords[5] = values[valsIdx+5]; + coords[6] = values[valsIdx+6]; + break; + } + // System.out.println("Seg: [" + segNum + "] type: " + ret + + // " vals: [" + coords[0] + ", " + coords[1] + + // "]"); + return ret; + } + + public int currentSegment(float[] coords) { + int ret = types[segNum]; + switch (ret) { + case SEG_CLOSE: break; + case SEG_MOVETO: + case SEG_LINETO: + coords[0] = (float)values[valsIdx]; + coords[1] = (float)values[valsIdx+1]; + break; + case SEG_QUADTO: + coords[0] = (float)values[valsIdx]; + coords[1] = (float)values[valsIdx+1]; + coords[2] = (float)values[valsIdx+2]; + coords[3] = (float)values[valsIdx+3]; + break; + case SEG_CUBICTO: + coords[0] = (float)values[valsIdx]; + coords[1] = (float)values[valsIdx+1]; + coords[2] = (float)values[valsIdx+2]; + coords[3] = (float)values[valsIdx+3]; + coords[4] = (float)values[valsIdx+4]; + coords[5] = (float)values[valsIdx+5]; + break; + case SEG_ARCTO: + coords[0] = (float)values[valsIdx]; + coords[1] = (float)values[valsIdx+1]; + coords[2] = (float)values[valsIdx+2]; + coords[3] = (float)values[valsIdx+3]; + coords[4] = (float)values[valsIdx+4]; + coords[5] = (float)values[valsIdx+5]; + coords[6] = (float)values[valsIdx+6]; + break; + } + return ret; + } + + public int getWindingRule() { + return path.getWindingRule(); + } + public boolean isDone() { + return segNum == numSeg; + } + public void next() { + int type = types[segNum++]; + switch (type) { + case SEG_CLOSE: break; + case SEG_MOVETO: + case SEG_LINETO: valsIdx+=2; break; + case SEG_QUADTO: valsIdx+=4; break; + case SEG_CUBICTO:valsIdx+=6; break; + case SEG_ARCTO: valsIdx+=7; break; + } + } + }; + + /** + * Delegates to the enclosed <code>GeneralPath</code>. + */ public Object clone() { try { ExtendedGeneralPath result = (ExtendedGeneralPath) super.clone(); result.path = (GeneralPath) path.clone(); + + result.values = new double[values.length]; + System.arraycopy(result.values, 0, values, 0, values.length); + result.numVals = numVals; + + result.types = new int[types.length]; + System.arraycopy(result.types, 0, types, 0, types.length); + result.numSeg = numSeg; + return result; } catch (CloneNotSupportedException ex) {} return null; + } + + private void makeRoom(int numValues) { + if (values == null) { + values = new double[2*numValues]; + types = new int[2]; + numVals = 0; + numSeg = 0; + return; + } + + if ((numVals + numValues) > values.length) { + int nlen = values.length*2; + if (nlen < (numVals + numValues)) + nlen = numVals + numValues; + + double [] nvals = new double[nlen]; + System.arraycopy(values, 0, nvals, 0, numVals); + values = nvals; + } + + if (numSeg == types.length) { + int [] ntypes = new int[types.length*2]; + System.arraycopy(types, 0, ntypes, 0, types.length); + types = ntypes; + } } } 1.1 xml-batik/sources/org/apache/batik/ext/awt/geom/ExtendedPathIterator.java Index: ExtendedPathIterator.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.ext.awt.geom; import java.awt.geom.PathIterator; /** * The <code>ExtendedPathIterator</code> class represents a geometric * path constructed from straight lines, quadratic and cubic (Bézier) * curves and elliptical arcs. This interface is identical to that of * PathIterator except it can return SEG_ARCTO from currentSegment, * also the array of values passed to currentSegment must be of length * 7 or an error will be thrown. * * This does not extend PathIterator as it would break the interface * contract for that class. * * @author <a href="mailto:paul24@example.com">Thomas DeWeese</a> * @version $Id: ExtendedPathIterator.java,v 1.1 2002/07/09 17:17:53 deweese Exp $ */ public interface ExtendedPathIterator { /** * The segment type constant that specifies that the preceding * subpath should be closed by appending a line segment back to * the point corresponding to the most recent SEG_MOVETO. */ public static final int SEG_CLOSE = PathIterator.SEG_CLOSE; /** * The segment type constant for a point that specifies the end * point of a line to be drawn from the most recently specified * point. */ public static final int SEG_MOVETO = PathIterator.SEG_MOVETO; /** * The segment type constant for a point that specifies the end * point of a line to be drawn from the most recently specified * point. */ public static final int SEG_LINETO = PathIterator.SEG_LINETO; /** * The segment type constant for the pair of points that specify a * quadratic parametric curve to be drawn from the most recently * specified point. The curve is interpolated by solving the * parametric control equation in the range (t=[0..1]) using the * most recently specified (current) point (CP), the first control * point (P1), and the final interpolated control point (P2). */ public static final int SEG_QUADTO = PathIterator.SEG_QUADTO; /** * The segment type constant for the set of 3 points that specify * a cubic parametric curve to be drawn from the most recently * specified point. The curve is interpolated by solving the * parametric control equation in the range (t=[0..1]) using the * most recently specified (current) point (CP), the first control * point (P1), the second control point (P2), and the final * interpolated control point (P3). */ public static final int SEG_CUBICTO = PathIterator.SEG_CUBICTO; /** The segment type constant for an elliptical arc. This consists of * Seven values [rx, ry, angle, largeArcFlag, sweepFlag, x, y]. * rx, ry are the radious of the ellipse. * angle is angle of the x axis of the ellipse. * largeArcFlag is zero if the smaller of the two arcs are to be used. * sweepFlag is zero if the 'left' branch is taken one otherwise. * x and y are the destination for the ellipse. */ public static final int SEG_ARCTO = 4321; /** The winding rule constant for specifying an even-odd rule for * determining the interior of a path. The even-odd rule specifies * that a point lies inside the path if a ray drawn in any * direction from that point to infinity is crossed by path * segments an odd number of times. */ public static final int WIND_EVEN_ODD = PathIterator.WIND_EVEN_ODD; /** * The winding rule constant for specifying a non-zero rule for * determining the interior of a path. The non-zero rule specifies * that a point lies inside the path if a ray drawn in any * direction from that point to infinity is crossed by path * segments a different number of times in the counter-clockwise * direction than the clockwise direction. */ public static final int WIND_NON_ZERO = PathIterator.WIND_NON_ZERO; public int currentSegment(double[] coords); public int currentSegment(float[] coords); public int getWindingRule(); public boolean isDone(); public void next(); } 1.1 xml-batik/sources/org/apache/batik/ext/awt/geom/ExtendedShape.java Index: ExtendedShape.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.ext.awt.geom; import java.awt.Shape; /** * The <code>ExtendedShape</code> class represents a geometric * path constructed from straight lines, quadratic and cubic (Bézier) * curves and elliptical arcs. * @author <a href="mailto:paul24@example.com">Thomas DeWeese</a> * @version $Id: ExtendedShape.java,v 1.1 2002/07/09 17:17:54 deweese Exp $ */ public interface ExtendedShape extends Shape { /** * Get an extended Path iterator that may return SEG_ARCTO commands */ public ExtendedPathIterator getExtendedPathIterator(); } 1.1 xml-batik/sources/org/apache/batik/ext/awt/geom/ShapeExtender.java Index: ShapeExtender.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.ext.awt.geom; import java.awt.Shape; import java.awt.Rectangle; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.geom.AffineTransform; import java.awt.geom.PathIterator; /** * This class wraps a normal path into an extended path. * @author <a href="mailto:paul24@example.com">Thomas DeWeese</a> * @version $Id: ShapeExtender.java,v 1.1 2002/07/09 17:17:54 deweese Exp $ */ public class ShapeExtender implements ExtendedShape { Shape shape; public ShapeExtender(Shape shape) { this.shape = shape; } public boolean contains(double x, double y) { return shape.contains(x, y); } public boolean contains(double x, double y, double w, double h) { return shape.contains(x, y, w, h); } public boolean contains(Point2D p) { return shape.contains(p); } public boolean contains(Rectangle2D r) { return shape.contains(r); } public Rectangle getBounds() { return shape.getBounds(); } public Rectangle2D getBounds2D() { return shape.getBounds2D(); } public PathIterator getPathIterator(AffineTransform at) { return shape.getPathIterator(at); } public PathIterator getPathIterator(AffineTransform at, double flatness) { return shape.getPathIterator(at, flatness); } public ExtendedPathIterator getExtendedPathIterator() { return new EPIWrap(shape.getPathIterator(null)); } public boolean intersects(double x, double y, double w, double h) { return shape.intersects(x, y, w, h); } public boolean intersects(Rectangle2D r) { return shape.intersects(r); } public static class EPIWrap implements ExtendedPathIterator { PathIterator pi = null; public EPIWrap(PathIterator pi) { this.pi = pi; } public int currentSegment(double[] coords) { return pi.currentSegment(coords); } public int currentSegment(float[] coords) { return pi.currentSegment(coords); } public int getWindingRule() { return pi.getWindingRule(); } public boolean isDone() { return pi.isDone(); } public void next() { pi.next(); } }; } 1.8 +177 -84 xml-batik/sources/org/apache/batik/gvt/MarkerShapePainter.java Index: MarkerShapePainter.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/MarkerShapePainter.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- MarkerShapePainter.java 6 Feb 2002 17:52:37 -0000 1.7 +++ MarkerShapePainter.java 9 Jul 2002 17:17:54 -0000 1.8 @@ -12,6 +12,7 @@ import java.awt.Graphics2D; import java.awt.geom.AffineTransform; +import java.awt.geom.Arc2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.geom.PathIterator; @@ -19,6 +20,11 @@ import java.util.List; import java.util.Vector; +import org.apache.batik.ext.awt.geom.ExtendedGeneralPath; +import org.apache.batik.ext.awt.geom.ExtendedPathIterator; +import org.apache.batik.ext.awt.geom.ExtendedShape; +import org.apache.batik.ext.awt.geom.ShapeExtender; + /** * A shape painter that can be used to paint markers on a shape. * @@ -30,7 +36,7 @@ /** * The Shape to be painted. */ - protected Shape shape; + protected ExtendedShape extShape; /** * Start Marker @@ -88,7 +94,11 @@ if (shape == null) { throw new IllegalArgumentException(); } - this.shape = shape; + if (shape instanceof ExtendedShape) { + this.extShape = (ExtendedShape)shape; + } else { + this.extShape = new ShapeExtender(shape); + } } /** @@ -138,7 +148,12 @@ if (shape == null) { throw new IllegalArgumentException(); } - this.shape = shape; + if (shape instanceof ExtendedShape) { + this.extShape = (ExtendedShape)shape; + } else { + this.extShape = new ShapeExtender(shape); + } + this.startMarkerProxy = null; this.middleMarkerProxies = null; this.endMarkerProxy = null; @@ -146,12 +161,21 @@ } /** + * Gets the Shape this shape painter is associated with as an + * Extended Shape. + * + * @return shape associated with this painter */ + public ExtendedShape getExtShape(){ + return extShape; + } + + /** * Gets the Shape this shape painter is associated with. * * @return shape associated with this painter */ public Shape getShape(){ - return shape; + return extShape; } /** @@ -259,10 +283,10 @@ */ protected ProxyGraphicsNode buildStartMarkerProxy() { - PathIterator iter = getShape().getPathIterator(null); + ExtendedPathIterator iter = getExtShape().getExtendedPathIterator(); // Get initial point on the path - double coords[] = new double[6]; + double coords[] = new double[7]; int segType = 0; if (iter.isDone()) { @@ -282,7 +306,7 @@ double rotation = startMarker.getOrient(); if (Double.isNaN(rotation)) { if (!iter.isDone()) { - double next[] = new double[6]; + double next[] = new double[7]; int nextSegType = 0; nextSegType = iter.currentSegment(next); if(nextSegType == PathIterator.SEG_CLOSE){ @@ -316,7 +340,7 @@ */ protected ProxyGraphicsNode buildEndMarkerProxy() { - PathIterator iter = getShape().getPathIterator(null); + ExtendedPathIterator iter = getExtShape().getExtendedPathIterator(); int nPoints = 0; @@ -326,7 +350,7 @@ return null; } - double coords[] = new double[6]; + double coords[] = new double[7]; double moveTo[] = new double[2]; int segType = 0; segType = iter.currentSegment(coords); @@ -340,9 +364,10 @@ iter.next(); // Now, get the last two points on the path - double[] lastButOne = new double[6]; + double[] lastButOne = new double[7]; double[] last = {coords[0], coords[1], coords[2], - coords[3], coords[4], coords[5] }, tmp = null; + coords[3], coords[4], coords[5], coords[6] }; + double[] tmp = null; int lastSegType = segType; int lastButOneSegType = 0; @@ -398,17 +423,17 @@ } /** - * Builds a proxy <tt>GraphicsNode</tt> for the input <tt>Marker</tt> to be - * drawn at the middle positions + * Builds a proxy <tt>GraphicsNode</tt> for the input + * <tt>Marker</tt> to be drawn at the middle positions */ protected ProxyGraphicsNode[] buildMiddleMarkerProxies() { - PathIterator iter = getShape().getPathIterator(null); + ExtendedPathIterator iter = getExtShape().getExtendedPathIterator(); - double[] prev = new double[6]; - double[] cur = new double[6]; - double[] next = new double[6], tmp = null; - int prevSegType = 0, curSegType = 0, nextSegType = 0; + double[] prev = new double[7]; + double[] curr = new double[7]; + double[] next = new double[7], tmp = null; + int prevSegType = 0, currSegType = 0, nextSegType = 0; // Get the first three points on the path if (iter.isDone()) { @@ -430,15 +455,15 @@ return null; } - curSegType = iter.currentSegment(cur); + currSegType = iter.currentSegment(curr); - if (curSegType == PathIterator.SEG_MOVETO) { - moveTo[0] = cur[0]; - moveTo[1] = cur[1]; - } else if (curSegType == PathIterator.SEG_CLOSE) { - curSegType = PathIterator.SEG_LINETO; - cur[0] = moveTo[0]; - cur[1] = moveTo[1]; + if (currSegType == PathIterator.SEG_MOVETO) { + moveTo[0] = curr[0]; + moveTo[1] = curr[1]; + } else if (currSegType == PathIterator.SEG_CLOSE) { + currSegType = PathIterator.SEG_LINETO; + curr[0] = moveTo[0]; + curr[1] = moveTo[1]; } iter.next(); @@ -457,14 +482,14 @@ } proxies.addElement(createMiddleMarker(prev, prevSegType, - cur, curSegType, + curr, currSegType, next, nextSegType)); tmp = prev; - prev = cur; - prevSegType = curSegType; - cur = next; - curSegType = nextSegType; + prev = curr; + prevSegType = currSegType; + curr = next; + currSegType = nextSegType; next = tmp; iter.next(); @@ -479,22 +504,20 @@ /** * Creates a ProxyGraphicsNode for a middle marker. */ - private ProxyGraphicsNode createMiddleMarker(double[] prev, - int prevSegType, - double[] cur, - int curSegType, - double[] next, - int nextSegType){ + private ProxyGraphicsNode createMiddleMarker + (double[] prev, int prevSegType, + double[] curr, int currSegType, + double[] next, int nextSegType) { - // Turn the cur segment into a position - Point2D markerPosition = getSegmentTerminatingPoint(cur, curSegType); + // Turn the curr segment into a position + Point2D markerPosition = getSegmentTerminatingPoint(curr, currSegType); // If the marker's orient property is NaN, // the slope needs to be computed double rotation = middleMarker.getOrient(); if (Double.isNaN(rotation)) { rotation = computeRotation(prev, prevSegType, - cur, curSegType, + curr, currSegType, next, nextSegType); } @@ -514,21 +537,18 @@ /** * Returns the rotation according to the specified parameters. */ - private double computeRotation(double[] prev, - int prevSegType, - double[] cur, - int curSegType, - double[] next, - int nextSegType){ + private double computeRotation(double[] prev, int prevSegType, + double[] curr, int currSegType, + double[] next, int nextSegType){ // Compute in slope, i.e., the slope of the segment // going into the current point double[] inSlope = computeInSlope(prev, prevSegType, - cur, curSegType); + curr, currSegType); // Compute out slope, i.e., the slope of the segment // going out of the current point - double[] outSlope = computeOutSlope(cur, curSegType, + double[] outSlope = computeOutSlope(curr, currSegType, next, nextSegType); if (inSlope == null) { @@ -553,39 +573,76 @@ /** * Returns dx/dy for the
{'source': 'Apache Software Foundation Public Mail Archives'}