summaryrefslogtreecommitdiff
path: root/javax/print/attribute/standard/MediaSize.java
blob: e094f8081da0a6e1b27c3ba952fba30be72ff372 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
/* MediaSize.java -- 
   Copyright (C) 2005, 2006  Free Software Foundation, Inc.

This file is part of GNU Classpath.

GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version. */


package javax.print.attribute.standard;

import java.util.ArrayList;

import javax.print.attribute.Attribute;
import javax.print.attribute.Size2DSyntax;

/**
 * The <code>MediaSize</code> printing attribute class specifies the size
 * of a printing media. The size is defined in portrait orientation with 
 * x at the bottom edge and y at the left edge.
 * <p>
 * There are several media sizes predefined through the nested classes. Further
 * sizes may be provided by the application. <code>MediaSize</code> is not used
 * as a printing attribute currently. It may be used to get the actual sizes 
 * for a named media or to find a suitable <code>MediaSizeName</code> instance
 * by querying with the needed sizes.
 * </p> 
 * <p>
 * <b>IPP Compatibility:</b> MediaSize is not an IPP 1.1 attribute.
 * </p>
 * @see javax.print.attribute.standard.MediaSizeName
 * 
 * @author Michael Koch (konqueror@gmx.de)
 * @author Wolfgang Baer (WBaer@gmx.de)
 */
public class MediaSize extends Size2DSyntax
  implements Attribute
{
  private static final long serialVersionUID = -1967958664615414771L;

  private static ArrayList mediaCache;
  
  static
    {
      mediaCache = new ArrayList();
      
      // We call one instance of every container class to make sure it gets
      // loaded during class initialization and therefore all other static
      // fields of this container class also.
      
      // This is needed to put all MediaSize instance into the mediaCache
      // for use by the static methods in this class.
      
      MediaSize tmp = MediaSize.ISO.A0;
      tmp = MediaSize.JIS.B0;
      tmp = MediaSize.Engineering.A;
      tmp = MediaSize.NA.LEGAL;
      tmp = MediaSize.Other.EXECUTIVE;
    }
  
  private MediaSizeName media;
  
  /**
   * Creates a <code>MediaSize</code> object. The created object will be added 
   * to an internal cache used in the static methods of this class for lookup 
   * of available <code>MediaSize</code> instances.
   *
   * @param x the size in x direction
   * @param y the size in y direction
   * @param units the units to use for the sizes
   *
   * @exception IllegalArgumentException if x or y &lt; 0 or units &lt; 1
   * 
   * @see #findMedia(float, float, int)
   * @see #getMediaSizeForName(MediaSizeName)
   */
  public MediaSize(float x, float y, int units)
  {
    super(x, y, units);
    mediaCache.add(this);
  }
  
  /**
   * Creates a <code>MediaSize</code> object associated with the given
   * media name. The created object will be added to an internal cache used 
   * in the static methods of this class for lookup of available 
   * <code>MediaSize</code> instances.
   *
   * @param x the size in x direction
   * @param y the size in y direction
   * @param units the units to use for the sizes
   * @param media the media name to associate
   *
   * @exception IllegalArgumentException if x or y &lt; 0 or units &lt; 1
   * 
   * @see #findMedia(float, float, int)
   * @see #getMediaSizeForName(MediaSizeName)
   */
  public MediaSize(float x, float y, int units, MediaSizeName media)
  {
    super(x, y, units);
    this.media = media;
    mediaCache.add(this);
  }
  
  /**
   * Creates a <code>MediaSize</code> object. The created object will be added 
   * to an internal cache used in the static methods of this class for lookup 
   * of available <code>MediaSize</code> instances.
   *
   * @param x the size in x direction
   * @param y the size in y direction
   * @param units the units to use for the sizes
   *
   * @exception IllegalArgumentException if x or y &lt; 0 or units &lt; 1
   * 
   * @see #findMedia(float, float, int)
   * @see #getMediaSizeForName(MediaSizeName)
   */
  public MediaSize(int x, int y, int units)
  {
    super(x, y, units);
    mediaCache.add(this);
  }
  
  /**
   * Creates a <code>MediaSize</code> object associated with the given
   * media name. The created object will be added to an internal cache used 
   * in the static methods of this class for lookup of available 
   * <code>MediaSize</code> instances.
   *
   * @param x the size in x direction
   * @param y the size in y direction
   * @param units the units to use for the sizes
   * @param media the media name to associate
   *
   * @exception IllegalArgumentException if x or y &lt; 0 or units &lt; 1
   * 
   * @see #findMedia(float, float, int)
   * @see #getMediaSizeForName(MediaSizeName)
   */
  public MediaSize(int x, int y, int units, MediaSizeName media)
  {
    super(x, y, units);
    this.media = media;
    mediaCache.add(this);
  }
  
  /**
   * Returns category of this class.
   *
   * @return The class <code>MediaSize</code> itself.
   */
  public final Class getCategory()
  {
    return MediaSize.class;
  }
    
  /**
   * Searches for a MediaSize object with the given dimensions.
   * If none is found with exact dimensions, the closest match is used.
   * Afterwards the MediaSizeName of the found MediaSize object is 
   * returned - which might be null if none is specified.
   * 
   * @param x the dimension for x
   * @param y the dimension for y
   * @param units the units to be used for comparison
   * @return the corresponding MediaSizeName object, or null
   */
  public static MediaSizeName findMedia(float x, float y, int units)
  {
    if (x <= 0.0f || y <= 0.0f)
      throw new IllegalArgumentException(
        "x and/or y may not be less or equal 0");

    if (units < 1)
      throw new IllegalArgumentException("units may not be less then 1");

    MediaSize bestMatch = null;
    int bestDistance = Integer.MAX_VALUE;

    int xMicro = (int) x * units;
    int yMicro = (int) y * units;

    for (int i = 0; i < mediaCache.size(); i++)
      {
        MediaSize size = (MediaSize) mediaCache.get(i);
        int dist = (Math.abs(size.getXMicrometers() - xMicro) 
                    + Math.abs(size.getYMicrometers() - yMicro));

        if (dist < bestDistance)
          {
            bestMatch = size;
            bestDistance = dist;
          }
      }

    return bestMatch.getMediaSizeName();
  }
  
  /**
   * Returns the associated <code>MediaSize</code> instance for the 
   * given named media <code>MediaSizeName</code> instance.
   * 
   * @param media the named media to search for.
   * @return The corresponding <code>MediaSize</code> instance or 
   * <code>null</code> if none found.
   */
  public static MediaSize getMediaSizeForName(MediaSizeName media)
  {
    for (int i = 0; i < mediaCache.size(); i++)
      {
	MediaSize size = (MediaSize) mediaCache.get(i);
	
	if (size.getMediaSizeName().equals(media))
	  return size;
      }

    return null;
  }
  
  /**
   * Tests if the given object is equal to this object.
   *
   * @param obj the object to test
   *
   * @return <code>true</code> if both objects are equal, 
   * <code>false</code> otherwise.
   */
  public boolean equals(Object obj)
  {
    if (!(obj instanceof MediaSize))
      return false;

    MediaSize tmp = (MediaSize) obj;
    return (tmp.getXMicrometers() == this.getXMicrometers()
            && tmp.getYMicrometers() == this.getYMicrometers());
  }
  
  /**
   * Returns the media name of this size.
   * 
   * @return The media name.
   */
  public MediaSizeName getMediaSizeName()
  {
    return media;
  }

  /**
   * Returns the name of this attribute.
   *
   * @return The name "media-size".
   */
  public final String getName()
  {
    return "media-size";
  }

  /**
   * Container class for predefined ISO media sizes.
   * 
   * @author Sven de Marothy (sven@physto.se)
   */
  public static final class ISO 
  {
    private ISO()
    {
      // prevent instantiation
    }
    
    /**
     * ISO A0 paper, 841 mm x 1189 mm.
     */
    public static final MediaSize A0 = new MediaSize(841, 1189, 
					       MediaSize.MM, 
					       MediaSizeName.ISO_A0);

    /**
     * ISO A1 paper, 594 mm x 841 mm
     */
    public static final MediaSize A1 = new MediaSize(594, 841, MediaSize.MM, 
					       MediaSizeName.ISO_A1);

    /**
     * ISO A2 paper, 420 mm x 594 mm
     */
    public static final MediaSize A2 = new MediaSize(420, 594, MediaSize.MM, MediaSizeName.ISO_A2);

    /**
     * ISO A3 paper, 297 mm x 420 mm
     */
    public static final MediaSize A3 = new MediaSize(297, 420, MediaSize.MM, MediaSizeName.ISO_A3);

    /**
     * ISO A4 paper, 210 mm x 297 mm
     */
    public static final MediaSize A4 = new MediaSize(210, 297, MediaSize.MM, MediaSizeName.ISO_A4);

    /**
     * ISO A5 paper, 148 mm x 210 mm
     */
    public static final MediaSize A5 = new MediaSize(148, 210, MediaSize.MM, MediaSizeName.ISO_A5);

    /**
     * ISO A6 paper, 105 mm x 148 mm
     */
    public static final MediaSize A6 = new MediaSize(105, 148, MediaSize.MM, MediaSizeName.ISO_A6);

    /**
     * ISO A7 paper, 74 mm x 105 mm
     */
    public static final MediaSize A7 = new MediaSize(74, 105, MediaSize.MM, MediaSizeName.ISO_A7);

    /**
     * ISO A8 paper, 52 mm x 74 mm
     */
    public static final MediaSize A8 = new MediaSize(52, 74, MediaSize.MM, MediaSizeName.ISO_A8);

    /**
     * ISO A9 paper, 37 mm x 52 mm
     */
    public static final MediaSize A9 = new MediaSize(37, 52, MediaSize.MM, MediaSizeName.ISO_A9);

    /**
     * ISO A10 paper, 26 mm x 37 mm
     */
    public static final MediaSize A10 = new MediaSize(26, 37, MediaSize.MM, MediaSizeName.ISO_A10);


    /**
     * ISO B0 paper, 1000 mm x 1414 mm
     */
    public static final MediaSize B0 = new MediaSize(1000, 1414, MediaSize.MM, MediaSizeName.ISO_B0);

    /**
     * ISO B1 paper, 707 mm x 1000 mm
     */
    public static final MediaSize B1 = new MediaSize(707, 1000, MediaSize.MM, MediaSizeName.ISO_B1);

    /**
     * ISO B2 paper, 500 mm x 707 mm
     */
    public static final MediaSize B2 = new MediaSize(500, 707, MediaSize.MM, MediaSizeName.ISO_B2);

    /**
     * ISO B3 paper, 353 mm x 500 mm
     */
    public static final MediaSize B3 = new MediaSize(353, 500, MediaSize.MM, MediaSizeName.ISO_B3);

    /**
     * ISO B4 paper, 250 mm x 353 mm
     */
    public static final MediaSize B4 = new MediaSize(250, 353, MediaSize.MM, MediaSizeName.ISO_B4);

    /**
     * ISO B5 paper, 176 mm x 250 mm
     */
    public static final MediaSize B5 = new MediaSize(176, 250, MediaSize.MM, MediaSizeName.ISO_B5);

    /**
     * ISO B6 paper, 125 mm x 176 mm
     */
    public static final MediaSize B6 = new MediaSize(125, 176, MediaSize.MM, MediaSizeName.ISO_B6);

    /**
     * ISO B7 paper, 88 mm x 125 mm
     */
    public static final MediaSize B7 = new MediaSize(88, 125, MediaSize.MM, MediaSizeName.ISO_B7);

    /**
     * ISO B8 paper, 62 mm x 88 mm
     */
    public static final MediaSize B8 = new MediaSize(62, 88, MediaSize.MM, MediaSizeName.ISO_B8);

    /**
     * ISO B9 paper, 44 mm x 62 mm
     */
    public static final MediaSize B9 = new MediaSize(44, 62, MediaSize.MM, MediaSizeName.ISO_B9);

    /**
     * ISO B10 paper, 31 mm x 44 mm
     */
    public static final MediaSize B10 = new MediaSize(31, 44, MediaSize.MM, MediaSizeName.ISO_B10);
    
    /**
     * ISO C3 envelope, 324 mm x 458 mm
     */
    public static final MediaSize C3 = new MediaSize(324, 458, MediaSize.MM, MediaSizeName.ISO_C3);

    /**
     * ISO C4 envelope, 229 mm x 324 mm
     */
    public static final MediaSize C4 = new MediaSize(229, 324, MediaSize.MM, MediaSizeName.ISO_C4);

    /**
     * ISO C5 envelope, 162 mm x 229 mm
     */
    public static final MediaSize C5 = new MediaSize(162, 229, MediaSize.MM, MediaSizeName.ISO_C5);

    /**
     * ISO C6 envelope, 114 mm x 162 mm
     */
    public static final MediaSize C6 = new MediaSize(114, 162, MediaSize.MM, MediaSizeName.ISO_C6);

    /**
     * ISO ISO Designated Long paper, 324 mm x 458 mm
     */
    public static final MediaSize DESIGNATED_LONG = 
      new MediaSize(324, 458, MediaSize.MM, MediaSizeName.ISO_DESIGNATED_LONG);
  } 

  /**
   * Container class for predefined North American media sizes.
   * 
   * @author Sven de Marothy (sven@physto.se)
   */
  public static final class NA
  {
    private NA()
    {
      // prevent instantiation
    }
    
    /**
     * US Legal paper size, 8.5 inch x 14 inch
     */
    public static final MediaSize LEGAL = new MediaSize(8.5f, 14f, MediaSize.INCH, 
						  MediaSizeName.NA_LEGAL);

    /**
     * US Letter paper size, 8.5 inch x 11 inch
     */
    public static final MediaSize LETTER = new MediaSize(8.5f, 11f, MediaSize.INCH,
						   MediaSizeName.NA_LETTER);

    /**
     * 5 inch x 7 inch paper size.
     */
    public static final MediaSize NA_5X7 = new MediaSize(5, 7, MediaSize.INCH,
							 MediaSizeName.NA_5X7);

    /**
     * 8 inch x 10 inch paper size.
     */
    public static final MediaSize NA_8X10 = new MediaSize(8, 10, MediaSize.INCH,
							  MediaSizeName.NA_8X10);

    /**
     * 6 inch x 9 inch envelope size.
     */
    public static final MediaSize NA_6X9_ENVELOPE = new MediaSize(6f, 9f, 
								  MediaSize.INCH,
								  MediaSizeName.NA_6X9_ENVELOPE);

    /**
     * 7 inch x 9 inch envelope size.
     */
    public static final MediaSize NA_7X9_ENVELOPE = new MediaSize(7f, 9f, 
								  MediaSize.INCH,
								  MediaSizeName.NA_7X9_ENVELOPE);

    /**
     * 9 inch x 11 inch envelope size.
     */
    public static final MediaSize NA_9x11_ENVELOPE = new MediaSize(9f, 11f, 
							     MediaSize.INCH,
							     MediaSizeName.NA_9X11_ENVELOPE);

    /**
     * 9 inch x 12 inch envelope size.
     */
    public static final MediaSize NA_9x12_ENVELOPE = new MediaSize(9f, 12f, 
							     MediaSize.INCH,
							     MediaSizeName.NA_9X12_ENVELOPE);


    /**
     * 10 inch x 13 inch envelope size.
     */
    public static final MediaSize NA_10x13_ENVELOPE = new MediaSize(10f, 13f, 
							      MediaSize.INCH,
							      MediaSizeName.NA_10X13_ENVELOPE);

    /**
     * 10 inch x 14 inch envelope size.
     */
    public static final MediaSize NA_10x14_ENVELOPE = new MediaSize(10f, 14f, 
							      MediaSize.INCH,
							      MediaSizeName.NA_10X14_ENVELOPE);

    /**
     * 10 inch x 15 inch envelope size.
     */
    public static final MediaSize NA_10X15_ENVELOPE = new MediaSize(10f, 15f, 
							      MediaSize.INCH,
							      MediaSizeName.NA_10X15_ENVELOPE);

    /**
     * Number 9 envelope size. 4.5 inch x 10.375 inch
     */
    public static final MediaSize NA_NUMBER_9_ENVELOPE = new MediaSize(3.875f, 8.875f,
								 MediaSize.INCH,
								 MediaSizeName.NA_NUMBER_9_ENVELOPE);

    /**
     * Number 10 envelope size. 4.125 inch x 9.5 inch
     */
    public static final MediaSize NA_NUMBER_10_ENVELOPE = 
      new MediaSize(4.125f, 9.5f, MediaSize.INCH, MediaSizeName.NA_NUMBER_10_ENVELOPE);

    /**
     * Number 11 envelope size. 4.5 inch x 10.375 inch
     */
    public static final MediaSize NA_NUMBER_11_ENVELOPE = new MediaSize(4.5f, 10.375f, MediaSize.INCH,
								  MediaSizeName.NA_NUMBER_11_ENVELOPE);
    
    /**
     * Number 12 envelope size. 4.75 inch x 11 inch
     */
    public static final MediaSize NA_NUMBER_12_ENVELOPE = new MediaSize(4.75f, 11f, 
								  MediaSize.INCH,
								  MediaSizeName.NA_NUMBER_12_ENVELOPE);

  /**
   * Number 14 envelope size. 5 inch x 11.5 inch
   */
  public static final MediaSize NA_NUMBER_14_ENVELOPE = new MediaSize(5f, 11.5f, 
								MediaSize.INCH,
								MediaSizeName.NA_NUMBER_14_ENVELOPE);
  }

  /**
   * Container class for predefined US Engineering media sizes.
   * 
   * @author Sven de Marothy (sven@physto.se)
   */
  public static final class Engineering 
  {
    private Engineering()
    {
      // prevent instantiation
    }
    
    /**
     * ANSI A paper size. 8.5 inch x 11 inch
     */
    public static final MediaSize A = new MediaSize(8.5f, 11f, 
					      MediaSize.INCH, MediaSizeName.A);

    /**
     * ANSI B paper size. 11 inch x 17 inch
     */
    public static final MediaSize B = new MediaSize(11f, 17f, 
					      MediaSize.INCH, MediaSizeName.B);

    /**
     * ANSI C paper size. 17 inch x 22 inch
     */
    public static final MediaSize C = new MediaSize(17f, 22f, 
					      MediaSize.INCH, MediaSizeName.C);

    /**
     * ANSI D paper size. 22 inch x 34 inch
     */
    public static final MediaSize D = new MediaSize(22f, 34f, 
					      MediaSize.INCH, MediaSizeName.D);

    /**
     * ANSI E paper size. 33 inch x 44 inch
     */
    public static final MediaSize E = new MediaSize(34f, 44f, 
					      MediaSize.INCH, MediaSizeName.E);
  }

  /**
   * Container class for predefined Japanese JIS media sizes.
   * 
   * @author Sven de Marothy (sven@physto.se)
   */
  public static final class JIS 
  {
    private JIS()
    {
      // prevent instantiation
    }
    
    /**
     * JIS B0 paper. 1030 mm x 1456 mm
     * Note: The JIS B-series is not identical to the ISO B-series.
     */
    public static final MediaSize B0 = new MediaSize(1030, 1456, MediaSize.MM, MediaSizeName.JIS_B0);

    /**
     * JIS B1 paper. 1030 mm x 1456 mm
     * Note: The JIS B-series is not identical to the ISO B-series.
     */
    public static final MediaSize B1 = new MediaSize(728, 1030, MediaSize.MM, MediaSizeName.JIS_B1);

    /**
     * JIS B2 paper. 515 mm x 728 mm
     * Note: The JIS B-series is not identical to the ISO B-series.
     */
    public static final MediaSize B2 = new MediaSize(515, 728, MediaSize.MM, MediaSizeName.JIS_B2);

    /**
     * JIS B3 paper. 364 mm x 515 mm
     * Note: The JIS B-series is not identical to the ISO B-series.
     */
    public static final MediaSize B3 = new MediaSize(364, 515, MediaSize.MM, MediaSizeName.JIS_B3);

    /**
     * JIS B4 paper. 257 mm x 364 mm
     * Note: The JIS B-series is not identical to the ISO B-series.
     */
    public static final MediaSize B4 = new MediaSize(257, 364, MediaSize.MM, MediaSizeName.JIS_B4);

    /**
     * JIS B5 paper. 1030 mm x 1456 mm
     * Note: The JIS B-series is not identical to the ISO B-series.
     */
    public static final MediaSize B5 = new MediaSize(182, 257, MediaSize.MM, MediaSizeName.JIS_B5);

    /**
     * JIS B6 paper. 128 mm x 182 mm
     * Note: The JIS B-series is not identical to the ISO B-series.
     */
    public static final MediaSize B6 = new MediaSize(128, 182, MediaSize.MM, MediaSizeName.JIS_B6);

    /**
     * JIS B7 paper. 91 mm x 128 mm
     * Note: The JIS B-series is not identical to the ISO B-series.
     */
    public static final MediaSize B7 = new MediaSize(91, 128, MediaSize.MM, MediaSizeName.JIS_B7);

    /**
     * JIS B8 paper. 64 mm x 91 mm
     * Note: The JIS B-series is not identical to the ISO B-series.
     */
    public static final MediaSize B8 = new MediaSize(64, 91, MediaSize.MM, MediaSizeName.JIS_B8);

    /**
     * JIS B9 paper. 45 mm x 64 mm
     * Note: The JIS B-series is not identical to the ISO B-series.
     */
    public static final MediaSize B9 = new MediaSize(45, 64, MediaSize.MM, MediaSizeName.JIS_B9);

    /**
     * JIS B10 paper. 32 mm x 45 mm
     * Note: The JIS B-series is not identical to the ISO B-series.
     */
    public static final MediaSize B10 = new MediaSize(32, 45, MediaSize.MM, MediaSizeName.JIS_B10);

    /**
     * JIS chou #1 envelope size, 142 mm x 332 mm
     */
    public static final MediaSize CHOU_1 = new MediaSize(142, 332, MediaSize.MM);

    /**
     * JIS chou #2 envelope size, 119 mm x 227 mm
     */
    public static final MediaSize CHOU_2 = new MediaSize(119, 227, MediaSize.MM);

    /**
     * JIS chou #3 envelope size, 120 mm x 235 mm
     */
    public static final MediaSize CHOU_3 = new MediaSize(120, 235, MediaSize.MM);

    /**
     * JIS chou #4 envelope size, 90 mm x 205 mm
     */
    public static final MediaSize CHOU_4 = new MediaSize(90, 205, MediaSize.MM);

    /**
     * JIS chou #30 envelope size, 92 mm x 235 mm
     */
    public static final MediaSize CHOU_30 = new MediaSize(92, 235, MediaSize.MM);

    /**
     * JIS chou #40 envelope size, 90 mm x 225 mm
     */
    public static final MediaSize CHOU_40 = new MediaSize(90, 225, MediaSize.MM);

    /**
     * JIS kaku #0 envelope size, 287 mm x 382 mm
     */
    public static final MediaSize KAKU_0 = new MediaSize(287, 382, MediaSize.MM);

    /**
     * JIS kaku #1 envelope size, 270 mm x 382 mm
     */
    public static final MediaSize KAKU_1 = new MediaSize(270, 382, MediaSize.MM);

    /**
     * JIS kaku #2 envelope size, 240 mm x 332 mm
     */
    public static final MediaSize KAKU_2 = new MediaSize(240, 332, MediaSize.MM);

    /**
     * JIS kaku #20 envelope size, 229 mm x 324 mm
     */
    public static final MediaSize KAKU_20 = new MediaSize(229, 324, MediaSize.MM);

    /**
     * JIS kaku #3 envelope size, 216 mm x 227 mm
     */
    public static final MediaSize KAKU_3 = new MediaSize(216, 227, MediaSize.MM);

    /**
     * JIS kaku #4 envelope size, 197 mm x 267 mm
     */
    public static final MediaSize KAKU_4 = new MediaSize(197, 267, MediaSize.MM);

    /**
     * JIS kaku #5 envelope size, 190 mm x 240 mm
     */
    public static final MediaSize KAKU_5 = new MediaSize(190, 240, MediaSize.MM);

    /**
     * JIS kaku #6 envelope size, 162 mm x 229 mm
     */
    public static final MediaSize KAKU_6 = new MediaSize(162, 229, MediaSize.MM);

    /**
     * JIS kaku #7 envelope size, 142 mm x 205 mm
     */
    public static final MediaSize KAKU_7 = new MediaSize(142, 205, MediaSize.MM);

    /**
     * JIS kaku #8 envelope size, 119 mm x 197 mm
     */
    public static final MediaSize KAKU_8 = new MediaSize(119, 197, MediaSize.MM);

    /**
     * JIS kaku A4 envelope size, 228 mm x 312 mm
     */
    public static final MediaSize KAKU_A4 = new MediaSize(228, 312, MediaSize.MM);

    /**
     * JIS you #1 envelope size, 120 mm x 176 mm
     */
    public static final MediaSize YOU_1 = new MediaSize(120, 176, MediaSize.MM);

    /**
     * JIS you #2 envelope size, 114 mm x 162 mm
     */
    public static final MediaSize YOU_2 = new MediaSize(114, 162, MediaSize.MM);

    /**
     * JIS you #3 envelope size, 98 mm x 148 mm
     */
    public static final MediaSize YOU_3 = new MediaSize(98, 148, MediaSize.MM);

    /**
     * JIS you #4 envelope size, 105 mm x 235 mm
     */
    public static final MediaSize YOU_4 = new MediaSize(105, 235, MediaSize.MM);

    /**
     * JIS you #5 envelope size, 95 mm x 217 mm
     */
    public static final MediaSize YOU_5 = new MediaSize(95, 217, MediaSize.MM);

    /**
     * JIS you #6 envelope size, 98 mm x 190 mm
     */
    public static final MediaSize YOU_6 = new MediaSize(98, 190, MediaSize.MM);

    /**
     * JIS you #7 envelope size, 92 mm x 165 mm
     */
    public static final MediaSize YOU_7 = new MediaSize(92, 165, MediaSize.MM);
  }

  /**
   * Container class for miscellaneous media sizes.
   * 
   * @author Sven de Marothy (sven@physto.se)
   */
  public static final class Other
  {
    private Other()
    {
      // prevent instantiation
    }
    
    /**
     * US Executive paper size, 7.25 inch x 10.5 inch
     */
    public static final MediaSize EXECUTIVE = new MediaSize(7.25f, 10.5f, 
						      MediaSize.INCH, MediaSizeName.EXECUTIVE);

    /**
     * US Folio paper size, 8.5 inch x 13 inch
     */
    public static final MediaSize FOLIO = new MediaSize(8.5f, 13f, MediaSize.INCH, MediaSizeName.FOLIO);

    /**
     * US Quarto paper size, 8.5 inches by 10.83 inches.
     */
    public static final MediaSize QUARTO = new MediaSize(8.5f, 10.83f, MediaSize.INCH,
						   MediaSizeName.QUARTO);

    /**
     * US Invoice size, 5.5 inch x 8.5 inch
     */
    public static final MediaSize INVOICE = new MediaSize(5.5f, 8.5f, 
						    MediaSize.INCH, MediaSizeName.INVOICE);

    /**
     * US Ledger size, 11 inch x 17 inch
     */
    public static final MediaSize LEDGER = new MediaSize(11, 17, MediaSize.INCH, 
						   MediaSizeName.LEDGER);

    /**
     * Monarch (7 3/4) envelope size, 3.87 inch x 7.5 inch
     */
    public static final MediaSize MONARCH_ENVELOPE = new MediaSize(3.87f, 7.5f, 
							     MediaSize.INCH,
							     MediaSizeName.MONARCH_ENVELOPE);

    /**
     * Personal envelope size, 3.625 inch x 6.5 inch.
     */
    public static final MediaSize PERSONAL_ENVELOPE = new MediaSize(3.625f, 6.5f, MediaSize.INCH,
							      MediaSizeName.PERSONAL_ENVELOPE);

    /**
     * Italian envelope size, 110 mm x 230 mm
     */
    public static final MediaSize ITALY_ENVELOPE = new MediaSize(110, 230, 
							   MediaSize.MM,
							   MediaSizeName.ITALY_ENVELOPE);

    /**
     * Japanese postcard, 100 mm x 148 mm
     */
    public static final MediaSize JAPANESE_POSTCARD = new MediaSize(100, 148, MediaSize.MM, MediaSizeName.JAPANESE_POSTCARD);

    /**
     * Japanese double postcard, 148 mm x 200 mm
     */
    public static final MediaSize JAPANESE_DOUBLE_POSTCARD = new MediaSize(148, 200, MediaSize.MM, MediaSizeName.JAPANESE_DOUBLE_POSTCARD);
    
    /**
     * Tabloid size, 11 inch x 17 inch.
     * @since 1.5
     */
    public static final MediaSize TABLOID = 
      new MediaSize(11, 17, Size2DSyntax.INCH, MediaSizeName.TABLOID);
  }
}