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.

GenericFOPBridgeContext.java 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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.image.loader.batik;
  19. import java.awt.geom.AffineTransform;
  20. import org.apache.batik.bridge.BridgeContext;
  21. import org.apache.batik.bridge.DocumentLoader;
  22. import org.apache.batik.bridge.UserAgent;
  23. import org.apache.batik.dom.svg.SVGOMDocument;
  24. import org.apache.xmlgraphics.image.loader.ImageManager;
  25. import org.apache.xmlgraphics.image.loader.ImageSessionContext;
  26. import org.apache.fop.fonts.FontInfo;
  27. import org.apache.fop.svg.AbstractFOPBridgeContext;
  28. import org.apache.fop.svg.SVGUserAgent;
  29. /**
  30. * BridgeContext which registers the custom bridges for Java2D output.
  31. */
  32. class GenericFOPBridgeContext extends AbstractFOPBridgeContext {
  33. /**
  34. * Constructs a new bridge context.
  35. * @param userAgent the user agent
  36. * @param documentLoader the Document Loader to use for referenced documents.
  37. * @param fontInfo the font list for the text painter, may be null
  38. * in which case text is painted as shapes
  39. * @param imageManager an image manager
  40. * @param imageSessionContext an image session context
  41. * @param linkTransform AffineTransform to properly place links,
  42. * may be null
  43. */
  44. public GenericFOPBridgeContext(UserAgent userAgent, DocumentLoader documentLoader,
  45. FontInfo fontInfo, ImageManager imageManager,
  46. ImageSessionContext imageSessionContext,
  47. AffineTransform linkTransform) {
  48. super(userAgent, documentLoader, fontInfo,
  49. imageManager, imageSessionContext, linkTransform);
  50. }
  51. /**
  52. * Constructs a new bridge context.
  53. * @param userAgent the user agent
  54. * @param fontInfo the font list for the text painter, may be null
  55. * in which case text is painted as shapes
  56. * @param imageManager an image manager
  57. * @param imageSessionContext an image session context
  58. */
  59. public GenericFOPBridgeContext(UserAgent userAgent, FontInfo fontInfo,
  60. ImageManager imageManager, ImageSessionContext imageSessionContext) {
  61. super(userAgent, fontInfo, imageManager, imageSessionContext);
  62. }
  63. /**
  64. * Constructs a new bridge context.
  65. * @param userAgent the user agent
  66. * @param fontInfo the font list for the text painter, may be null
  67. * in which case text is painted as shapes
  68. * @param imageManager an image manager
  69. * @param imageSessionContext an image session context
  70. * @param linkTransform AffineTransform to properly place links,
  71. * may be null
  72. */
  73. public GenericFOPBridgeContext(SVGUserAgent userAgent, FontInfo fontInfo,
  74. ImageManager imageManager, ImageSessionContext imageSessionContext,
  75. AffineTransform linkTransform) {
  76. super(userAgent, fontInfo, imageManager, imageSessionContext, linkTransform);
  77. }
  78. /** {@inheritDoc} */
  79. public void registerSVGBridges() {
  80. super.registerSVGBridges();
  81. //This makes Batik load images via FOP and the XGC image loading framework
  82. putBridge(new GenericFOPImageElementBridge());
  83. }
  84. /** {@inheritDoc} */
  85. public BridgeContext createBridgeContext(SVGOMDocument doc) {
  86. return createBridgeContext();
  87. }
  88. /** {@inheritDoc} */
  89. public BridgeContext createBridgeContext() {
  90. return new GenericFOPBridgeContext(getUserAgent(), getDocumentLoader(),
  91. fontInfo,
  92. getImageManager(),
  93. getImageSessionContext(),
  94. linkTransform);
  95. }
  96. }