You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SVGElementMapping.java 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * $Id$
  3. * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  4. * For details on use and redistribution please refer to the
  5. * LICENSE file included with these sources.
  6. */
  7. package org.apache.fop.svg;
  8. import java.util.Enumeration;
  9. import java.util.HashMap;
  10. import org.apache.fop.fo.DirectPropertyListBuilder;
  11. import org.apache.fop.fo.TreeBuilder;
  12. import org.apache.fop.fo.FOTreeBuilder;
  13. import org.apache.fop.fo.ElementMapping;
  14. import org.apache.fop.apps.Driver;
  15. import org.apache.batik.util.XMLResourceDescriptor;
  16. import org.apache.batik.dom.svg.SVGDOMImplementation;
  17. public class SVGElementMapping implements ElementMapping {
  18. private static HashMap foObjs = null;
  19. public synchronized void addToBuilder(TreeBuilder builder) {
  20. try {
  21. if (foObjs == null) {
  22. // this sets the parser that will be used
  23. // by default (SVGBrokenLinkProvider)
  24. // normally the user agent value is used
  25. XMLResourceDescriptor.setXMLParserClassName(
  26. Driver.getParserClassName());
  27. foObjs = new HashMap();
  28. foObjs.put("svg", SVGElement.maker());
  29. foObjs.put("rect", SVGObj.maker("rect"));
  30. foObjs.put("line", SVGObj.maker("line"));
  31. foObjs.put("text", SVGObj.maker("text"));
  32. foObjs.put("desc", SVGObj.maker("desc"));
  33. foObjs.put("title", SVGObj.maker("title"));
  34. foObjs.put("circle", SVGObj.maker("circle"));
  35. foObjs.put("ellipse", SVGObj.maker("ellipse"));
  36. foObjs.put("g", SVGObj.maker("g"));
  37. foObjs.put("polyline", SVGObj.maker("polyline"));
  38. foObjs.put("polygon", SVGObj.maker("polygon"));
  39. foObjs.put("defs", SVGObj.maker("defs"));
  40. foObjs.put("path", SVGObj.maker("path"));
  41. foObjs.put("use", SVGObj.maker("use"));
  42. foObjs.put("tspan", SVGObj.maker("tspan"));
  43. foObjs.put("tref", SVGObj.maker("tref"));
  44. foObjs.put("image", SVGObj.maker("image"));
  45. foObjs.put("style", SVGObj.maker("style"));
  46. foObjs.put("textPath", SVGObj.maker("textPath"));
  47. foObjs.put("clipPath", SVGObj.maker("clipPath"));
  48. foObjs.put("mask", SVGObj.maker("mask"));
  49. foObjs.put("linearGradient", SVGObj.maker("linearGradient"));
  50. foObjs.put("radialGradient", SVGObj.maker("radialGradient"));
  51. foObjs.put("stop", SVGObj.maker("stop"));
  52. foObjs.put("a", SVGObj.maker("a"));
  53. foObjs.put("switch", SVGObj.maker("switch"));
  54. foObjs.put("symbol", SVGObj.maker("symbol"));
  55. foObjs.put("pattern", SVGObj.maker("pattern"));
  56. foObjs.put("marker", SVGObj.maker("marker"));
  57. foObjs.put("animate", SVGObj.maker("animate"));
  58. foObjs.put("altGlyph", SVGObj.maker("altGlyph"));
  59. foObjs.put("font", SVGObj.maker("font"));
  60. foObjs.put("glyph", SVGObj.maker("glyph"));
  61. foObjs.put("missing-glyph", SVGObj.maker("missing-glyph"));
  62. foObjs.put("hkern", SVGObj.maker("hkern"));
  63. foObjs.put("vkern", SVGObj.maker("vkern"));
  64. foObjs.put("set", SVGObj.maker("set"));
  65. foObjs.put("animateMotion", SVGObj.maker("animateMotion"));
  66. foObjs.put("animateColor", SVGObj.maker("animateColor"));
  67. foObjs.put("animateTransform", SVGObj.maker("animateTransform"));
  68. foObjs.put("cursor", SVGObj.maker("cursor"));
  69. foObjs.put("filter", SVGObj.maker("filter"));
  70. foObjs.put("feFlood", SVGObj.maker("feFlood"));
  71. foObjs.put("feGaussianBlur", SVGObj.maker("feGaussianBlur"));
  72. foObjs.put("feOffset", SVGObj.maker("feOffset"));
  73. foObjs.put("feMerge", SVGObj.maker("feMerge"));
  74. foObjs.put("feMergeNode", SVGObj.maker("feMergeNode"));
  75. }
  76. String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
  77. builder.addMapping(svgNS, foObjs);
  78. builder.addPropertyListBuilder(svgNS,
  79. new DirectPropertyListBuilder());
  80. } catch (Throwable t) {
  81. // if the classes are not available
  82. }
  83. }
  84. }