Path: blob/master/src/java.desktop/share/classes/javax/print/attribute/standard/OrientationRequested.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.EnumSyntax;32import javax.print.attribute.PrintJobAttribute;33import javax.print.attribute.PrintRequestAttribute;3435/**36* Class {@code OrientationRequested} is a printing attribute class, an37* enumeration, that indicates the desired orientation for printed print-stream38* pages; it does not describe the orientation of the client-supplied39* print-stream pages.40* <p>41* For some document formats (such as {@code "application/postscript"}), the42* desired orientation of the print-stream pages is specified within the43* document data. This information is generated by a device driver prior to the44* submission of the print job. Other document formats (such as45* {@code "text/plain"}) do not include the notion of desired orientation within46* the document data. In the latter case it is possible for the printer to bind47* the desired orientation to the document data after it has been submitted. It48* is expected that a printer would only support the49* {@code OrientationRequested} attribute for some document formats (e.g.,50* {@code "text/plain"} or {@code "text/html"}) but not others (e.g.51* {@code "application/postscript"}). This is no different from any other job52* template attribute, since a print job can always impose constraints among the53* values of different job template attributes. However, a special mention is54* made here since it is very likely that a printer will support the55* {@code OrientationRequested} attribute for only a subset of the supported56* document formats.57* <p>58* <b>IPP Compatibility:</b> The category name returned by {@code getName()} is59* the IPP attribute name. The enumeration's integer value is the IPP enum60* value. The {@code toString()} method returns the IPP string representation of61* the attribute value.62*63* @author Alan Kaminsky64*/65public final class OrientationRequested extends EnumSyntax66implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {6768/**69* Use serialVersionUID from JDK 1.4 for interoperability.70*/71@Serial72private static final long serialVersionUID = -4447437289862822276L;7374/**75* The content will be imaged across the short edge of the medium.76*/77public static final OrientationRequested78PORTRAIT = new OrientationRequested(3);7980/**81* The content will be imaged across the long edge of the medium. Landscape82* is defined to be a rotation of the print-stream page to be imaged by +9083* degrees with respect to the medium (i.e. anti-clockwise) from the84* portrait orientation. <i>Note:</i> The +90 direction was chosen because85* simple finishing on the long edge is the same edge whether portrait or86* landscape.87*/88public static final OrientationRequested89LANDSCAPE = new OrientationRequested(4);9091/**92* The content will be imaged across the long edge of the medium, but in the93* opposite manner from landscape. Reverse-landscape is defined to be a94* rotation of the print-stream page to be imaged by -90 degrees with95* respect to the medium (i.e. clockwise) from the portrait orientation.96* <i>Note:</i> The REVERSE_LANDSCAPE value was added because some97* applications rotate landscape -90 degrees from portrait, rather than +9098* degrees.99*/100public static final OrientationRequested101REVERSE_LANDSCAPE = new OrientationRequested(5);102103/**104* The content will be imaged across the short edge of the medium, but in105* the opposite manner from portrait. Reverse-portrait is defined to be a106* rotation of the print-stream page to be imaged by 180 degrees with107* respect to the medium from the portrait orientation. <i>Note:</i> The108* REVERSE_PORTRAIT value was added for use with the109* {@link Finishings Finishings} attribute in cases where the opposite edge110* is desired for finishing a portrait document on simple finishing devices111* that have only one finishing position. Thus a {@code "text/plain"}112* portrait document can be stapled "on the right" by a simple finishing113* device as is common use with some Middle Eastern languages such as114* Hebrew.115*/116public static final OrientationRequested117REVERSE_PORTRAIT = new OrientationRequested(6);118119/**120* Construct a new orientation requested enumeration value with the given121* integer value.122*123* @param value Integer value124*/125protected OrientationRequested(int value) {126super(value);127}128129/**130* The string table for class {@code OrientationRequested}.131*/132private static final String[] myStringTable = {133"portrait",134"landscape",135"reverse-landscape",136"reverse-portrait"137};138139/**140* The enumeration value table for class {@code OrientationRequested}.141*/142private static final OrientationRequested[] myEnumValueTable = {143PORTRAIT,144LANDSCAPE,145REVERSE_LANDSCAPE,146REVERSE_PORTRAIT147};148149/**150* Returns the string table for class {@code OrientationRequested}.151*/152protected String[] getStringTable() {153return myStringTable;154}155156/**157* Returns the enumeration value table for class158* {@code OrientationRequested}.159*/160protected EnumSyntax[] getEnumValueTable() {161return myEnumValueTable;162}163164/**165* Returns the lowest integer value used by class166* {@code OrientationRequested}.167*/168protected int getOffset() {169return 3;170}171172/**173* Get the printing attribute class which is to be used as the "category"174* for this printing attribute value.175* <p>176* For class {@code OrientationRequested}, the category is class177* {@code OrientationRequested} itself.178*179* @return printing attribute class (category), an instance of class180* {@link Class java.lang.Class}181*/182public final Class<? extends Attribute> getCategory() {183return OrientationRequested.class;184}185186/**187* Get the name of the category of which this attribute value is an188* instance.189* <p>190* For class {@code OrientationRequested}, the category name is191* {@code "orientation-requested"}.192*193* @return attribute category name194*/195public final String getName() {196return "orientation-requested";197}198}199200201