KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > format > PaperSize


1 /*********************************************************************
2  *
3  * Copyright (C) 2002 Andrew Khan
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  ***************************************************************************/

19
20 package jxl.format;
21
22 /**
23  * Enumeration type which contains the available excel paper sizes and their
24  * codes
25  */

26 public final class PaperSize
27 {
28     private static final int LAST_PAPER_SIZE = 89;
29     /**
30      * The excel encoding
31      */

32     private int val;
33
34     /**
35      * The paper sizes
36      */

37     private static PaperSize[] paperSizes = new PaperSize[LAST_PAPER_SIZE + 1];
38
39     /**
40      * Constructor
41      */

42     private PaperSize(int v, boolean growArray)
43     {
44         val = v;
45
46         if (v >= paperSizes.length && growArray)
47         {
48             // Grow the array and add this to it
49
PaperSize[] newarray = new PaperSize[v + 1];
50             System.arraycopy(paperSizes, 0, newarray, 0, paperSizes.length);
51             paperSizes = newarray;
52         }
53         if (v < paperSizes.length)
54         {
55             paperSizes[v] = this;
56         }
57     }
58
59     /**
60      * Constructor
61      */

62     private PaperSize(int v)
63     {
64         this(v, true);
65     }
66
67     /**
68      * Accessor for the internal binary value association with this paper size
69      *
70      * @return the internal value
71      */

72     public int getValue()
73     {
74         return val;
75     }
76
77     /**
78      * Gets the paper size for a specific value
79      *
80      * @param val the value
81      * @return the paper size
82      */

83     public static PaperSize getPaperSize(int val)
84     {
85         PaperSize p = val > paperSizes.length - 1 ? null : paperSizes[val];
86         return p == null ? new PaperSize(val, false) : p;
87     }
88
89     /** US Letter 8.5 x 11" */
90     public static final PaperSize UNDEFINED = new PaperSize(0);
91
92     /** US Letter 8.5 x 11" */
93     public static final PaperSize LETTER = new PaperSize(1);
94
95     /** Letter small 8.5" × 11" */
96     public static final PaperSize LETTER_SMALL = new PaperSize(2);
97
98     /** Tabloid 11" x 17" */
99     public static final PaperSize TABLOID = new PaperSize(3);
100
101     /** Leger 17" x 11" */
102     public static final PaperSize LEDGER = new PaperSize(4);
103
104     /** US Legal 8.5" x 14" */
105     public static final PaperSize LEGAL = new PaperSize(5);
106
107     /** Statement 5.5" x 8.5" */
108     public static final PaperSize STATEMENT = new PaperSize(6);
109
110     /** Executive 7.25" x 10.5" */
111     public static final PaperSize EXECUTIVE = new PaperSize(7);
112
113     /** A3 297mm x 420mm */
114     public static final PaperSize A3 = new PaperSize(8);
115
116     /** A4 210mm x 297mm */
117     public static final PaperSize A4 = new PaperSize(9);
118
119     /** A4 Small 210mm x 297 mm */
120     public static final PaperSize A4_SMALL = new PaperSize(10);
121
122     /** A5 148mm x 210mm */
123     public static final PaperSize A5 = new PaperSize(11);
124
125     /** B4 (JIS) 257mm x 364mm */
126     public static final PaperSize B4 = new PaperSize(12);
127
128     /** B5 (JIS) 182mm x 257mm */
129     public static final PaperSize B5 = new PaperSize(13);
130
131     /** Folio 8.5" x 13" */
132     public static final PaperSize FOLIO = new PaperSize(14);
133
134     /** Quarto 215mm x 275mm */
135     public static final PaperSize QUARTO = new PaperSize(15);
136
137     /** 10" x 14" */
138     public static final PaperSize SIZE_10x14 = new PaperSize(16);
139
140     /** 11" x 17" */
141     public static final PaperSize SIZE_10x17 = new PaperSize(17);
142
143     /** NOTE 8.5" x 11" */
144     public static final PaperSize NOTE = new PaperSize(18);
145
146     /** Envelope #9 3 7/8" x 8 7/8" */
147     public static final PaperSize ENVELOPE_9 = new PaperSize(19);
148
149     /** Envelope #10 4 1/8" x 9.5" */
150     public static final PaperSize ENVELOPE_10 = new PaperSize(20);
151
152     /** Envelope #11 4.5" x 10 3/8" */
153     public static final PaperSize ENVELOPE_11 = new PaperSize(21);
154
155     /** Envelope #12 4.75" x 11" */
156     public static final PaperSize ENVELOPE_12 = new PaperSize(22);
157
158     /** Envelope #14 5" x 11.5" */
159     public static final PaperSize ENVELOPE_14 = new PaperSize(23);
160
161     /** C 17" x 22" */
162     public static final PaperSize C = new PaperSize(24);
163
164     /** D 22" x 34" */
165     public static final PaperSize D = new PaperSize(25);
166
167     /** E 34" x 44" */
168     public static final PaperSize E = new PaperSize(26);
169
170     /** Envelope DL 110mm × 220mm */
171     public static final PaperSize ENVELOPE_DL = new PaperSize(27);
172
173     /** Envelope C5 162mm × 229mm */
174     public static final PaperSize ENVELOPE_C5 = new PaperSize(28);
175
176     /** Envelope C3 324mm × 458mm */
177     public static final PaperSize ENVELOPE_C3 = new PaperSize(29);
178
179     /** Envelope C4 229mm × 324mm */
180     public static final PaperSize ENVELOPE_C4 = new PaperSize(30);
181
182     /** Envelope C6 114mm × 162mm */
183     public static final PaperSize ENVELOPE_C6 = new PaperSize(31);
184
185     /** Envelope C6/C5 114mm × 229mm */
186     public static final PaperSize ENVELOPE_C6_C5 = new PaperSize(32);
187
188     /** B4 (ISO) 250mm × 353mm */
189     public static final PaperSize B4_ISO = new PaperSize(33);
190
191     /** B5 (ISO) 176mm × 250mm */
192     public static final PaperSize B5_ISO = new PaperSize(34);
193
194     /** B6 (ISO) 125mm × 176mm */
195     public static final PaperSize B6_ISO = new PaperSize(35);
196
197     /** Envelope Italy 110mm × 230mm */
198     public static final PaperSize ENVELOPE_ITALY = new PaperSize(36);
199
200     /** Envelope Monarch 3 7/8" × 7.5" */
201     public static final PaperSize ENVELOPE_MONARCH = new PaperSize(37);
202
203     /** 6.75 Envelope 3 5/8" × 6.5" */
204     public static final PaperSize ENVELOPE_6_75 = new PaperSize(38);
205
206     /** US Standard Fanfold 14 7/8" × 11" */
207     public static final PaperSize US_FANFOLD = new PaperSize(39);
208
209     /** German Std. Fanfold 8.5" × 12" */
210     public static final PaperSize GERMAN_FANFOLD = new PaperSize(40);
211
212     /** German Legal Fanfold 8.5" × 13" */
213     public static final PaperSize GERMAN_LEGAL_FANFOLD = new PaperSize(41);
214
215     /** B4 (ISO) 250mm × 353mm */
216     public static final PaperSize B4_ISO_2 = new PaperSize(42);
217
218     /** Japanese Postcard 100mm × 148mm */
219     public static final PaperSize JAPANESE_POSTCARD = new PaperSize(43);
220
221     /** 9×11 9" × 11" */
222     public static final PaperSize SIZE_9x11 = new PaperSize(44);
223
224     /** 10×11 10" × 11" */
225     public static final PaperSize SIZE_10x11 = new PaperSize(45);
226
227     /** 15×11 15" × 11" */
228     public static final PaperSize SIZE_15x11 = new PaperSize(46);
229
230     /** Envelope Invite 220mm × 220mm */
231     public static final PaperSize ENVELOPE_INVITE = new PaperSize(47);
232
233     /* 48 & 49 Undefined */
234
235     /** Letter Extra 9.5" × 12" */
236     public static final PaperSize LETTER_EXTRA = new PaperSize(50);
237
238     /** Legal Extra 9.5" × 15" */
239     public static final PaperSize LEGAL_EXTRA = new PaperSize(51);
240
241     /** Tabloid Extra 11 11/16" × 18" */
242     public static final PaperSize TABLOID_EXTRA = new PaperSize(52);
243
244     /** A4 Extra 235mm × 322mm */
245     public static final PaperSize A4_EXTRA = new PaperSize(53);
246
247     /** Letter Transverse 8.5" × 11" */
248     public static final PaperSize LETTER_TRANSVERSE = new PaperSize(54);
249
250     /** A4 Transverse 210mm × 297mm */
251     public static final PaperSize A4_TRANSVERSE = new PaperSize(55);
252
253     /** Letter Extra Transv. 9.5" × 12" */
254     public static final PaperSize LETTER_EXTRA_TRANSVERSE = new PaperSize(56);
255
256     /** Super A/A4 227mm × 356mm */
257     public static final PaperSize SUPER_A_A4 = new PaperSize(57);
258
259     /** Super B/A3 305mm × 487mm */
260     public static final PaperSize SUPER_B_A3 = new PaperSize(58);
261
262     /** Letter Plus 8.5" x 12 11/16" */
263     public static final PaperSize LETTER_PLUS = new PaperSize(59);
264
265     /** A4 Plus 210mm × 330mm */
266     public static final PaperSize A4_PLUS = new PaperSize(60);
267
268     /** A5 Transverse 148mm × 210mm */
269     public static final PaperSize A5_TRANSVERSE = new PaperSize(61);
270
271     /** B5 (JIS) Transverse 182mm × 257mm */
272     public static final PaperSize B5_TRANSVERSE = new PaperSize(62);
273
274     /** A3 Extra 322mm × 445mm */
275     public static final PaperSize A3_EXTRA = new PaperSize(63);
276
277     /** A5 Extra 174mm × 235mm */
278     public static final PaperSize A5_EXTRA = new PaperSize(64);
279
280     /** B5 (ISO) Extra 201mm × 276mm */
281     public static final PaperSize B5_EXTRA = new PaperSize(65);
282
283     /** A2 420mm × 594mm */
284     public static final PaperSize A2 = new PaperSize(66);
285
286     /** A3 Transverse 297mm × 420mm */
287     public static final PaperSize A3_TRANSVERSE = new PaperSize(67);
288
289     /** A3 Extra Transverse 322mm × 445mm */
290     public static final PaperSize A3_EXTRA_TRANSVERSE = new PaperSize(68);
291
292     /** Dbl. Japanese Postcard 200mm × 148mm */
293     public static final PaperSize DOUBLE_JAPANESE_POSTCARD = new PaperSize(69);
294
295     /** A6 105mm × 148mm */
296     public static final PaperSize A6 = new PaperSize(70);
297
298     /* 71 - 74 undefined */
299
300     /** Letter Rotated 11" × 8.5" */
301     public static final PaperSize LETTER_ROTATED = new PaperSize(75);
302
303     /** A3 Rotated 420mm × 297mm */
304     public static final PaperSize A3_ROTATED = new PaperSize(76);
305
306     /** A4 Rotated 297mm × 210mm */
307     public static final PaperSize A4_ROTATED = new PaperSize(77);
308
309     /** A5 Rotated 210mm × 148mm */
310     public static final PaperSize A5_ROTATED = new PaperSize(78);
311
312     /** B4 (JIS) Rotated 364mm × 257mm */
313     public static final PaperSize B4_ROTATED = new PaperSize(79);
314
315     /** B5 (JIS) Rotated 257mm × 182mm */
316     public static final PaperSize B5_ROTATED = new PaperSize(80);
317
318     /** Japanese Postcard Rot. 148mm × 100mm */
319     public static final PaperSize JAPANESE_POSTCARD_ROTATED = new PaperSize(81);
320
321     /** Dbl. Jap. Postcard Rot. 148mm × 200mm */
322     public static final PaperSize DOUBLE_JAPANESE_POSTCARD_ROTATED = new PaperSize(82);
323
324     /** A6 Rotated 148mm × 105mm */
325     public static final PaperSize A6_ROTATED = new PaperSize(83);
326
327     /* 84 - 87 undefined */
328
329     /** B6 (JIS) 128mm × 182mm */
330     public static final PaperSize B6 = new PaperSize(88);
331
332     /** B6 (JIS) Rotated 182mm × 128mm */
333     public static final PaperSize B6_ROTATED = new PaperSize(89);
334 }
335
Popular Tags