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