1. /*
  2. * @(#)PrinterResolution.java 1.6 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.print.attribute.standard;
  8. import javax.print.attribute.ResolutionSyntax;
  9. import javax.print.attribute.DocAttribute;
  10. import javax.print.attribute.PrintRequestAttribute;
  11. import javax.print.attribute.PrintJobAttribute;
  12. /**
  13. * Class PrinterResolution is a printing attribute class that specifies an
  14. * exact resolution supported by a printer or to be used for a print job.
  15. * This attribute assumes that printers have a small set of device resolutions
  16. * at which they can operate rather than a continuum.
  17. * <p>
  18. * PrinterResolution is used in multiple ways:
  19. * <OL TYPE=1>
  20. * <LI>
  21. * When a client searches looking for a printer that supports the client's
  22. * desired resolution exactly (no more, no less), the client specifies
  23. * an instance of class PrinterResolution indicating the exact resolution the
  24. * client wants. Only printers supporting that exact resolution will match the
  25. * search.
  26. * <P>
  27. * <LI>
  28. * When a client needs to print a job using the client's desired resolution
  29. * exactly (no more, no less), the client specifies an instance of class
  30. * PrinterResolution as an attribute of the Print Job. This will fail if the
  31. * Print Job doesn't support that exact resolution, and Fidelity is set to
  32. * true.
  33. * </OL>
  34. * If a client wants to locate a printer supporting a resolution
  35. * greater than some required minimum, then it may be necessary to exclude
  36. * this attribute from a lookup request and to directly query the set of
  37. * supported resolutions, and specify the one that most closely meets
  38. * the client's requirements.
  39. * In some cases this may be more simply achieved by specifying a
  40. * PrintQuality attribute which often controls resolution.
  41. * <P>
  42. * <P>
  43. * <B>IPP Compatibility:</B> The information needed to construct an IPP
  44. * <CODE>"printer-resolution"</CODE> attribute can be obtained by calling
  45. * methods on the PrinterResolution object. The category name returned by
  46. * <CODE>getName()</CODE> gives the IPP attribute name.
  47. * <P>
  48. *
  49. * @author David Mendenhall
  50. * @author Alan Kaminsky
  51. */
  52. public final class PrinterResolution extends ResolutionSyntax
  53. implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
  54. /**
  55. * Construct a new printer resolution attribute from the given items.
  56. *
  57. * @param crossFeedResolution
  58. * Cross feed direction resolution.
  59. * @param feedResolution
  60. * Feed direction resolution.
  61. * @param units
  62. * Unit conversion factor, e.g. <code>ResolutionSyntax.DPI</CODE>
  63. * or <code>ResolutionSyntax.>DPCM</CODE>.
  64. *
  65. * @exception IllegalArgumentException
  66. * (unchecked exception) Thrown if <CODE>crossFeedResolution</CODE> <
  67. * 1 or <CODE>feedResolution</CODE> < 1 or <CODE>units</CODE> < 1.
  68. */
  69. public PrinterResolution(int crossFeedResolution, int feedResolution,
  70. int units) {
  71. super (crossFeedResolution, feedResolution, units);
  72. }
  73. /**
  74. * Returns whether this printer resolution attribute is equivalent to the
  75. * passed in object. To be equivalent, all of the following conditions
  76. * must be true:
  77. * <OL TYPE=1>
  78. * <LI>
  79. * <CODE>object</CODE> is not null.
  80. * <LI>
  81. * <CODE>object</CODE> is an instance of class PrinterResolution.
  82. * <LI>
  83. * This attribute's cross feed direction resolution is equal to
  84. * <CODE>object</CODE>'s cross feed direction resolution.
  85. * <LI>
  86. * This attribute's feed direction resolution is equal to
  87. * <CODE>object</CODE>'s feed direction resolution.
  88. * </OL>
  89. *
  90. * @param object Object to compare to.
  91. *
  92. * @return True if <CODE>object</CODE> is equivalent to this printer
  93. * resolution attribute, false otherwise.
  94. */
  95. public boolean equals(Object object) {
  96. return (super.equals (object) &&
  97. object instanceof PrinterResolution);
  98. }
  99. /**
  100. * Get the printing attribute class which is to be used as the "category"
  101. * for this printing attribute value.
  102. * <P>
  103. * For class PrinterResolution, the category is class PrinterResolution itself.
  104. *
  105. * @return Printing attribute class (category), an instance of class
  106. * {@link java.lang.Class java.lang.Class}.
  107. */
  108. public final Class getCategory() {
  109. return PrinterResolution.class;
  110. }
  111. /**
  112. * Get the name of the category of which this attribute value is an
  113. * instance.
  114. * <P>
  115. * For class PrinterResolution, the
  116. * category name is <CODE>"printer-resolution"</CODE>.
  117. *
  118. * @return Attribute category name.
  119. */
  120. public final String getName() {
  121. return "printer-resolution";
  122. }
  123. }