1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package net.sourceforge.jeuclid.fop;
24
25 import net.sourceforge.jeuclid.elements.AbstractJEuclidElement;
26 import net.sourceforge.jeuclid.xmlgraphics.Graphics2DImagePainterMathML;
27
28 import org.apache.fop.render.Graphics2DAdapter;
29 import org.apache.fop.render.Renderer;
30 import org.apache.fop.render.RendererContext;
31 import org.apache.fop.render.XMLHandler;
32 import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
33 import org.w3c.dom.Document;
34
35
36
37
38
39
40 public class JEuclidXMLHandler implements XMLHandler {
41
42
43 public JEuclidXMLHandler() {
44 }
45
46
47 public void handleXML(final RendererContext rendererContext,
48 final Document document, final String ns) throws Exception {
49 final Graphics2DAdapter g2dAdapter = rendererContext.getRenderer()
50 .getGraphics2DAdapter();
51
52 if (g2dAdapter != null) {
53 final Graphics2DImagePainter painter = Graphics2DImagePainterMathML
54 .createGraphics2DImagePainter(document);
55 g2dAdapter.paintImage(painter, rendererContext,
56 ((Integer) rendererContext.getProperty("xpos"))
57 .intValue(), ((Integer) rendererContext
58 .getProperty("ypos")).intValue(),
59 ((Integer) rendererContext.getProperty("width"))
60 .intValue(), ((Integer) rendererContext
61 .getProperty("height")).intValue());
62
63 }
64 }
65
66
67 public boolean supportsRenderer(final Renderer renderer) {
68 return renderer.getGraphics2DAdapter() != null;
69 }
70
71
72 public String getNamespace() {
73 return AbstractJEuclidElement.URI;
74 }
75
76 }