1 /* 2 * Copyright (c) 2000, 2014, 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 package javax.print.attribute.standard; 26 27 import javax.print.attribute.Attribute; 28 import javax.print.attribute.EnumSyntax; 29 import javax.print.attribute.DocAttribute; 30 import javax.print.attribute.PrintRequestAttribute; 31 import javax.print.attribute.PrintJobAttribute; 32 33 /** 34 * Class OrientationRequested is a printing attribute class, an enumeration, 35 * that indicates the desired orientation for printed print-stream pages; it 36 * does not describe the orientation of the client-supplied print-stream 37 * pages. 38 * <P> 39 * For some document formats (such as {@code "application/postscript"}), 40 * the desired orientation of the print-stream pages is specified within the 41 * document data. This information is generated by a device driver prior to 42 * the submission of the print job. Other document formats (such as 43 * {@code "text/plain"}) do not include the notion of desired orientation 44 * within the document data. In the latter case it is possible for the printer 45 * to bind the desired orientation to the document data after it has been 46 * submitted. It is expected that a printer would only support the 47 * OrientationRequested attribute for some document formats (e.g., 48 * {@code "text/plain"} or {@code "text/html"}) but not others (e.g. 49 * {@code "application/postscript"}). This is no different from any other 50 * job template attribute, since a print job can always impose constraints 51 * among the values of different job template attributes. 52 * However, a special mention 53 * is made here since it is very likely that a printer will support the 54 * OrientationRequested attribute for only a subset of the supported document 55 * formats. 56 * <P> 57 * <B>IPP Compatibility:</B> The category name returned by 58 * {@code getName()} is the IPP attribute name. The enumeration's 59 * integer value is the IPP enum value. The {@code toString()} method 60 * returns the IPP string representation of the attribute value. 61 * 62 * @author Alan Kaminsky 63 */ 64 public final class OrientationRequested extends EnumSyntax 65 implements DocAttribute, PrintRequestAttribute, PrintJobAttribute { 66 67 private static final long serialVersionUID = -4447437289862822276L; 68 69 /** 70 * The content will be imaged across the short edge of the medium. 71 */ 72 public static final OrientationRequested 73 PORTRAIT = new OrientationRequested(3); 74 75 /** 76 * The content will be imaged across the long edge of the medium. 77 * Landscape is defined to be a rotation of the print-stream page to be 78 * imaged by +90 degrees with respect to the medium 79 * (i.e. anti-clockwise) from the 80 * portrait orientation. <I>Note:</I> The +90 direction was chosen because 81 * simple finishing on the long edge is the same edge whether portrait or 82 * landscape. 83 */ 84 public static final OrientationRequested 85 LANDSCAPE = new OrientationRequested(4); 86 87 /** 88 * The content will be imaged across the long edge of the medium, but in 89 * the opposite manner from landscape. Reverse-landscape is defined to be 90 * a rotation of the print-stream page to be imaged by -90 degrees with 91 * respect to the medium (i.e. clockwise) from the portrait orientation. 92 * <I>Note:</I> The REVERSE_LANDSCAPE value was added because some 93 * applications rotate landscape -90 degrees from portrait, rather than 94 * +90 degrees. 95 */ 96 public static final OrientationRequested 97 REVERSE_LANDSCAPE = new OrientationRequested(5); 98 99 /** 100 * The content will be imaged across the short edge of the medium, but in 101 * the opposite manner from portrait. Reverse-portrait is defined to be a 102 * rotation of the print-stream page to be imaged by 180 degrees with 103 * respect to the medium from the portrait orientation. <I>Note:</I> The 104 * REVERSE_PORTRAIT value was added for use with the {@link 105 * Finishings Finishings} attribute in cases where the 106 * opposite edge is desired for finishing a portrait document on simple 107 * finishing devices that have only one finishing position. Thus a 108 * {@code "text/plain"} portrait document can be stapled "on the 109 * right" by a simple finishing device as is common use with some 110 * Middle Eastern languages such as Hebrew. 111 */ 112 public static final OrientationRequested 113 REVERSE_PORTRAIT = new OrientationRequested(6); 114 115 /** 116 * Construct a new orientation requested enumeration value with the given 117 * integer value. 118 * 119 * @param value Integer value. 120 */ 121 protected OrientationRequested(int value) { 122 super(value); 123 } 124 125 private static final String[] myStringTable = { 126 "portrait", 127 "landscape", 128 "reverse-landscape", 129 "reverse-portrait" 130 }; 131 132 private static final OrientationRequested[] myEnumValueTable = { 133 PORTRAIT, 134 LANDSCAPE, 135 REVERSE_LANDSCAPE, 136 REVERSE_PORTRAIT 137 }; 138 139 /** 140 * Returns the string table for class OrientationRequested. 141 */ 142 protected String[] getStringTable() { 143 return myStringTable; 144 } 145 146 /** 147 * Returns the enumeration value table for class OrientationRequested. 148 */ 149 protected EnumSyntax[] getEnumValueTable() { 150 return myEnumValueTable; 151 } 152 153 /** 154 * Returns the lowest integer value used by class OrientationRequested. 155 */ 156 protected int getOffset() { 157 return 3; 158 } 159 160 /** 161 * Get the printing attribute class which is to be used as the "category" 162 * for this printing attribute value. 163 * <P> 164 * For class OrientationRequested, the 165 * category is class OrientationRequested itself. 166 * 167 * @return Printing attribute class (category), an instance of class 168 * {@link java.lang.Class java.lang.Class}. 169 */ 170 public final Class<? extends Attribute> getCategory() { 171 return OrientationRequested.class; 172 } 173 174 /** 175 * Get the name of the category of which this attribute value is an 176 * instance. 177 * <P> 178 * For class OrientationRequested, the 179 * category name is {@code "orientation-requested"}. 180 * 181 * @return Attribute category name. 182 */ 183 public final String getName() { 184 return "orientation-requested"; 185 } 186 187 } | 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 } |