KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > svggen > Bug21259


1 /*
2
3    Copyright 2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.svggen;
19
20 import java.awt.Color JavaDoc;
21 import java.awt.Dimension JavaDoc;
22 import java.awt.Rectangle JavaDoc;
23
24 import java.io.StringWriter JavaDoc;
25 import java.io.Writer JavaDoc;
26
27 import org.w3c.dom.Document JavaDoc;
28 import org.w3c.dom.Element JavaDoc;
29
30
31 import org.apache.batik.dom.svg.SVGDOMImplementation;
32 import org.apache.batik.test.AbstractTest;
33 import org.apache.batik.test.TestReport;
34
35 /**
36  * Checks that the streamed root is not removed from its parent
37  * as shown by bug report 21259.
38  *
39  * @author <a HREF="mailto:vincent.hardy@sun.com">Vincent Hardy</a>
40  * @version $Id: Bug21259.java,v 1.4 2004/08/18 07:16:44 vhardy Exp $
41  */

42 public class Bug21259 extends AbstractTest{
43     public TestReport runImpl() throws Exception JavaDoc {
44         Document JavaDoc document =
45             SVGDOMImplementation.getDOMImplementation()
46             .createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI , "svg", null);
47         SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(document);
48         ctx.setComment("Test");
49         SVGGraphics2D graphics = new SVGGraphics2D(ctx, false);
50         graphics.setSVGCanvasSize(new Dimension JavaDoc(600, 400));
51
52         graphics.setColor(Color.red);
53         graphics.setBackground(Color.black);
54         graphics.fill(new Rectangle JavaDoc(0,0,100,100));
55
56         // Populate the Document's root with the content of the tree
57
Element JavaDoc root = document.getDocumentElement();
58         graphics.getRoot(root);
59         Writer JavaDoc writer = new StringWriter JavaDoc();
60         graphics.stream(root, writer);
61
62         assertTrue(root.getParentNode() == document);
63         return reportSuccess();
64     }
65 }
66
Popular Tags