/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A set of attributes which control the output of a printed page.
* <p>
* 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.
* <p>
* 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:
* <pre>
* import java.awt.PageAttributes;
*
* public class MonochromeExample {
* public void setMonochrome(PageAttributes pageAttributes) {
* pageAttributes.setColor(PageAttributes.ColorType.MONOCHROME);
* }
* }
* </pre>
* <p>
* Every IPP attribute which supports an <i>attributeName</i>-default value
* has a corresponding <code>set<i>attributeName</i>ToDefault</code> method.
* Default value fields are not provided.
*
* @author David Mendenhall
* @since 1.3
*/
/**
* A type-safe enumeration of possible color states.
* @since 1.3
*/
"color", "monochrome"
};
/**
* The ColorType instance to use for specifying color printing.
*/
/**
* The ColorType instance to use for specifying monochrome printing.
*/
}
}
/**
* A type-safe enumeration of possible paper sizes. These sizes are in
* compliance with IPP 1.1.
* @since 1.3
*/
"iso-4a0", "iso-2a0", "iso-a0", "iso-a1", "iso-a2", "iso-a3",
"iso-a4", "iso-a5", "iso-a6", "iso-a7", "iso-a8", "iso-a9",
"iso-a10", "iso-b0", "iso-b1", "iso-b2", "iso-b3", "iso-b4",
"iso-b5", "iso-b6", "iso-b7", "iso-b8", "iso-b9", "iso-b10",
"jis-b0", "jis-b1", "jis-b2", "jis-b3", "jis-b4", "jis-b5",
"jis-b6", "jis-b7", "jis-b8", "jis-b9", "jis-b10", "iso-c0",
"iso-c1", "iso-c2", "iso-c3", "iso-c4", "iso-c5", "iso-c6",
"iso-c7", "iso-c8", "iso-c9", "iso-c10", "iso-designated-long",
"executive", "folio", "invoice", "ledger", "na-letter", "na-legal",
"quarto", "a", "b", "c", "d", "e", "na-10x15-envelope",
"na-10x14-envelope", "na-10x13-envelope", "na-9x12-envelope",
"na-9x11-envelope", "na-7x9-envelope", "na-6x9-envelope",
"na-number-9-envelope", "na-number-10-envelope",
"na-number-11-envelope", "na-number-12-envelope",
"na-number-14-envelope", "invite-envelope", "italy-envelope",
"monarch-envelope", "personal-envelope"
};
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
* The MediaType instance for JIS B0, 1030 x 1456 mm.
*/
/**
* The MediaType instance for JIS B1, 728 x 1030 mm.
*/
/**
* The MediaType instance for JIS B2, 515 x 728 mm.
*/
/**
* The MediaType instance for JIS B3, 364 x 515 mm.
*/
/**
* The MediaType instance for JIS B4, 257 x 364 mm.
*/
/**
* The MediaType instance for JIS B5, 182 x 257 mm.
*/
/**
* The MediaType instance for JIS B6, 128 x 182 mm.
*/
/**
* The MediaType instance for JIS B7, 91 x 128 mm.
*/
/**
* The MediaType instance for JIS B8, 64 x 91 mm.
*/
/**
* The MediaType instance for JIS B9, 45 x 64 mm.
*/
/**
* The MediaType instance for JIS B10, 32 x 45 mm.
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
* The MediaType instance for ISO Designated Long, 110 x 220 mm.
*/
/**
* The MediaType instance for Executive, 7 1/4 x 10 1/2 in.
*/
/**
* The MediaType instance for Folio, 8 1/2 x 13 in.
*/
/**
* The MediaType instance for Invoice, 5 1/2 x 8 1/2 in.
*/
/**
* The MediaType instance for Ledger, 11 x 17 in.
*/
/**
* The MediaType instance for North American Letter, 8 1/2 x 11 in.
*/
/**
* The MediaType instance for North American Legal, 8 1/2 x 14 in.
*/
/**
* The MediaType instance for Quarto, 215 x 275 mm.
*/
/**
* The MediaType instance for Engineering A, 8 1/2 x 11 in.
*/
/**
* The MediaType instance for Engineering B, 11 x 17 in.
*/
/**
* The MediaType instance for Engineering C, 17 x 22 in.
*/
/**
* The MediaType instance for Engineering D, 22 x 34 in.
*/
/**
* The MediaType instance for Engineering E, 34 x 44 in.
*/
/**
* The MediaType instance for North American 10 x 15 in.
*/
new MediaType(I_NA_10X15_ENVELOPE);
/**
* The MediaType instance for North American 10 x 14 in.
*/
new MediaType(I_NA_10X14_ENVELOPE);
/**
* The MediaType instance for North American 10 x 13 in.
*/
new MediaType(I_NA_10X13_ENVELOPE);
/**
* The MediaType instance for North American 9 x 12 in.
*/
new MediaType(I_NA_9X12_ENVELOPE);
/**
* The MediaType instance for North American 9 x 11 in.
*/
new MediaType(I_NA_9X11_ENVELOPE);
/**
* The MediaType instance for North American 7 x 9 in.
*/
new MediaType(I_NA_7X9_ENVELOPE);
/**
* The MediaType instance for North American 6 x 9 in.
*/
new MediaType(I_NA_6X9_ENVELOPE);
/**
* The MediaType instance for North American #9 Business Envelope,
* 3 7/8 x 8 7/8 in.
*/
/**
* The MediaType instance for North American #10 Business Envelope,
* 4 1/8 x 9 1/2 in.
*/
/**
* The MediaType instance for North American #11 Business Envelope,
* 4 1/2 x 10 3/8 in.
*/
/**
* The MediaType instance for North American #12 Business Envelope,
* 4 3/4 x 11 in.
*/
/**
* The MediaType instance for North American #14 Business Envelope,
* 5 x 11 1/2 in.
*/
/**
* The MediaType instance for Invitation Envelope, 220 x 220 mm.
*/
new MediaType(I_INVITE_ENVELOPE);
/**
* The MediaType instance for Italy Envelope, 110 x 230 mm.
*/
new MediaType(I_ITALY_ENVELOPE);
/**
* The MediaType instance for Monarch Envelope, 3 7/8 x 7 1/2 in.
*/
new MediaType(I_MONARCH_ENVELOPE);
/**
* The MediaType instance for 6 3/4 envelope, 3 5/8 x 6 1/2 in.
*/
new MediaType(I_PERSONAL_ENVELOPE);
/**
* An alias for ISO_A0.
*/
/**
* An alias for ISO_A1.
*/
/**
* An alias for ISO_A2.
*/
/**
* An alias for ISO_A3.
*/
/**
* An alias for ISO_A4.
*/
/**
* An alias for ISO_A5.
*/
/**
* An alias for ISO_A6.
*/
/**
* An alias for ISO_A7.
*/
/**
* An alias for ISO_A8.
*/
/**
* An alias for ISO_A9.
*/
/**
* An alias for ISO_A10.
*/
/**
* An alias for ISO_B0.
*/
/**
* An alias for ISO_B1.
*/
/**
* An alias for ISO_B2.
*/
/**
* An alias for ISO_B3.
*/
/**
* An alias for ISO_B4.
*/
/**
* An alias for ISO_B4.
*/
/**
* An alias for ISO_B5.
*/
/**
* An alias for ISO_B5.
*/
/**
* An alias for ISO_B6.
*/
/**
* An alias for ISO_B7.
*/
/**
* An alias for ISO_B8.
*/
/**
* An alias for ISO_B9.
*/
/**
* An alias for ISO_B10.
*/
/**
* An alias for ISO_C0.
*/
/**
* An alias for ISO_C0.
*/
/**
* An alias for ISO_C1.
*/
/**
* An alias for ISO_C1.
*/
/**
* An alias for ISO_C2.
*/
/**
* An alias for ISO_C2.
*/
/**
* An alias for ISO_C3.
*/
/**
* An alias for ISO_C3.
*/
/**
* An alias for ISO_C4.
*/
/**
* An alias for ISO_C4.
*/
/**
* An alias for ISO_C5.
*/
/**
* An alias for ISO_C5.
*/
/**
* An alias for ISO_C6.
*/
/**
* An alias for ISO_C6.
*/
/**
* An alias for ISO_C7.
*/
/**
* An alias for ISO_C7.
*/
/**
* An alias for ISO_C8.
*/
/**
* An alias for ISO_C8.
*/
/**
* An alias for ISO_C9.
*/
/**
* An alias for ISO_C9.
*/
/**
* An alias for ISO_C10.
*/
/**
* An alias for ISO_C10.
*/
/**
* An alias for ISO_DESIGNATED_LONG.
*/
/**
* An alias for INVOICE.
*/
/**
* An alias for LEDGER.
*/
/**
* An alias for NA_LETTER.
*/
/**
* An alias for NA_LETTER.
*/
/**
* An alias for NA_LEGAL.
*/
/**
* An alias for NA_10X15_ENVELOPE.
*/
/**
* An alias for NA_10X14_ENVELOPE.
*/
/**
* An alias for NA_10X13_ENVELOPE.
*/
/**
* An alias for NA_9X12_ENVELOPE.
*/
/**
* An alias for NA_9X11_ENVELOPE.
*/
/**
* An alias for NA_7X9_ENVELOPE.
*/
/**
* An alias for NA_6X9_ENVELOPE.
*/
/**
* An alias for NA_NUMBER_9_ENVELOPE.
*/
/**
* An alias for NA_NUMBER_10_ENVELOPE.
*/
/**
* An alias for NA_NUMBER_11_ENVELOPE.
*/
/**
* An alias for NA_NUMBER_12_ENVELOPE.
*/
/**
* An alias for NA_NUMBER_14_ENVELOPE.
*/
/**
* An alias for INVITE_ENVELOPE.
*/
/**
* An alias for ITALY_ENVELOPE.
*/
/**
* An alias for MONARCH_ENVELOPE.
*/
/**
* An alias for PERSONAL_ENVELOPE.
*/
/**
* An alias for INVITE_ENVELOPE.
*/
/**
* An alias for ITALY_ENVELOPE.
*/
/**
* An alias for MONARCH_ENVELOPE.
*/
/**
* An alias for PERSONAL_ENVELOPE.
*/
}
}
/**
* A type-safe enumeration of possible orientations. These orientations
* are in partial compliance with IPP 1.1.
* @since 1.3
*/
"portrait", "landscape"
};
/**
* The OrientationRequestedType instance to use for specifying a
* portrait orientation.
*/
/**
* The OrientationRequestedType instance to use for specifying a
* landscape orientation.
*/
}
}
/**
* A type-safe enumeration of possible origins.
* @since 1.3
*/
"physical", "printable"
};
/**
* The OriginType instance to use for specifying a physical origin.
*/
/**
* The OriginType instance to use for specifying a printable origin.
*/
}
}
/**
* A type-safe enumeration of possible print qualities. These print
* qualities are in compliance with IPP 1.1.
* @since 1.3
*/
"high", "normal", "draft"
};
/**
* The PrintQualityType instance to use for specifying a high print
* quality.
*/
new PrintQualityType(I_HIGH);
/**
* The PrintQualityType instance to use for specifying a normal print
* quality.
*/
new PrintQualityType(I_NORMAL);
/**
* The PrintQualityType instance to use for specifying a draft print
* quality.
*/
new PrintQualityType(I_DRAFT);
}
}
private int[] printerResolution;
/**
* Constructs a PageAttributes instance with default values for every
* attribute.
*/
public PageAttributes() {
}
/**
* Constructs a PageAttributes instance which is a copy of the supplied
* PageAttributes.
*
* @param obj the PageAttributes to copy.
*/
}
/**
* Constructs a PageAttributes instance with the specified values for
* every attribute.
*
* @param color ColorType.COLOR or ColorType.MONOCHROME.
* @param media one of the constant fields of the MediaType class.
* @param orientationRequested OrientationRequestedType.PORTRAIT or
* OrientationRequestedType.LANDSCAPE.
* @param origin OriginType.PHYSICAL or OriginType.PRINTABLE
* @param printQuality PrintQualityType.DRAFT, PrintQualityType.NORMAL,
* or PrintQualityType.HIGH
* @param 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
* <code>3</code> or <code>4</code>.
* @throws IllegalArgumentException if one or more of the above
* conditions is violated.
*/
int[] printerResolution) {
}
/**
* Creates and returns a copy of this PageAttributes.
*
* @return the newly created copy. It is safe to cast this Object into
* a PageAttributes.
*/
try {
return super.clone();
} catch (CloneNotSupportedException e) {
// Since we implement Cloneable, this should never happen
throw new InternalError();
}
}
/**
* Sets all of the attributes of this PageAttributes to the same values as
* the attributes of obj.
*
* @param obj the PageAttributes to copy.
*/
// okay because we never modify the contents of printerResolution
}
/**
* 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 ColorType.COLOR or ColorType.MONOCHROME.
*/
return color;
}
/**
* Specifies whether pages using these attributes will be rendered in
* color or monochrome. Not specifying this attribute is equivalent to
* specifying ColorType.MONOCHROME.
*
* @param color ColorType.COLOR or ColorType.MONOCHROME.
* @throws IllegalArgumentException if color is null.
*/
throw new IllegalArgumentException("Invalid value for attribute "+
"color");
}
}
/**
* Returns the paper size for pages using these attributes. This
* attribute is updated to the value chosen by the user.
*
* @return one of the constant fields of the MediaType class.
*/
return 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.
*
* @param media one of the constant fields of the MediaType class.
* @throws IllegalArgumentException if media is null.
*/
throw new IllegalArgumentException("Invalid value for attribute "+
"media");
}
}
/**
* 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.
*/
public void setMediaToDefault(){
if (defaultCountry != null &&
} else {
}
}
/**
* Returns the print orientation for pages using these attributes. This
* attribute is updated to the value chosen by the user.
*
* @return OrientationRequestedType.PORTRAIT or
* OrientationRequestedType.LANDSCAPE.
*/
return orientationRequested;
}
/**
* Specifies the print orientation for pages using these attributes. Not
* specifying the property is equivalent to specifying
* OrientationRequestedType.PORTRAIT.
*
* @param orientationRequested OrientationRequestedType.PORTRAIT or
* OrientationRequestedType.LANDSCAPE.
* @throws IllegalArgumentException if orientationRequested is null.
*/
if (orientationRequested == null) {
throw new IllegalArgumentException("Invalid value for attribute "+
"orientationRequested");
}
}
/**
* Specifies the print orientation for pages using these attributes.
* Specifying <code>3</code> denotes portrait. Specifying <code>4</code>
* denotes landscape. Specifying any other value will generate an
* IllegalArgumentException. Not specifying the property is equivalent
* to calling setOrientationRequested(OrientationRequestedType.PORTRAIT).
*
* @param orientationRequested <code>3</code> or <code>4</code>
* @throws IllegalArgumentException if orientationRequested is not
* <code>3</code> or <code>4</code>
*/
switch (orientationRequested) {
case 3:
break;
case 4:
break;
default:
// This will throw an IllegalArgumentException
break;
}
}
/**
* Sets the print orientation for pages using these attributes to the
* default. The default orientation is portrait.
*/
public void setOrientationRequestedToDefault() {
}
/**
* 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 OriginType.PHYSICAL or OriginType.PRINTABLE
*/
return 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.
*
* @param origin OriginType.PHYSICAL or OriginType.PRINTABLE
* @throws IllegalArgumentException if origin is null.
*/
throw new IllegalArgumentException("Invalid value for attribute "+
"origin");
}
}
/**
* Returns the print quality for pages using these attributes. This
* attribute is updated to the value chosen by the user.
*
* @return PrintQualityType.DRAFT, PrintQualityType.NORMAL, or
* PrintQualityType.HIGH
*/
return printQuality;
}
/**
* Specifies the print quality for pages using these attributes. Not
* specifying the property is equivalent to specifying
* PrintQualityType.NORMAL.
*
* @param printQuality PrintQualityType.DRAFT, PrintQualityType.NORMAL,
* or PrintQualityType.HIGH
* @throws IllegalArgumentException if printQuality is null.
*/
if (printQuality == null) {
throw new IllegalArgumentException("Invalid value for attribute "+
"printQuality");
}
this.printQuality = printQuality;
}
/**
* Specifies the print quality for pages using these attributes.
* Specifying <code>3</code> denotes draft. Specifying <code>4</code>
* denotes normal. Specifying <code>5</code> denotes high. Specifying
* any other value will generate an IllegalArgumentException. Not
* specifying the property is equivalent to calling
* setPrintQuality(PrintQualityType.NORMAL).
*
* @param printQuality <code>3</code>, <code>4</code>, or <code>5</code>
* @throws IllegalArgumentException if printQuality is not <code>3
* </code>, <code>4</code>, or <code>5</code>
*/
switch (printQuality) {
case 3:
break;
case 4:
break;
case 5:
break;
default:
// This will throw an IllegalArgumentException
break;
}
}
/**
* Sets the print quality for pages using these attributes to the default.
* The default print quality is normal.
*/
public void setPrintQualityToDefault() {
}
/**
* 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. <code>3</code> denotes dots per inch.
* <code>4</code> denotes dots per centimeter.
*
* @return 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
* <code>3</code> or <code>4</code>.
*/
public int[] getPrinterResolution() {
// 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];
return copy;
}
/**
* 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. <code>3</code> denotes dots per inch. <code>4</code>
* 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).
*
* @param 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
* <code>3</code> or <code>4</code>.
* @throws IllegalArgumentException if one or more of the above
* conditions is violated.
*/
if (printerResolution == null ||
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];
this.printerResolution = copy;
}
/**
* 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 <code>72</code>.
*
* @param printerResolution an integer greater than 0.
* @throws IllegalArgumentException if printerResolution is less than or
* equal to 0.
*/
3 } );
}
/**
* 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.
*/
public void setPrinterResolutionToDefault() {
setPrinterResolution(72);
}
/**
* Determines whether two PageAttributes are equal to each other.
* <p>
* 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.
*
* @param obj the object whose equality will be checked.
* @return whether obj is equal to this PageAttribute according to the
* above criteria.
*/
if (!(obj instanceof PageAttributes)) {
return false;
}
}
/**
* Returns a hash code value for this PageAttributes.
*
* @return the hash code.
*/
public int hashCode() {
printerResolution[0]);
}
/**
* Returns a string representation of this PageAttributes.
*
* @return the string representation.
*/
// int[] printerResolution = getPrinterResolution();
",orientation-requested=" + getOrientationRequested() +
}
}