You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general-cvs@xml.apache.org by vh...@apache.org on 2002/07/05 17:17:59 UTC
cvs commit: xml-site/targets/batik svggen.html
vhardy 2002/07/05 08:17:58
Modified: targets/batik svggen.html
Log:
Added example showing how to view the generated content
Revision Changes Path
1.16 +50 -0 xml-site/targets/batik/svggen.html
Index: svggen.html
===================================================================
RCS file: /home/cvs/xml-site/targets/batik/svggen.html,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- svggen.html 20 Jun 2002 07:38:47 -0000 1.15
+++ svggen.html 5 Jul 2002 15:17:58 -0000 1.16
@@ -96,6 +96,7 @@
<LI><A href="#whatIsIt">What is <CODE><FONT face="courier, monospaced">SVGGraphics2D</FONT></CODE>?</A></LI>
<LI><A href="#howToUse">How to use <CODE><FONT face="courier, monospaced">SVGGraphics2D</FONT></CODE>?</A></LI>
<LI><A href="#custom">How to customize SVG Generation process?</A></LI>
+ <LI><A href="#view">How to view the generated SVG document?</A></LI>
</UL></BLOCKQUOTE>
</FONT></TD></TR></TABLE></DIV><BR>
@@ -472,6 +473,55 @@
SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);</PRE></TD><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></DIV>
</FONT></TD></TR></TABLE></DIV><BR>
</FONT></TD></TR></TABLE></DIV><BR>
+
+ <A name="view"><!--anchor--></A>
+ <DIV align="right"><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD align="right" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-top.gif"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD align="left" height="7" valign="bottom" width="9"><IMG border="0" height="7" hspace="0" src="resources/bar-top-right.gif" vspace="0" width="9"></TD></TR><TR><TD background="resources/bar-border-left.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD><TD bgcolor="#0086b2" width="100%"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="5" hspace="0" src="resources/void.gif" vspace="0" width="5"><B>How to view the generated SVG document</B></FONT></TD><TD background="resources/bar-border-right.gif" width="9"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="9"></TD></TR><TR><TD align="right" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-left.gif" vspace="0" width="9"></TD><TD background="resources/bar-border-bottom.gif"><IMG border="0" height="12" hspace="0" src="resources/void.gif" vspace="0"></TD><TD align="left" height="12" valign="top" width="9"><IMG border="0" height="12" hspace="0" src="resources/bar-bottom-right.gif" vspace="0" width="9"></TD></TR></TABLE><TABLE border="0" cellpadding="0" cellspacing="0" width="98%"><TR><TD><FONT color="#000000" face="arial,helvetica,sanserif">
+
+ <P align="left">The following code example illustrates how to view the SVG content generated
+ by an <CODE><FONT face="courier, monospaced">SVGGraphics2D</FONT></CODE> object.</P>
+
+<DIV align="center"><TABLE border="0" cellpadding="0" cellspacing="4"><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#ffffff"><PRE>
+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);</PRE></TD><TD bgcolor="#0086b2" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></DIV>
+ </FONT></TD></TR></TABLE></DIV><BR>
</TD></TR></TABLE></TD></TR></TABLE><BR><TABLE border="0" cellpadding="0" cellspacing="0" width="100%"><TR><TD bgcolor="#0086b2"><IMG height="1" src="images/dot.gif" width="1"></TD></TR><TR><TD align="center"><FONT color="#0086b2" face="arial,helvetica,sanserif" size="-1"><I>
Copyright © 2000-2002 The Apache Software Foundation.
---------------------------------------------------------------------
To unsubscribe, e-mail: general-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: general-cvs-help@xml.apache.org