1 /* 2 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package javax.print.attribute.standard; 27 28 import javax.print.attribute.Attribute; 29 import javax.print.attribute.DocAttribute; 30 import javax.print.attribute.EnumSyntax; 31 import javax.print.attribute.PrintJobAttribute; 32 import javax.print.attribute.PrintRequestAttribute; 33 34 /** 35 * Class {@code OrientationRequested} is a printing attribute class, an 36 * enumeration, that indicates the desired orientation for printed print-stream 37 * pages; it does not describe the orientation of the client-supplied 38 * print-stream pages. 39 * <p> 40 * For some document formats (such as {@code "application/postscript"}), the 41 * desired orientation of the print-stream pages is specified within the 42 * document data. This information is generated by a device driver prior to the 43 * submission of the print job. Other document formats (such as 44 * {@code "text/plain"}) do not include the notion of desired orientation within 45 * the document data. In the latter case it is possible for the printer to bind 46 * the desired orientation to the document data after it has been submitted. It 47 * is expected that a printer would only support the 48 * {@code OrientationRequested} attribute for some document formats (e.g., 49 * {@code "text/plain"} or {@code "text/html"}) but not others (e.g. 50 * {@code "application/postscript"}). This is no different from any other job 51 * template attribute, since a print job can always impose constraints among the 52 * values of different job template attributes. However, a special mention is 53 * made here since it is very likely that a printer will support the 54 * {@code OrientationRequested} attribute for only a subset of the supported 55 * document formats. 56 * <p> 57 * <b>IPP Compatibility:</b> The category name returned by {@code getName()} is 58 * the IPP attribute name. The enumeration's integer value is the IPP enum 59 * value. The {@code toString()} method returns the IPP string representation of 60 * the attribute value. 61 * 62 * @author Alan Kaminsky 63 */ 64 public final class OrientationRequested extends EnumSyntax 65 implements DocAttribute, PrintRequestAttribute, PrintJobAttribute { 66 67 /** 68 * Use serialVersionUID from JDK 1.4 for interoperability. 69 */ 70 private static final long serialVersionUID = -4447437289862822276L; 71 72 /** 73 * The content will be imaged across the short edge of the medium. 74 */ 75 public static final OrientationRequested 76 PORTRAIT = new OrientationRequested(3); 77 78 /** 79 * The content will be imaged across the long edge of the medium. Landscape 80 * is defined to be a rotation of the print-stream page to be imaged by +90 81 * degrees with respect to the medium (i.e. anti-clockwise) from the 82 * portrait orientation. <i>Note:</i> The +90 direction was chosen because 83 * simple finishing on the long edge is the same edge whether portrait or 84 * landscape. 85 */ 86 public static final OrientationRequested 87 LANDSCAPE = new OrientationRequested(4); 88 89 /** 90 * The content will be imaged across the long edge of the medium, but in the 91 * opposite manner from landscape. Reverse-landscape is defined to be a 92 * rotation of the print-stream page to be imaged by -90 degrees with 93 * respect to the medium (i.e. clockwise) from the portrait orientation. 94 * <i>Note:</i> The REVERSE_LANDSCAPE value was added because some 95 * applications rotate landscape -90 degrees from portrait, rather than +90 96 * degrees. 97 */ 98 public static final OrientationRequested 99 REVERSE_LANDSCAPE = new OrientationRequested(5); 100 101 /** 102 * The content will be imaged across the short edge of the medium, but in 103 * the opposite manner from portrait. Reverse-portrait is defined to be a 104 * rotation of the print-stream page to be imaged by 180 degrees with 105 * respect to the medium from the portrait orientation. <i>Note:</i> The 106 * REVERSE_PORTRAIT value was added for use with the 107 * {@link Finishings Finishings} attribute in cases where the opposite edge 108 * is desired for finishing a portrait document on simple finishing devices 109 * that have only one finishing position. Thus a {@code "text/plain"} 110 * portrait document can be stapled "on the right" by a simple finishing 111 * device as is common use with some Middle Eastern languages such as 112 * Hebrew. 113 */ 114 public static final OrientationRequested 115 REVERSE_PORTRAIT = new OrientationRequested(6); 116 117 /** 118 * Construct a new orientation requested enumeration value with the given 119 * integer value. 120 * 121 * @param value Integer value 122 */ 123 protected OrientationRequested(int value) { 124 super(value); 125 } 126 127 /** 128 * The string table for class {@code OrientationRequested}. 129 */ 130 private static final String[] myStringTable = { 131 "portrait", 132 "landscape", 133 "reverse-landscape", 134 "reverse-portrait" 135 }; 136 137 /** 138 * The enumeration value table for class {@code OrientationRequested}. 139 */ 140 private static final OrientationRequested[] myEnumValueTable = { 141 PORTRAIT, 142 LANDSCAPE, 143 REVERSE_LANDSCAPE, 144 REVERSE_PORTRAIT 145 }; 146 147 /** 148 * Returns the string table for class {@code OrientationRequested}. 149 */ 150 protected String[] getStringTable() { 151 return myStringTable; 152 } 153 154 /** 155 * Returns the enumeration value table for class 156 * {@code OrientationRequested}. 157 */ 158 protected EnumSyntax[] getEnumValueTable() { 159 return myEnumValueTable; 160 } 161 162 /** 163 * Returns the lowest integer value used by class 164 * {@code OrientationRequested}. 165 */ 166 protected int getOffset() { 167 return 3; 168 } 169 170 /** 171 * Get the printing attribute class which is to be used as the "category" 172 * for this printing attribute value. 173 * <p> 174 * For class {@code OrientationRequested}, the category is class 175 * {@code OrientationRequested} itself. 176 * 177 * @return printing attribute class (category), an instance of class 178 * {@link Class java.lang.Class} 179 */ 180 public final Class<? extends Attribute> getCategory() { 181 return OrientationRequested.class; 182 } 183 184 /** 185 * Get the name of the category of which this attribute value is an 186 * instance. 187 * <p> 188 * For class {@code OrientationRequested}, the category name is 189 * {@code "orientation-requested"}. 190 * 191 * @return attribute category name 192 */ 193 public final String getName() { 194 return "orientation-requested"; 195 } 196 }