Source for javax.print.attribute.standard.MediaSize

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