Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/print/attribute/standard/NumberUp.java
38918 views
/*1* Copyright (c) 2000, 2004, 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*/24package javax.print.attribute.standard;2526import javax.print.attribute.Attribute;27import javax.print.attribute.IntegerSyntax;28import javax.print.attribute.DocAttribute;29import javax.print.attribute.PrintRequestAttribute;30import javax.print.attribute.PrintJobAttribute;3132/**33* Class NumberUp is an integer valued printing attribute class that specifies34* the number of print-stream pages to impose upon a single side of an35* instance of a selected medium. That is, if the NumberUp value is <I>n,</I>36* the printer must place <I>n</I> print-stream pages on a single side of37* an instance of the38* selected medium. To accomplish this, the printer may add some sort of39* translation, scaling, or rotation. This attribute primarily controls the40* translation, scaling and rotation of print-stream pages.41* <P>42* The effect of a NumberUp attribute on a multidoc print job (a job with43* multiple documents) depends on whether all the docs have the same number up44* values specified or whether different docs have different number up values45* specified, and on the (perhaps defaulted) value of the {@link46* MultipleDocumentHandling MultipleDocumentHandling} attribute.47* <UL>48* <LI>49* If all the docs have the same number up value <I>n</I> specified, then any50* value of {@link MultipleDocumentHandling MultipleDocumentHandling} makes51* sense, and the printer's processing depends on the {@link52* MultipleDocumentHandling MultipleDocumentHandling} value:53* <UL>54* <LI>55* SINGLE_DOCUMENT -- All the input docs will be combined together into one56* output document. Each media impression will consist of <I>n</I>m57* print-stream pages from the output document.58* <P>59* <LI>60* SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together61* into one output document. Each media impression will consist of <I>n</I>62* print-stream pages from the output document. However, the first impression of63* each input doc will always start on a new media sheet; this means the last64* impression of an input doc may have fewer than <I>n</I> print-stream pages65* on it.66* <P>67* <LI>68* SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The input docs will remain separate.69* Each media impression will consist of <I>n</I> print-stream pages from the70* input doc. Since the input docs are separate, the first impression of each71* input doc will always start on a new media sheet; this means the last72* impression of an input doc may have fewer than <I>n</I> print-stream pages on73* it.74* <P>75* <LI>76* SEPARATE_DOCUMENTS_COLLATED_COPIES -- The input docs will remain separate.77* Each media impression will consist of <I>n</I> print-stream pages from the78* input doc. Since the input docs are separate, the first impression of each79* input doc will always start on a new media sheet; this means the last80* impression of an input doc may have fewer than <I>n</I> print-stream pages81* on it.82* </UL>83* <UL>84* <LI>85* SINGLE_DOCUMENT -- All the input docs will be combined together into one86* output document. Each media impression will consist of <I>n<SUB>i</SUB></I>87* print-stream pages from the output document, where <I>i</I> is the number of88* the input doc corresponding to that point in the output document. When the89* next input doc has a different number up value from the previous input doc,90* the first print-stream page of the next input doc goes at the start of the91* next media impression, possibly leaving fewer than the full number of92* print-stream pages on the previous media impression.93* <P>94* <LI>95* SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together96* into one output document. Each media impression will consist of <I>n</I>97* print-stream pages from the output document. However, the first impression of98* each input doc will always start on a new media sheet; this means the last99* impression of an input doc may have fewer than <I>n</I> print-stream pages100* on it.101* <P>102* <LI>103* SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The input docs will remain separate.104* For input doc <I>i,</I> each media impression will consist of105* <I>n<SUB>i</SUB></I> print-stream pages from the input doc. Since the input106* docs are separate, the first impression of each input doc will always start107* on a new media sheet; this means the last impression of an input doc may have108* fewer than <I>n<SUB>i</SUB></I> print-stream pages on it.109* <P>110* <LI>111* SEPARATE_DOCUMENTS_COLLATED_COPIES -- The input docs will remain separate.112* For input doc <I>i,</I> each media impression will consist of113* <I>n<SUB>i</SUB></I> print-stream pages from the input doc. Since the input114* docs are separate, the first impression of each input doc will always start115* on a new media sheet; this means the last impression of an input doc may116* have fewer than <I>n<SUB>i</SUB></I> print-stream pages on it.117* </UL>118* </UL>119* <B>IPP Compatibility:</B> The integer value gives the IPP integer value.120* The category name returned by <CODE>getName()</CODE> gives the IPP121* attribute name.122* <P>123*124* @author Alan Kaminsky125*/126public final class NumberUp extends IntegerSyntax127implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {128129private static final long serialVersionUID = -3040436486786527811L;130131132/**133* Construct a new number up attribute with the given integer value.134*135* @param value Integer value.136*137* @exception IllegalArgumentException138* (Unchecked exception) Thrown if <CODE>value</CODE> is less than 1.139*/140public NumberUp(int value) {141super (value, 1, Integer.MAX_VALUE);142}143144/**145* Returns whether this number up attribute is equivalent to the passed in146* object. To be equivalent, all of the following conditions must be true:147* <OL TYPE=1>148* <LI>149* <CODE>object</CODE> is not null.150* <LI>151* <CODE>object</CODE> is an instance of class NumberUp.152* <LI>153* This number up attribute's value and <CODE>object</CODE>'s value are154* equal.155* </OL>156*157* @param object Object to compare to.158*159* @return True if <CODE>object</CODE> is equivalent to this number up160* attribute, false otherwise.161*/162public boolean equals(Object object) {163return (super.equals(object) && object instanceof NumberUp);164}165166/**167* Get the printing attribute class which is to be used as the "category"168* for this printing attribute value.169* <P>170* For class NumberUp, the category is class NumberUp itself.171*172* @return Printing attribute class (category), an instance of class173* {@link java.lang.Class java.lang.Class}.174*/175public final Class<? extends Attribute> getCategory() {176return NumberUp.class;177}178179/**180* Get the name of the category of which this attribute value is an181* instance.182* <P>183* For class NumberUp, the category name is <CODE>"number-up"</CODE>.184*185* @return Attribute category name.186*/187public final String getName() {188return "number-up";189}190191}192193194