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 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright 2006 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id$ */
  17. package org.apache.fop.render.pcl;
  18. import java.util.Map;
  19. import org.apache.avalon.framework.configuration.Configuration;
  20. import org.apache.fop.fo.extensions.ExtensionElementMapping;
  21. import org.apache.fop.render.RendererContext;
  22. import org.apache.fop.util.QName;
  23. /**
  24. * Wrapper on the RendererContext to access the information structure for drawing
  25. * the XML document.
  26. */
  27. public class PCLRendererContext {
  28. private RendererContext context;
  29. /**
  30. * Wrap the render context to allow easier access to its values.
  31. *
  32. * @param context the renderer context
  33. * @return the PCL-specific renderer context wrapper
  34. */
  35. public static PCLRendererContext wrapRendererContext(RendererContext context) {
  36. PCLRendererContext pcli = new PCLRendererContext(context);
  37. return pcli;
  38. }
  39. /**
  40. * Main constructor
  41. * @param context the RendererContent instance
  42. */
  43. public PCLRendererContext(RendererContext context) {
  44. this.context = context;
  45. }
  46. /** @return the currentXPosition */
  47. public int getCurrentXPosition() {
  48. return ((Integer)context.getProperty(PCLSVGHandler.XPOS)).intValue();
  49. }
  50. /** @return the currentYPosition */
  51. public int getCurrentYPosition() {
  52. return ((Integer)context.getProperty(PCLSVGHandler.YPOS)).intValue();
  53. }
  54. /** @return the width of the image */
  55. public int getWidth() {
  56. return ((Integer)context.getProperty(PCLSVGHandler.WIDTH)).intValue();
  57. }
  58. /** @return the height of the image */
  59. public int getHeight() {
  60. return ((Integer)context.getProperty(PCLSVGHandler.HEIGHT)).intValue();
  61. }
  62. /** @return the handler configuration */
  63. public Configuration getHandlerConfiguration() {
  64. return (Configuration)context.getProperty(PCLSVGHandler.HANDLER_CONFIGURATION);
  65. }
  66. /** @return the foreign attributes */
  67. public Map getForeignAttributes() {
  68. return (Map)context.getProperty(PCLSVGHandler.FOREIGN_ATTRIBUTES);
  69. }
  70. /** @return true if the SVG image should be rendered as a bitmap */
  71. public boolean paintAsBitmap() {
  72. QName qName = new QName(ExtensionElementMapping.URI, null, "conversion-mode");
  73. return getForeignAttributes() != null
  74. && "bitmap".equals(getForeignAttributes().get(qName));
  75. }
  76. }