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