1 | /* PageAttributes.java --
|
---|
2 | Copyright (C) 2002 Free Software Foundation, Inc.
|
---|
3 |
|
---|
4 | This file is part of GNU Classpath.
|
---|
5 |
|
---|
6 | GNU Classpath is free software; you can redistribute it and/or modify
|
---|
7 | it under the terms of the GNU General Public License as published by
|
---|
8 | the Free Software Foundation; either version 2, or (at your option)
|
---|
9 | any later version.
|
---|
10 |
|
---|
11 | GNU Classpath is distributed in the hope that it will be useful, but
|
---|
12 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
14 | General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU General Public License
|
---|
17 | along with GNU Classpath; see the file COPYING. If not, write to the
|
---|
18 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
---|
19 | 02111-1307 USA.
|
---|
20 |
|
---|
21 | Linking this library statically or dynamically with other modules is
|
---|
22 | making a combined work based on this library. Thus, the terms and
|
---|
23 | conditions of the GNU General Public License cover the whole
|
---|
24 | combination.
|
---|
25 |
|
---|
26 | As a special exception, the copyright holders of this library give you
|
---|
27 | permission to link this library with independent modules to produce an
|
---|
28 | executable, regardless of the license terms of these independent
|
---|
29 | modules, and to copy and distribute the resulting executable under
|
---|
30 | terms of your choice, provided that you also meet, for each linked
|
---|
31 | independent module, the terms and conditions of the license of that
|
---|
32 | module. An independent module is a module which is not derived from
|
---|
33 | or based on this library. If you modify this library, you may extend
|
---|
34 | this exception to your version of the library, but you are not
|
---|
35 | obligated to do so. If you do not wish to do so, delete this
|
---|
36 | exception statement from your version. */
|
---|
37 |
|
---|
38 |
|
---|
39 | package java.awt;
|
---|
40 |
|
---|
41 | import java.util.Locale;
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Missing Documentation
|
---|
45 | *
|
---|
46 | * @author Eric Blake <ebb9@email.byu.edu>
|
---|
47 | * @since 1.3
|
---|
48 | * @status updated to 1.4, but missing documentation
|
---|
49 | */
|
---|
50 | public final class PageAttributes implements Cloneable
|
---|
51 | {
|
---|
52 | public static final class ColorType extends AttributeValue
|
---|
53 | {
|
---|
54 | private static final String[] NAMES = { "color", "monochrome" };
|
---|
55 | public static final ColorType COLOR = new ColorType(0);
|
---|
56 | public static final ColorType MONOCHROME = new ColorType(1);
|
---|
57 | private ColorType(int value)
|
---|
58 | {
|
---|
59 | super(value, NAMES);
|
---|
60 | }
|
---|
61 | } // class ColorType
|
---|
62 | public static final class MediaType extends AttributeValue
|
---|
63 | {
|
---|
64 | private static final String[] NAMES
|
---|
65 | = { "iso-4a0", "iso-2a0", "iso-a0", "iso-a1", "iso-a2", "iso-a3",
|
---|
66 | "iso-a4", "iso-a5", "iso-a6", "iso-a7", "iso-a8", "iso-a9",
|
---|
67 | "iso-a10", "iso-b0", "iso-b1", "iso-b2", "iso-b3", "iso-b4",
|
---|
68 | "iso-b5", "iso-b6", "iso-b7", "iso-b8", "iso-b9", "iso-b10",
|
---|
69 | "jis-b0", "jis-b1", "jis-b2", "jis-b3", "jis-b4", "jis-b5",
|
---|
70 | "jis-b6", "jis-b7", "jis-b8", "jis-b9", "jis-b10", "iso-c0",
|
---|
71 | "iso-c1", "iso-c2", "iso-c3", "iso-c4", "iso-c5", "iso-c6",
|
---|
72 | "iso-c7", "iso-c8", "iso-c9", "iso-c10", "iso-designated-long",
|
---|
73 | "executive", "folio", "invoice", "ledger", "na-letter", "na-legal",
|
---|
74 | "quarto", "a", "b", "c", "d", "e", "na-10x15-envelope",
|
---|
75 | "na-10x14-envelope", "na-10x13-envelope", "na-9x12-envelope",
|
---|
76 | "na-9x11-envelope", "na-7x9-envelope", "na-6x9-envelope",
|
---|
77 | "na-number-9-envelope", "na-number-10-envelope",
|
---|
78 | "na-number-11-envelope", "na-number-12-envelope",
|
---|
79 | "na-number-14-envelope", "invite-envelope", "italy-envelope",
|
---|
80 | "monarch-envelope", "personal-envelope" };
|
---|
81 | public static final MediaType ISO_4A0 = new MediaType(0);
|
---|
82 | public static final MediaType ISO_2A0 = new MediaType(1);
|
---|
83 | public static final MediaType ISO_A0 = new MediaType(2);
|
---|
84 | public static final MediaType ISO_A1 = new MediaType(3);
|
---|
85 | public static final MediaType ISO_A2 = new MediaType(4);
|
---|
86 | public static final MediaType ISO_A3 = new MediaType(5);
|
---|
87 | public static final MediaType ISO_A4 = new MediaType(6);
|
---|
88 | public static final MediaType ISO_A5 = new MediaType(7);
|
---|
89 | public static final MediaType ISO_A6 = new MediaType(8);
|
---|
90 | public static final MediaType ISO_A7 = new MediaType(9);
|
---|
91 | public static final MediaType ISO_A8 = new MediaType(10);
|
---|
92 | public static final MediaType ISO_A9 = new MediaType(11);
|
---|
93 | public static final MediaType ISO_A10 = new MediaType(12);
|
---|
94 | public static final MediaType ISO_B0 = new MediaType(13);
|
---|
95 | public static final MediaType ISO_B1 = new MediaType(14);
|
---|
96 | public static final MediaType ISO_B2 = new MediaType(15);
|
---|
97 | public static final MediaType ISO_B3 = new MediaType(16);
|
---|
98 | public static final MediaType ISO_B4 = new MediaType(17);
|
---|
99 | public static final MediaType ISO_B5 = new MediaType(18);
|
---|
100 | public static final MediaType ISO_B6 = new MediaType(19);
|
---|
101 | public static final MediaType ISO_B7 = new MediaType(20);
|
---|
102 | public static final MediaType ISO_B8 = new MediaType(21);
|
---|
103 | public static final MediaType ISO_B9 = new MediaType(22);
|
---|
104 | public static final MediaType ISO_B10 = new MediaType(23);
|
---|
105 | public static final MediaType JIS_B0 = new MediaType(24);
|
---|
106 | public static final MediaType JIS_B1 = new MediaType(25);
|
---|
107 | public static final MediaType JIS_B2 = new MediaType(26);
|
---|
108 | public static final MediaType JIS_B3 = new MediaType(27);
|
---|
109 | public static final MediaType JIS_B4 = new MediaType(28);
|
---|
110 | public static final MediaType JIS_B5 = new MediaType(29);
|
---|
111 | public static final MediaType JIS_B6 = new MediaType(30);
|
---|
112 | public static final MediaType JIS_B7 = new MediaType(31);
|
---|
113 | public static final MediaType JIS_B8 = new MediaType(32);
|
---|
114 | public static final MediaType JIS_B9 = new MediaType(33);
|
---|
115 | public static final MediaType JIS_B10 = new MediaType(34);
|
---|
116 | public static final MediaType ISO_C0 = new MediaType(35);
|
---|
117 | public static final MediaType ISO_C1 = new MediaType(36);
|
---|
118 | public static final MediaType ISO_C2 = new MediaType(37);
|
---|
119 | public static final MediaType ISO_C3 = new MediaType(38);
|
---|
120 | public static final MediaType ISO_C4 = new MediaType(39);
|
---|
121 | public static final MediaType ISO_C5 = new MediaType(40);
|
---|
122 | public static final MediaType ISO_C6 = new MediaType(41);
|
---|
123 | public static final MediaType ISO_C7 = new MediaType(42);
|
---|
124 | public static final MediaType ISO_C8 = new MediaType(43);
|
---|
125 | public static final MediaType ISO_C9 = new MediaType(44);
|
---|
126 | public static final MediaType ISO_C10 = new MediaType(45);
|
---|
127 | public static final MediaType ISO_DESIGNATED_LONG = new MediaType(46);
|
---|
128 | public static final MediaType EXECUTIVE = new MediaType(47);
|
---|
129 | public static final MediaType FOLIO = new MediaType(48);
|
---|
130 | public static final MediaType INVOICE = new MediaType(49);
|
---|
131 | public static final MediaType LEDGER = new MediaType(50);
|
---|
132 | public static final MediaType NA_LETTER = new MediaType(51);
|
---|
133 | public static final MediaType NA_LEGAL = new MediaType(52);
|
---|
134 | public static final MediaType QUARTO = new MediaType(53);
|
---|
135 | public static final MediaType A = new MediaType(54);
|
---|
136 | public static final MediaType B = new MediaType(55);
|
---|
137 | public static final MediaType C = new MediaType(56);
|
---|
138 | public static final MediaType D = new MediaType(57);
|
---|
139 | public static final MediaType E = new MediaType(58);
|
---|
140 | public static final MediaType NA_10X15_ENVELOPE = new MediaType(59);
|
---|
141 | public static final MediaType NA_10X14_ENVELOPE = new MediaType(60);
|
---|
142 | public static final MediaType NA_10X13_ENVELOPE = new MediaType(61);
|
---|
143 | public static final MediaType NA_9X12_ENVELOPE = new MediaType(62);
|
---|
144 | public static final MediaType NA_9X11_ENVELOPE = new MediaType(63);
|
---|
145 | public static final MediaType NA_7X9_ENVELOPE = new MediaType(64);
|
---|
146 | public static final MediaType NA_6X9_ENVELOPE = new MediaType(65);
|
---|
147 | public static final MediaType NA_NUMBER_9_ENVELOPE = new MediaType(66);
|
---|
148 | public static final MediaType NA_NUMBER_10_ENVELOPE = new MediaType(67);
|
---|
149 | public static final MediaType NA_NUMBER_11_ENVELOPE = new MediaType(68);
|
---|
150 | public static final MediaType NA_NUMBER_12_ENVELOPE = new MediaType(69);
|
---|
151 | public static final MediaType NA_NUMBER_14_ENVELOPE = new MediaType(70);
|
---|
152 | public static final MediaType INVITE_ENVELOPE = new MediaType(71);
|
---|
153 | public static final MediaType ITALY_ENVELOPE = new MediaType(72);
|
---|
154 | public static final MediaType MONARCH_ENVELOPE = new MediaType(73);
|
---|
155 | public static final MediaType PERSONAL_ENVELOPE = new MediaType(74);
|
---|
156 | public static final MediaType A0 = ISO_A0;
|
---|
157 | public static final MediaType A1 = ISO_A1;
|
---|
158 | public static final MediaType A2 = ISO_A2;
|
---|
159 | public static final MediaType A3 = ISO_A3;
|
---|
160 | public static final MediaType A4 = ISO_A4;
|
---|
161 | public static final MediaType A5 = ISO_A5;
|
---|
162 | public static final MediaType A6 = ISO_A6;
|
---|
163 | public static final MediaType A7 = ISO_A7;
|
---|
164 | public static final MediaType A8 = ISO_A8;
|
---|
165 | public static final MediaType A9 = ISO_A9;
|
---|
166 | public static final MediaType A10 = ISO_A10;
|
---|
167 | public static final MediaType B0 = ISO_B0;
|
---|
168 | public static final MediaType B1 = ISO_B1;
|
---|
169 | public static final MediaType B2 = ISO_B2;
|
---|
170 | public static final MediaType B3 = ISO_B3;
|
---|
171 | public static final MediaType B4 = ISO_B4;
|
---|
172 | public static final MediaType ISO_B4_ENVELOPE = ISO_B4;
|
---|
173 | public static final MediaType B5 = ISO_B5;
|
---|
174 | public static final MediaType ISO_B5_ENVELOPE = ISO_B4;
|
---|
175 | public static final MediaType B6 = ISO_B6;
|
---|
176 | public static final MediaType B7 = ISO_B7;
|
---|
177 | public static final MediaType B8 = ISO_B8;
|
---|
178 | public static final MediaType B9 = ISO_B9;
|
---|
179 | public static final MediaType B10 = ISO_B10;
|
---|
180 | public static final MediaType C0 = ISO_B0;
|
---|
181 | public static final MediaType ISO_C0_ENVELOPE = ISO_C0;
|
---|
182 | public static final MediaType C1 = ISO_C1;
|
---|
183 | public static final MediaType ISO_C1_ENVELOPE = ISO_C1;
|
---|
184 | public static final MediaType C2 = ISO_C2;
|
---|
185 | public static final MediaType ISO_C2_ENVELOPE = ISO_C2;
|
---|
186 | public static final MediaType C3 = ISO_C3;
|
---|
187 | public static final MediaType ISO_C3_ENVELOPE = ISO_C3;
|
---|
188 | public static final MediaType C4 = ISO_C4;
|
---|
189 | public static final MediaType ISO_C4_ENVELOPE = ISO_C4;
|
---|
190 | public static final MediaType C5 = ISO_C5;
|
---|
191 | public static final MediaType ISO_C5_ENVELOPE = ISO_C5;
|
---|
192 | public static final MediaType C6 = ISO_C6;
|
---|
193 | public static final MediaType ISO_C6_ENVELOPE = ISO_C6;
|
---|
194 | public static final MediaType C7 = ISO_C7;
|
---|
195 | public static final MediaType ISO_C7_ENVELOPE = ISO_C7;
|
---|
196 | public static final MediaType C8 = ISO_C8;
|
---|
197 | public static final MediaType ISO_C8_ENVELOPE = ISO_C8;
|
---|
198 | public static final MediaType C9 = ISO_C9;
|
---|
199 | public static final MediaType ISO_C9_ENVELOPE = ISO_C9;
|
---|
200 | public static final MediaType C10 = ISO_C10;
|
---|
201 | public static final MediaType ISO_C10_ENVELOPE = ISO_C10;
|
---|
202 | public static final MediaType ISO_DESIGNATED_LONG_ENVELOPE
|
---|
203 | = ISO_DESIGNATED_LONG;
|
---|
204 | public static final MediaType STATEMENT = INVOICE;
|
---|
205 | public static final MediaType TABLOID = LEDGER;
|
---|
206 | public static final MediaType LETTER = NA_LETTER;
|
---|
207 | public static final MediaType NOTE = NA_LETTER;
|
---|
208 | public static final MediaType LEGAL = NA_LEGAL;
|
---|
209 | public static final MediaType ENV_10X15 = NA_10X15_ENVELOPE;
|
---|
210 | public static final MediaType ENV_10X14 = NA_10X14_ENVELOPE;
|
---|
211 | public static final MediaType ENV_10X13 = NA_10X13_ENVELOPE;
|
---|
212 | public static final MediaType ENV_9X12 = NA_9X12_ENVELOPE;
|
---|
213 | public static final MediaType ENV_9X11 = NA_9X11_ENVELOPE;
|
---|
214 | public static final MediaType ENV_7X9 = NA_7X9_ENVELOPE;
|
---|
215 | public static final MediaType ENV_6X9 = NA_6X9_ENVELOPE;
|
---|
216 | public static final MediaType ENV_9 = NA_NUMBER_9_ENVELOPE;
|
---|
217 | public static final MediaType ENV_10 = NA_NUMBER_10_ENVELOPE;
|
---|
218 | public static final MediaType ENV_11 = NA_NUMBER_11_ENVELOPE;
|
---|
219 | public static final MediaType ENV_12 = NA_NUMBER_12_ENVELOPE;
|
---|
220 | public static final MediaType ENV_14 = NA_NUMBER_14_ENVELOPE;
|
---|
221 | public static final MediaType ENV_INVITE = INVITE_ENVELOPE;
|
---|
222 | public static final MediaType ENV_ITALY = ITALY_ENVELOPE;
|
---|
223 | public static final MediaType ENV_MONARCH = MONARCH_ENVELOPE;
|
---|
224 | public static final MediaType ENV_PERSONAL = PERSONAL_ENVELOPE;
|
---|
225 | public static final MediaType INVITE = INVITE_ENVELOPE;
|
---|
226 | public static final MediaType ITALY = ITALY_ENVELOPE;
|
---|
227 | public static final MediaType MONARCH = MONARCH_ENVELOPE;
|
---|
228 | public static final MediaType PERSONAL = PERSONAL_ENVELOPE;
|
---|
229 | private MediaType(int value)
|
---|
230 | {
|
---|
231 | super(value, NAMES);
|
---|
232 | }
|
---|
233 | } // class MediaType
|
---|
234 | public static final class OrientationRequestedType extends AttributeValue
|
---|
235 | {
|
---|
236 | private static final String[] NAMES = { "portrait", "landscape" };
|
---|
237 | public static final OrientationRequestedType PORTRAIT
|
---|
238 | = new OrientationRequestedType(0);
|
---|
239 | public static final OrientationRequestedType LANDSCAPE
|
---|
240 | = new OrientationRequestedType(1);
|
---|
241 | private OrientationRequestedType(int value)
|
---|
242 | {
|
---|
243 | super(value, NAMES);
|
---|
244 | }
|
---|
245 | } // class OrientationRequestedType
|
---|
246 | public static final class OriginType extends AttributeValue
|
---|
247 | {
|
---|
248 | private static final String[] NAMES = { "physical", "printable" };
|
---|
249 | public static final OriginType PHYSICAL = new OriginType(0);
|
---|
250 | public static final OriginType PRINTABLE = new OriginType(1);
|
---|
251 | private OriginType(int value)
|
---|
252 | {
|
---|
253 | super(value, NAMES);
|
---|
254 | }
|
---|
255 | } // class OriginType
|
---|
256 | public static final class PrintQualityType extends AttributeValue
|
---|
257 | {
|
---|
258 | private static final String[] NAMES = { "high", "normal", "draft" };
|
---|
259 | public static final PrintQualityType HIGH = new PrintQualityType(0);
|
---|
260 | public static final PrintQualityType NORMAL = new PrintQualityType(1);
|
---|
261 | public static final PrintQualityType DRAFT = new PrintQualityType(2);
|
---|
262 | private PrintQualityType(int value)
|
---|
263 | {
|
---|
264 | super(value, NAMES);
|
---|
265 | }
|
---|
266 | } // class PrintQualityType
|
---|
267 |
|
---|
268 | |
---|
269 |
|
---|
270 | private ColorType color;
|
---|
271 | private MediaType media;
|
---|
272 | private OrientationRequestedType orientation;
|
---|
273 | private OriginType origin;
|
---|
274 | private PrintQualityType quality;
|
---|
275 | private int resolutionX;
|
---|
276 | private int resolutionY;
|
---|
277 | private int resolutionScale;
|
---|
278 | public PageAttributes()
|
---|
279 | {
|
---|
280 | color = ColorType.MONOCHROME;
|
---|
281 | setMediaToDefault();
|
---|
282 | orientation = OrientationRequestedType.PORTRAIT;
|
---|
283 | origin = OriginType.PHYSICAL;
|
---|
284 | quality = PrintQualityType.NORMAL;
|
---|
285 | setPrinterResolutionToDefault();
|
---|
286 | }
|
---|
287 |
|
---|
288 | public PageAttributes(PageAttributes attr)
|
---|
289 | {
|
---|
290 | set(attr);
|
---|
291 | }
|
---|
292 |
|
---|
293 | public PageAttributes(ColorType color, MediaType media,
|
---|
294 | OrientationRequestedType orientation,
|
---|
295 | OriginType origin, PrintQualityType quality,
|
---|
296 | int[] resolution)
|
---|
297 | {
|
---|
298 | if (color == null || media == null || orientation == null
|
---|
299 | || origin == null || quality == null)
|
---|
300 | throw new IllegalArgumentException();
|
---|
301 | setPrinterResolution(resolution);
|
---|
302 | this.color = color;
|
---|
303 | this.media = media;
|
---|
304 | this.orientation = orientation;
|
---|
305 | this.origin = origin;
|
---|
306 | this.quality = quality;
|
---|
307 | }
|
---|
308 |
|
---|
309 | public Object clone()
|
---|
310 | {
|
---|
311 | return new PageAttributes(this);
|
---|
312 | }
|
---|
313 |
|
---|
314 | public void set(PageAttributes attr)
|
---|
315 | {
|
---|
316 | color = attr.color;
|
---|
317 | media = attr.media;
|
---|
318 | orientation = attr.orientation;
|
---|
319 | origin = attr.origin;
|
---|
320 | quality = attr.quality;
|
---|
321 | resolutionX = attr.resolutionX;
|
---|
322 | resolutionY = attr.resolutionY;
|
---|
323 | resolutionScale = attr.resolutionScale;
|
---|
324 | }
|
---|
325 |
|
---|
326 | public ColorType getColor()
|
---|
327 | {
|
---|
328 | return color;
|
---|
329 | }
|
---|
330 |
|
---|
331 | public void setColor(ColorType color)
|
---|
332 | {
|
---|
333 | if (color == null)
|
---|
334 | throw new IllegalArgumentException();
|
---|
335 | this.color = color;
|
---|
336 | }
|
---|
337 |
|
---|
338 | public MediaType getMedia()
|
---|
339 | {
|
---|
340 | return media;
|
---|
341 | }
|
---|
342 |
|
---|
343 | public void setMedia(MediaType media)
|
---|
344 | {
|
---|
345 | if (media == null)
|
---|
346 | throw new IllegalArgumentException();
|
---|
347 | this.media = media;
|
---|
348 | }
|
---|
349 |
|
---|
350 | public void setMediaToDefault()
|
---|
351 | {
|
---|
352 | String country = Locale.getDefault().getCountry();
|
---|
353 | media = ("US".equals(country) || "CA".equals(country)) ? MediaType.LETTER
|
---|
354 | : MediaType.A4;
|
---|
355 | }
|
---|
356 |
|
---|
357 | public OrientationRequestedType getOrientationRequested()
|
---|
358 | {
|
---|
359 | return orientation;
|
---|
360 | }
|
---|
361 |
|
---|
362 | public void setOrientationRequested(OrientationRequestedType orientation)
|
---|
363 | {
|
---|
364 | if (orientation == null)
|
---|
365 | throw new IllegalArgumentException();
|
---|
366 | this.orientation = orientation;
|
---|
367 | }
|
---|
368 |
|
---|
369 | public void setOrientationRequested(int orientation)
|
---|
370 | {
|
---|
371 | if (orientation == 3)
|
---|
372 | this.orientation = OrientationRequestedType.PORTRAIT;
|
---|
373 | else if (orientation == 4)
|
---|
374 | this.orientation = OrientationRequestedType.LANDSCAPE;
|
---|
375 | else
|
---|
376 | throw new IllegalArgumentException();
|
---|
377 | }
|
---|
378 |
|
---|
379 | public void setOrientationRequestedToDefault()
|
---|
380 | {
|
---|
381 | orientation = OrientationRequestedType.PORTRAIT;
|
---|
382 | }
|
---|
383 |
|
---|
384 | public OriginType getOrigin()
|
---|
385 | {
|
---|
386 | return origin;
|
---|
387 | }
|
---|
388 |
|
---|
389 | public void setOrigin(OriginType origin)
|
---|
390 | {
|
---|
391 | if (origin == null)
|
---|
392 | throw new IllegalArgumentException();
|
---|
393 | this.origin = origin;
|
---|
394 | }
|
---|
395 |
|
---|
396 | public PrintQualityType getPrintQuality()
|
---|
397 | {
|
---|
398 | return quality;
|
---|
399 | }
|
---|
400 |
|
---|
401 | public void setPrintQuality(PrintQualityType quality)
|
---|
402 | {
|
---|
403 | if (quality == null)
|
---|
404 | throw new IllegalArgumentException();
|
---|
405 | this.quality = quality;
|
---|
406 | }
|
---|
407 |
|
---|
408 | public void setPrintQuality(int quality)
|
---|
409 | {
|
---|
410 | if (quality == 3)
|
---|
411 | this.quality = PrintQualityType.DRAFT;
|
---|
412 | else if (quality == 4)
|
---|
413 | this.quality = PrintQualityType.NORMAL;
|
---|
414 | else if (quality == 5)
|
---|
415 | this.quality = PrintQualityType.HIGH;
|
---|
416 | else
|
---|
417 | throw new IllegalArgumentException();
|
---|
418 | }
|
---|
419 |
|
---|
420 | public void setPrintQualityToDefault()
|
---|
421 | {
|
---|
422 | quality = PrintQualityType.NORMAL;
|
---|
423 | }
|
---|
424 |
|
---|
425 | public int[] getPrinterResolution()
|
---|
426 | {
|
---|
427 | return new int[] { resolutionX, resolutionY, resolutionScale };
|
---|
428 | }
|
---|
429 |
|
---|
430 | public void setPrinterResolution(int[] resolution)
|
---|
431 | {
|
---|
432 | if (resolution == null || resolution.length != 3 || resolution[0] <= 0
|
---|
433 | || resolution[1] <= 0 || resolution[2] < 3 || resolution[2] > 4)
|
---|
434 | throw new IllegalArgumentException();
|
---|
435 | resolutionX = resolution[0];
|
---|
436 | resolutionY = resolution[1];
|
---|
437 | resolutionScale = resolution[2];
|
---|
438 | }
|
---|
439 |
|
---|
440 | public void setPrinterResolution(int resolution)
|
---|
441 | {
|
---|
442 | if (resolution <= 0)
|
---|
443 | throw new IllegalArgumentException();
|
---|
444 | resolutionX = resolution;
|
---|
445 | resolutionY = resolution;
|
---|
446 | resolutionScale = 3;
|
---|
447 | }
|
---|
448 |
|
---|
449 | public void setPrinterResolutionToDefault()
|
---|
450 | {
|
---|
451 | resolutionX = 72;
|
---|
452 | resolutionY = 72;
|
---|
453 | resolutionScale = 3;
|
---|
454 | }
|
---|
455 |
|
---|
456 | public boolean equals(Object o)
|
---|
457 | {
|
---|
458 | if (this == o)
|
---|
459 | return true;
|
---|
460 | if (! (o instanceof PageAttributes))
|
---|
461 | return false;
|
---|
462 | PageAttributes pa = (PageAttributes) o;
|
---|
463 | return color == pa.color && media == pa.media
|
---|
464 | && orientation == pa.orientation && origin == pa.origin
|
---|
465 | && quality == pa.quality && resolutionX == pa.resolutionX
|
---|
466 | && resolutionY == pa.resolutionY
|
---|
467 | && resolutionScale == pa.resolutionScale;
|
---|
468 | }
|
---|
469 | public int hashCode()
|
---|
470 | {
|
---|
471 | return (color.value << 31) ^ (media.value << 24)
|
---|
472 | ^ (orientation.value << 23) ^ (origin.value << 22)
|
---|
473 | ^ (quality.value << 20) ^ (resolutionScale << 19)
|
---|
474 | ^ (resolutionY << 10) ^ resolutionX;
|
---|
475 | }
|
---|
476 | public String toString()
|
---|
477 | {
|
---|
478 | return "color=" + color + ",media=" + media + ",orientation-requested="
|
---|
479 | + orientation + ",origin=" + origin + ",print-quality=" + quality
|
---|
480 | + ",printer-resolution=[" + resolutionX + ',' + resolutionY + ','
|
---|
481 | + resolutionScale + ']';
|
---|
482 | }
|
---|
483 | } // class PageAttributes
|
---|