KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > print > attribute > standard > MediaSize


1 /*
2  * @(#)MediaSize.java 1.14 04/05/05
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package javax.print.attribute.standard;
8
9 import java.util.HashMap JavaDoc;
10 import java.util.Vector JavaDoc;
11
12 import javax.print.attribute.Size2DSyntax JavaDoc;
13 import javax.print.attribute.Attribute JavaDoc;
14
15 /**
16  * Class MediaSize is a two-dimensional size valued printing attribute class
17  * that indicates the dimensions of the medium in a portrait orientation, with
18  * the X dimension running along the bottom edge and the Y dimension running
19  * along the left edge. Thus, the Y dimension must be greater than or equal to
20  * the X dimension. Class MediaSize declares many standard media size
21  * values, organized into nested classes for ISO, JIS, North American,
22  * engineering, and other media.
23  * <P>
24  * MediaSize is not yet used to specify media. Its current role is
25  * as a mapping for named media (see {@link MediaSizeName MediaSizeName}).
26  * Clients can use the mapping method
27  * <code>MediaSize.getMediaSizeForName(MediaSizeName)</code>
28  * to find the physical dimensions of the MediaSizeName instances
29  * enumerated in this API. This is useful for clients which need this
30  * information to format & paginate printing.
31  * <P>
32  *
33  * @author Phil Race, Alan Kaminsky
34  */

35 public class MediaSize extends Size2DSyntax JavaDoc implements Attribute JavaDoc {
36
37     private static final long serialVersionUID = -1967958664615414771L;
38
39     private MediaSizeName JavaDoc mediaName;
40
41     private static HashMap JavaDoc mediaMap = new HashMap JavaDoc(100, 10);
42
43     private static Vector JavaDoc sizeVector = new Vector JavaDoc(100, 10);
44  
45     /**
46      * Construct a new media size attribute from the given floating-point
47      * values.
48      *
49      * @param x X dimension.
50      * @param y Y dimension.
51      * @param units
52      * Unit conversion factor, e.g. <CODE>Size2DSyntax.INCH</CODE> or
53      * <CODE>Size2DSyntax.MM</CODE>.
54      *
55      * @exception IllegalArgumentException
56      * (Unchecked exception) Thrown if <CODE>x</CODE> < 0 or <CODE>y</CODE>
57      * < 0 or <CODE>units</CODE> < 1 or <CODE>x</CODE> > <CODE>y</CODE>.
58      */

59     public MediaSize(float x, float y,int units) {
60     super (x, y, units);
61     if (x > y) {
62         throw new IllegalArgumentException JavaDoc("X dimension > Y dimension");
63     }
64     sizeVector.add(this);
65     }
66
67     /**
68      * Construct a new media size attribute from the given integer values.
69      *
70      * @param x X dimension.
71      * @param y Y dimension.
72      * @param units
73      * Unit conversion factor, e.g. <CODE>Size2DSyntax.INCH</CODE> or
74      * <CODE>Size2DSyntax.MM</CODE>.
75      *
76      * @exception IllegalArgumentException
77      * (Unchecked exception) Thrown if <CODE>x</CODE> < 0 or <CODE>y</CODE>
78      * < 0 or <CODE>units</CODE> < 1 or <CODE>x</CODE> > <CODE>y</CODE>.
79      */

80     public MediaSize(int x, int y,int units) {
81     super (x, y, units);
82     if (x > y) {
83         throw new IllegalArgumentException JavaDoc("X dimension > Y dimension");
84     }
85     sizeVector.add(this);
86     }
87
88    /**
89      * Construct a new media size attribute from the given floating-point
90      * values.
91      *
92      * @param x X dimension.
93      * @param y Y dimension.
94      * @param units
95      * Unit conversion factor, e.g. <CODE>Size2DSyntax.INCH</CODE> or
96      * <CODE>Size2DSyntax.MM</CODE>.
97      * @param media a media name to associate with this MediaSize
98      *
99      * @exception IllegalArgumentException
100      * (Unchecked exception) Thrown if <CODE>x</CODE> < 0 or <CODE>y</CODE>
101      * < 0 or <CODE>units</CODE> < 1 or <CODE>x</CODE> > <CODE>y</CODE>.
102      */

103     public MediaSize(float x, float y,int units, MediaSizeName JavaDoc media) {
104     super (x, y, units);
105     if (x > y) {
106         throw new IllegalArgumentException JavaDoc("X dimension > Y dimension");
107     }
108     mediaName = media;
109     mediaMap.put(mediaName, this);
110     sizeVector.add(this);
111     }
112
113     /**
114      * Construct a new media size attribute from the given integer values.
115      *
116      * @param x X dimension.
117      * @param y Y dimension.
118      * @param units
119      * Unit conversion factor, e.g. <CODE>Size2DSyntax.INCH</CODE> or
120      * <CODE>Size2DSyntax.MM</CODE>.
121      * @param media a media name to associate with this MediaSize
122      *
123      * @exception IllegalArgumentException
124      * (Unchecked exception) Thrown if <CODE>x</CODE> < 0 or <CODE>y</CODE>
125      * < 0 or <CODE>units</CODE> < 1 or <CODE>x</CODE> > <CODE>y</CODE>.
126      */

127     public MediaSize(int x, int y,int units, MediaSizeName JavaDoc media) {
128     super (x, y, units);
129     if (x > y) {
130         throw new IllegalArgumentException JavaDoc("X dimension > Y dimension");
131     }
132     mediaName = media;
133     mediaMap.put(mediaName, this);
134     sizeVector.add(this);
135     }
136
137     /**
138      * Get the media name, if any, for this size.
139      *
140      * @return the name for this media size, or null if no name was
141      * associated with this size (an anonymous size).
142      */

143     public MediaSizeName JavaDoc getMediaSizeName() {
144     return mediaName;
145     }
146
147     /**
148      * Get the MediaSize for the specified named media.
149      *
150      * @param media - the name of the media for which the size is sought
151      * @return size of the media, or null if this media is not associated
152      * with any size.
153      */

154     public static MediaSize JavaDoc getMediaSizeForName(MediaSizeName JavaDoc media) {
155     return (MediaSize JavaDoc)mediaMap.get(media);
156     }
157
158     /**
159      * The specified dimensions are used to locate a matching MediaSize
160      * instance from amongst all the standard MediaSize instances.
161      * If there is no exact match, the closest match is used.
162      * <p>
163      * The MediaSize is in turn used to locate the MediaSizeName object.
164      * This method may return null if the closest matching MediaSize
165      * has no corresponding Media instance.
166      * <p>
167      * This method is useful for clients which have only dimensions and
168      * want to find a Media which corresponds to the dimensions.
169      * @param x - X dimension
170      * @param y - Y dimension.
171      * @param units
172      * Unit conversion factor, e.g. <CODE>Size2DSyntax.INCH</CODE> or
173      * <CODE>Size2DSyntax.MM</CODE>
174      * @return MediaSizeName matching these dimensions, or null.
175      * @exception IllegalArgumentException if x <= 0, y <= 0, or units < 1
176      *
177      */

178     public static MediaSizeName JavaDoc findMedia(float x, float y, int units) {
179
180     MediaSize JavaDoc match = MediaSize.ISO.A4;
181
182     if (x <= 0.0f || y <= 0.0f || units < 1) {
183         throw new IllegalArgumentException JavaDoc("args must be +ve values");
184     }
185
186     double ls = x * x + y * y;
187     double tmp_ls;
188     float []dim;
189     float diffx = x;
190     float diffy = y;
191
192     for (int i=0; i < sizeVector.size() ; i++) {
193         MediaSize JavaDoc mediaSize = (MediaSize JavaDoc)sizeVector.elementAt(i);
194         dim = mediaSize.getSize(units);
195         if (x == dim[0] && y == dim[1]) {
196         match = mediaSize;
197         break;
198         } else {
199         diffx = x - dim[0];
200         diffy = y - dim[1];
201         tmp_ls = diffx * diffx + diffy * diffy;
202         if (tmp_ls < ls) {
203             ls = tmp_ls;
204             match = mediaSize;
205         }
206         }
207     }
208
209     return match.getMediaSizeName();
210     }
211
212     /**
213      * Returns whether this media size attribute is equivalent to the passed
214      * in object.
215      * To be equivalent, all of the following conditions must be true:
216      * <OL TYPE=1>
217      * <LI>
218      * <CODE>object</CODE> is not null.
219      * <LI>
220      * <CODE>object</CODE> is an instance of class MediaSize.
221      * <LI>
222      * This media size attribute's X dimension is equal to
223      * <CODE>object</CODE>'s X dimension.
224      * <LI>
225      * This media size attribute's Y dimension is equal to
226      * <CODE>object</CODE>'s Y dimension.
227      * </OL>
228      *
229      * @param object Object to compare to.
230      *
231      * @return True if <CODE>object</CODE> is equivalent to this media size
232      * attribute, false otherwise.
233      */

234     public boolean equals(Object JavaDoc object) {
235     return (super.equals(object) && object instanceof MediaSize JavaDoc);
236     }
237
238     /**
239      * Get the printing attribute class which is to be used as the "category"
240      * for this printing attribute value.
241      * <P>
242      * For class MediaSize and any vendor-defined subclasses, the category is
243      * class MediaSize itself.
244      *
245      * @return Printing attribute class (category), an instance of class
246      * {@link java.lang.Class java.lang.Class}.
247      */

248     public final Class JavaDoc<? extends Attribute JavaDoc> getCategory() {
249     return MediaSize JavaDoc.class;
250     }
251
252     /**
253      * Get the name of the category of which this attribute value is an
254      * instance.
255      * <P>
256      * For class MediaSize and any vendor-defined subclasses, the category
257      * name is <CODE>"media-size"</CODE>.
258      *
259      * @return Attribute category name.
260      */

261     public final String JavaDoc getName() {
262     return "media-size";
263     }
264
265     /**
266      * Class MediaSize.ISO includes {@link MediaSize MediaSize} values for ISO
267      * media.
268      * <P>
269      */

270     public final static class ISO {
271     /**
272      * Specifies the ISO A0 size, 841 mm by 1189 mm.
273      */

274     public static final MediaSize JavaDoc
275         A0 = new MediaSize JavaDoc(841, 1189, Size2DSyntax.MM, MediaSizeName.ISO_A0);
276     /**
277      * Specifies the ISO A1 size, 594 mm by 841 mm.
278      */

279     public static final MediaSize JavaDoc
280         A1 = new MediaSize JavaDoc(594, 841, Size2DSyntax.MM, MediaSizeName.ISO_A1);
281     /**
282      * Specifies the ISO A2 size, 420 mm by 594 mm.
283      */

284     public static final MediaSize JavaDoc
285         A2 = new MediaSize JavaDoc(420, 594, Size2DSyntax.MM, MediaSizeName.ISO_A2);
286     /**
287      * Specifies the ISO A3 size, 297 mm by 420 mm.
288      */

289     public static final MediaSize JavaDoc
290         A3 = new MediaSize JavaDoc(297, 420, Size2DSyntax.MM, MediaSizeName.ISO_A3);
291     /**
292      * Specifies the ISO A4 size, 210 mm by 297 mm.
293      */

294     public static final MediaSize JavaDoc
295         A4 = new MediaSize JavaDoc(210, 297, Size2DSyntax.MM, MediaSizeName.ISO_A4);
296     /**
297      * Specifies the ISO A5 size, 148 mm by 210 mm.
298      */

299     public static final MediaSize JavaDoc
300         A5 = new MediaSize JavaDoc(148, 210, Size2DSyntax.MM, MediaSizeName.ISO_A5);
301     /**
302      * Specifies the ISO A6 size, 105 mm by 148 mm.
303      */

304     public static final MediaSize JavaDoc
305         A6 = new MediaSize JavaDoc(105, 148, Size2DSyntax.MM, MediaSizeName.ISO_A6);
306     /**
307      * Specifies the ISO A7 size, 74 mm by 105 mm.
308      */

309     public static final MediaSize JavaDoc
310         A7 = new MediaSize JavaDoc(74, 105, Size2DSyntax.MM, MediaSizeName.ISO_A7);
311     /**
312      * Specifies the ISO A8 size, 52 mm by 74 mm.
313      */

314     public static final MediaSize JavaDoc
315         A8 = new MediaSize JavaDoc(52, 74, Size2DSyntax.MM, MediaSizeName.ISO_A8);
316     /**
317      * Specifies the ISO A9 size, 37 mm by 52 mm.
318      */

319     public static final MediaSize JavaDoc
320         A9 = new MediaSize JavaDoc(37, 52, Size2DSyntax.MM, MediaSizeName.ISO_A9);
321     /**
322      * Specifies the ISO A10 size, 26 mm by 37 mm.
323      */

324     public static final MediaSize JavaDoc
325         A10 = new MediaSize JavaDoc(26, 37, Size2DSyntax.MM, MediaSizeName.ISO_A10);
326     /**
327      * Specifies the ISO B0 size, 1000 mm by 1414 mm.
328      */

329     public static final MediaSize JavaDoc
330         B0 = new MediaSize JavaDoc(1000, 1414, Size2DSyntax.MM, MediaSizeName.ISO_B0);
331     /**
332      * Specifies the ISO B1 size, 707 mm by 1000 mm.
333      */

334     public static final MediaSize JavaDoc
335         B1 = new MediaSize JavaDoc(707, 1000, Size2DSyntax.MM, MediaSizeName.ISO_B1);
336     /**
337      * Specifies the ISO B2 size, 500 mm by 707 mm.
338      */

339     public static final MediaSize JavaDoc
340         B2 = new MediaSize JavaDoc(500, 707, Size2DSyntax.MM, MediaSizeName.ISO_B2);
341     /**
342      * Specifies the ISO B3 size, 353 mm by 500 mm.
343      */

344     public static final MediaSize JavaDoc
345         B3 = new MediaSize JavaDoc(353, 500, Size2DSyntax.MM, MediaSizeName.ISO_B3);
346     /**
347      * Specifies the ISO B4 size, 250 mm by 353 mm.
348      */

349     public static final MediaSize JavaDoc
350         B4 = new MediaSize JavaDoc(250, 353, Size2DSyntax.MM, MediaSizeName.ISO_B4);
351     /**
352      * Specifies the ISO B5 size, 176 mm by 250 mm.
353      */

354     public static final MediaSize JavaDoc
355         B5 = new MediaSize JavaDoc(176, 250, Size2DSyntax.MM, MediaSizeName.ISO_B5);
356     /**
357      * Specifies the ISO B6 size, 125 mm by 176 mm.
358      */

359     public static final MediaSize JavaDoc
360         B6 = new MediaSize JavaDoc(125, 176, Size2DSyntax.MM, MediaSizeName.ISO_B6);
361     /**
362      * Specifies the ISO B7 size, 88 mm by 125 mm.
363      */

364     public static final MediaSize JavaDoc
365         B7 = new MediaSize JavaDoc(88, 125, Size2DSyntax.MM, MediaSizeName.ISO_B7);
366     /**
367      * Specifies the ISO B8 size, 62 mm by 88 mm.
368      */

369     public static final MediaSize JavaDoc
370         B8 = new MediaSize JavaDoc(62, 88, Size2DSyntax.MM, MediaSizeName.ISO_B8);
371     /**
372      * Specifies the ISO B9 size, 44 mm by 62 mm.
373      */

374     public static final MediaSize JavaDoc
375         B9 = new MediaSize JavaDoc(44, 62, Size2DSyntax.MM, MediaSizeName.ISO_B9);
376     /**
377      * Specifies the ISO B10 size, 31 mm by 44 mm.
378      */

379     public static final MediaSize JavaDoc
380         B10 = new MediaSize JavaDoc(31, 44, Size2DSyntax.MM, MediaSizeName.ISO_B10);
381     /**
382      * Specifies the ISO C3 size, 324 mm by 458 mm.
383      */

384     public static final MediaSize JavaDoc
385         C3 = new MediaSize JavaDoc(324, 458, Size2DSyntax.MM, MediaSizeName.ISO_C3);
386     /**
387      * Specifies the ISO C4 size, 229 mm by 324 mm.
388      */

389     public static final MediaSize JavaDoc
390         C4 = new MediaSize JavaDoc(229, 324, Size2DSyntax.MM, MediaSizeName.ISO_C4);
391     /**
392      * Specifies the ISO C5 size, 162 mm by 229 mm.
393      */

394     public static final MediaSize JavaDoc
395         C5 = new MediaSize JavaDoc(162, 229, Size2DSyntax.MM, MediaSizeName.ISO_C5);
396     /**
397      * Specifies the ISO C6 size, 114 mm by 162 mm.
398      */

399     public static final MediaSize JavaDoc
400         C6 = new MediaSize JavaDoc(114, 162, Size2DSyntax.MM, MediaSizeName.ISO_C6);
401     /**
402      * Specifies the ISO Designated Long size, 110 mm by 220 mm.
403      */

404     public static final MediaSize JavaDoc
405         DESIGNATED_LONG = new MediaSize JavaDoc(110, 220, Size2DSyntax.MM,
406                         MediaSizeName.ISO_DESIGNATED_LONG);
407
408     /**
409      * Hide all constructors.
410      */

411     private ISO() {
412     }
413     }
414
415     /**
416      * Class MediaSize.JIS includes {@link MediaSize MediaSize} values for JIS
417      * (Japanese) media. *
418      */

419     public final static class JIS {
420
421     /**
422      * Specifies the JIS B0 size, 1030 mm by 1456 mm.
423      */

424     public static final MediaSize JavaDoc
425         B0 = new MediaSize JavaDoc(1030, 1456, Size2DSyntax.MM, MediaSizeName.JIS_B0);
426     /**
427      * Specifies the JIS B1 size, 728 mm by 1030 mm.
428      */

429     public static final MediaSize JavaDoc
430         B1 = new MediaSize JavaDoc(728, 1030, Size2DSyntax.MM, MediaSizeName.JIS_B1);
431     /**
432      * Specifies the JIS B2 size, 515 mm by 728 mm.
433      */

434     public static final MediaSize JavaDoc
435         B2 = new MediaSize JavaDoc(515, 728, Size2DSyntax.MM, MediaSizeName.JIS_B2);
436     /**
437      * Specifies the JIS B3 size, 364 mm by 515 mm.
438      */

439     public static final MediaSize JavaDoc
440         B3 = new MediaSize JavaDoc(364, 515, Size2DSyntax.MM, MediaSizeName.JIS_B3);
441     /**
442      * Specifies the JIS B4 size, 257 mm by 364 mm.
443      */

444     public static final MediaSize JavaDoc
445         B4 = new MediaSize JavaDoc(257, 364, Size2DSyntax.MM, MediaSizeName.JIS_B4);
446     /**
447      * Specifies the JIS B5 size, 182 mm by 257 mm.
448      */

449     public static final MediaSize JavaDoc
450         B5 = new MediaSize JavaDoc(182, 257, Size2DSyntax.MM, MediaSizeName.JIS_B5);
451     /**
452      * Specifies the JIS B6 size, 128 mm by 182 mm.
453      */

454     public static final MediaSize JavaDoc
455         B6 = new MediaSize JavaDoc(128, 182, Size2DSyntax.MM, MediaSizeName.JIS_B6);
456     /**
457      * Specifies the JIS B7 size, 91 mm by 128 mm.
458      */

459     public static final MediaSize JavaDoc
460         B7 = new MediaSize JavaDoc(91, 128, Size2DSyntax.MM, MediaSizeName.JIS_B7);
461     /**
462      * Specifies the JIS B8 size, 64 mm by 91 mm.
463      */

464     public static final MediaSize JavaDoc
465         B8 = new MediaSize JavaDoc(64, 91, Size2DSyntax.MM, MediaSizeName.JIS_B8);
466     /**
467      * Specifies the JIS B9 size, 45 mm by 64 mm.
468      */

469     public static final MediaSize JavaDoc
470         B9 = new MediaSize JavaDoc(45, 64, Size2DSyntax.MM, MediaSizeName.JIS_B9);
471     /**
472      * Specifies the JIS B10 size, 32 mm by 45 mm.
473      */

474     public static final MediaSize JavaDoc
475         B10 = new MediaSize JavaDoc(32, 45, Size2DSyntax.MM, MediaSizeName.JIS_B10);
476     /**
477      * Specifies the JIS Chou ("long") #1 envelope size, 142 mm by 332 mm.
478      */

479     public static final MediaSize JavaDoc CHOU_1 = new MediaSize JavaDoc(142, 332, Size2DSyntax.MM);
480     /**
481      * Specifies the JIS Chou ("long") #2 envelope size, 119 mm by 277 mm.
482      */

483     public static final MediaSize JavaDoc CHOU_2 = new MediaSize JavaDoc(119, 277, Size2DSyntax.MM);
484     /**
485      * Specifies the JIS Chou ("long") #3 envelope size, 120 mm by 235 mm.
486      */

487     public static final MediaSize JavaDoc CHOU_3 = new MediaSize JavaDoc(120, 235, Size2DSyntax.MM);
488     /**
489      * Specifies the JIS Chou ("long") #4 envelope size, 90 mm by 205 mm.
490      */

491     public static final MediaSize JavaDoc CHOU_4 = new MediaSize JavaDoc(90, 205, Size2DSyntax.MM);
492     /**
493      * Specifies the JIS Chou ("long") #30 envelope size, 92 mm by 235 mm.
494      */

495     public static final MediaSize JavaDoc CHOU_30 = new MediaSize JavaDoc(92, 235, Size2DSyntax.MM);
496     /**
497      * Specifies the JIS Chou ("long") #40 envelope size, 90 mm by 225 mm.
498      */

499     public static final MediaSize JavaDoc CHOU_40 = new MediaSize JavaDoc(90, 225, Size2DSyntax.MM);
500     /**
501      * Specifies the JIS Kaku ("square") #0 envelope size, 287 mm by 382 mm.
502      */

503     public static final MediaSize JavaDoc KAKU_0 = new MediaSize JavaDoc(287, 382, Size2DSyntax.MM);
504     /**
505      * Specifies the JIS Kaku ("square") #1 envelope size, 270 mm by 382 mm.
506      */

507     public static final MediaSize JavaDoc KAKU_1 = new MediaSize JavaDoc(270, 382, Size2DSyntax.MM);
508     /**
509      * Specifies the JIS Kaku ("square") #2 envelope size, 240 mm by 332 mm.
510      */

511     public static final MediaSize JavaDoc KAKU_2 = new MediaSize JavaDoc(240, 332, Size2DSyntax.MM);
512     /**
513      * Specifies the JIS Kaku ("square") #3 envelope size, 216 mm by 277 mm.
514      */

515     public static final MediaSize JavaDoc KAKU_3 = new MediaSize JavaDoc(216, 277, Size2DSyntax.MM);
516     /**
517      * Specifies the JIS Kaku ("square") #4 envelope size, 197 mm by 267 mm.
518      */

519     public static final MediaSize JavaDoc KAKU_4 = new MediaSize JavaDoc(197, 267, Size2DSyntax.MM);
520     /**
521      * Specifies the JIS Kaku ("square") #5 envelope size, 190 mm by 240 mm.
522      */

523     public static final MediaSize JavaDoc KAKU_5 = new MediaSize JavaDoc(190, 240, Size2DSyntax.MM);
524     /**
525      * Specifies the JIS Kaku ("square") #6 envelope size, 162 mm by 229 mm.
526      */

527     public static final MediaSize JavaDoc KAKU_6 = new MediaSize JavaDoc(162, 229, Size2DSyntax.MM);
528     /**
529      * Specifies the JIS Kaku ("square") #7 envelope size, 142 mm by 205 mm.
530      */

531     public static final MediaSize JavaDoc KAKU_7 = new MediaSize JavaDoc(142, 205, Size2DSyntax.MM);
532     /**
533      * Specifies the JIS Kaku ("square") #8 envelope size, 119 mm by 197 mm.
534      */

535     public static final MediaSize JavaDoc KAKU_8 = new MediaSize JavaDoc(119, 197, Size2DSyntax.MM);
536     /**
537      * Specifies the JIS Kaku ("square") #20 envelope size, 229 mm by 324 mm.
538      */

539     public static final MediaSize JavaDoc KAKU_20 = new MediaSize JavaDoc(229, 324, Size2DSyntax.MM);
540     /**
541      * Specifies the JIS Kaku ("square") A4 envelope size, 228 mm by 312 mm.
542      */

543     public static final MediaSize JavaDoc KAKU_A4 = new MediaSize JavaDoc(228, 312, Size2DSyntax.MM);
544     /**
545      * Specifies the JIS You ("Western") #1 envelope size, 120 mm by 176 mm.
546      */

547     public static final MediaSize JavaDoc YOU_1 = new MediaSize JavaDoc(120, 176, Size2DSyntax.MM);
548     /**
549      * Specifies the JIS You ("Western") #2 envelope size, 114 mm by 162 mm.
550      */

551     public static final MediaSize JavaDoc YOU_2 = new MediaSize JavaDoc(114, 162, Size2DSyntax.MM);
552     /**
553      * Specifies the JIS You ("Western") #3 envelope size, 98 mm by 148 mm.
554      */

555     public static final MediaSize JavaDoc YOU_3 = new MediaSize JavaDoc(98, 148, Size2DSyntax.MM);
556     /**
557      * Specifies the JIS You ("Western") #4 envelope size, 105 mm by 235 mm.
558      */

559     public static final MediaSize JavaDoc YOU_4 = new MediaSize JavaDoc(105, 235, Size2DSyntax.MM);
560     /**
561      * Specifies the JIS You ("Western") #5 envelope size, 95 mm by 217 mm.
562      */

563     public static final MediaSize JavaDoc YOU_5 = new MediaSize JavaDoc(95, 217, Size2DSyntax.MM);
564     /**
565      * Specifies the JIS You ("Western") #6 envelope size, 98 mm by 190 mm.
566      */

567     public static final MediaSize JavaDoc YOU_6 = new MediaSize JavaDoc(98, 190, Size2DSyntax.MM);
568     /**
569      * Specifies the JIS You ("Western") #7 envelope size, 92 mm by 165 mm.
570      */

571     public static final MediaSize JavaDoc YOU_7 = new MediaSize JavaDoc(92, 165, Size2DSyntax.MM);
572     /**
573      * Hide all constructors.
574      */

575     private JIS() {
576     }
577     }
578
579     /**
580      * Class MediaSize.NA includes {@link MediaSize MediaSize} values for North
581      * American media.
582      */

583     public final static class NA {
584
585     /**
586      * Specifies the North American letter size, 8.5 inches by 11 inches.
587      */

588     public static final MediaSize JavaDoc
589         LETTER = new MediaSize JavaDoc(8.5f, 11.0f, Size2DSyntax.INCH,
590                                 MediaSizeName.NA_LETTER);
591     /**
592      * Specifies the North American legal size, 8.5 inches by 14 inches.
593      */

594     public static final MediaSize JavaDoc
595         LEGAL = new MediaSize JavaDoc(8.5f, 14.0f, Size2DSyntax.INCH,
596                                MediaSizeName.NA_LEGAL);
597     /**
598      * Specifies the North American 5 inch by 7 inch paper.
599      */

600     public static final MediaSize JavaDoc
601         NA_5X7 = new MediaSize JavaDoc(5, 7, Size2DSyntax.INCH,
602                    MediaSizeName.NA_5X7);
603     /**
604      * Specifies the North American 8 inch by 10 inch paper.
605      */

606     public static final MediaSize JavaDoc
607         NA_8X10 = new MediaSize JavaDoc(8, 10, Size2DSyntax.INCH,
608                    MediaSizeName.NA_8X10);
609     /**
610      * Specifies the North American Number 9 business envelope size,
611      * 3.875 inches by 8.875 inches.
612      */

613     public static final MediaSize JavaDoc
614         NA_NUMBER_9_ENVELOPE =
615         new MediaSize JavaDoc(3.875f, 8.875f, Size2DSyntax.INCH,
616               MediaSizeName.NA_NUMBER_9_ENVELOPE);
617     /**
618      * Specifies the North American Number 10 business envelope size,
619      * 4.125 inches by 9.5 inches.
620      */

621     public static final MediaSize JavaDoc
622         NA_NUMBER_10_ENVELOPE =
623         new MediaSize JavaDoc(4.125f, 9.5f, Size2DSyntax.INCH,
624               MediaSizeName.NA_NUMBER_10_ENVELOPE);
625     /**
626      * Specifies the North American Number 11 business envelope size,
627      * 4.5 inches by 10.375 inches.
628      */

629     public static final MediaSize JavaDoc
630         NA_NUMBER_11_ENVELOPE =
631         new MediaSize JavaDoc(4.5f, 10.375f, Size2DSyntax.INCH,
632               MediaSizeName.NA_NUMBER_11_ENVELOPE);
633     /**
634      * Specifies the North American Number 12 business envelope size,
635      * 4.75 inches by 11 inches.
636      */

637     public static final MediaSize JavaDoc
638         NA_NUMBER_12_ENVELOPE =
639         new MediaSize JavaDoc(4.75f, 11.0f, Size2DSyntax.INCH,
640               MediaSizeName.NA_NUMBER_12_ENVELOPE);
641     /**
642      * Specifies the North American Number 14 business envelope size,
643      * 5 inches by 11.5 inches.
644      */

645     public static final MediaSize JavaDoc
646         NA_NUMBER_14_ENVELOPE =
647         new MediaSize JavaDoc(5.0f, 11.5f, Size2DSyntax.INCH,
648               MediaSizeName.NA_NUMBER_14_ENVELOPE);
649
650     /**
651      * Specifies the North American 6 inch by 9 inch envelope size.
652      */

653     public static final MediaSize JavaDoc
654         NA_6X9_ENVELOPE = new MediaSize JavaDoc(6.0f, 9.0f, Size2DSyntax.INCH,
655                         MediaSizeName.NA_6X9_ENVELOPE);
656     /**
657      * Specifies the North American 7 inch by 9 inch envelope size.
658      */

659     public static final MediaSize JavaDoc
660         NA_7X9_ENVELOPE = new MediaSize JavaDoc(7.0f, 9.0f, Size2DSyntax.INCH,
661                         MediaSizeName.NA_7X9_ENVELOPE);
662     /**
663      * Specifies the North American 9 inch by 11 inch envelope size.
664      */

665     public static final MediaSize JavaDoc
666         NA_9x11_ENVELOPE = new MediaSize JavaDoc(9.0f, 11.0f, Size2DSyntax.INCH,
667                          MediaSizeName.NA_9X11_ENVELOPE);
668     /**
669      * Specifies the North American 9 inch by 12 inch envelope size.
670      */

671     public static final MediaSize JavaDoc
672         NA_9x12_ENVELOPE = new MediaSize JavaDoc(9.0f, 12.0f, Size2DSyntax.INCH,
673                          MediaSizeName.NA_9X12_ENVELOPE);
674     /**
675      * Specifies the North American 10 inch by 13 inch envelope size.
676      */

677     public static final MediaSize JavaDoc
678         NA_10x13_ENVELOPE = new MediaSize JavaDoc(10.0f, 13.0f, Size2DSyntax.INCH,
679                           MediaSizeName.NA_10X13_ENVELOPE);
680     /**
681      * Specifies the North American 10 inch by 14 inch envelope size.
682      */

683     public static final MediaSize JavaDoc
684         NA_10x14_ENVELOPE = new MediaSize JavaDoc(10.0f, 14.0f, Size2DSyntax.INCH,
685                           MediaSizeName.NA_10X14_ENVELOPE);
686     /**
687      * Specifies the North American 10 inch by 15 inch envelope size.
688      */

689     public static final MediaSize JavaDoc
690         NA_10X15_ENVELOPE = new MediaSize JavaDoc(10.0f, 15.0f, Size2DSyntax.INCH,
691                           MediaSizeName.NA_10X15_ENVELOPE);
692     /**
693      * Hide all constructors.
694      */

695     private NA() {
696     }
697     }
698
699     /**
700      * Class MediaSize.Engineering includes {@link MediaSize MediaSize} values
701      * for engineering media.
702      */

703     public final static class Engineering {
704
705     /**
706      * Specifies the engineering A size, 8.5 inch by 11 inch.
707      */

708     public static final MediaSize JavaDoc
709         A = new MediaSize JavaDoc(8.5f, 11.0f, Size2DSyntax.INCH,
710                   MediaSizeName.A);
711     /**
712      * Specifies the engineering B size, 11 inch by 17 inch.
713      */

714     public static final MediaSize JavaDoc
715         B = new MediaSize JavaDoc(11.0f, 17.0f, Size2DSyntax.INCH,
716                   MediaSizeName.B);
717     /**
718      * Specifies the engineering C size, 17 inch by 22 inch.
719      */

720     public static final MediaSize JavaDoc
721         C = new MediaSize JavaDoc(17.0f, 22.0f, Size2DSyntax.INCH,
722                   MediaSizeName.C);
723     /**
724      * Specifies the engineering D size, 22 inch by 34 inch.
725      */

726     public static final MediaSize JavaDoc
727         D = new MediaSize JavaDoc(22.0f, 34.0f, Size2DSyntax.INCH,
728                   MediaSizeName.D);
729     /**
730      * Specifies the engineering E size, 34 inch by 44 inch.
731      */

732     public static final MediaSize JavaDoc
733         E = new MediaSize JavaDoc(34.0f, 44.0f, Size2DSyntax.INCH,
734                   MediaSizeName.E);
735     /**
736      * Hide all constructors.
737      */

738     private Engineering() {
739     }
740     }
741
742     /**
743      * Class MediaSize.Other includes {@link MediaSize MediaSize} values for
744      * miscellaneous media.
745      */

746     public final static class Other {
747     /**
748      * Specifies the executive size, 7.25 inches by 10.5 inches.
749      */

750     public static final MediaSize JavaDoc
751         EXECUTIVE = new MediaSize JavaDoc(7.25f, 10.5f, Size2DSyntax.INCH,
752                       MediaSizeName.EXECUTIVE);
753     /**
754      * Specifies the ledger size, 11 inches by 17 inches.
755      */

756     public static final MediaSize JavaDoc
757         LEDGER = new MediaSize JavaDoc(11.0f, 17.0f, Size2DSyntax.INCH,
758                    MediaSizeName.LEDGER);
759
760     /**
761      * Specifies the tabloid size, 11 inches by 17 inches.
762      */

763     public static final MediaSize JavaDoc
764         TABLOID = new MediaSize JavaDoc(11.0f, 17.0f, Size2DSyntax.INCH,
765                    MediaSizeName.TABLOID);
766
767     /**
768      * Specifies the invoice size, 5.5 inches by 8.5 inches.
769      */

770     public static final MediaSize JavaDoc
771         INVOICE = new MediaSize JavaDoc(5.5f, 8.5f, Size2DSyntax.INCH,
772                   MediaSizeName.INVOICE);
773     /**
774      * Specifies the folio size, 8.5 inches by 13 inches.
775      */

776     public static final MediaSize JavaDoc
777         FOLIO = new MediaSize JavaDoc(8.5f, 13.0f, Size2DSyntax.INCH,
778                   MediaSizeName.FOLIO);
779     /**
780      * Specifies the quarto size, 8.5 inches by 10.83 inches.
781      */

782     public static final MediaSize JavaDoc
783         QUARTO = new MediaSize JavaDoc(8.5f, 10.83f, Size2DSyntax.INCH,
784                    MediaSizeName.QUARTO);
785     /**
786      * Specifies the Italy envelope size, 110 mm by 230 mm.
787      */

788     public static final MediaSize JavaDoc
789     ITALY_ENVELOPE = new MediaSize JavaDoc(110, 230, Size2DSyntax.MM,
790                        MediaSizeName.ITALY_ENVELOPE);
791     /**
792      * Specifies the Monarch envelope size, 3.87 inch by 7.5 inch.
793      */

794     public static final MediaSize JavaDoc
795     MONARCH_ENVELOPE = new MediaSize JavaDoc(3.87f, 7.5f, Size2DSyntax.INCH,
796                      MediaSizeName.MONARCH_ENVELOPE);
797     /**
798      * Specifies the Personal envelope size, 3.625 inch by 6.5 inch.
799      */

800     public static final MediaSize JavaDoc
801     PERSONAL_ENVELOPE = new MediaSize JavaDoc(3.625f, 6.5f, Size2DSyntax.INCH,
802                      MediaSizeName.PERSONAL_ENVELOPE);
803     /**
804      * Specifies the Japanese postcard size, 100 mm by 148 mm.
805      */

806     public static final MediaSize JavaDoc
807         JAPANESE_POSTCARD = new MediaSize JavaDoc(100, 148, Size2DSyntax.MM,
808                           MediaSizeName.JAPANESE_POSTCARD);
809     /**
810      * Specifies the Japanese Double postcard size, 148 mm by 200 mm.
811      */

812     public static final MediaSize JavaDoc
813         JAPANESE_DOUBLE_POSTCARD = new MediaSize JavaDoc(148, 200, Size2DSyntax.MM,
814                      MediaSizeName.JAPANESE_DOUBLE_POSTCARD);
815     /**
816      * Hide all constructors.
817      */

818     private Other() {
819     }
820     }
821
822     /* force loading of all the subclasses so that the instances
823      * are created and inserted into the hashmap.
824      */

825     static {
826     MediaSize JavaDoc ISOA4 = ISO.A4;
827     MediaSize JavaDoc JISB5 = JIS.B5;
828     MediaSize JavaDoc NALETTER = NA.LETTER;
829     MediaSize JavaDoc EngineeringC = Engineering.C;
830     MediaSize JavaDoc OtherEXECUTIVE = Other.EXECUTIVE;
831     }
832 }
833
Popular Tags