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.

PCLRendererContext.java 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.pcl;
  19. import org.apache.fop.render.ImageHandlerUtil;
  20. import org.apache.fop.render.RendererContext;
  21. /**
  22. * Wrapper on the RendererContext to access the information structure for drawing
  23. * the XML document.
  24. */
  25. public class PCLRendererContext extends RendererContext.RendererContextWrapper {
  26. /**
  27. * Wrap the render context to allow easier access to its values.
  28. *
  29. * @param context the renderer context
  30. * @return the PCL-specific renderer context wrapper
  31. */
  32. public static PCLRendererContext wrapRendererContext(RendererContext context) {
  33. PCLRendererContext pcli = new PCLRendererContext(context);
  34. return pcli;
  35. }
  36. /**
  37. * Main constructor
  38. * @param context the RendererContent instance
  39. */
  40. public PCLRendererContext(RendererContext context) {
  41. super(context);
  42. }
  43. /** @return true if the SVG image should be rendered as a bitmap */
  44. public boolean paintAsBitmap() {
  45. return ImageHandlerUtil.isConversionModeBitmap(getForeignAttributes());
  46. }
  47. /** @return true if clipping is disabled inside the PCLGraphics2D. */
  48. public boolean isClippingDisabled() {
  49. return getForeignAttributes() != null
  50. && "true".equalsIgnoreCase((String)getForeignAttributes().get(
  51. PCLConstants.DISABLE_CLIPPING));
  52. }
  53. /**
  54. * Indicates whether the background should not be erased prior to painting.
  55. * @return true if the background shouldn't be erased
  56. */
  57. public boolean isSourceTransparency() {
  58. return getForeignAttributes() != null
  59. && "true".equalsIgnoreCase((String)getForeignAttributes().get(
  60. PCLConstants.SRC_TRANSPARENCY));
  61. }
  62. /**
  63. * Indicates whether an RGB canvas should be used rather than one with grayscales.
  64. * This can be used to work around limitations of Apache Batik if you get error while
  65. * processing SVG graphics. Note, however, that RGB mode will use more memory.
  66. * @return true if an EGB canvas should be used
  67. */
  68. public boolean isColorCanvas() {
  69. Boolean prop = (Boolean)context.getProperty(PCLRendererContextConstants.PCL_COLOR_CANVAS);
  70. return Boolean.TRUE.equals(prop)
  71. || (getForeignAttributes() != null
  72. && "true".equalsIgnoreCase((String)getForeignAttributes().get(
  73. PCLConstants.COLOR_CANVAS)));
  74. }
  75. }