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.ResolutionSyntax;
029 import javax.print.attribute.DocAttribute;
030 import javax.print.attribute.PrintRequestAttribute;
031 import javax.print.attribute.PrintJobAttribute;
032
033 /**
034 * Class PrinterResolution is a printing attribute class that specifies an
035 * exact resolution supported by a printer or to be used for a print job.
036 * This attribute assumes that printers have a small set of device resolutions
037 * at which they can operate rather than a continuum.
038 * <p>
039 * PrinterResolution is used in multiple ways:
040 * <OL TYPE=1>
041 * <LI>
042 * When a client searches looking for a printer that supports the client's
043 * desired resolution exactly (no more, no less), the client specifies
044 * an instance of class PrinterResolution indicating the exact resolution the
045 * client wants. Only printers supporting that exact resolution will match the
046 * search.
047 * <P>
048 * <LI>
049 * When a client needs to print a job using the client's desired resolution
050 * exactly (no more, no less), the client specifies an instance of class
051 * PrinterResolution as an attribute of the Print Job. This will fail if the
052 * Print Job doesn't support that exact resolution, and Fidelity is set to
053 * true.
054 * </OL>
055 * If a client wants to locate a printer supporting a resolution
056 * greater than some required minimum, then it may be necessary to exclude
057 * this attribute from a lookup request and to directly query the set of
058 * supported resolutions, and specify the one that most closely meets
059 * the client's requirements.
060 * In some cases this may be more simply achieved by specifying a
061 * PrintQuality attribute which often controls resolution.
062 * <P>
063 * <P>
064 * <B>IPP Compatibility:</B> The information needed to construct an IPP
065 * <CODE>"printer-resolution"</CODE> attribute can be obtained by calling
066 * methods on the PrinterResolution object. The category name returned by
067 * <CODE>getName()</CODE> gives the IPP attribute name.
068 * <P>
069 *
070 * @author David Mendenhall
071 * @author Alan Kaminsky
072 */
073 public final class PrinterResolution extends ResolutionSyntax implements
074 DocAttribute, PrintRequestAttribute, PrintJobAttribute {
075
076 private static final long serialVersionUID = 13090306561090558L;
077
078 /**
079 * Construct a new printer resolution attribute from the given items.
080 *
081 * @param crossFeedResolution
082 * Cross feed direction resolution.
083 * @param feedResolution
084 * Feed direction resolution.
085 * @param units
086 * Unit conversion factor, e.g. <code>ResolutionSyntax.DPI</CODE>
087 * or <code>ResolutionSyntax.>DPCM</CODE>.
088 *
089 * @exception IllegalArgumentException
090 * (unchecked exception) Thrown if <CODE>crossFeedResolution</CODE> <
091 * 1 or <CODE>feedResolution</CODE> < 1 or <CODE>units</CODE> < 1.
092 */
093 public PrinterResolution(int crossFeedResolution,
094 int feedResolution, int units) {
095 super (crossFeedResolution, feedResolution, units);
096 }
097
098 /**
099 * Returns whether this printer resolution attribute is equivalent to the
100 * passed in object. To be equivalent, all of the following conditions
101 * must be true:
102 * <OL TYPE=1>
103 * <LI>
104 * <CODE>object</CODE> is not null.
105 * <LI>
106 * <CODE>object</CODE> is an instance of class PrinterResolution.
107 * <LI>
108 * This attribute's cross feed direction resolution is equal to
109 * <CODE>object</CODE>'s cross feed direction resolution.
110 * <LI>
111 * This attribute's feed direction resolution is equal to
112 * <CODE>object</CODE>'s feed direction resolution.
113 * </OL>
114 *
115 * @param object Object to compare to.
116 *
117 * @return True if <CODE>object</CODE> is equivalent to this printer
118 * resolution attribute, false otherwise.
119 */
120 public boolean equals(Object object) {
121 return (super .equals(object) && object instanceof PrinterResolution);
122 }
123
124 /**
125 * Get the printing attribute class which is to be used as the "category"
126 * for this printing attribute value.
127 * <P>
128 * For class PrinterResolution, the category is class PrinterResolution itself.
129 *
130 * @return Printing attribute class (category), an instance of class
131 * {@link java.lang.Class java.lang.Class}.
132 */
133 public final Class<? extends Attribute> getCategory() {
134 return PrinterResolution.class;
135 }
136
137 /**
138 * Get the name of the category of which this attribute value is an
139 * instance.
140 * <P>
141 * For class PrinterResolution, the
142 * category name is <CODE>"printer-resolution"</CODE>.
143 *
144 * @return Attribute category name.
145 */
146 public final String getName() {
147 return "printer-resolution";
148 }
149
150 }
|