Path: blob/master/src/java.desktop/share/classes/javax/print/attribute/standard/NumberUp.java
41171 views
/*1* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.print.attribute.standard;2627import java.io.Serial;2829import javax.print.attribute.Attribute;30import javax.print.attribute.DocAttribute;31import javax.print.attribute.IntegerSyntax;32import javax.print.attribute.PrintJobAttribute;33import javax.print.attribute.PrintRequestAttribute;3435/**36* Class {@code NumberUp} is an integer valued printing attribute class that37* specifies the number of print-stream pages to impose upon a single side of an38* instance of a selected medium. That is, if the NumberUp value is <i>n,</i>39* the printer must place <i>n</i> print-stream pages on a single side of an40* instance of the selected medium. To accomplish this, the printer may add some41* sort of translation, scaling, or rotation. This attribute primarily controls42* the translation, scaling and rotation of print-stream pages.43* <p>44* The effect of a {@code NumberUp} attribute on a multidoc print job (a job45* with multiple documents) depends on whether all the docs have the same number46* up values specified or whether different docs have different number up values47* specified, and on the (perhaps defaulted) value of the48* {@link MultipleDocumentHandling MultipleDocumentHandling} attribute.49* <ul>50* <li>If all the docs have the same number up value <i>n</i> specified, then51* any value of {@link MultipleDocumentHandling MultipleDocumentHandling}52* makes sense, and the printer's processing depends on the53* {@link MultipleDocumentHandling MultipleDocumentHandling} value:54* <ul>55* <li>{@code SINGLE_DOCUMENT} -- All the input docs will be combined56* together into one output document. Each media impression will consist of57* <i>n</i>m print-stream pages from the output document.58* <li>{@code SINGLE_DOCUMENT_NEW_SHEET} -- All the input docs will be59* combined together into one output document. Each media impression will60* consist of <i>n</i> print-stream pages from the output document. However,61* the first impression of each input doc will always start on a new media62* sheet; this means the last impression of an input doc may have fewer than63* <i>n</i> print-stream pages on it.64* <li>{@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} -- The input docs will65* remain separate. Each media impression will consist of <i>n</i>66* print-stream pages from the input doc. Since the input docs are separate,67* the first impression of each input doc will always start on a new media68* sheet; this means the last impression of an input doc may have fewer than69* <i>n</i> print-stream pages on it.70* <li>{@code SEPARATE_DOCUMENTS_COLLATED_COPIES} -- The input docs will71* remain separate. Each media impression will consist of <i>n</i>72* print-stream pages from the input doc. Since the input docs are separate,73* the first impression of each input doc will always start on a new media74* sheet; this means the last impression of an input doc may have fewer than75* <i>n</i> print-stream pages on it.76* </ul>77* <ul>78* <li>{@code SINGLE_DOCUMENT} -- All the input docs will be combined79* together into one output document. Each media impression will consist of80* <i>n<sub>i</sub></i> print-stream pages from the output document, where81* <i>i</i> is the number of the input doc corresponding to that point in82* the output document. When the next input doc has a different number up83* value from the previous input doc, the first print-stream page of the84* next input doc goes at the start of the next media impression, possibly85* leaving fewer than the full number of print-stream pages on the previous86* media impression.87* <li>{@code SINGLE_DOCUMENT_NEW_SHEET} -- All the input docs will be88* combined together into one output document. Each media impression will89* consist of <i>n</i> print-stream pages from the output document. However,90* the first impression of each input doc will always start on a new media91* sheet; this means the last impression of an input doc may have fewer than92* <i>n</i> print-stream pages on it.93* <li>{@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} -- The input docs will94* remain separate. For input doc <i>i,</i> each media impression will95* consist of <i>n<sub>i</sub></i> print-stream pages from the input doc.96* Since the input docs are separate, the first impression of each input doc97* will always start on a new media sheet; this means the last impression of98* an input doc may have fewer than <i>n<sub>i</sub></i> print-stream pages99* on it.100* <li>{@code SEPARATE_DOCUMENTS_COLLATED_COPIES} -- The input docs will101* remain separate. For input doc <i>i,</i> each media impression will102* consist of <i>n<sub>i</sub></i> print-stream pages from the input doc.103* Since the input docs are separate, the first impression of each input doc104* will always start on a new media sheet; this means the last impression of105* an input doc may have fewer than <i>n<sub>i</sub></i> print-stream pages106* on it.107* </ul>108* </ul>109* <b>IPP Compatibility:</b> The integer value gives the IPP integer value. The110* category name returned by {@code getName()} gives the IPP attribute name.111*112* @author Alan Kaminsky113*/114public final class NumberUp extends IntegerSyntax115implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {116117/**118* Use serialVersionUID from JDK 1.4 for interoperability.119*/120@Serial121private static final long serialVersionUID = -3040436486786527811L;122123/**124* Construct a new number up attribute with the given integer value.125*126* @param value Integer value127* @throws IllegalArgumentException if {@code value < 1}128*/129public NumberUp(int value) {130super (value, 1, Integer.MAX_VALUE);131}132133/**134* Returns whether this number up attribute is equivalent to the passed in135* object. To be equivalent, all of the following conditions must be true:136* <ol type=1>137* <li>{@code object} is not {@code null}.138* <li>{@code object} is an instance of class {@code NumberUp}.139* <li>This number up attribute's value and {@code object}'s value are140* equal.141* </ol>142*143* @param object {@code Object} to compare to144* @return {@code true} if {@code object} is equivalent to this number up145* attribute, {@code false} otherwise146*/147public boolean equals(Object object) {148return (super.equals(object) && object instanceof NumberUp);149}150151/**152* Get the printing attribute class which is to be used as the "category"153* for this printing attribute value.154* <p>155* For class {@code NumberUp}, the category is class {@code NumberUp}156* itself.157*158* @return printing attribute class (category), an instance of class159* {@link Class java.lang.Class}160*/161public final Class<? extends Attribute> getCategory() {162return NumberUp.class;163}164165/**166* Get the name of the category of which this attribute value is an167* instance.168* <p>169* For class {@code NumberUp}, the category name is {@code "number-up"}.170*171* @return attribute category name172*/173public final String getName() {174return "number-up";175}176}177178179