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.

PSRenderingContext.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.ps;
  19. import org.apache.xmlgraphics.ps.PSGenerator;
  20. import org.apache.xmlgraphics.util.MimeConstants;
  21. import org.apache.fop.apps.FOUserAgent;
  22. import org.apache.fop.fonts.FontInfo;
  23. import org.apache.fop.render.AbstractRenderingContext;
  24. /**
  25. * Rendering context for PostScript production.
  26. */
  27. public class PSRenderingContext extends AbstractRenderingContext {
  28. private PSGenerator gen;
  29. private FontInfo fontInfo;
  30. private boolean createForms;
  31. /**
  32. * Main constructor.
  33. * @param userAgent the user agent
  34. * @param gen the PostScript generator
  35. * @param fontInfo the font list
  36. */
  37. public PSRenderingContext(FOUserAgent userAgent,
  38. PSGenerator gen, FontInfo fontInfo) {
  39. this(userAgent, gen, fontInfo, false);
  40. }
  41. /**
  42. * Special constructor.
  43. * @param userAgent the user agent
  44. * @param gen the PostScript generator
  45. * @param fontInfo the font list
  46. * @param createForms true if form generation mode should be enabled
  47. */
  48. public PSRenderingContext(FOUserAgent userAgent,
  49. PSGenerator gen, FontInfo fontInfo, boolean createForms) {
  50. super(userAgent);
  51. this.gen = gen;
  52. this.fontInfo = fontInfo;
  53. this.createForms = createForms;
  54. }
  55. /** {@inheritDoc} */
  56. public String getMimeType() {
  57. return MimeConstants.MIME_POSTSCRIPT;
  58. }
  59. /**
  60. * Returns the PostScript generator.
  61. * @return the PostScript generator
  62. */
  63. public PSGenerator getGenerator() {
  64. return this.gen;
  65. }
  66. /**
  67. * Returns the font list.
  68. * @return the font list
  69. */
  70. public FontInfo getFontInfo() {
  71. return this.fontInfo;
  72. }
  73. /**
  74. * Indicates whether PS forms should be created for the images instead of inline images.
  75. * Note that not all image handlers will support this!
  76. * @return true if PS forms shall be created
  77. */
  78. public boolean isCreateForms() {
  79. return this.createForms;
  80. }
  81. /**
  82. * Create a copy of this rendering context and activate form mode.
  83. * @return the form-enabled rendering context
  84. */
  85. public PSRenderingContext toFormContext() {
  86. return new PSRenderingContext(getUserAgent(), getGenerator(), getFontInfo(), true);
  87. }
  88. }