001 /*
002 * Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025 package javax.print.attribute.standard;
026
027 import javax.print.attribute.Attribute;
028 import javax.print.attribute.EnumSyntax;
029 import javax.print.attribute.DocAttribute;
030 import javax.print.attribute.PrintRequestAttribute;
031 import javax.print.attribute.PrintJobAttribute;
032
033 /**
034 * Class OrientationRequested is a printing attribute class, an enumeration,
035 * that indicates the desired orientation for printed print-stream pages; it
036 * does not describe the orientation of the client-supplied print-stream
037 * pages.
038 * <P>
039 * For some document formats (such as <CODE>"application/postscript"</CODE>),
040 * the desired orientation of the print-stream pages is specified within the
041 * document data. This information is generated by a device driver prior to
042 * the submission of the print job. Other document formats (such as
043 * <CODE>"text/plain"</CODE>) do not include the notion of desired orientation
044 * within the document data. In the latter case it is possible for the printer
045 * to bind the desired orientation to the document data after it has been
046 * submitted. It is expected that a printer would only support the
047 * OrientationRequested attribute for some document formats (e.g.,
048 * <CODE>"text/plain"</CODE> or <CODE>"text/html"</CODE>) but not others (e.g.
049 * <CODE>"application/postscript"</CODE>). This is no different from any other
050 * job template attribute, since a print job can always impose constraints
051 * among the values of different job template attributes.
052 * However, a special mention
053 * is made here since it is very likely that a printer will support the
054 * OrientationRequested attribute for only a subset of the supported document
055 * formats.
056 * <P>
057 * <B>IPP Compatibility:</B> The category name returned by
058 * <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
059 * integer value is the IPP enum value. The <code>toString()</code> method
060 * returns the IPP string representation of the attribute value.
061 * <P>
062 *
063 * @author Alan Kaminsky
064 */
065 public final class OrientationRequested extends EnumSyntax implements
066 DocAttribute, PrintRequestAttribute, PrintJobAttribute {
067
068 private static final long serialVersionUID = -4447437289862822276L;
069
070 /**
071 * The content will be imaged across the short edge of the medium.
072 */
073 public static final OrientationRequested PORTRAIT = new OrientationRequested(
074 3);
075
076 /**
077 * The content will be imaged across the long edge of the medium.
078 * Landscape is defined to be a rotation of the print-stream page to be
079 * imaged by +90 degrees with respect to the medium
080 * (i.e. anti-clockwise) from the
081 * portrait orientation. <I>Note:</I> The +90 direction was chosen because
082 * simple finishing on the long edge is the same edge whether portrait or
083 * landscape.
084 */
085 public static final OrientationRequested LANDSCAPE = new OrientationRequested(
086 4);
087
088 /**
089 * The content will be imaged across the long edge of the medium, but in
090 * the opposite manner from landscape. Reverse-landscape is defined to be
091 * a rotation of the print-stream page to be imaged by -90 degrees with
092 * respect to the medium (i.e. clockwise) from the portrait orientation.
093 * <I>Note:</I> The REVERSE_LANDSCAPE value was added because some
094 * applications rotate landscape -90 degrees from portrait, rather than
095 * +90 degrees.
096 */
097 public static final OrientationRequested REVERSE_LANDSCAPE = new OrientationRequested(
098 5);
099
100 /**
101 * The content will be imaged across the short edge of the medium, but in
102 * the opposite manner from portrait. Reverse-portrait is defined to be a
103 * rotation of the print-stream page to be imaged by 180 degrees with
104 * respect to the medium from the portrait orientation. <I>Note:</I> The
105 * REVERSE_PORTRAIT value was added for use with the {@link
106 * Finishings Finishings} attribute in cases where the
107 * opposite edge is desired for finishing a portrait document on simple
108 * finishing devices that have only one finishing position. Thus a
109 * <CODE>"text/plain"</CODE> portrait document can be stapled "on the
110 * right" by a simple finishing device as is common use with some
111 * Middle Eastern languages such as Hebrew.
112 */
113 public static final OrientationRequested REVERSE_PORTRAIT = new OrientationRequested(
114 6);
115
116 /**
117 * Construct a new orientation requested enumeration value with the given
118 * integer value.
119 *
120 * @param value Integer value.
121 */
122 protected OrientationRequested(int value) {
123 super (value);
124 }
125
126 private static final String[] myStringTable = { "portrait",
127 "landscape", "reverse-landscape", "reverse-portrait" };
128
129 private static final OrientationRequested[] myEnumValueTable = {
130 PORTRAIT, LANDSCAPE, REVERSE_LANDSCAPE, REVERSE_PORTRAIT };
131
132 /**
133 * Returns the string table for class OrientationRequested.
134 */
135 protected String[] getStringTable() {
136 return myStringTable;
137 }
138
139 /**
140 * Returns the enumeration value table for class OrientationRequested.
141 */
142 protected EnumSyntax[] getEnumValueTable() {
143 return myEnumValueTable;
144 }
145
146 /**
147 * Returns the lowest integer value used by class OrientationRequested.
148 */
149 protected int getOffset() {
150 return 3;
151 }
152
153 /**
154 * Get the printing attribute class which is to be used as the "category"
155 * for this printing attribute value.
156 * <P>
157 * For class OrientationRequested, the
158 * category is class OrientationRequested itself.
159 *
160 * @return Printing attribute class (category), an instance of class
161 * {@link java.lang.Class java.lang.Class}.
162 */
163 public final Class<? extends Attribute> getCategory() {
164 return OrientationRequested.class;
165 }
166
167 /**
168 * Get the name of the category of which this attribute value is an
169 * instance.
170 * <P>
171 * For class OrientationRequested, the
172 * category name is <CODE>"orientation-requested"</CODE>.
173 *
174 * @return Attribute category name.
175 */
176 public final String getName() {
177 return "orientation-requested";
178 }
179
180 }
|