1. /*
  2. * @(#)NumberUp.java 1.4 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.IntegerSyntax;
  9. import javax.print.attribute.DocAttribute;
  10. import javax.print.attribute.PrintRequestAttribute;
  11. import javax.print.attribute.PrintJobAttribute;
  12. /**
  13. * Class NumberUp is an integer valued printing attribute class that specifies
  14. * the number of print-stream pages to impose upon a single side of an
  15. * instance of a selected medium. That is, if the NumberUp value is <I>n,</I>
  16. * the printer must place <I>n</I> print-stream pages on a single side of
  17. * an instance of the
  18. * selected medium. To accomplish this, the printer may add some sort of
  19. * translation, scaling, or rotation. This attribute primarily controls the
  20. * translation, scaling and rotation of print-stream pages.
  21. * <P>
  22. * The effect of a NumberUp attribute on a multidoc print job (a job with
  23. * multiple documents) depends on whether all the docs have the same number up
  24. * values specified or whether different docs have different number up values
  25. * specified, and on the (perhaps defaulted) value of the {@link
  26. * MultipleDocumentHandling MultipleDocumentHandling} attribute.
  27. * <UL>
  28. * <LI>
  29. * If all the docs have the same number up value <I>n</I> specified, then any
  30. * value of {@link MultipleDocumentHandling MultipleDocumentHandling} makes
  31. * sense, and the printer's processing depends on the {@link
  32. * MultipleDocumentHandling MultipleDocumentHandling} value:
  33. * <UL>
  34. * <LI>
  35. * SINGLE_DOCUMENT -- All the input docs will be combined together into one
  36. * output document. Each media impression will consist of <I>n</I>m
  37. * print-stream pages from the output document.
  38. * <P>
  39. * <LI>
  40. * SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together
  41. * into one output document. Each media impression will consist of <I>n</I>
  42. * print-stream pages from the output document. However, the first impression of
  43. * each input doc will always start on a new media sheet; this means the last
  44. * impression of an input doc may have fewer than <I>n</I> print-stream pages
  45. * on it.
  46. * <P>
  47. * <LI>
  48. * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The input docs will remain separate.
  49. * Each media impression will consist of <I>n</I> print-stream pages from the
  50. * input doc. Since the input docs are separate, the first impression of each
  51. * input doc will always start on a new media sheet; this means the last
  52. * impression of an input doc may have fewer than <I>n</I> print-stream pages on
  53. * it.
  54. * <P>
  55. * <LI>
  56. * SEPARATE_DOCUMENTS_COLLATED_COPIES -- The input docs will remain separate.
  57. * Each media impression will consist of <I>n</I> print-stream pages from the
  58. * input doc. Since the input docs are separate, the first impression of each
  59. * input doc will always start on a new media sheet; this means the last
  60. * impression of an input doc may have fewer than <I>n</I> print-stream pages
  61. * on it.
  62. * </UL>
  63. * <UL>
  64. * <LI>
  65. * SINGLE_DOCUMENT -- All the input docs will be combined together into one
  66. * output document. Each media impression will consist of <I>n<SUB>i</SUB></I>
  67. * print-stream pages from the output document, where <I>i</I> is the number of
  68. * the input doc corresponding to that point in the output document. When the
  69. * next input doc has a different number up value from the previous input doc,
  70. * the first print-stream page of the next input doc goes at the start of the
  71. * next media impression, possibly leaving fewer than the full number of
  72. * print-stream pages on the previous media impression.
  73. * <P>
  74. * <LI>
  75. * SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together
  76. * into one output document. Each media impression will consist of <I>n</I>
  77. * print-stream pages from the output document. However, the first impression of
  78. * each input doc will always start on a new media sheet; this means the last
  79. * impression of an input doc may have fewer than <I>n</I> print-stream pages
  80. * on it.
  81. * <P>
  82. * <LI>
  83. * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The input docs will remain separate.
  84. * For input doc <I>i,</I> each media impression will consist of
  85. * <I>n<SUB>i</SUB></I> print-stream pages from the input doc. Since the input
  86. * docs are separate, the first impression of each input doc will always start
  87. * on a new media sheet; this means the last impression of an input doc may have
  88. * fewer than <I>n<SUB>i</SUB></I> print-stream pages on it.
  89. * <P>
  90. * <LI>
  91. * SEPARATE_DOCUMENTS_COLLATED_COPIES -- The input docs will remain separate.
  92. * For input doc <I>i,</I> each media impression will consist of
  93. * <I>n<SUB>i</SUB></I> print-stream pages from the input doc. Since the input
  94. * docs are separate, the first impression of each input doc will always start
  95. * on a new media sheet; this means the last impression of an input doc may
  96. * have fewer than <I>n<SUB>i</SUB></I> print-stream pages on it.
  97. * </UL>
  98. * </UL>
  99. * <B>IPP Compatibility:</B> The integer value gives the IPP integer value.
  100. * The category name returned by <CODE>getName()</CODE> gives the IPP
  101. * attribute name.
  102. * <P>
  103. *
  104. * @author Alan Kaminsky
  105. */
  106. public final class NumberUp extends IntegerSyntax
  107. implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
  108. /**
  109. * Construct a new number up attribute with the given integer value.
  110. *
  111. * @param value Integer value.
  112. *
  113. * @exception IllegalArgumentException
  114. * (Unchecked exception) Thrown if <CODE>value</CODE> is less than 1.
  115. */
  116. public NumberUp(int value) {
  117. super (value, 1, Integer.MAX_VALUE);
  118. }
  119. /**
  120. * Returns whether this number up attribute is equivalent to the passed in
  121. * object. To be equivalent, all of the following conditions must be true:
  122. * <OL TYPE=1>
  123. * <LI>
  124. * <CODE>object</CODE> is not null.
  125. * <LI>
  126. * <CODE>object</CODE> is an instance of class NumberUp.
  127. * <LI>
  128. * This number up attribute's value and <CODE>object</CODE>'s value are
  129. * equal.
  130. * </OL>
  131. *
  132. * @param object Object to compare to.
  133. *
  134. * @return True if <CODE>object</CODE> is equivalent to this number up
  135. * attribute, false otherwise.
  136. */
  137. public boolean equals(Object object) {
  138. return (super.equals(object) && object instanceof NumberUp);
  139. }
  140. /**
  141. * Get the printing attribute class which is to be used as the "category"
  142. * for this printing attribute value.
  143. * <P>
  144. * For class NumberUp, the category is class NumberUp itself.
  145. *
  146. * @return Printing attribute class (category), an instance of class
  147. * {@link java.lang.Class java.lang.Class}.
  148. */
  149. public final Class getCategory() {
  150. return NumberUp.class;
  151. }
  152. /**
  153. * Get the name of the category of which this attribute value is an
  154. * instance.
  155. * <P>
  156. * For class NumberUp, the category name is <CODE>"number-up"</CODE>.
  157. *
  158. * @return Attribute category name.
  159. */
  160. public final String getName() {
  161. return "number-up";
  162. }
  163. }