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"</CODE>),
  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"</CODE>) 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"</CODE> or <CODE>"text/html"</CODE>) but not others (e.g.
  49  * <CODE>"application/postscript"</CODE>). 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()</CODE> is the IPP attribute name.  The enumeration's
  59  * integer value is the IPP enum value.  The <code>toString()</code> 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"</CODE> 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"</CODE>.
 180      *
 181      * @return  Attribute category name.
 182      */
 183     public final String getName() {
 184         return "orientation-requested";
 185     }
 186 
 187 }