001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Igor A. Pyankov
019: * @version $Revision$
020: */package java.awt;
021:
022: import java.util.Locale;
023:
024: import org.apache.harmony.awt.internal.nls.Messages;
025:
026: public final class PageAttributes implements Cloneable {
027: private MediaType media;
028: private ColorType color;
029: private OrientationRequestedType orientationRequested;
030: private OriginType origin;
031: private PrintQualityType printQuality;
032: private int[] printerResolution;
033:
034: /*----------------- section of the nested classes --------------------*/
035: public static final class ColorType {
036: private final String name;
037: public static final ColorType COLOR = new ColorType(0, "COLOR"); //$NON-NLS-1$
038: public static final ColorType MONOCHROME = new ColorType(1,
039: "MONOCHROME"); //$NON-NLS-1$
040:
041: private ColorType(int i, String n) {
042: super ();
043: name = n;
044: }
045:
046: private ColorType() {
047: this (1, "MONOCHROME"); //$NON-NLS-1$
048: }
049: }
050:
051: public static final class MediaType {
052: private final String name;
053:
054: public static final MediaType ISO_4A0 = new MediaType(71,
055: "ISO_4A0"); //$NON-NLS-1$
056: public static final MediaType ISO_2A0 = new MediaType(70,
057: "ISO_2A0"); //$NON-NLS-1$
058:
059: public static final MediaType ISO_A0 = new MediaType(0,
060: "ISO_A0"); //$NON-NLS-1$
061: public static final MediaType ISO_A1 = new MediaType(1,
062: "ISO_A1"); //$NON-NLS-1$
063: public static final MediaType ISO_A2 = new MediaType(2,
064: "ISO_A2"); //$NON-NLS-1$
065: public static final MediaType ISO_A3 = new MediaType(3,
066: "ISO_A3"); //$NON-NLS-1$
067: public static final MediaType ISO_A4 = new MediaType(4,
068: "ISO_A4"); //$NON-NLS-1$
069: public static final MediaType ISO_A5 = new MediaType(5,
070: "ISO_A5"); //$NON-NLS-1$
071: public static final MediaType ISO_A6 = new MediaType(6,
072: "ISO_A6"); //$NON-NLS-1$
073: public static final MediaType ISO_A7 = new MediaType(7,
074: "ISO_A7"); //$NON-NLS-1$
075: public static final MediaType ISO_A8 = new MediaType(8,
076: "ISO_A8"); //$NON-NLS-1$
077: public static final MediaType ISO_A9 = new MediaType(9,
078: "ISO_A9"); //$NON-NLS-1$
079: public static final MediaType ISO_A10 = new MediaType(10,
080: "ISO_A10"); //$NON-NLS-1$
081:
082: public static final MediaType ISO_B0 = new MediaType(10,
083: "ISO_B0"); //$NON-NLS-1$
084: public static final MediaType ISO_B1 = new MediaType(11,
085: "ISO_B1"); //$NON-NLS-1$
086: public static final MediaType ISO_B2 = new MediaType(12,
087: "ISO_B2"); //$NON-NLS-1$
088: public static final MediaType ISO_B3 = new MediaType(13,
089: "ISO_B3"); //$NON-NLS-1$
090: public static final MediaType ISO_B4 = new MediaType(14,
091: "ISO_B4"); //$NON-NLS-1$
092: public static final MediaType ISO_B5 = new MediaType(15,
093: "ISO_B5"); //$NON-NLS-1$
094: public static final MediaType ISO_B6 = new MediaType(16,
095: "ISO_B6"); //$NON-NLS-1$
096: public static final MediaType ISO_B7 = new MediaType(17,
097: "ISO_B7"); //$NON-NLS-1$
098: public static final MediaType ISO_B8 = new MediaType(18,
099: "ISO_B8"); //$NON-NLS-1$
100: public static final MediaType ISO_B9 = new MediaType(19,
101: "ISO_B9"); //$NON-NLS-1$
102: public static final MediaType ISO_B10 = new MediaType(20,
103: "ISO_B10"); //$NON-NLS-1$
104:
105: public static final MediaType JIS_B0 = new MediaType(30,
106: "JIS_B0"); //$NON-NLS-1$
107: public static final MediaType JIS_B1 = new MediaType(31,
108: "JIS_B1"); //$NON-NLS-1$
109: public static final MediaType JIS_B2 = new MediaType(32,
110: "JIS_B2"); //$NON-NLS-1$
111: public static final MediaType JIS_B3 = new MediaType(33,
112: "JIS_B3"); //$NON-NLS-1$
113: public static final MediaType JIS_B4 = new MediaType(34,
114: "JIS_B4"); //$NON-NLS-1$
115: public static final MediaType JIS_B5 = new MediaType(35,
116: "JIS_B5"); //$NON-NLS-1$
117: public static final MediaType JIS_B6 = new MediaType(36,
118: "JIS_B6"); //$NON-NLS-1$
119: public static final MediaType JIS_B7 = new MediaType(37,
120: "JIS_B7"); //$NON-NLS-1$
121: public static final MediaType JIS_B8 = new MediaType(38,
122: "JIS_B8"); //$NON-NLS-1$
123: public static final MediaType JIS_B9 = new MediaType(39,
124: "JIS_B9"); //$NON-NLS-1$
125: public static final MediaType JIS_B10 = new MediaType(40,
126: "JIS_B10"); //$NON-NLS-1$
127:
128: public static final MediaType ISO_C0 = new MediaType(50,
129: "ISO_C0"); //$NON-NLS-1$
130: public static final MediaType ISO_C1 = new MediaType(51,
131: "ISO_C1"); //$NON-NLS-1$
132: public static final MediaType ISO_C2 = new MediaType(52,
133: "ISO_C2"); //$NON-NLS-1$
134: public static final MediaType ISO_C3 = new MediaType(53,
135: "ISO_C3"); //$NON-NLS-1$
136: public static final MediaType ISO_C4 = new MediaType(54,
137: "ISO_C4"); //$NON-NLS-1$
138: public static final MediaType ISO_C5 = new MediaType(55,
139: "ISO_C5"); //$NON-NLS-1$
140: public static final MediaType ISO_C6 = new MediaType(56,
141: "ISO_C6"); //$NON-NLS-1$
142: public static final MediaType ISO_C7 = new MediaType(57,
143: "ISO_C7"); //$NON-NLS-1$
144: public static final MediaType ISO_C8 = new MediaType(58,
145: "ISO_C8"); //$NON-NLS-1$
146: public static final MediaType ISO_C9 = new MediaType(59,
147: "ISO_C9"); //$NON-NLS-1$
148: public static final MediaType ISO_C10 = new MediaType(60,
149: "ISO_C10"); //$NON-NLS-1$
150:
151: public static final MediaType ISO_DESIGNATED_LONG = new MediaType(
152: 100, "ISO_DESIGNATED_LONG"); //$NON-NLS-1$
153:
154: public static final MediaType EXECUTIVE = new MediaType(101,
155: "EXECUTIVE"); //$NON-NLS-1$
156:
157: public static final MediaType FOLIO = new MediaType(102,
158: "FOLIO"); //$NON-NLS-1$
159:
160: public static final MediaType INVOICE = new MediaType(103,
161: "INVOICE"); //$NON-NLS-1$
162:
163: public static final MediaType LEDGER = new MediaType(104,
164: "LEDGER"); //$NON-NLS-1$
165:
166: public static final MediaType NA_LETTER = new MediaType(105,
167: "NA_LETTER"); //$NON-NLS-1$
168:
169: public static final MediaType NA_LEGAL = new MediaType(106,
170: "NA_LEGAL"); //$NON-NLS-1$
171:
172: public static final MediaType QUARTO = new MediaType(107,
173: "QUARTO"); //$NON-NLS-1$
174:
175: public static final MediaType A = new MediaType(200, "A"); //$NON-NLS-1$
176: public static final MediaType B = new MediaType(201, "B"); //$NON-NLS-1$
177: public static final MediaType C = new MediaType(202, "C"); //$NON-NLS-1$
178: public static final MediaType D = new MediaType(203, "D"); //$NON-NLS-1$
179: public static final MediaType E = new MediaType(204, "E"); //$NON-NLS-1$
180:
181: public static final MediaType NA_10X15_ENVELOPE = new MediaType(
182: 311, "NA_10X15_ENVELOPE"); //$NON-NLS-1$
183: public static final MediaType NA_10X14_ENVELOPE = new MediaType(
184: 310, "NA_10X14_ENVELOPE"); //$NON-NLS-1$
185: public static final MediaType NA_10X13_ENVELOPE = new MediaType(
186: 309, "NA_10X13_ENVELOPE"); //$NON-NLS-1$
187: public static final MediaType NA_9X12_ENVELOPE = new MediaType(
188: 308, "NA_9X12_ENVELOPE"); //$NON-NLS-1$
189: public static final MediaType NA_9X11_ENVELOPE = new MediaType(
190: 307, "NA_9X11_ENVELOPE"); //$NON-NLS-1$
191: public static final MediaType NA_7X9_ENVELOPE = new MediaType(
192: 306, "NA_7X9_ENVELOPE"); //$NON-NLS-1$
193: public static final MediaType NA_6X9_ENVELOPE = new MediaType(
194: 305, "NA_6X9_ENVELOPE"); //$NON-NLS-1$
195: public static final MediaType NA_NUMBER_9_ENVELOPE = new MediaType(
196: 312, "NA_NUMBER_9_ENVELOPE"); //$NON-NLS-1$
197: public static final MediaType NA_NUMBER_10_ENVELOPE = new MediaType(
198: 313, "NA_NUMBER_10_ENVELOPE"); //$NON-NLS-1$
199: public static final MediaType NA_NUMBER_11_ENVELOPE = new MediaType(
200: 314, "NA_NUMBER_11_ENVELOPE"); //$NON-NLS-1$
201: public static final MediaType NA_NUMBER_12_ENVELOPE = new MediaType(
202: 315, "NA_NUMBER_12_ENVELOPE"); //$NON-NLS-1$
203: public static final MediaType NA_NUMBER_14_ENVELOPE = new MediaType(
204: 316, "NA_NUMBER_14_ENVELOPE"); //$NON-NLS-1$
205: public static final MediaType INVITE_ENVELOPE = new MediaType(
206: 300, "INVITE_ENVELOPE"); //$NON-NLS-1$
207: public static final MediaType ITALY_ENVELOPE = new MediaType(
208: 301, "ITALY_ENVELOPE"); //$NON-NLS-1$
209: public static final MediaType MONARCH_ENVELOPE = new MediaType(
210: 302, "MONARCH_ENVELOPE"); //$NON-NLS-1$
211: public static final MediaType PERSONAL_ENVELOPE = new MediaType(
212: 304, "PERSONAL_ENVELOPE"); //$NON-NLS-1$
213:
214: /*aliases*/
215: public static final MediaType A0 = ISO_A0;
216: public static final MediaType A1 = ISO_A1;
217: public static final MediaType A2 = ISO_A2;
218: public static final MediaType A3 = ISO_A3;
219: public static final MediaType A4 = ISO_A4;
220: public static final MediaType A5 = ISO_A5;
221: public static final MediaType A6 = ISO_A6;
222: public static final MediaType A7 = ISO_A7;
223: public static final MediaType A8 = ISO_A8;
224: public static final MediaType A9 = ISO_A9;
225: public static final MediaType A10 = ISO_A10;
226:
227: public static final MediaType B0 = ISO_B0;
228: public static final MediaType B1 = ISO_B1;
229: public static final MediaType B2 = ISO_B2;
230: public static final MediaType B3 = ISO_B3;
231: public static final MediaType B4 = ISO_B4;
232: public static final MediaType B5 = ISO_B5;
233: public static final MediaType B6 = ISO_B6;
234: public static final MediaType B7 = ISO_B7;
235: public static final MediaType B8 = ISO_B8;
236: public static final MediaType B9 = ISO_B9;
237: public static final MediaType B10 = ISO_B10;
238:
239: public static final MediaType ISO_B4_ENVELOPE = ISO_B4;
240: public static final MediaType ISO_B5_ENVELOPE = ISO_B5;
241:
242: public static final MediaType ISO_C0_ENVELOPE = ISO_C0;
243: public static final MediaType ISO_C1_ENVELOPE = ISO_C1;
244: public static final MediaType ISO_C2_ENVELOPE = ISO_C2;
245: public static final MediaType ISO_C3_ENVELOPE = ISO_C3;
246: public static final MediaType ISO_C4_ENVELOPE = ISO_C4;
247: public static final MediaType ISO_C5_ENVELOPE = ISO_C5;
248: public static final MediaType ISO_C6_ENVELOPE = ISO_C6;
249: public static final MediaType ISO_C7_ENVELOPE = ISO_C7;
250: public static final MediaType ISO_C8_ENVELOPE = ISO_C8;
251: public static final MediaType ISO_C9_ENVELOPE = ISO_C9;
252: public static final MediaType ISO_C10_ENVELOPE = ISO_C10;
253:
254: public static final MediaType C0 = ISO_C0;
255: public static final MediaType C1 = ISO_C1;
256: public static final MediaType C2 = ISO_C2;
257: public static final MediaType C3 = ISO_C3;
258: public static final MediaType C4 = ISO_C4;
259: public static final MediaType C5 = ISO_C5;
260: public static final MediaType C6 = ISO_C6;
261: public static final MediaType C7 = ISO_C7;
262: public static final MediaType C8 = ISO_C8;
263: public static final MediaType C9 = ISO_C9;
264: public static final MediaType C10 = ISO_C10;
265:
266: public static final MediaType ISO_DESIGNATED_LONG_ENVELOPE = ISO_DESIGNATED_LONG;
267:
268: public static final MediaType STATEMENT = INVOICE;
269: public static final MediaType TABLOID = LEDGER;
270: public static final MediaType LETTER = NA_LETTER;
271: public static final MediaType NOTE = NA_LETTER;
272: public static final MediaType LEGAL = NA_LEGAL;
273:
274: public static final MediaType ENV_10X15 = NA_10X15_ENVELOPE;
275: public static final MediaType ENV_10X14 = NA_10X14_ENVELOPE;
276: public static final MediaType ENV_10X13 = NA_10X13_ENVELOPE;
277: public static final MediaType ENV_9X12 = NA_9X12_ENVELOPE;
278: public static final MediaType ENV_9X11 = NA_9X11_ENVELOPE;
279: public static final MediaType ENV_7X9 = NA_7X9_ENVELOPE;
280: public static final MediaType ENV_6X9 = NA_6X9_ENVELOPE;
281:
282: public static final MediaType ENV_9 = NA_NUMBER_9_ENVELOPE;
283: public static final MediaType ENV_10 = NA_NUMBER_10_ENVELOPE;
284: public static final MediaType ENV_11 = NA_NUMBER_11_ENVELOPE;
285: public static final MediaType ENV_12 = NA_NUMBER_12_ENVELOPE;
286: public static final MediaType ENV_14 = NA_NUMBER_14_ENVELOPE;
287:
288: public static final MediaType ENV_INVITE = INVITE_ENVELOPE;
289: public static final MediaType ENV_ITALY = ITALY_ENVELOPE;
290: public static final MediaType ENV_MONARCH = MONARCH_ENVELOPE;
291: public static final MediaType ENV_PERSONAL = PERSONAL_ENVELOPE;
292: public static final MediaType INVITE = INVITE_ENVELOPE;
293: public static final MediaType ITALY = ITALY_ENVELOPE;
294: public static final MediaType MONARCH = MONARCH_ENVELOPE;
295: public static final MediaType PERSONAL = PERSONAL_ENVELOPE;
296:
297: private MediaType(int i, String n) {
298: super ();
299: name = n;
300: }
301:
302: private MediaType() {
303: this (4, "ISO_A4"); //$NON-NLS-1$
304: }
305: }
306:
307: public static final class OrientationRequestedType {
308: private final String name;
309:
310: public static final OrientationRequestedType PORTRAIT = new OrientationRequestedType(
311: 0, "PORTRAIT"); //$NON-NLS-1$
312: public static final OrientationRequestedType LANDSCAPE = new OrientationRequestedType(
313: 1, "LANDSCAPE"); //$NON-NLS-1$
314:
315: private OrientationRequestedType(int i, String n) {
316: super ();
317: name = n;
318: }
319:
320: private OrientationRequestedType() {
321: this (0, "PORTRAIT"); //$NON-NLS-1$
322: }
323: }
324:
325: public static final class OriginType {
326: private final String name;
327:
328: public static final OriginType PHYSICAL = new OriginType(0,
329: "PHYSICAL"); //$NON-NLS-1$
330: public static final OriginType PRINTABLE = new OriginType(1,
331: "PRINTABLE"); //$NON-NLS-1$
332:
333: private OriginType(int i, String n) {
334: super ();
335: name = n;
336: }
337:
338: private OriginType() {
339: this (0, "PHYSICAL"); //$NON-NLS-1$
340: }
341: }
342:
343: public static final class PrintQualityType {
344: private final String name;
345:
346: public static final PrintQualityType HIGH = new PrintQualityType(
347: 5, "HIGH"); //$NON-NLS-1$
348: public static final PrintQualityType NORMAL = new PrintQualityType(
349: 4, "NORMAL"); //$NON-NLS-1$
350: public static final PrintQualityType DRAFT = new PrintQualityType(
351: 2, "DRAFT"); //$NON-NLS-1$
352:
353: private PrintQualityType(int i, String n) {
354: name = n;
355: }
356:
357: private PrintQualityType() {
358: this (4, "NORMAL"); //$NON-NLS-1$
359: }
360: }
361:
362: /*--------------- end of section of the nested classes ------------------*/
363:
364: public PageAttributes() {
365: setColor(ColorType.MONOCHROME);
366: setMediaToDefault();
367: setOrientationRequestedToDefault();
368: setOrigin(OriginType.PHYSICAL);
369: setPrintQualityToDefault();
370: setPrinterResolutionToDefault();
371: }
372:
373: public PageAttributes(
374: PageAttributes.ColorType color,
375: PageAttributes.MediaType media,
376: PageAttributes.OrientationRequestedType orientationRequested,
377: PageAttributes.OriginType origin,
378: PageAttributes.PrintQualityType printQuality,
379: int[] printerResolution) {
380:
381: setColor(color);
382: setMedia(media);
383: setOrientationRequested(orientationRequested);
384: setOrigin(origin);
385: setPrintQuality(printQuality);
386: setPrinterResolution(printerResolution);
387: }
388:
389: public PageAttributes(PageAttributes pageAttributes) {
390: set(pageAttributes);
391: }
392:
393: @Override
394: public Object clone() {
395: PageAttributes pa = new PageAttributes(this );
396: return pa;
397: }
398:
399: @Override
400: public boolean equals(Object obj) {
401: PageAttributes pa;
402:
403: if (!(obj instanceof PageAttributes)) {
404: return false;
405: }
406: pa = (PageAttributes) obj;
407: if (color != pa.color) {
408: return false;
409: }
410: if (media != pa.media) {
411: return false;
412: }
413: if (orientationRequested != pa.orientationRequested) {
414: return false;
415: }
416: if (origin != pa.origin) {
417: return false;
418: }
419: if (printQuality != pa.printQuality) {
420: return false;
421: }
422: if (origin != pa.origin) {
423: return false;
424: }
425: if (!(printerResolution[0] == pa.printerResolution[0]
426: && printerResolution[1] == pa.printerResolution[1] && printerResolution[2] == pa.printerResolution[2])) {
427: return false;
428: }
429: return true;
430: }
431:
432: @Override
433: public String toString() {
434: /* The format is based on 1.5 release behavior
435: * which can be revealed by the following code:
436: * System.out.println(new PageAttributes());
437: */
438:
439: String s;
440: s = "color=" + getColor().name + ",media=" + getMedia().name //$NON-NLS-1$ //$NON-NLS-2$
441: + ",orientation-requested=" + getOrientationRequested().name //$NON-NLS-1$
442: + ",origin=" + getOrigin().name //$NON-NLS-1$
443: + ",print-quality=" + getPrintQuality().name //$NON-NLS-1$
444: + ",printer-resolution=" + printerResolution[0] + "x" //$NON-NLS-1$ //$NON-NLS-2$
445: + printerResolution[1]
446: + (printerResolution[2] == 3 ? "dpi" : "dpcm"); //$NON-NLS-1$ //$NON-NLS-2$
447: return s;
448: }
449:
450: @Override
451: public int hashCode() {
452: int hash = this .toString().hashCode();
453: return hash;
454: }
455:
456: public void set(PageAttributes obj) {
457: color = obj.color;
458: media = obj.media;
459: orientationRequested = obj.orientationRequested;
460: origin = obj.origin;
461: printQuality = obj.printQuality;
462: printerResolution = obj.printerResolution;
463: }
464:
465: public void setColor(PageAttributes.ColorType color) {
466: if (color == null) {
467: // awt.11C=Invalid value for color
468: throw new IllegalArgumentException(Messages
469: .getString("awt.11C")); //$NON-NLS-1$
470: }
471: this .color = color;
472: }
473:
474: public PageAttributes.ColorType getColor() {
475: return color;
476: }
477:
478: public void setMedia(PageAttributes.MediaType media) {
479: if (media == null) {
480: // awt.116=Invalid value for media
481: throw new IllegalArgumentException(Messages
482: .getString("awt.116")); //$NON-NLS-1$
483: }
484: this .media = media;
485: }
486:
487: public PageAttributes.MediaType getMedia() {
488: return media;
489: }
490:
491: public void setOrientationRequested(
492: PageAttributes.OrientationRequestedType orientationRequested) {
493:
494: if (orientationRequested == null) {
495: // awt.117=Invalid value for orientationRequested
496: throw new IllegalArgumentException(Messages
497: .getString("awt.117")); //$NON-NLS-1$
498: }
499: this .orientationRequested = orientationRequested;
500: }
501:
502: public void setOrientationRequested(int i_orientationRequested) {
503: if (i_orientationRequested == 3) {
504: setOrientationRequested(OrientationRequestedType.PORTRAIT);
505: return;
506: }
507: if (i_orientationRequested == 4) {
508: setOrientationRequested(OrientationRequestedType.LANDSCAPE);
509: return;
510: }
511: // awt.117=Invalid value for orientationRequested
512: throw new IllegalArgumentException(Messages
513: .getString("awt.117")); //$NON-NLS-1$
514: }
515:
516: public PageAttributes.OrientationRequestedType getOrientationRequested() {
517: return orientationRequested;
518: }
519:
520: public void setOrigin(PageAttributes.OriginType origin) {
521: if (origin == null) {
522: // awt.119=Invalid value for origin
523: throw new IllegalArgumentException(Messages
524: .getString("awt.119")); //$NON-NLS-1$
525: }
526: this .origin = origin;
527: }
528:
529: public PageAttributes.OriginType getOrigin() {
530: return origin;
531: }
532:
533: public void setPrintQuality(
534: PageAttributes.PrintQualityType printQuality) {
535: if (printQuality == null) {
536: // awt.11A=Invalid value for printQuality
537: throw new IllegalArgumentException(Messages
538: .getString("awt.11A")); //$NON-NLS-1$
539: }
540: this .printQuality = printQuality;
541: }
542:
543: public void setPrintQuality(int iprintQuality) {
544: if (iprintQuality == 3) {
545: setPrintQuality(PrintQualityType.DRAFT);
546: return;
547: }
548: if (iprintQuality == 4) {
549: setPrintQuality(PrintQualityType.NORMAL);
550: return;
551: }
552: if (iprintQuality == 5) {
553: setPrintQuality(PrintQualityType.HIGH);
554: return;
555: }
556: // awt.11A=Invalid value for printQuality
557: throw new IllegalArgumentException(Messages
558: .getString("awt.11A")); //$NON-NLS-1$
559: }
560:
561: public PageAttributes.PrintQualityType getPrintQuality() {
562: return printQuality;
563: }
564:
565: public void setPrinterResolution(int[] aprinterResolution) {
566: if (aprinterResolution == null
567: || aprinterResolution.length != 3
568: || aprinterResolution[0] <= 0
569: || aprinterResolution[1] <= 0
570: || (aprinterResolution[2] != 3 && aprinterResolution[2] != 4)) {
571: // awt.11B=Invalid value for printerResolution[]
572: throw new IllegalArgumentException(Messages
573: .getString("awt.11B")); //$NON-NLS-1$
574: }
575: printerResolution = new int[3];
576: printerResolution[0] = aprinterResolution[0];
577: printerResolution[1] = aprinterResolution[1];
578: printerResolution[2] = aprinterResolution[2];
579: }
580:
581: public void setPrinterResolution(int iprinterResolution) {
582: if (iprinterResolution <= 0) {
583: // awt.118=Invalid value for printerResolution
584: throw new IllegalArgumentException(Messages
585: .getString("awt.118")); //$NON-NLS-1$
586: }
587: printerResolution = new int[3];
588: printerResolution[0] = iprinterResolution;
589: printerResolution[1] = iprinterResolution;
590: printerResolution[2] = 3;
591: }
592:
593: public int[] getPrinterResolution() {
594: return printerResolution;
595: }
596:
597: public void setMediaToDefault() {
598: Locale loc = Locale.getDefault();
599:
600: if (loc.equals(Locale.CANADA) || loc.equals(Locale.US)) {
601: setMedia(MediaType.NA_LETTER);
602: return;
603: }
604: setMedia(MediaType.ISO_A4);
605: return;
606: }
607:
608: public void setOrientationRequestedToDefault() {
609: setOrientationRequested(OrientationRequestedType.PORTRAIT);
610: return;
611: }
612:
613: public void setPrintQualityToDefault() {
614: setPrintQuality(PrintQualityType.NORMAL);
615: return;
616: }
617:
618: public void setPrinterResolutionToDefault() {
619: setPrinterResolution(72);
620: return;
621: }
622: }
|