jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterResolution.java
changeset 47196 a3211bb4daff
parent 35667 ed476aba94de
equal deleted inserted replaced
47195:b309b58eb190 47196:a3211bb4daff
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
     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.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    20  *
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    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
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    23  * questions.
    24  */
    24  */
       
    25 
    25 package javax.print.attribute.standard;
    26 package javax.print.attribute.standard;
    26 
    27 
    27 import javax.print.attribute.Attribute;
    28 import javax.print.attribute.Attribute;
       
    29 import javax.print.attribute.DocAttribute;
       
    30 import javax.print.attribute.PrintJobAttribute;
       
    31 import javax.print.attribute.PrintRequestAttribute;
    28 import javax.print.attribute.ResolutionSyntax;
    32 import javax.print.attribute.ResolutionSyntax;
    29 import javax.print.attribute.DocAttribute;
       
    30 import javax.print.attribute.PrintRequestAttribute;
       
    31 import javax.print.attribute.PrintJobAttribute;
       
    32 
    33 
    33 /**
    34 /**
    34  * Class PrinterResolution is a printing attribute class that specifies an
    35  * Class {@code PrinterResolution} is a printing attribute class that specifies
    35  * exact resolution supported by a printer or to be used for a print job.
    36  * an exact resolution supported by a printer or to be used for a print job.
    36  * This attribute assumes that printers have a small set of device resolutions
    37  * This attribute assumes that printers have a small set of device resolutions
    37  * at which they can operate rather than a continuum.
    38  * at which they can operate rather than a continuum.
    38  * <p>
    39  * <p>
    39  * PrinterResolution is used in multiple ways:
    40  * {@code PrinterResolution} is used in multiple ways:
    40  * <OL TYPE=1>
    41  * <ol type=1>
    41  * <LI>
    42  *   <li>When a client searches looking for a printer that supports the client's
    42  * When a client searches looking for a printer that supports the client's
    43  *   desired resolution exactly (no more, no less), the client specifies an
    43  * desired resolution exactly (no more, no less), the client specifies
    44  *   instance of class {@code PrinterResolution} indicating the exact resolution
    44  * an instance of class PrinterResolution indicating the exact resolution the
    45  *   the client wants. Only printers supporting that exact resolution will match
    45  * client wants. Only printers supporting that exact resolution will match the
    46  *   the search.
    46  * search.
    47  *   <li>When a client needs to print a job using the client's desired
       
    48  *   resolution exactly (no more, no less), the client specifies an instance of
       
    49  *   class {@code PrinterResolution} as an attribute of the Print Job. This will
       
    50  *   fail if the Print Job doesn't support that exact resolution, and
       
    51  *   {@code Fidelity} is set to true.
       
    52  * </ol>
       
    53  * If a client wants to locate a printer supporting a resolution greater than
       
    54  * some required minimum, then it may be necessary to exclude this attribute
       
    55  * from a lookup request and to directly query the set of supported resolutions,
       
    56  * and specify the one that most closely meets the client's requirements. In
       
    57  * some cases this may be more simply achieved by specifying a
       
    58  * {@code PrintQuality} attribute which often controls resolution.
       
    59  * <p>
       
    60  * <b>IPP Compatibility:</b> The information needed to construct an IPP
       
    61  * {@code "printer-resolution"} attribute can be obtained by calling methods on
       
    62  * the PrinterResolution object. The category name returned by {@code getName()}
       
    63  * gives the IPP attribute name.
    47  *
    64  *
    48  * <LI>
    65  * @author David Mendenhall
    49  * When a client needs to print a job using the client's desired resolution
    66  * @author Alan Kaminsky
    50  * exactly (no more, no less), the client specifies an instance of class
       
    51  * PrinterResolution as an attribute of the Print Job. This will fail if the
       
    52  * Print Job doesn't support that exact resolution, and Fidelity is set to
       
    53  * true.
       
    54  * </OL>
       
    55  * If a client wants to locate a printer supporting a resolution
       
    56  * greater than some required minimum, then it may be necessary to exclude
       
    57  * this attribute from a lookup request and to directly query the set of
       
    58  * supported resolutions, and specify the one that most closely meets
       
    59  * the client's requirements.
       
    60  * In some cases this may be more simply achieved by specifying a
       
    61  * PrintQuality attribute which often controls resolution.
       
    62  * <P>
       
    63  * <B>IPP Compatibility:</B> The information needed to construct an IPP
       
    64  * {@code "printer-resolution"} attribute can be obtained by calling
       
    65  * methods on the PrinterResolution object. The category name returned by
       
    66  * {@code getName()} gives the IPP attribute name.
       
    67  *
       
    68  * @author  David Mendenhall
       
    69  * @author  Alan Kaminsky
       
    70  */
    67  */
    71 public final class PrinterResolution    extends ResolutionSyntax
    68 public final class PrinterResolution    extends ResolutionSyntax
    72         implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
    69         implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
    73 
    70 
       
    71     /**
       
    72      * Use serialVersionUID from JDK 1.4 for interoperability.
       
    73      */
    74     private static final long serialVersionUID = 13090306561090558L;
    74     private static final long serialVersionUID = 13090306561090558L;
    75 
    75 
    76     /**
    76     /**
    77      * Construct a new printer resolution attribute from the given items.
    77      * Construct a new printer resolution attribute from the given items.
    78      *
    78      *
    79      * @param  crossFeedResolution
    79      * @param  crossFeedResolution cross feed direction resolution
    80      *     Cross feed direction resolution.
    80      * @param  feedResolution feed direction resolution
    81      * @param  feedResolution
    81      * @param  units unit conversion factor, e.g. {@code ResolutionSyntax.DPI}
    82      *     Feed direction resolution.
    82      *         or {@code ResolutionSyntax.DPCM}
    83      * @param  units
    83      * @throws IllegalArgumentException if {@code crossFeedResolution < 1} or
    84      *    Unit conversion factor, e.g. {@code ResolutionSyntax.DPI}
    84      *         {@code feedResolution < 1} or {@code units < 1}
    85      * or {@code ResolutionSyntax.DPCM}.
       
    86      *
       
    87      * @exception  IllegalArgumentException
       
    88      *     (unchecked exception) Thrown if {@code crossFeedResolution < 1} or
       
    89      *     {@code feedResolution < 1} or {@code units < 1}.
       
    90      */
    85      */
    91     public PrinterResolution(int crossFeedResolution, int feedResolution,
    86     public PrinterResolution(int crossFeedResolution, int feedResolution,
    92                              int units) {
    87                              int units) {
    93         super (crossFeedResolution, feedResolution, units);
    88         super (crossFeedResolution, feedResolution, units);
    94     }
    89     }
    95 
    90 
    96     /**
    91     /**
    97      * Returns whether this printer resolution attribute is equivalent to the
    92      * Returns whether this printer resolution attribute is equivalent to the
    98      * passed in object. To be equivalent, all of the following conditions
    93      * passed in object. To be equivalent, all of the following conditions must
    99      * must be true:
    94      * be true:
   100      * <OL TYPE=1>
    95      * <ol type=1>
   101      * <LI>
    96      *   <li>{@code object} is not {@code null}.
   102      * {@code object} is not null.
    97      *   <li>{@code object} is an instance of class {@code PrinterResolution}.
   103      * <LI>
    98      *   <li>This attribute's cross feed direction resolution is equal to
   104      * {@code object} is an instance of class PrinterResolution.
    99      *   {@code object}'s cross feed direction resolution.
   105      * <LI>
   100      *   <li>This attribute's feed direction resolution is equal to
   106      * This attribute's cross feed direction resolution is equal to
   101      *   {@code object}'s feed direction resolution.
   107      * {@code object}'s cross feed direction resolution.
   102      * </ol>
   108      * <LI>
       
   109      * This attribute's feed direction resolution is equal to
       
   110      * {@code object}'s feed direction resolution.
       
   111      * </OL>
       
   112      *
   103      *
   113      * @param  object  Object to compare to.
   104      * @param  object {@code Object} to compare to
   114      *
   105      * @return {@code true} if {@code object} is equivalent to this printer
   115      * @return  True if {@code object} is equivalent to this printer
   106      *         resolution attribute, {@code false} otherwise
   116      *          resolution attribute, false otherwise.
       
   117      */
   107      */
   118     public boolean equals(Object object) {
   108     public boolean equals(Object object) {
   119         return (super.equals (object) &&
   109         return (super.equals (object) &&
   120                 object instanceof PrinterResolution);
   110                 object instanceof PrinterResolution);
   121     }
   111     }
   122 
   112 
   123     /**
   113     /**
   124      * Get the printing attribute class which is to be used as the "category"
   114      * Get the printing attribute class which is to be used as the "category"
   125      * for this printing attribute value.
   115      * for this printing attribute value.
   126      * <P>
   116      * <p>
   127      * For class PrinterResolution, the category is class PrinterResolution itself.
   117      * For class {@code PrinterResolution}, the category is class
       
   118      * {@code PrinterResolution} itself.
   128      *
   119      *
   129      * @return  Printing attribute class (category), an instance of class
   120      * @return printing attribute class (category), an instance of class
   130      *          {@link java.lang.Class java.lang.Class}.
   121      *         {@link Class java.lang.Class}
   131      */
   122      */
   132     public final Class<? extends Attribute> getCategory() {
   123     public final Class<? extends Attribute> getCategory() {
   133         return PrinterResolution.class;
   124         return PrinterResolution.class;
   134                 }
   125     }
   135 
   126 
   136     /**
   127     /**
   137      * Get the name of the category of which this attribute value is an
   128      * Get the name of the category of which this attribute value is an
   138      * instance.
   129      * instance.
   139      * <P>
   130      * <p>
   140      * For class PrinterResolution, the
   131      * For class {@code PrinterResolution}, the category name is
   141      * category name is {@code "printer-resolution"}.
   132      * {@code "printer-resolution"}.
   142      *
   133      *
   143      * @return  Attribute category name.
   134      * @return attribute category name
   144      */
   135      */
   145     public final String getName() {
   136     public final String getName() {
   146         return "printer-resolution";
   137         return "printer-resolution";
   147     }
   138     }
   148 
       
   149 }
   139 }