1. /*
  2. * @(#)OrientationRequested.java 1.9 04/05/05
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.print.attribute.standard;
  8. import javax.print.attribute.Attribute;
  9. import javax.print.attribute.EnumSyntax;
  10. import javax.print.attribute.DocAttribute;
  11. import javax.print.attribute.PrintRequestAttribute;
  12. import javax.print.attribute.PrintJobAttribute;
  13. /**
  14. * Class OrientationRequested is a printing attribute class, an enumeration,
  15. * that indicates the desired orientation for printed print-stream pages; it
  16. * does not describe the orientation of the client-supplied print-stream
  17. * pages.
  18. * <P>
  19. * For some document formats (such as <CODE>"application/postscript"</CODE>),
  20. * the desired orientation of the print-stream pages is specified within the
  21. * document data. This information is generated by a device driver prior to
  22. * the submission of the print job. Other document formats (such as
  23. * <CODE>"text/plain"</CODE>) do not include the notion of desired orientation
  24. * within the document data. In the latter case it is possible for the printer
  25. * to bind the desired orientation to the document data after it has been
  26. * submitted. It is expected that a printer would only support the
  27. * OrientationRequested attribute for some document formats (e.g.,
  28. * <CODE>"text/plain"</CODE> or <CODE>"text/html"</CODE>) but not others (e.g.
  29. * <CODE>"application/postscript"</CODE>). This is no different from any other
  30. * job template attribute, since a print job can always impose constraints
  31. * among the values of different job template attributes.
  32. * However, a special mention
  33. * is made here since it is very likely that a printer will support the
  34. * OrientationRequested attribute for only a subset of the supported document
  35. * formats.
  36. * <P>
  37. * <B>IPP Compatibility:</B> The category name returned by
  38. * <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
  39. * integer value is the IPP enum value. The <code>toString()</code> method
  40. * returns the IPP string representation of the attribute value.
  41. * <P>
  42. *
  43. * @author Alan Kaminsky
  44. */
  45. public final class OrientationRequested extends EnumSyntax
  46. implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
  47. private static final long serialVersionUID = -4447437289862822276L;
  48. /**
  49. * The content will be imaged across the short edge of the medium.
  50. */
  51. public static final OrientationRequested
  52. PORTRAIT = new OrientationRequested(3);
  53. /**
  54. * The content will be imaged across the long edge of the medium.
  55. * Landscape is defined to be a rotation of the print-stream page to be
  56. * imaged by +90 degrees with respect to the medium
  57. * (i.e. anti-clockwise) from the
  58. * portrait orientation. <I>Note:</I> The +90 direction was chosen because
  59. * simple finishing on the long edge is the same edge whether portrait or
  60. * landscape.
  61. */
  62. public static final OrientationRequested
  63. LANDSCAPE = new OrientationRequested(4);
  64. /**
  65. * The content will be imaged across the long edge of the medium, but in
  66. * the opposite manner from landscape. Reverse-landscape is defined to be
  67. * a rotation of the print-stream page to be imaged by -90 degrees with
  68. * respect to the medium (i.e. clockwise) from the portrait orientation.
  69. * <I>Note:</I> The REVERSE_LANDSCAPE value was added because some
  70. * applications rotate landscape -90 degrees from portrait, rather than
  71. * +90 degrees.
  72. */
  73. public static final OrientationRequested
  74. REVERSE_LANDSCAPE = new OrientationRequested(5);
  75. /**
  76. * The content will be imaged across the short edge of the medium, but in
  77. * the opposite manner from portrait. Reverse-portrait is defined to be a
  78. * rotation of the print-stream page to be imaged by 180 degrees with
  79. * respect to the medium from the portrait orientation. <I>Note:</I> The
  80. * REVERSE_PORTRAIT value was added for use with the {@link
  81. * Finishings Finishings} attribute in cases where the
  82. * opposite edge is desired for finishing a portrait document on simple
  83. * finishing devices that have only one finishing position. Thus a
  84. * <CODE>"text/plain"</CODE> portrait document can be stapled "on the
  85. * right" by a simple finishing device as is common use with some
  86. * Middle Eastern languages such as Hebrew.
  87. */
  88. public static final OrientationRequested
  89. REVERSE_PORTRAIT = new OrientationRequested(6);
  90. /**
  91. * Construct a new orientation requested enumeration value with the given
  92. * integer value.
  93. *
  94. * @param value Integer value.
  95. */
  96. protected OrientationRequested(int value) {
  97. super(value);
  98. }
  99. private static final String[] myStringTable = {
  100. "portrait",
  101. "landscape",
  102. "reverse-landscape",
  103. "reverse-portrait"
  104. };
  105. private static final OrientationRequested[] myEnumValueTable = {
  106. PORTRAIT,
  107. LANDSCAPE,
  108. REVERSE_LANDSCAPE,
  109. REVERSE_PORTRAIT
  110. };
  111. /**
  112. * Returns the string table for class OrientationRequested.
  113. */
  114. protected String[] getStringTable() {
  115. return myStringTable;
  116. }
  117. /**
  118. * Returns the enumeration value table for class OrientationRequested.
  119. */
  120. protected EnumSyntax[] getEnumValueTable() {
  121. return myEnumValueTable;
  122. }
  123. /**
  124. * Returns the lowest integer value used by class OrientationRequested.
  125. */
  126. protected int getOffset() {
  127. return 3;
  128. }
  129. /**
  130. * Get the printing attribute class which is to be used as the "category"
  131. * for this printing attribute value.
  132. * <P>
  133. * For class OrientationRequested, the
  134. * category is class OrientationRequested itself.
  135. *
  136. * @return Printing attribute class (category), an instance of class
  137. * {@link java.lang.Class java.lang.Class}.
  138. */
  139. public final Class<? extends Attribute> getCategory() {
  140. return OrientationRequested.class;
  141. }
  142. /**
  143. * Get the name of the category of which this attribute value is an
  144. * instance.
  145. * <P>
  146. * For class OrientationRequested, the
  147. * category name is <CODE>"orientation-requested"</CODE>.
  148. *
  149. * @return Attribute category name.
  150. */
  151. public final String getName() {
  152. return "orientation-requested";
  153. }
  154. }