jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterResolution.java
author avstepan
Mon, 11 Jan 2016 17:51:54 +0300
changeset 35667 ed476aba94de
parent 25859 3317bb8137f4
child 47196 a3211bb4daff
permissions -rw-r--r--
8138838: docs cleanup for java.desktop Summary: docs cleanup for java.desktop Reviewed-by: serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
25770
d132697706ea 8037511: Tidy warnings cleanup for java.awt - 2d part
avstepan
parents: 22260
diff changeset
     2
 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.print.attribute.standard;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import javax.print.attribute.Attribute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.print.attribute.ResolutionSyntax;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.print.attribute.DocAttribute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.print.attribute.PrintRequestAttribute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.print.attribute.PrintJobAttribute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * Class PrinterResolution is a printing attribute class that specifies an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * exact resolution supported by a printer or to be used for a print job.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * This attribute assumes that printers have a small set of device resolutions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * at which they can operate rather than a continuum.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * PrinterResolution is used in multiple ways:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <OL TYPE=1>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * When a client searches looking for a printer that supports the client's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * desired resolution exactly (no more, no less), the client specifies
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * an instance of class PrinterResolution indicating the exact resolution the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * client wants. Only printers supporting that exact resolution will match the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * search.
22260
c9185e010e03 8031082: Fix non-missing doclint problems in client libraries
darcy
parents: 19166
diff changeset
    47
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * When a client needs to print a job using the client's desired resolution
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * exactly (no more, no less), the client specifies an instance of class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * PrinterResolution as an attribute of the Print Job. This will fail if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * Print Job doesn't support that exact resolution, and Fidelity is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * </OL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * If a client wants to locate a printer supporting a resolution
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * greater than some required minimum, then it may be necessary to exclude
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * this attribute from a lookup request and to directly query the set of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * supported resolutions, and specify the one that most closely meets
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * the client's requirements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * In some cases this may be more simply achieved by specifying a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * PrintQuality attribute which often controls resolution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <B>IPP Compatibility:</B> The information needed to construct an IPP
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    64
 * {@code "printer-resolution"} attribute can be obtained by calling
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * methods on the PrinterResolution object. The category name returned by
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    66
 * {@code getName()} gives the IPP attribute name.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * @author  David Mendenhall
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * @author  Alan Kaminsky
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
public final class PrinterResolution    extends ResolutionSyntax
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private static final long serialVersionUID = 13090306561090558L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * Construct a new printer resolution attribute from the given items.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * @param  crossFeedResolution
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     *     Cross feed direction resolution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * @param  feedResolution
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *     Feed direction resolution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @param  units
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    84
     *    Unit conversion factor, e.g. {@code ResolutionSyntax.DPI}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    85
     * or {@code ResolutionSyntax.DPCM}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @exception  IllegalArgumentException
19166
e6cd1eb44237 8022175: Fix doclint warnings in javax.print
prr
parents: 5506
diff changeset
    88
     *     (unchecked exception) Thrown if {@code crossFeedResolution < 1} or
e6cd1eb44237 8022175: Fix doclint warnings in javax.print
prr
parents: 5506
diff changeset
    89
     *     {@code feedResolution < 1} or {@code units < 1}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    public PrinterResolution(int crossFeedResolution, int feedResolution,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                             int units) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        super (crossFeedResolution, feedResolution, units);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * Returns whether this printer resolution attribute is equivalent to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * passed in object. To be equivalent, all of the following conditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * must be true:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * <OL TYPE=1>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * <LI>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   102
     * {@code object} is not null.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * <LI>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   104
     * {@code object} is an instance of class PrinterResolution.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * This attribute's cross feed direction resolution is equal to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   107
     * {@code object}'s cross feed direction resolution.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * This attribute's feed direction resolution is equal to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   110
     * {@code object}'s feed direction resolution.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * </OL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @param  object  Object to compare to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   115
     * @return  True if {@code object} is equivalent to this printer
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *          resolution attribute, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    public boolean equals(Object object) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        return (super.equals (object) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                object instanceof PrinterResolution);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * Get the printing attribute class which is to be used as the "category"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * for this printing attribute value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * For class PrinterResolution, the category is class PrinterResolution itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @return  Printing attribute class (category), an instance of class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *          {@link java.lang.Class java.lang.Class}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public final Class<? extends Attribute> getCategory() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        return PrinterResolution.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * Get the name of the category of which this attribute value is an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * For class PrinterResolution, the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   141
     * category name is {@code "printer-resolution"}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @return  Attribute category name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    public final String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        return "printer-resolution";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
}