| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public final class PageAttributes extends Object implements Cloneable
A set of attributes which control the output of a printed page.
Instances of this class control the color state, paper size (media type), orientation, logical origin, print quality, and resolution of every page which uses the instance. Attribute names are compliant with the Internet Printing Protocol (IPP) 1.1 where possible. Attribute values are partially compliant where possible.
To use a method which takes an inner class type, pass a reference to one of the constant fields of the inner class. Client code cannot create new instances of the inner class types because none of those classes has a public constructor. For example, to set the color state to monochrome, use the following code:
import java.awt.PageAttributes; public class MonochromeExample { public void setMonochrome(PageAttributes pageAttributes) { pageAttributes.setColor(PageAttributes.ColorType.MONOCHROME); } }
Every IPP attribute which supports an attributeName-default value
has a corresponding setattributeNameToDefault
method.
Default value fields are not provided.
Nested Class Summary | |
---|---|
static class |
A type-safe enumeration of possible color states. |
static class |
A type-safe enumeration of possible paper sizes. |
static class |
A type-safe enumeration of possible orientations. |
static class |
A type-safe enumeration of possible origins. |
static class |
A type-safe enumeration of possible print qualities. |
Constructor Summary | |
---|---|
Constructs a PageAttributes instance with default values for every attribute. |
|
Constructs a PageAttributes instance which is a copy of the supplied PageAttributes. |
|
PageAttributes(PageAttributes.ColorType color, PageAttributes.MediaType media, PageAttributes.OrientationRequestedType orientationRequested, PageAttributes.OriginType origin, PageAttributes.PrintQualityType printQuality, int[] printerResolution) Constructs a PageAttributes instance with the specified values for every attribute. |
Method Summary | |
---|---|
Object |
clone() Creates and returns a copy of this PageAttributes. |
boolean |
Determines whether two PageAttributes are equal to each other. |
PageAttributes.ColorType |
getColor() Returns whether pages using these attributes will be rendered in color or monochrome. |
PageAttributes.MediaType |
getMedia() Returns the paper size for pages using these attributes. |
PageAttributes.OrientationRequestedType |
Returns the print orientation for pages using these attributes. |
PageAttributes.OriginType |
Returns whether drawing at (0, 0) to pages using these attributes draws at the upper-left corner of the physical page, or at the upper-left corner of the printable area. |
int[] |
Returns the print resolution for pages using these attributes. |
PageAttributes.PrintQualityType |
Returns the print quality for pages using these attributes. |
int |
hashCode() Returns a hash code value for this PageAttributes. |
void |
set(PageAttributes obj) Sets all of the attributes of this PageAttributes to the same values as the attributes of obj. |
void |
setColor(PageAttributes.ColorType color) Specifies whether pages using these attributes will be rendered in color or monochrome. |
void |
setMedia(PageAttributes.MediaType media) Specifies the desired paper size for pages using these attributes. |
void |
Sets the paper size for pages using these attributes to the default size for the default locale. |
void |
setOrientationRequested(int orientationRequested) Specifies the print orientation for pages using these attributes. |
void |
setOrientationRequested(PageAttributes.OrientationRequestedType orientationRequested) Specifies the print orientation for pages using these attributes. |
void |
Sets the print orientation for pages using these attributes to the default. |
void |
setOrigin(PageAttributes.OriginType origin) Specifies whether drawing at (0, 0) to pages using these attributes draws at the upper-left corner of the physical page, or at the upper-left corner of the printable area. |
void |
setPrinterResolution(int printerResolution) Specifies the desired cross feed and feed print resolutions in dots per inch for pages using these attributes. |
void |
setPrinterResolution(int[] printerResolution) Specifies the desired print resolution for pages using these attributes. |
void |
Sets the printer resolution for pages using these attributes to the default. |
void |
setPrintQuality(int printQuality) Specifies the print quality for pages using these attributes. |
void |
setPrintQuality(PageAttributes.PrintQualityType printQuality) Specifies the print quality for pages using these attributes. |
void |
Sets the print quality for pages using these attributes to the default. |
String |
toString() Returns a string representation of this PageAttributes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PageAttributes()
public PageAttributes(PageAttributes obj)
obj
- the PageAttributes to copy.public PageAttributes(PageAttributes.ColorType color, PageAttributes.MediaType media, PageAttributes.OrientationRequestedType orientationRequested, PageAttributes.OriginType origin, PageAttributes.PrintQualityType printQuality, int[] printerResolution)
color
- ColorType.COLOR or ColorType.MONOCHROME.media
- one of the constant fields of the MediaType class.orientationRequested
- OrientationRequestedType.PORTRAIT or
OrientationRequestedType.LANDSCAPE.origin
- OriginType.PHYSICAL or OriginType.PRINTABLEprintQuality
- PrintQualityType.DRAFT, PrintQualityType.NORMAL,
or PrintQualityType.HIGHprinterResolution
- an integer array of 3 elements. The first
element must be greater than 0. The second element must be
must be greater than 0. The third element must be either
3
or 4
.Method Detail |
---|
public Object clone()
clone
in class Object
public boolean equals(Object obj)
Two PageAttributes are equal if and only if each of their attributes are equal. Attributes of enumeration type are equal if and only if the fields refer to the same unique enumeration object. This means that an aliased media is equal to its underlying unique media. Printer resolutions are equal if and only if the feed resolution, cross feed resolution, and units are equal.
equals
in class Object
obj
- the object whose equality will be checked.public PageAttributes.ColorType getColor()
public PageAttributes.MediaType getMedia()
public PageAttributes.OrientationRequestedType getOrientationRequested()
public PageAttributes.OriginType getOrigin()
public int[] getPrinterResolution()
3
denotes dots per inch.
4
denotes dots per centimeter.
3
or 4
.public PageAttributes.PrintQualityType getPrintQuality()
public int hashCode()
hashCode
in class Object
public void set(PageAttributes obj)
obj
- the PageAttributes to copy.public void setColor(PageAttributes.ColorType color)
color
- ColorType.COLOR or ColorType.MONOCHROME.public void setMedia(PageAttributes.MediaType media)
media
- one of the constant fields of the MediaType class.public void setMediaToDefault()
public void setOrientationRequested(int orientationRequested)
3
denotes portrait. Specifying 4
denotes landscape. Specifying any other value will generate an
IllegalArgumentException. Not specifying the property is equivalent
to calling setOrientationRequested(OrientationRequestedType.PORTRAIT).
orientationRequested
- 3
or 4
public void setOrientationRequested(PageAttributes.OrientationRequestedType orientationRequested)
orientationRequested
- OrientationRequestedType.PORTRAIT or
OrientationRequestedType.LANDSCAPE.public void setOrientationRequestedToDefault()
public void setOrigin(PageAttributes.OriginType origin)
origin
- OriginType.PHYSICAL or OriginType.PRINTABLEpublic void setPrinterResolution(int printerResolution)
72
.
printerResolution
- an integer greater than 0.public void setPrinterResolution(int[] printerResolution)
3
denotes dots per inch. 4
denotes dots per centimeter. Note that the 1.1 printing implementation
(Toolkit.getPrintJob) requires that the feed and cross feed resolutions
be the same. Not specifying the property is equivalent to calling
setPrinterResolution(72).
printerResolution
- an integer array of 3 elements. The first
element must be greater than 0. The second element must be
must be greater than 0. The third element must be either
3
or 4
.public void setPrinterResolutionToDefault()
public void setPrintQuality(int printQuality)
3
denotes draft. Specifying 4
denotes normal. Specifying 5
denotes high. Specifying
any other value will generate an IllegalArgumentException. Not
specifying the property is equivalent to calling
setPrintQuality(PrintQualityType.NORMAL).
printQuality
- 3
, 4
, or 5
public void setPrintQuality(PageAttributes.PrintQualityType printQuality)
printQuality
- PrintQualityType.DRAFT, PrintQualityType.NORMAL,
or PrintQualityType.HIGHpublic void setPrintQualityToDefault()
public String toString()
toString
in class Object
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |