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.

PCLRenderingMode.java 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 java.io.ObjectStreamException;
  20. /**
  21. * Enumeration class for PCL rendering modes.
  22. */
  23. public enum PCLRenderingMode {
  24. /** "Quality" rendering (mixed native and bitmap for improved quality) */
  25. QUALITY("quality", 1.0f),
  26. /** "Speed" rendering (maximum speed with native rendering, reduced visual quality) */
  27. SPEED("speed", 0.25f),
  28. /**
  29. * "Bitmap" rendering (pages are painted entirely as bitmaps, maximum quality,
  30. * reduced performance)
  31. */
  32. BITMAP("bitmap", 1.0f);
  33. private static final long serialVersionUID = 6359884255324755026L;
  34. private String name;
  35. private float defaultDitheringQuality;
  36. /**
  37. * Constructor to add a new named item.
  38. * @param name Name of the item.
  39. * @param defaultDitheringQuality the default dithering quality (0.0f..1.0f)
  40. */
  41. private PCLRenderingMode(String name, float defaultDitheringQuality) {
  42. this.name = name;
  43. this.defaultDitheringQuality = defaultDitheringQuality;
  44. }
  45. /** @return the name of the enum */
  46. public String getName() {
  47. return this.name;
  48. }
  49. /**
  50. * Returns the default dithering quality for this rendering mode.
  51. * @return the default dithering quality (0.0f..1.0f)
  52. */
  53. public float getDefaultDitheringQuality() {
  54. return this.defaultDitheringQuality;
  55. }
  56. /**
  57. * Returns the enumeration/singleton object based on its name.
  58. * @param name the name of the enumeration value
  59. * @return the enumeration object
  60. */
  61. public static PCLRenderingMode getValueOf(String name) {
  62. for (PCLRenderingMode mode : PCLRenderingMode.values()) {
  63. if (mode.getName().equalsIgnoreCase(name)) {
  64. return mode;
  65. }
  66. }
  67. throw new IllegalArgumentException("Illegal value for enumeration: " + name);
  68. }
  69. private Object readResolve() throws ObjectStreamException {
  70. return getValueOf(getName());
  71. }
  72. /** {@inheritDoc} */
  73. @Override
  74. public String toString() {
  75. return "PCLRenderingMode:" + name;
  76. }
  77. }