home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / java / awt / PageAttributes.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  4.9 KB  |  200 lines

  1. package java.awt;
  2.  
  3. import java.util.Locale;
  4.  
  5. public final class PageAttributes implements Cloneable {
  6.    private ColorType color;
  7.    private MediaType media;
  8.    private OrientationRequestedType orientationRequested;
  9.    private OriginType origin;
  10.    private PrintQualityType printQuality;
  11.    private int[] printerResolution;
  12.  
  13.    public PageAttributes() {
  14.       this.setColor(java.awt.PageAttributes.ColorType.MONOCHROME);
  15.       this.setMediaToDefault();
  16.       this.setOrientationRequestedToDefault();
  17.       this.setOrigin(java.awt.PageAttributes.OriginType.PHYSICAL);
  18.       this.setPrintQualityToDefault();
  19.       this.setPrinterResolutionToDefault();
  20.    }
  21.  
  22.    public PageAttributes(PageAttributes var1) {
  23.       this.set(var1);
  24.    }
  25.  
  26.    public PageAttributes(ColorType var1, MediaType var2, OrientationRequestedType var3, OriginType var4, PrintQualityType var5, int[] var6) {
  27.       this.setColor(var1);
  28.       this.setMedia(var2);
  29.       this.setOrientationRequested(var3);
  30.       this.setOrigin(var4);
  31.       this.setPrintQuality(var5);
  32.       this.setPrinterResolution(var6);
  33.    }
  34.  
  35.    public Object clone() {
  36.       try {
  37.          return super.clone();
  38.       } catch (CloneNotSupportedException var2) {
  39.          throw new InternalError();
  40.       }
  41.    }
  42.  
  43.    public void set(PageAttributes var1) {
  44.       this.color = var1.color;
  45.       this.media = var1.media;
  46.       this.orientationRequested = var1.orientationRequested;
  47.       this.origin = var1.origin;
  48.       this.printQuality = var1.printQuality;
  49.       this.printerResolution = var1.printerResolution;
  50.    }
  51.  
  52.    public ColorType getColor() {
  53.       return this.color;
  54.    }
  55.  
  56.    public void setColor(ColorType var1) {
  57.       if (var1 == null) {
  58.          throw new IllegalArgumentException("Invalid value for attribute color");
  59.       } else {
  60.          this.color = var1;
  61.       }
  62.    }
  63.  
  64.    public MediaType getMedia() {
  65.       return this.media;
  66.    }
  67.  
  68.    public void setMedia(MediaType var1) {
  69.       if (var1 == null) {
  70.          throw new IllegalArgumentException("Invalid value for attribute media");
  71.       } else {
  72.          this.media = var1;
  73.       }
  74.    }
  75.  
  76.    public void setMediaToDefault() {
  77.       String var1 = Locale.getDefault().getCountry();
  78.       if (var1 == null || !var1.equals(Locale.US.getCountry()) && !var1.equals(Locale.CANADA.getCountry())) {
  79.          this.setMedia(java.awt.PageAttributes.MediaType.ISO_A4);
  80.       } else {
  81.          this.setMedia(java.awt.PageAttributes.MediaType.NA_LETTER);
  82.       }
  83.  
  84.    }
  85.  
  86.    public OrientationRequestedType getOrientationRequested() {
  87.       return this.orientationRequested;
  88.    }
  89.  
  90.    public void setOrientationRequested(OrientationRequestedType var1) {
  91.       if (var1 == null) {
  92.          throw new IllegalArgumentException("Invalid value for attribute orientationRequested");
  93.       } else {
  94.          this.orientationRequested = var1;
  95.       }
  96.    }
  97.  
  98.    public void setOrientationRequested(int var1) {
  99.       switch (var1) {
  100.          case 3:
  101.             this.setOrientationRequested(java.awt.PageAttributes.OrientationRequestedType.PORTRAIT);
  102.             break;
  103.          case 4:
  104.             this.setOrientationRequested(java.awt.PageAttributes.OrientationRequestedType.LANDSCAPE);
  105.             break;
  106.          default:
  107.             this.setOrientationRequested((OrientationRequestedType)null);
  108.       }
  109.  
  110.    }
  111.  
  112.    public void setOrientationRequestedToDefault() {
  113.       this.setOrientationRequested(java.awt.PageAttributes.OrientationRequestedType.PORTRAIT);
  114.    }
  115.  
  116.    public OriginType getOrigin() {
  117.       return this.origin;
  118.    }
  119.  
  120.    public void setOrigin(OriginType var1) {
  121.       if (var1 == null) {
  122.          throw new IllegalArgumentException("Invalid value for attribute origin");
  123.       } else {
  124.          this.origin = var1;
  125.       }
  126.    }
  127.  
  128.    public PrintQualityType getPrintQuality() {
  129.       return this.printQuality;
  130.    }
  131.  
  132.    public void setPrintQuality(PrintQualityType var1) {
  133.       if (var1 == null) {
  134.          throw new IllegalArgumentException("Invalid value for attribute printQuality");
  135.       } else {
  136.          this.printQuality = var1;
  137.       }
  138.    }
  139.  
  140.    public void setPrintQuality(int var1) {
  141.       switch (var1) {
  142.          case 3:
  143.             this.setPrintQuality(java.awt.PageAttributes.PrintQualityType.DRAFT);
  144.             break;
  145.          case 4:
  146.             this.setPrintQuality(java.awt.PageAttributes.PrintQualityType.NORMAL);
  147.             break;
  148.          case 5:
  149.             this.setPrintQuality(java.awt.PageAttributes.PrintQualityType.HIGH);
  150.             break;
  151.          default:
  152.             this.setPrintQuality((PrintQualityType)null);
  153.       }
  154.  
  155.    }
  156.  
  157.    public void setPrintQualityToDefault() {
  158.       this.setPrintQuality(java.awt.PageAttributes.PrintQualityType.NORMAL);
  159.    }
  160.  
  161.    public int[] getPrinterResolution() {
  162.       int[] var1 = new int[]{this.printerResolution[0], this.printerResolution[1], this.printerResolution[2]};
  163.       return var1;
  164.    }
  165.  
  166.    public void setPrinterResolution(int[] var1) {
  167.       if (var1 != null && var1.length == 3 && var1[0] > 0 && var1[1] > 0 && (var1[2] == 3 || var1[2] == 4)) {
  168.          int[] var2 = new int[]{var1[0], var1[1], var1[2]};
  169.          this.printerResolution = var2;
  170.       } else {
  171.          throw new IllegalArgumentException("Invalid value for attribute printerResolution");
  172.       }
  173.    }
  174.  
  175.    public void setPrinterResolution(int var1) {
  176.       this.setPrinterResolution(new int[]{var1, var1, 3});
  177.    }
  178.  
  179.    public void setPrinterResolutionToDefault() {
  180.       this.setPrinterResolution(72);
  181.    }
  182.  
  183.    public boolean equals(Object var1) {
  184.       if (!(var1 instanceof PageAttributes)) {
  185.          return false;
  186.       } else {
  187.          PageAttributes var2 = (PageAttributes)var1;
  188.          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];
  189.       }
  190.    }
  191.  
  192.    public int hashCode() {
  193.       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];
  194.    }
  195.  
  196.    public String toString() {
  197.       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] + "]";
  198.    }
  199. }
  200.