Methods Summary |
---|
public java.lang.Object | clone()Creates and returns a copy of this PageAttributes.
try {
return super.clone();
} catch (CloneNotSupportedException e) {
// Since we implement Cloneable, this should never happen
throw new InternalError();
}
|
public boolean | equals(java.lang.Object obj)Determines whether two PageAttributes are equal to each other.
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.
if (!(obj instanceof PageAttributes)) {
return false;
}
PageAttributes rhs = (PageAttributes)obj;
return (color == rhs.color &&
media == rhs.media &&
orientationRequested == rhs.orientationRequested &&
origin == rhs.origin &&
printQuality == rhs.printQuality &&
printerResolution[0] == rhs.printerResolution[0] &&
printerResolution[1] == rhs.printerResolution[1] &&
printerResolution[2] == rhs.printerResolution[2]);
|
public java.awt.PageAttributes$ColorType | getColor()Returns whether pages using these attributes will be rendered in
color or monochrome. This attribute is updated to the value chosen
by the user.
return color;
|
public java.awt.PageAttributes$MediaType | getMedia()Returns the paper size for pages using these attributes. This
attribute is updated to the value chosen by the user.
return media;
|
public java.awt.PageAttributes$OrientationRequestedType | getOrientationRequested()Returns the print orientation for pages using these attributes. This
attribute is updated to the value chosen by the user.
return orientationRequested;
|
public java.awt.PageAttributes$OriginType | getOrigin()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. (Note that these locations
could be equivalent.) This attribute cannot be modified by,
and is not subject to any limitations of, the implementation or the
target printer.
return origin;
|
public java.awt.PageAttributes$PrintQualityType | getPrintQuality()Returns the print quality for pages using these attributes. This
attribute is updated to the value chosen by the user.
return printQuality;
|
public int[] | getPrinterResolution()Returns the print resolution for pages using these attributes.
Index 0 of the array specifies the cross feed direction resolution
(typically the horizontal resolution). Index 1 of the array specifies
the feed direction resolution (typically the vertical resolution).
Index 2 of the array specifies whether the resolutions are in dots per
inch or dots per centimeter. 3 denotes dots per inch.
4 denotes dots per centimeter.
// Return a copy because otherwise client code could circumvent the
// the checks made in setPrinterResolution by modifying the
// returned array.
int[] copy = new int[3];
copy[0] = printerResolution[0];
copy[1] = printerResolution[1];
copy[2] = printerResolution[2];
return copy;
|
public int | hashCode()Returns a hash code value for this PageAttributes.
return (color.hashCode() << 31 ^
media.hashCode() << 24 ^
orientationRequested.hashCode() << 23 ^
origin.hashCode() << 22 ^
printQuality.hashCode() << 20 ^
printerResolution[2] >> 2 << 19 ^
printerResolution[1] << 10 ^
printerResolution[0]);
|
public void | set(java.awt.PageAttributes obj)Sets all of the attributes of this PageAttributes to the same values as
the attributes of obj.
color = obj.color;
media = obj.media;
orientationRequested = obj.orientationRequested;
origin = obj.origin;
printQuality = obj.printQuality;
// okay because we never modify the contents of printerResolution
printerResolution = obj.printerResolution;
|
public void | setColor(java.awt.PageAttributes$ColorType color)Specifies whether pages using these attributes will be rendered in
color or monochrome. Not specifying this attribute is equivalent to
specifying ColorType.MONOCHROME.
if (color == null) {
throw new IllegalArgumentException("Invalid value for attribute "+
"color");
}
this.color = color;
|
public void | setMedia(java.awt.PageAttributes$MediaType media)Specifies the desired paper size for pages using these attributes. The
actual paper size will be determined by the limitations of the target
printer. If an exact match cannot be found, an implementation will
choose the closest possible match. Not specifying this attribute is
equivalent to specifying the default size for the default locale. The
default size for locales in the United States and Canada is
MediaType.NA_LETTER. The default size for all other locales is
MediaType.ISO_A4.
if (media == null) {
throw new IllegalArgumentException("Invalid value for attribute "+
"media");
}
this.media = media;
|
public void | setMediaToDefault()Sets the paper size for pages using these attributes to the default
size for the default locale. The default size for locales in the
United States and Canada is MediaType.NA_LETTER. The default size for
all other locales is MediaType.ISO_A4.
String defaultCountry = Locale.getDefault().getCountry();
if (defaultCountry != null &&
(defaultCountry.equals(Locale.US.getCountry()) ||
defaultCountry.equals(Locale.CANADA.getCountry()))) {
setMedia(MediaType.NA_LETTER);
} else {
setMedia(MediaType.ISO_A4);
}
|
public void | setOrientationRequested(java.awt.PageAttributes$OrientationRequestedType orientationRequested)Specifies the print orientation for pages using these attributes. Not
specifying the property is equivalent to specifying
OrientationRequestedType.PORTRAIT.
if (orientationRequested == null) {
throw new IllegalArgumentException("Invalid value for attribute "+
"orientationRequested");
}
this.orientationRequested = orientationRequested;
|
public void | setOrientationRequested(int orientationRequested)Specifies the print orientation for pages using these attributes.
Specifying 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).
switch (orientationRequested) {
case 3:
setOrientationRequested(OrientationRequestedType.PORTRAIT);
break;
case 4:
setOrientationRequested(OrientationRequestedType.LANDSCAPE);
break;
default:
// This will throw an IllegalArgumentException
setOrientationRequested(null);
break;
}
|
public void | setOrientationRequestedToDefault()Sets the print orientation for pages using these attributes to the
default. The default orientation is portrait.
setOrientationRequested(OrientationRequestedType.PORTRAIT);
|
public void | setOrigin(java.awt.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. (Note that these locations
could be equivalent.) Not specifying the property is equivalent to
specifying OriginType.PHYSICAL.
if (origin == null) {
throw new IllegalArgumentException("Invalid value for attribute "+
"origin");
}
this.origin = origin;
|
public void | setPrintQuality(java.awt.PageAttributes$PrintQualityType printQuality)Specifies the print quality for pages using these attributes. Not
specifying the property is equivalent to specifying
PrintQualityType.NORMAL.
if (printQuality == null) {
throw new IllegalArgumentException("Invalid value for attribute "+
"printQuality");
}
this.printQuality = printQuality;
|
public void | setPrintQuality(int printQuality)Specifies the print quality for pages using these attributes.
Specifying 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).
switch (printQuality) {
case 3:
setPrintQuality(PrintQualityType.DRAFT);
break;
case 4:
setPrintQuality(PrintQualityType.NORMAL);
break;
case 5:
setPrintQuality(PrintQualityType.HIGH);
break;
default:
// This will throw an IllegalArgumentException
setPrintQuality(null);
break;
}
|
public void | setPrintQualityToDefault()Sets the print quality for pages using these attributes to the default.
The default print quality is normal.
setPrintQuality(PrintQualityType.NORMAL);
|
public void | setPrinterResolution(int[] printerResolution)Specifies the desired print resolution for pages using these attributes.
The actual resolution will be determined by the limitations of the
implementation and the target printer. Index 0 of the array specifies
the cross feed direction resolution (typically the horizontal
resolution). Index 1 of the array specifies the feed direction
resolution (typically the vertical resolution). Index 2 of the array
specifies whether the resolutions are in dots per inch or dots per
centimeter. 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).
if (printerResolution == null ||
printerResolution.length != 3 ||
printerResolution[0] <= 0 ||
printerResolution[1] <= 0 ||
(printerResolution[2] != 3 && printerResolution[2] != 4)) {
throw new IllegalArgumentException("Invalid value for attribute "+
"printerResolution");
}
// Store a copy because otherwise client code could circumvent the
// the checks made above by holding a reference to the array and
// modifying it after calling setPrinterResolution.
int[] copy = new int[3];
copy[0] = printerResolution[0];
copy[1] = printerResolution[1];
copy[2] = printerResolution[2];
this.printerResolution = copy;
|
public void | setPrinterResolution(int printerResolution)Specifies the desired cross feed and feed print resolutions in dots per
inch for pages using these attributes. The same value is used for both
resolutions. The actual resolutions will be determined by the
limitations of the implementation and the target printer. Not
specifying the property is equivalent to specifying 72 .
setPrinterResolution(new int[] { printerResolution, printerResolution,
3 } );
|
public void | setPrinterResolutionToDefault()Sets the printer resolution for pages using these attributes to the
default. The default is 72 dpi for both the feed and cross feed
resolutions.
setPrinterResolution(72);
|
public java.lang.String | toString()Returns a string representation of this PageAttributes.
// int[] printerResolution = getPrinterResolution();
return "color=" + getColor() + ",media=" + getMedia() +
",orientation-requested=" + getOrientationRequested() +
",origin=" + getOrigin() + ",print-quality=" + getPrintQuality() +
",printer-resolution=[" + printerResolution[0] + "," +
printerResolution[1] + "," + printerResolution[2] + "]";
|