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