home *** CD-ROM | disk | FTP | other *** search
- package java.awt;
-
- import java.util.Locale;
-
- public final class PageAttributes implements Cloneable {
- private ColorType color;
- private MediaType media;
- private OrientationRequestedType orientationRequested;
- private OriginType origin;
- private PrintQualityType printQuality;
- private int[] printerResolution;
-
- public PageAttributes() {
- this.setColor(java.awt.PageAttributes.ColorType.MONOCHROME);
- this.setMediaToDefault();
- this.setOrientationRequestedToDefault();
- this.setOrigin(java.awt.PageAttributes.OriginType.PHYSICAL);
- this.setPrintQualityToDefault();
- this.setPrinterResolutionToDefault();
- }
-
- public PageAttributes(PageAttributes var1) {
- this.set(var1);
- }
-
- public PageAttributes(ColorType var1, MediaType var2, OrientationRequestedType var3, OriginType var4, PrintQualityType var5, int[] var6) {
- this.setColor(var1);
- this.setMedia(var2);
- this.setOrientationRequested(var3);
- this.setOrigin(var4);
- this.setPrintQuality(var5);
- this.setPrinterResolution(var6);
- }
-
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException var2) {
- throw new InternalError();
- }
- }
-
- public void set(PageAttributes var1) {
- this.color = var1.color;
- this.media = var1.media;
- this.orientationRequested = var1.orientationRequested;
- this.origin = var1.origin;
- this.printQuality = var1.printQuality;
- this.printerResolution = var1.printerResolution;
- }
-
- public ColorType getColor() {
- return this.color;
- }
-
- public void setColor(ColorType var1) {
- if (var1 == null) {
- throw new IllegalArgumentException("Invalid value for attribute color");
- } else {
- this.color = var1;
- }
- }
-
- public MediaType getMedia() {
- return this.media;
- }
-
- public void setMedia(MediaType var1) {
- if (var1 == null) {
- throw new IllegalArgumentException("Invalid value for attribute media");
- } else {
- this.media = var1;
- }
- }
-
- public void setMediaToDefault() {
- String var1 = Locale.getDefault().getCountry();
- if (var1 == null || !var1.equals(Locale.US.getCountry()) && !var1.equals(Locale.CANADA.getCountry())) {
- this.setMedia(java.awt.PageAttributes.MediaType.ISO_A4);
- } else {
- this.setMedia(java.awt.PageAttributes.MediaType.NA_LETTER);
- }
-
- }
-
- public OrientationRequestedType getOrientationRequested() {
- return this.orientationRequested;
- }
-
- public void setOrientationRequested(OrientationRequestedType var1) {
- if (var1 == null) {
- throw new IllegalArgumentException("Invalid value for attribute orientationRequested");
- } else {
- this.orientationRequested = var1;
- }
- }
-
- public void setOrientationRequested(int var1) {
- switch (var1) {
- case 3:
- this.setOrientationRequested(java.awt.PageAttributes.OrientationRequestedType.PORTRAIT);
- break;
- case 4:
- this.setOrientationRequested(java.awt.PageAttributes.OrientationRequestedType.LANDSCAPE);
- break;
- default:
- this.setOrientationRequested((OrientationRequestedType)null);
- }
-
- }
-
- public void setOrientationRequestedToDefault() {
- this.setOrientationRequested(java.awt.PageAttributes.OrientationRequestedType.PORTRAIT);
- }
-
- public OriginType getOrigin() {
- return this.origin;
- }
-
- public void setOrigin(OriginType var1) {
- if (var1 == null) {
- throw new IllegalArgumentException("Invalid value for attribute origin");
- } else {
- this.origin = var1;
- }
- }
-
- public PrintQualityType getPrintQuality() {
- return this.printQuality;
- }
-
- public void setPrintQuality(PrintQualityType var1) {
- if (var1 == null) {
- throw new IllegalArgumentException("Invalid value for attribute printQuality");
- } else {
- this.printQuality = var1;
- }
- }
-
- public void setPrintQuality(int var1) {
- switch (var1) {
- case 3:
- this.setPrintQuality(java.awt.PageAttributes.PrintQualityType.DRAFT);
- break;
- case 4:
- this.setPrintQuality(java.awt.PageAttributes.PrintQualityType.NORMAL);
- break;
- case 5:
- this.setPrintQuality(java.awt.PageAttributes.PrintQualityType.HIGH);
- break;
- default:
- this.setPrintQuality((PrintQualityType)null);
- }
-
- }
-
- public void setPrintQualityToDefault() {
- this.setPrintQuality(java.awt.PageAttributes.PrintQualityType.NORMAL);
- }
-
- public int[] getPrinterResolution() {
- int[] var1 = new int[]{this.printerResolution[0], this.printerResolution[1], this.printerResolution[2]};
- return var1;
- }
-
- public void setPrinterResolution(int[] var1) {
- if (var1 != null && var1.length == 3 && var1[0] > 0 && var1[1] > 0 && (var1[2] == 3 || var1[2] == 4)) {
- int[] var2 = new int[]{var1[0], var1[1], var1[2]};
- this.printerResolution = var2;
- } else {
- throw new IllegalArgumentException("Invalid value for attribute printerResolution");
- }
- }
-
- public void setPrinterResolution(int var1) {
- this.setPrinterResolution(new int[]{var1, var1, 3});
- }
-
- public void setPrinterResolutionToDefault() {
- this.setPrinterResolution(72);
- }
-
- public boolean equals(Object var1) {
- if (!(var1 instanceof PageAttributes)) {
- return false;
- } else {
- PageAttributes var2 = (PageAttributes)var1;
- return this.color == var2.color && this.media == var2.media && this.orientationRequested == var2.orientationRequested && this.origin == var2.origin && this.printQuality == var2.printQuality && this.printerResolution[0] == var2.printerResolution[0] && this.printerResolution[1] == var2.printerResolution[1] && this.printerResolution[2] == var2.printerResolution[2];
- }
- }
-
- public int hashCode() {
- return this.color.hashCode() << 31 ^ this.media.hashCode() << 24 ^ this.orientationRequested.hashCode() << 23 ^ this.origin.hashCode() << 22 ^ this.printQuality.hashCode() << 20 ^ this.printerResolution[2] >> 2 << 19 ^ this.printerResolution[1] << 10 ^ this.printerResolution[0];
- }
-
- public String toString() {
- return "color=" + this.getColor() + ",media=" + this.getMedia() + ",orientation-requested=" + this.getOrientationRequested() + ",origin=" + this.getOrigin() + ",print-quality=" + this.getPrintQuality() + ",printer-resolution=[" + this.printerResolution[0] + "," + this.printerResolution[1] + "," + this.printerResolution[2] + "]";
- }
- }
-