KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > print > attribute > standard > PrinterResolution


1 /*
2  * @(#)PrinterResolution.java 1.9 04/05/05
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package javax.print.attribute.standard;
8
9 import javax.print.attribute.Attribute JavaDoc;
10 import javax.print.attribute.ResolutionSyntax JavaDoc;
11 import javax.print.attribute.DocAttribute JavaDoc;
12 import javax.print.attribute.PrintRequestAttribute JavaDoc;
13 import javax.print.attribute.PrintJobAttribute JavaDoc;
14
15 /**
16  * Class PrinterResolution is a printing attribute class that specifies an
17  * exact resolution supported by a printer or to be used for a print job.
18  * This attribute assumes that printers have a small set of device resolutions
19  * at which they can operate rather than a continuum.
20  * <p>
21  * PrinterResolution is used in multiple ways:
22  * <OL TYPE=1>
23  * <LI>
24  * When a client searches looking for a printer that supports the client's
25  * desired resolution exactly (no more, no less), the client specifies
26  * an instance of class PrinterResolution indicating the exact resolution the
27  * client wants. Only printers supporting that exact resolution will match the
28  * search.
29  * <P>
30  * <LI>
31  * When a client needs to print a job using the client's desired resolution
32  * exactly (no more, no less), the client specifies an instance of class
33  * PrinterResolution as an attribute of the Print Job. This will fail if the
34  * Print Job doesn't support that exact resolution, and Fidelity is set to
35  * true.
36  * </OL>
37  * If a client wants to locate a printer supporting a resolution
38  * greater than some required minimum, then it may be necessary to exclude
39  * this attribute from a lookup request and to directly query the set of
40  * supported resolutions, and specify the one that most closely meets
41  * the client's requirements.
42  * In some cases this may be more simply achieved by specifying a
43  * PrintQuality attribute which often controls resolution.
44  * <P>
45  * <P>
46  * <B>IPP Compatibility:</B> The information needed to construct an IPP
47  * <CODE>"printer-resolution"</CODE> attribute can be obtained by calling
48  * methods on the PrinterResolution object. The category name returned by
49  * <CODE>getName()</CODE> gives the IPP attribute name.
50  * <P>
51  *
52  * @author David Mendenhall
53  * @author Alan Kaminsky
54  */

55 public final class PrinterResolution extends ResolutionSyntax JavaDoc
56     implements DocAttribute JavaDoc, PrintRequestAttribute JavaDoc, PrintJobAttribute JavaDoc {
57
58     private static final long serialVersionUID = 13090306561090558L;
59
60     /**
61      * Construct a new printer resolution attribute from the given items.
62      *
63      * @param crossFeedResolution
64      * Cross feed direction resolution.
65      * @param feedResolution
66      * Feed direction resolution.
67      * @param units
68      * Unit conversion factor, e.g. <code>ResolutionSyntax.DPI</CODE>
69      * or <code>ResolutionSyntax.>DPCM</CODE>.
70      *
71      * @exception IllegalArgumentException
72      * (unchecked exception) Thrown if <CODE>crossFeedResolution</CODE> <
73      * 1 or <CODE>feedResolution</CODE> < 1 or <CODE>units</CODE> < 1.
74      */

75     public PrinterResolution(int crossFeedResolution, int feedResolution,
76                  int units) {
77     super (crossFeedResolution, feedResolution, units);
78     }
79
80     /**
81      * Returns whether this printer resolution attribute is equivalent to the
82      * passed in object. To be equivalent, all of the following conditions
83      * must be true:
84      * <OL TYPE=1>
85      * <LI>
86      * <CODE>object</CODE> is not null.
87      * <LI>
88      * <CODE>object</CODE> is an instance of class PrinterResolution.
89      * <LI>
90      * This attribute's cross feed direction resolution is equal to
91      * <CODE>object</CODE>'s cross feed direction resolution.
92      * <LI>
93      * This attribute's feed direction resolution is equal to
94      * <CODE>object</CODE>'s feed direction resolution.
95      * </OL>
96      *
97      * @param object Object to compare to.
98      *
99      * @return True if <CODE>object</CODE> is equivalent to this printer
100      * resolution attribute, false otherwise.
101      */

102     public boolean equals(Object JavaDoc object) {
103     return (super.equals (object) &&
104         object instanceof PrinterResolution JavaDoc);
105     }
106
107     /**
108      * Get the printing attribute class which is to be used as the "category"
109      * for this printing attribute value.
110      * <P>
111      * For class PrinterResolution, the category is class PrinterResolution itself.
112      *
113      * @return Printing attribute class (category), an instance of class
114      * {@link java.lang.Class java.lang.Class}.
115      */

116     public final Class JavaDoc<? extends Attribute JavaDoc> getCategory() {
117     return PrinterResolution JavaDoc.class;
118         }
119     
120     /**
121      * Get the name of the category of which this attribute value is an
122      * instance.
123      * <P>
124      * For class PrinterResolution, the
125      * category name is <CODE>"printer-resolution"</CODE>.
126      *
127      * @return Attribute category name.
128      */

129     public final String JavaDoc getName() {
130     return "printer-resolution";
131     }
132
133 }
134
Popular Tags