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.

AFPImageHandlerXML.java 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. 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. /* $Id$ */
  18. package org.apache.fop.render.afp;
  19. import java.awt.Point;
  20. import java.awt.Rectangle;
  21. import java.io.IOException;
  22. import java.util.Map;
  23. import org.apache.fop.afp.AFPDataObjectInfo;
  24. import org.apache.fop.render.RendererContext;
  25. import org.apache.fop.render.RendererContextConstants;
  26. import org.apache.xmlgraphics.image.loader.Image;
  27. import org.apache.xmlgraphics.image.loader.ImageFlavor;
  28. import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
  29. import org.w3c.dom.Document;
  30. /**
  31. * PDFImageHandler implementation which handles XML-based images.
  32. */
  33. public class AFPImageHandlerXML extends AFPImageHandler {
  34. private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
  35. ImageFlavor.XML_DOM,
  36. };
  37. private static final Class[] CLASSES = new Class[] {
  38. ImageXMLDOM.class,
  39. };
  40. /** {@inheritDoc} */
  41. public AFPDataObjectInfo generateDataObjectInfo(RendererContext context, Image image,
  42. Point origin, Rectangle pos)
  43. throws IOException {
  44. AFPRenderer renderer = (AFPRenderer)context.getRenderer();
  45. ImageXMLDOM imgXML = (ImageXMLDOM)image;
  46. Document doc = imgXML.getDocument();
  47. String ns = imgXML.getRootNamespace();
  48. Map foreignAttributes = (Map)context.getProperty(
  49. RendererContextConstants.FOREIGN_ATTRIBUTES);
  50. renderer.renderDocument(doc, ns, pos, foreignAttributes);
  51. return null;
  52. }
  53. /** {@inheritDoc} */
  54. public int getPriority() {
  55. return 400;
  56. }
  57. /** {@inheritDoc} */
  58. public Class[] getSupportedImageClasses() {
  59. return CLASSES;
  60. }
  61. /** {@inheritDoc} */
  62. public ImageFlavor[] getSupportedImageFlavors() {
  63. return FLAVORS;
  64. }
  65. /** {@inheritDoc} */
  66. protected AFPDataObjectInfo createDataObjectInfo() {
  67. return null;
  68. }
  69. }