001    /* MediaSize.java -- 
002       Copyright (C) 2005, 2006  Free Software Foundation, Inc.
003    
004    This file is part of GNU Classpath.
005    
006    GNU Classpath is free software; you can redistribute it and/or modify
007    it under the terms of the GNU General Public License as published by
008    the Free Software Foundation; either version 2, or (at your option)
009    any later version.
010    
011    GNU Classpath is distributed in the hope that it will be useful, but
012    WITHOUT ANY WARRANTY; without even the implied warranty of
013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014    General Public License for more details.
015    
016    You should have received a copy of the GNU General Public License
017    along with GNU Classpath; see the file COPYING.  If not, write to the
018    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
019    02110-1301 USA.
020    
021    Linking this library statically or dynamically with other modules is
022    making a combined work based on this library.  Thus, the terms and
023    conditions of the GNU General Public License cover the whole
024    combination.
025    
026    As a special exception, the copyright holders of this library give you
027    permission to link this library with independent modules to produce an
028    executable, regardless of the license terms of these independent
029    modules, and to copy and distribute the resulting executable under
030    terms of your choice, provided that you also meet, for each linked
031    independent module, the terms and conditions of the license of that
032    module.  An independent module is a module which is not derived from
033    or based on this library.  If you modify this library, you may extend
034    this exception to your version of the library, but you are not
035    obligated to do so.  If you do not wish to do so, delete this
036    exception statement from your version. */
037    
038    
039    package javax.print.attribute.standard;
040    
041    import java.util.ArrayList;
042    
043    import javax.print.attribute.Attribute;
044    import javax.print.attribute.Size2DSyntax;
045    
046    /**
047     * The <code>MediaSize</code> printing attribute class specifies the size
048     * of a printing media. The size is defined in portrait orientation with 
049     * x at the bottom edge and y at the left edge.
050     * <p>
051     * There are several media sizes predefined through the nested classes. Further
052     * sizes may be provided by the application. <code>MediaSize</code> is not used
053     * as a printing attribute currently. It may be used to get the actual sizes 
054     * for a named media or to find a suitable <code>MediaSizeName</code> instance
055     * by querying with the needed sizes.
056     * </p> 
057     * <p>
058     * <b>IPP Compatibility:</b> MediaSize is not an IPP 1.1 attribute.
059     * </p>
060     * @see javax.print.attribute.standard.MediaSizeName
061     * 
062     * @author Michael Koch (konqueror@gmx.de)
063     * @author Wolfgang Baer (WBaer@gmx.de)
064     */
065    public class MediaSize extends Size2DSyntax
066      implements Attribute
067    {
068      private static final long serialVersionUID = -1967958664615414771L;
069      
070      private static ArrayList<MediaSize> mediaCache;
071      
072      static
073        {
074          mediaCache = new ArrayList<MediaSize>();
075    
076          // We call one instance of every container class to make sure it gets
077          // loaded during class initialization and therefore all other static
078          // fields of this container class also.
079          
080          // This is needed to put all MediaSize instance into the mediaCache
081          // for use by the static methods in this class.
082          
083          MediaSize tmp = MediaSize.ISO.A0;
084          tmp = MediaSize.JIS.B0;
085          tmp = MediaSize.Engineering.A;
086          tmp = MediaSize.NA.LEGAL;
087          tmp = MediaSize.Other.EXECUTIVE;
088        }
089    
090      private MediaSizeName mediaName;
091      
092      /**
093       * Creates a <code>MediaSize</code> object. The created object will be added 
094       * to an internal cache used in the static methods of this class for lookup 
095       * of available <code>MediaSize</code> instances.
096       *
097       * @param x the size in x direction
098       * @param y the size in y direction
099       * @param units the units to use for the sizes
100       *
101       * @exception IllegalArgumentException if x or y &lt; 0 or units &lt; 1
102       * 
103       * @see #findMedia(float, float, int)
104       * @see #getMediaSizeForName(MediaSizeName)
105       */
106      public MediaSize(float x, float y, int units)
107      {
108        super(x, y, units);
109        mediaCache.add(this);
110      }
111      
112      /**
113       * Creates a <code>MediaSize</code> object associated with the given
114       * media name. The created object will be added to an internal cache used 
115       * in the static methods of this class for lookup of available 
116       * <code>MediaSize</code> instances.
117       *
118       * @param x the size in x direction
119       * @param y the size in y direction
120       * @param units the units to use for the sizes
121       * @param media the media name to associate
122       *
123       * @exception IllegalArgumentException if x or y &lt; 0 or units &lt; 1
124       * 
125       * @see #findMedia(float, float, int)
126       * @see #getMediaSizeForName(MediaSizeName)
127       */
128      public MediaSize(float x, float y, int units, MediaSizeName media)
129      {
130        super(x, y, units);
131        mediaName = media;
132        mediaCache.add(this);
133      }
134      
135      /**
136       * Creates a <code>MediaSize</code> object. The created object will be added 
137       * to an internal cache used in the static methods of this class for lookup 
138       * of available <code>MediaSize</code> instances.
139       *
140       * @param x the size in x direction
141       * @param y the size in y direction
142       * @param units the units to use for the sizes
143       *
144       * @exception IllegalArgumentException if x or y &lt; 0 or units &lt; 1
145       * 
146       * @see #findMedia(float, float, int)
147       * @see #getMediaSizeForName(MediaSizeName)
148       */
149      public MediaSize(int x, int y, int units)
150      {
151        super(x, y, units);
152        mediaCache.add(this);
153      }
154      
155      /**
156       * Creates a <code>MediaSize</code> object associated with the given
157       * media name. The created object will be added to an internal cache used 
158       * in the static methods of this class for lookup of available 
159       * <code>MediaSize</code> instances.
160       *
161       * @param x the size in x direction
162       * @param y the size in y direction
163       * @param units the units to use for the sizes
164       * @param media the media name to associate
165       *
166       * @exception IllegalArgumentException if x or y &lt; 0 or units &lt; 1
167       * 
168       * @see #findMedia(float, float, int)
169       * @see #getMediaSizeForName(MediaSizeName)
170       */
171      public MediaSize(int x, int y, int units, MediaSizeName media)
172      {
173        super(x, y, units);
174        mediaName = media;
175        mediaCache.add(this);
176      }
177      
178      /**
179       * Returns category of this class.
180       *
181       * @return The class <code>MediaSize</code> itself.
182       */
183      public Class< ? extends Attribute> getCategory()
184      {
185        return MediaSize.class;
186      }
187    
188        
189      /**
190       * Searches for a MediaSize object with the given dimensions.
191       * If none is found with exact dimensions, the closest match is used.
192       * Afterwards the MediaSizeName of the found MediaSize object is 
193       * returned - which might be null if none is specified.
194       * 
195       * @param x the dimension for x
196       * @param y the dimension for y
197       * @param units the units to be used for comparison
198       * @return the corresponding MediaSizeName object, or null
199       */
200      public static MediaSizeName findMedia(float x, float y, int units)
201      {
202        if (x <= 0.0f || y <= 0.0f)
203          throw new IllegalArgumentException(
204            "x and/or y may not be less or equal 0");
205      
206        if (units < 1)
207          throw new IllegalArgumentException("units may not be less then 1");
208    
209        MediaSize bestMatch = null;
210        int bestDistance = Integer.MAX_VALUE;
211    
212        int xMicro = (int) x * units;
213        int yMicro = (int) y * units;
214    
215        for (int i = 0; i < mediaCache.size(); i++)
216          {
217            MediaSize size = mediaCache.get(i);
218            int dist = (Math.abs(size.getXMicrometers() - xMicro) 
219                        + Math.abs(size.getYMicrometers() - yMicro));
220    
221            if (dist < bestDistance)
222              {
223                bestMatch = size;
224                bestDistance = dist;
225              }
226          }
227    
228        return bestMatch.getMediaSizeName();
229      }
230      
231      /**
232       * Returns the associated <code>MediaSize</code> instance for the 
233       * given named media <code>MediaSizeName</code> instance.
234       * 
235       * @param media the named media to search for.
236       * @return The corresponding <code>MediaSize</code> instance or 
237       * <code>null</code> if none found.
238       */
239      public static MediaSize getMediaSizeForName(MediaSizeName media)
240      {
241        for (int i = 0; i < mediaCache.size(); i++)
242          {
243            MediaSize size = mediaCache.get(i);
244            
245            if (size.getMediaSizeName().equals(media))
246              return size;
247          }
248    
249        return null;
250      }
251      
252      /**
253       * Tests if the given object is equal to this object.
254       *
255       * @param obj the object to test
256       *
257       * @return <code>true</code> if both objects are equal, 
258       * <code>false</code> otherwise.
259       */
260      public boolean equals(Object obj)
261      {
262        if (!(obj instanceof MediaSize))
263          return false;
264    
265        MediaSize tmp = (MediaSize) obj;
266        return (tmp.getXMicrometers() == this.getXMicrometers()
267                && tmp.getYMicrometers() == this.getYMicrometers());
268      }
269      
270      /**
271       * Returns the media name of this size.
272       * 
273       * @return The media name.
274       */
275      public MediaSizeName getMediaSizeName()
276      {
277        return mediaName;
278      }
279    
280      /**
281       * Returns the name of this attribute.
282       *
283       * @return The name "media-size".
284       */
285      public final String getName()
286      {
287        return "media-size";
288      }
289    
290      /**
291       * Container class for predefined ISO media sizes.
292       * 
293       * @author Sven de Marothy (sven@physto.se)
294       */
295      public static final class ISO 
296      {
297        private ISO()
298        {
299          // prevent instantiation
300        }
301        
302        /**
303         * ISO A0 paper, 841 mm x 1189 mm.
304         */
305        public static final MediaSize A0 = new MediaSize(841, 1189, 
306                                                   MediaSize.MM, 
307                                                   MediaSizeName.ISO_A0);
308    
309        /**
310         * ISO A1 paper, 594 mm x 841 mm
311         */
312        public static final MediaSize A1 = new MediaSize(594, 841, MediaSize.MM, 
313                                                   MediaSizeName.ISO_A1);
314    
315        /**
316         * ISO A2 paper, 420 mm x 594 mm
317         */
318        public static final MediaSize A2 = new MediaSize(420, 594, MediaSize.MM, MediaSizeName.ISO_A2);
319    
320        /**
321         * ISO A3 paper, 297 mm x 420 mm
322         */
323        public static final MediaSize A3 = new MediaSize(297, 420, MediaSize.MM, MediaSizeName.ISO_A3);
324    
325        /**
326         * ISO A4 paper, 210 mm x 297 mm
327         */
328        public static final MediaSize A4 = new MediaSize(210, 297, MediaSize.MM, MediaSizeName.ISO_A4);
329    
330        /**
331         * ISO A5 paper, 148 mm x 210 mm
332         */
333        public static final MediaSize A5 = new MediaSize(148, 210, MediaSize.MM, MediaSizeName.ISO_A5);
334    
335        /**
336         * ISO A6 paper, 105 mm x 148 mm
337         */
338        public static final MediaSize A6 = new MediaSize(105, 148, MediaSize.MM, MediaSizeName.ISO_A6);
339    
340        /**
341         * ISO A7 paper, 74 mm x 105 mm
342         */
343        public static final MediaSize A7 = new MediaSize(74, 105, MediaSize.MM, MediaSizeName.ISO_A7);
344    
345        /**
346         * ISO A8 paper, 52 mm x 74 mm
347         */
348        public static final MediaSize A8 = new MediaSize(52, 74, MediaSize.MM, MediaSizeName.ISO_A8);
349    
350        /**
351         * ISO A9 paper, 37 mm x 52 mm
352         */
353        public static final MediaSize A9 = new MediaSize(37, 52, MediaSize.MM, MediaSizeName.ISO_A9);
354    
355        /**
356         * ISO A10 paper, 26 mm x 37 mm
357         */
358        public static final MediaSize A10 = new MediaSize(26, 37, MediaSize.MM, MediaSizeName.ISO_A10);
359    
360    
361        /**
362         * ISO B0 paper, 1000 mm x 1414 mm
363         */
364        public static final MediaSize B0 = new MediaSize(1000, 1414, MediaSize.MM, MediaSizeName.ISO_B0);
365    
366        /**
367         * ISO B1 paper, 707 mm x 1000 mm
368         */
369        public static final MediaSize B1 = new MediaSize(707, 1000, MediaSize.MM, MediaSizeName.ISO_B1);
370    
371        /**
372         * ISO B2 paper, 500 mm x 707 mm
373         */
374        public static final MediaSize B2 = new MediaSize(500, 707, MediaSize.MM, MediaSizeName.ISO_B2);
375    
376        /**
377         * ISO B3 paper, 353 mm x 500 mm
378         */
379        public static final MediaSize B3 = new MediaSize(353, 500, MediaSize.MM, MediaSizeName.ISO_B3);
380    
381        /**
382         * ISO B4 paper, 250 mm x 353 mm
383         */
384        public static final MediaSize B4 = new MediaSize(250, 353, MediaSize.MM, MediaSizeName.ISO_B4);
385    
386        /**
387         * ISO B5 paper, 176 mm x 250 mm
388         */
389        public static final MediaSize B5 = new MediaSize(176, 250, MediaSize.MM, MediaSizeName.ISO_B5);
390    
391        /**
392         * ISO B6 paper, 125 mm x 176 mm
393         */
394        public static final MediaSize B6 = new MediaSize(125, 176, MediaSize.MM, MediaSizeName.ISO_B6);
395    
396        /**
397         * ISO B7 paper, 88 mm x 125 mm
398         */
399        public static final MediaSize B7 = new MediaSize(88, 125, MediaSize.MM, MediaSizeName.ISO_B7);
400    
401        /**
402         * ISO B8 paper, 62 mm x 88 mm
403         */
404        public static final MediaSize B8 = new MediaSize(62, 88, MediaSize.MM, MediaSizeName.ISO_B8);
405    
406        /**
407         * ISO B9 paper, 44 mm x 62 mm
408         */
409        public static final MediaSize B9 = new MediaSize(44, 62, MediaSize.MM, MediaSizeName.ISO_B9);
410    
411        /**
412         * ISO B10 paper, 31 mm x 44 mm
413         */
414        public static final MediaSize B10 = new MediaSize(31, 44, MediaSize.MM, MediaSizeName.ISO_B10);
415        
416        /**
417         * ISO C3 envelope, 324 mm x 458 mm
418         */
419        public static final MediaSize C3 = new MediaSize(324, 458, MediaSize.MM, MediaSizeName.ISO_C3);
420    
421        /**
422         * ISO C4 envelope, 229 mm x 324 mm
423         */
424        public static final MediaSize C4 = new MediaSize(229, 324, MediaSize.MM, MediaSizeName.ISO_C4);
425    
426        /**
427         * ISO C5 envelope, 162 mm x 229 mm
428         */
429        public static final MediaSize C5 = new MediaSize(162, 229, MediaSize.MM, MediaSizeName.ISO_C5);
430    
431        /**
432         * ISO C6 envelope, 114 mm x 162 mm
433         */
434        public static final MediaSize C6 = new MediaSize(114, 162, MediaSize.MM, MediaSizeName.ISO_C6);
435    
436        /**
437         * ISO ISO Designated Long paper, 324 mm x 458 mm
438         */
439        public static final MediaSize DESIGNATED_LONG = 
440          new MediaSize(324, 458, MediaSize.MM, MediaSizeName.ISO_DESIGNATED_LONG);
441      } 
442    
443      /**
444       * Container class for predefined North American media sizes.
445       * 
446       * @author Sven de Marothy (sven@physto.se)
447       */
448      public static final class NA
449      {
450        private NA()
451        {
452          // prevent instantiation
453        }
454        
455        /**
456         * US Legal paper size, 8.5 inch x 14 inch
457         */
458        public static final MediaSize LEGAL = new MediaSize(8.5f, 14f, MediaSize.INCH, 
459                                                      MediaSizeName.NA_LEGAL);
460    
461        /**
462         * US Letter paper size, 8.5 inch x 11 inch
463         */
464        public static final MediaSize LETTER = new MediaSize(8.5f, 11f, MediaSize.INCH,
465                                                       MediaSizeName.NA_LETTER);
466    
467        /**
468         * 5 inch x 7 inch paper size.
469         */
470        public static final MediaSize NA_5X7 = new MediaSize(5, 7, MediaSize.INCH,
471                                                             MediaSizeName.NA_5X7);
472    
473        /**
474         * 8 inch x 10 inch paper size.
475         */
476        public static final MediaSize NA_8X10 = new MediaSize(8, 10, MediaSize.INCH,
477                                                              MediaSizeName.NA_8X10);
478    
479        /**
480         * 6 inch x 9 inch envelope size.
481         */
482        public static final MediaSize NA_6X9_ENVELOPE = new MediaSize(6f, 9f, 
483                                                                      MediaSize.INCH,
484                                                                      MediaSizeName.NA_6X9_ENVELOPE);
485    
486        /**
487         * 7 inch x 9 inch envelope size.
488         */
489        public static final MediaSize NA_7X9_ENVELOPE = new MediaSize(7f, 9f, 
490                                                                      MediaSize.INCH,
491                                                                      MediaSizeName.NA_7X9_ENVELOPE);
492    
493        /**
494         * 9 inch x 11 inch envelope size.
495         */
496        public static final MediaSize NA_9x11_ENVELOPE = new MediaSize(9f, 11f, 
497                                                                 MediaSize.INCH,
498                                                                 MediaSizeName.NA_9X11_ENVELOPE);
499    
500        /**
501         * 9 inch x 12 inch envelope size.
502         */
503        public static final MediaSize NA_9x12_ENVELOPE = new MediaSize(9f, 12f, 
504                                                                 MediaSize.INCH,
505                                                                 MediaSizeName.NA_9X12_ENVELOPE);
506    
507    
508        /**
509         * 10 inch x 13 inch envelope size.
510         */
511        public static final MediaSize NA_10x13_ENVELOPE = new MediaSize(10f, 13f, 
512                                                                  MediaSize.INCH,
513                                                                  MediaSizeName.NA_10X13_ENVELOPE);
514    
515        /**
516         * 10 inch x 14 inch envelope size.
517         */
518        public static final MediaSize NA_10x14_ENVELOPE = new MediaSize(10f, 14f, 
519                                                                  MediaSize.INCH,
520                                                                  MediaSizeName.NA_10X14_ENVELOPE);
521    
522        /**
523         * 10 inch x 15 inch envelope size.
524         */
525        public static final MediaSize NA_10X15_ENVELOPE = new MediaSize(10f, 15f, 
526                                                                  MediaSize.INCH,
527                                                                  MediaSizeName.NA_10X15_ENVELOPE);
528    
529        /**
530         * Number 9 envelope size. 4.5 inch x 10.375 inch
531         */
532        public static final MediaSize NA_NUMBER_9_ENVELOPE = new MediaSize(3.875f, 8.875f,
533                                                                     MediaSize.INCH,
534                                                                     MediaSizeName.NA_NUMBER_9_ENVELOPE);
535    
536        /**
537         * Number 10 envelope size. 4.125 inch x 9.5 inch
538         */
539        public static final MediaSize NA_NUMBER_10_ENVELOPE = 
540          new MediaSize(4.125f, 9.5f, MediaSize.INCH, MediaSizeName.NA_NUMBER_10_ENVELOPE);
541    
542        /**
543         * Number 11 envelope size. 4.5 inch x 10.375 inch
544         */
545        public static final MediaSize NA_NUMBER_11_ENVELOPE = new MediaSize(4.5f, 10.375f, MediaSize.INCH,
546                                                                      MediaSizeName.NA_NUMBER_11_ENVELOPE);
547        
548        /**
549         * Number 12 envelope size. 4.75 inch x 11 inch
550         */
551        public static final MediaSize NA_NUMBER_12_ENVELOPE = new MediaSize(4.75f, 11f, 
552                                                                      MediaSize.INCH,
553                                                                      MediaSizeName.NA_NUMBER_12_ENVELOPE);
554    
555      /**
556       * Number 14 envelope size. 5 inch x 11.5 inch
557       */
558      public static final MediaSize NA_NUMBER_14_ENVELOPE = new MediaSize(5f, 11.5f, 
559                                                                    MediaSize.INCH,
560                                                                    MediaSizeName.NA_NUMBER_14_ENVELOPE);
561      }
562    
563      /**
564       * Container class for predefined US Engineering media sizes.
565       * 
566       * @author Sven de Marothy (sven@physto.se)
567       */
568      public static final class Engineering 
569      {
570        private Engineering()
571        {
572          // prevent instantiation
573        }
574        
575        /**
576         * ANSI A paper size. 8.5 inch x 11 inch
577         */
578        public static final MediaSize A = new MediaSize(8.5f, 11f, 
579                                                  MediaSize.INCH, MediaSizeName.A);
580    
581        /**
582         * ANSI B paper size. 11 inch x 17 inch
583         */
584        public static final MediaSize B = new MediaSize(11f, 17f, 
585                                                  MediaSize.INCH, MediaSizeName.B);
586    
587        /**
588         * ANSI C paper size. 17 inch x 22 inch
589         */
590        public static final MediaSize C = new MediaSize(17f, 22f, 
591                                                  MediaSize.INCH, MediaSizeName.C);
592    
593        /**
594         * ANSI D paper size. 22 inch x 34 inch
595         */
596        public static final MediaSize D = new MediaSize(22f, 34f, 
597                                                  MediaSize.INCH, MediaSizeName.D);
598    
599        /**
600         * ANSI E paper size. 33 inch x 44 inch
601         */
602        public static final MediaSize E = new MediaSize(34f, 44f, 
603                                                  MediaSize.INCH, MediaSizeName.E);
604      }
605    
606      /**
607       * Container class for predefined Japanese JIS media sizes.
608       * 
609       * @author Sven de Marothy (sven@physto.se)
610       */
611      public static final class JIS 
612      {
613        private JIS()
614        {
615          // prevent instantiation
616        }
617        
618        /**
619         * JIS B0 paper. 1030 mm x 1456 mm
620         * Note: The JIS B-series is not identical to the ISO B-series.
621         */
622        public static final MediaSize B0 = new MediaSize(1030, 1456, MediaSize.MM, MediaSizeName.JIS_B0);
623    
624        /**
625         * JIS B1 paper. 1030 mm x 1456 mm
626         * Note: The JIS B-series is not identical to the ISO B-series.
627         */
628        public static final MediaSize B1 = new MediaSize(728, 1030, MediaSize.MM, MediaSizeName.JIS_B1);
629    
630        /**
631         * JIS B2 paper. 515 mm x 728 mm
632         * Note: The JIS B-series is not identical to the ISO B-series.
633         */
634        public static final MediaSize B2 = new MediaSize(515, 728, MediaSize.MM, MediaSizeName.JIS_B2);
635    
636        /**
637         * JIS B3 paper. 364 mm x 515 mm
638         * Note: The JIS B-series is not identical to the ISO B-series.
639         */
640        public static final MediaSize B3 = new MediaSize(364, 515, MediaSize.MM, MediaSizeName.JIS_B3);
641    
642        /**
643         * JIS B4 paper. 257 mm x 364 mm
644         * Note: The JIS B-series is not identical to the ISO B-series.
645         */
646        public static final MediaSize B4 = new MediaSize(257, 364, MediaSize.MM, MediaSizeName.JIS_B4);
647    
648        /**
649         * JIS B5 paper. 1030 mm x 1456 mm
650         * Note: The JIS B-series is not identical to the ISO B-series.
651         */
652        public static final MediaSize B5 = new MediaSize(182, 257, MediaSize.MM, MediaSizeName.JIS_B5);
653    
654        /**
655         * JIS B6 paper. 128 mm x 182 mm
656         * Note: The JIS B-series is not identical to the ISO B-series.
657         */
658        public static final MediaSize B6 = new MediaSize(128, 182, MediaSize.MM, MediaSizeName.JIS_B6);
659    
660        /**
661         * JIS B7 paper. 91 mm x 128 mm
662         * Note: The JIS B-series is not identical to the ISO B-series.
663         */
664        public static final MediaSize B7 = new MediaSize(91, 128, MediaSize.MM, MediaSizeName.JIS_B7);
665    
666        /**
667         * JIS B8 paper. 64 mm x 91 mm
668         * Note: The JIS B-series is not identical to the ISO B-series.
669         */
670        public static final MediaSize B8 = new MediaSize(64, 91, MediaSize.MM, MediaSizeName.JIS_B8);
671    
672        /**
673         * JIS B9 paper. 45 mm x 64 mm
674         * Note: The JIS B-series is not identical to the ISO B-series.
675         */
676        public static final MediaSize B9 = new MediaSize(45, 64, MediaSize.MM, MediaSizeName.JIS_B9);
677    
678        /**
679         * JIS B10 paper. 32 mm x 45 mm
680         * Note: The JIS B-series is not identical to the ISO B-series.
681         */
682        public static final MediaSize B10 = new MediaSize(32, 45, MediaSize.MM, MediaSizeName.JIS_B10);
683    
684        /**
685         * JIS chou #1 envelope size, 142 mm x 332 mm
686         */
687        public static final MediaSize CHOU_1 = new MediaSize(142, 332, MediaSize.MM);
688    
689        /**
690         * JIS chou #2 envelope size, 119 mm x 227 mm
691         */
692        public static final MediaSize CHOU_2 = new MediaSize(119, 227, MediaSize.MM);
693    
694        /**
695         * JIS chou #3 envelope size, 120 mm x 235 mm
696         */
697        public static final MediaSize CHOU_3 = new MediaSize(120, 235, MediaSize.MM);
698    
699        /**
700         * JIS chou #4 envelope size, 90 mm x 205 mm
701         */
702        public static final MediaSize CHOU_4 = new MediaSize(90, 205, MediaSize.MM);
703    
704        /**
705         * JIS chou #30 envelope size, 92 mm x 235 mm
706         */
707        public static final MediaSize CHOU_30 = new MediaSize(92, 235, MediaSize.MM);
708    
709        /**
710         * JIS chou #40 envelope size, 90 mm x 225 mm
711         */
712        public static final MediaSize CHOU_40 = new MediaSize(90, 225, MediaSize.MM);
713    
714        /**
715         * JIS kaku #0 envelope size, 287 mm x 382 mm
716         */
717        public static final MediaSize KAKU_0 = new MediaSize(287, 382, MediaSize.MM);
718    
719        /**
720         * JIS kaku #1 envelope size, 270 mm x 382 mm
721         */
722        public static final MediaSize KAKU_1 = new MediaSize(270, 382, MediaSize.MM);
723    
724        /**
725         * JIS kaku #2 envelope size, 240 mm x 332 mm
726         */
727        public static final MediaSize KAKU_2 = new MediaSize(240, 332, MediaSize.MM);
728    
729        /**
730         * JIS kaku #20 envelope size, 229 mm x 324 mm
731         */
732        public static final MediaSize KAKU_20 = new MediaSize(229, 324, MediaSize.MM);
733    
734        /**
735         * JIS kaku #3 envelope size, 216 mm x 227 mm
736         */
737        public static final MediaSize KAKU_3 = new MediaSize(216, 227, MediaSize.MM);
738    
739        /**
740         * JIS kaku #4 envelope size, 197 mm x 267 mm
741         */
742        public static final MediaSize KAKU_4 = new MediaSize(197, 267, MediaSize.MM);
743    
744        /**
745         * JIS kaku #5 envelope size, 190 mm x 240 mm
746         */
747        public static final MediaSize KAKU_5 = new MediaSize(190, 240, MediaSize.MM);
748    
749        /**
750         * JIS kaku #6 envelope size, 162 mm x 229 mm
751         */
752        public static final MediaSize KAKU_6 = new MediaSize(162, 229, MediaSize.MM);
753    
754        /**
755         * JIS kaku #7 envelope size, 142 mm x 205 mm
756         */
757        public static final MediaSize KAKU_7 = new MediaSize(142, 205, MediaSize.MM);
758    
759        /**
760         * JIS kaku #8 envelope size, 119 mm x 197 mm
761         */
762        public static final MediaSize KAKU_8 = new MediaSize(119, 197, MediaSize.MM);
763    
764        /**
765         * JIS kaku A4 envelope size, 228 mm x 312 mm
766         */
767        public static final MediaSize KAKU_A4 = new MediaSize(228, 312, MediaSize.MM);
768    
769        /**
770         * JIS you #1 envelope size, 120 mm x 176 mm
771         */
772        public static final MediaSize YOU_1 = new MediaSize(120, 176, MediaSize.MM);
773    
774        /**
775         * JIS you #2 envelope size, 114 mm x 162 mm
776         */
777        public static final MediaSize YOU_2 = new MediaSize(114, 162, MediaSize.MM);
778    
779        /**
780         * JIS you #3 envelope size, 98 mm x 148 mm
781         */
782        public static final MediaSize YOU_3 = new MediaSize(98, 148, MediaSize.MM);
783    
784        /**
785         * JIS you #4 envelope size, 105 mm x 235 mm
786         */
787        public static final MediaSize YOU_4 = new MediaSize(105, 235, MediaSize.MM);
788    
789        /**
790         * JIS you #5 envelope size, 95 mm x 217 mm
791         */
792        public static final MediaSize YOU_5 = new MediaSize(95, 217, MediaSize.MM);
793    
794        /**
795         * JIS you #6 envelope size, 98 mm x 190 mm
796         */
797        public static final MediaSize YOU_6 = new MediaSize(98, 190, MediaSize.MM);
798    
799        /**
800         * JIS you #7 envelope size, 92 mm x 165 mm
801         */
802        public static final MediaSize YOU_7 = new MediaSize(92, 165, MediaSize.MM);
803      }
804    
805      /**
806       * Container class for miscellaneous media sizes.
807       * 
808       * @author Sven de Marothy (sven@physto.se)
809       */
810      public static final class Other
811      {
812        private Other()
813        {
814          // prevent instantiation
815        }
816        
817        /**
818         * US Executive paper size, 7.25 inch x 10.5 inch
819         */
820        public static final MediaSize EXECUTIVE = new MediaSize(7.25f, 10.5f, 
821                                                          MediaSize.INCH, MediaSizeName.EXECUTIVE);
822    
823        /**
824         * US Folio paper size, 8.5 inch x 13 inch
825         */
826        public static final MediaSize FOLIO = new MediaSize(8.5f, 13f, MediaSize.INCH, MediaSizeName.FOLIO);
827    
828        /**
829         * US Quarto paper size, 8.5 inches by 10.83 inches.
830         */
831        public static final MediaSize QUARTO = new MediaSize(8.5f, 10.83f, MediaSize.INCH,
832                                                       MediaSizeName.QUARTO);
833    
834        /**
835         * US Invoice size, 5.5 inch x 8.5 inch
836         */
837        public static final MediaSize INVOICE = new MediaSize(5.5f, 8.5f, 
838                                                        MediaSize.INCH, MediaSizeName.INVOICE);
839    
840        /**
841         * US Ledger size, 11 inch x 17 inch
842         */
843        public static final MediaSize LEDGER = new MediaSize(11, 17, MediaSize.INCH, 
844                                                       MediaSizeName.LEDGER);
845    
846        /**
847         * Monarch (7 3/4) envelope size, 3.87 inch x 7.5 inch
848         */
849        public static final MediaSize MONARCH_ENVELOPE = new MediaSize(3.87f, 7.5f, 
850                                                                 MediaSize.INCH,
851                                                                 MediaSizeName.MONARCH_ENVELOPE);
852    
853        /**
854         * Personal envelope size, 3.625 inch x 6.5 inch.
855         */
856        public static final MediaSize PERSONAL_ENVELOPE = new MediaSize(3.625f, 6.5f, MediaSize.INCH,
857                                                                  MediaSizeName.PERSONAL_ENVELOPE);
858    
859        /**
860         * Italian envelope size, 110 mm x 230 mm
861         */
862        public static final MediaSize ITALY_ENVELOPE = new MediaSize(110, 230, 
863                                                               MediaSize.MM,
864                                                               MediaSizeName.ITALY_ENVELOPE);
865    
866        /**
867         * Japanese postcard, 100 mm x 148 mm
868         */
869        public static final MediaSize JAPANESE_POSTCARD = new MediaSize(100, 148, MediaSize.MM, MediaSizeName.JAPANESE_POSTCARD);
870    
871        /**
872         * Japanese double postcard, 148 mm x 200 mm
873         */
874        public static final MediaSize JAPANESE_DOUBLE_POSTCARD = new MediaSize(148, 200, MediaSize.MM, MediaSizeName.JAPANESE_DOUBLE_POSTCARD);
875        
876        /**
877         * Tabloid size, 11 inch x 17 inch.
878         * @since 1.5
879         */
880        public static final MediaSize TABLOID = 
881          new MediaSize(11, 17, Size2DSyntax.INCH, MediaSizeName.TABLOID);
882      }
883    }
884