Source for javax.print.attribute.standard.MediaSize

   1: /* MediaSize.java -- 
   2:    Copyright (C) 2005, 2006  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:       // We call one instance of every container class to make sure it gets
  77:       // loaded during class initialization and therefore all other static
  78:       // fields of this container class also.
  79:       
  80:       // This is needed to put all MediaSize instance into the mediaCache
  81:       // for use by the static methods in this class.
  82:       
  83:       MediaSize tmp = MediaSize.ISO.A0;
  84:       tmp = MediaSize.JIS.B0;
  85:       tmp = MediaSize.Engineering.A;
  86:       tmp = MediaSize.NA.LEGAL;
  87:       tmp = MediaSize.Other.EXECUTIVE;
  88:     }
  89:   
  90:   private MediaSizeName mediaName;
  91:   
  92:   /**
  93:    * Creates a <code>MediaSize</code> object. The created object will be added 
  94:    * to an internal cache used in the static methods of this class for lookup 
  95:    * of available <code>MediaSize</code> instances.
  96:    *
  97:    * @param x the size in x direction
  98:    * @param y the size in y direction
  99:    * @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 final Class getCategory()
 184:   {
 185:     return MediaSize.class;
 186:   }
 187:     
 188:   /**
 189:    * Searches for a MediaSize object with the given dimensions.
 190:    * If none is found with exact dimensions, the closest match is used.
 191:    * Afterwards the MediaSizeName of the found MediaSize object is 
 192:    * returned - which might be null if none is specified.
 193:    * 
 194:    * @param x the dimension for x
 195:    * @param y the dimension for y
 196:    * @param units the units to be used for comparison
 197:    * @return the corresponding MediaSizeName object, or null
 198:    */
 199:   public static MediaSizeName findMedia(float x, float y, int units)
 200:   {
 201:     if (x <= 0.0f || y <= 0.0f)
 202:       throw new IllegalArgumentException(
 203:         "x and/or y may not be less or equal 0");
 204: 
 205:     if (units < 1)
 206:       throw new IllegalArgumentException("units may not be less then 1");
 207: 
 208:     MediaSize bestMatch = null;
 209:     int bestDistance = Integer.MAX_VALUE;
 210: 
 211:     int xMicro = (int) x * units;
 212:     int yMicro = (int) y * units;
 213: 
 214:     for (int i = 0; i < mediaCache.size(); i++)
 215:       {
 216:         MediaSize size = (MediaSize) mediaCache.get(i);
 217:         int dist = (Math.abs(size.getXMicrometers() - xMicro) 
 218:                     + Math.abs(size.getYMicrometers() - yMicro));
 219: 
 220:         if (dist < bestDistance)
 221:           {
 222:             bestMatch = size;
 223:             bestDistance = dist;
 224:           }
 225:       }
 226: 
 227:     return bestMatch.getMediaSizeName();
 228:   }
 229:   
 230:   /**
 231:    * Returns the associated <code>MediaSize</code> instance for the 
 232:    * given named media <code>MediaSizeName</code> instance.
 233:    * 
 234:    * @param media the named media to search for.
 235:    * @return The corresponding <code>MediaSize</code> instance or 
 236:    * <code>null</code> if none found.
 237:    */
 238:   public static MediaSize getMediaSizeForName(MediaSizeName media)
 239:   {
 240:     for (int i = 0; i < mediaCache.size(); i++)
 241:       {
 242:     MediaSize size = (MediaSize) mediaCache.get(i);
 243:     
 244:     if (size.getMediaSizeName().equals(media))
 245:       return size;
 246:       }
 247: 
 248:     return null;
 249:   }
 250:   
 251:   /**
 252:    * Tests if the given object is equal to this object.
 253:    *
 254:    * @param obj the object to test
 255:    *
 256:    * @return <code>true</code> if both objects are equal, 
 257:    * <code>false</code> otherwise.
 258:    */
 259:   public boolean equals(Object obj)
 260:   {
 261:     if (!(obj instanceof MediaSize))
 262:       return false;
 263: 
 264:     MediaSize tmp = (MediaSize) obj;
 265:     return (tmp.getXMicrometers() == this.getXMicrometers()
 266:             && tmp.getYMicrometers() == this.getYMicrometers());
 267:   }
 268:   
 269:   /**
 270:    * Returns the media name of this size.
 271:    * 
 272:    * @return The media name.
 273:    */
 274:   public MediaSizeName getMediaSizeName()
 275:   {
 276:     return mediaName;
 277:   }
 278: 
 279:   /**
 280:    * Returns the name of this attribute.
 281:    *
 282:    * @return The name "media-size".
 283:    */
 284:   public final String getName()
 285:   {
 286:     return "media-size";
 287:   }
 288: 
 289:   /**
 290:    * Container class for predefined ISO media sizes.
 291:    * 
 292:    * @author Sven de Marothy (sven@physto.se)
 293:    */
 294:   public static final class ISO 
 295:   {
 296:     private ISO()
 297:     {
 298:       // prevent instantiation
 299:     }
 300:     
 301:     /**
 302:      * ISO A0 paper, 841 mm x 1189 mm.
 303:      */
 304:     public static final MediaSize A0 = new MediaSize(841, 1189, 
 305:                            MediaSize.MM, 
 306:                            MediaSizeName.ISO_A0);
 307: 
 308:     /**
 309:      * ISO A1 paper, 594 mm x 841 mm
 310:      */
 311:     public static final MediaSize A1 = new MediaSize(594, 841, MediaSize.MM, 
 312:                            MediaSizeName.ISO_A1);
 313: 
 314:     /**
 315:      * ISO A2 paper, 420 mm x 594 mm
 316:      */
 317:     public static final MediaSize A2 = new MediaSize(420, 594, MediaSize.MM, MediaSizeName.ISO_A2);
 318: 
 319:     /**
 320:      * ISO A3 paper, 297 mm x 420 mm
 321:      */
 322:     public static final MediaSize A3 = new MediaSize(297, 420, MediaSize.MM, MediaSizeName.ISO_A3);
 323: 
 324:     /**
 325:      * ISO A4 paper, 210 mm x 297 mm
 326:      */
 327:     public static final MediaSize A4 = new MediaSize(210, 297, MediaSize.MM, MediaSizeName.ISO_A4);
 328: 
 329:     /**
 330:      * ISO A5 paper, 148 mm x 210 mm
 331:      */
 332:     public static final MediaSize A5 = new MediaSize(148, 210, MediaSize.MM, MediaSizeName.ISO_A5);
 333: 
 334:     /**
 335:      * ISO A6 paper, 105 mm x 148 mm
 336:      */
 337:     public static final MediaSize A6 = new MediaSize(105, 148, MediaSize.MM, MediaSizeName.ISO_A6);
 338: 
 339:     /**
 340:      * ISO A7 paper, 74 mm x 105 mm
 341:      */
 342:     public static final MediaSize A7 = new MediaSize(74, 105, MediaSize.MM, MediaSizeName.ISO_A7);
 343: 
 344:     /**
 345:      * ISO A8 paper, 52 mm x 74 mm
 346:      */
 347:     public static final MediaSize A8 = new MediaSize(52, 74, MediaSize.MM, MediaSizeName.ISO_A8);
 348: 
 349:     /**
 350:      * ISO A9 paper, 37 mm x 52 mm
 351:      */
 352:     public static final MediaSize A9 = new MediaSize(37, 52, MediaSize.MM, MediaSizeName.ISO_A9);
 353: 
 354:     /**
 355:      * ISO A10 paper, 26 mm x 37 mm
 356:      */
 357:     public static final MediaSize A10 = new MediaSize(26, 37, MediaSize.MM, MediaSizeName.ISO_A10);
 358: 
 359: 
 360:     /**
 361:      * ISO B0 paper, 1000 mm x 1414 mm
 362:      */
 363:     public static final MediaSize B0 = new MediaSize(1000, 1414, MediaSize.MM, MediaSizeName.ISO_B0);
 364: 
 365:     /**
 366:      * ISO B1 paper, 707 mm x 1000 mm
 367:      */
 368:     public static final MediaSize B1 = new MediaSize(707, 1000, MediaSize.MM, MediaSizeName.ISO_B1);
 369: 
 370:     /**
 371:      * ISO B2 paper, 500 mm x 707 mm
 372:      */
 373:     public static final MediaSize B2 = new MediaSize(500, 707, MediaSize.MM, MediaSizeName.ISO_B2);
 374: 
 375:     /**
 376:      * ISO B3 paper, 353 mm x 500 mm
 377:      */
 378:     public static final MediaSize B3 = new MediaSize(353, 500, MediaSize.MM, MediaSizeName.ISO_B3);
 379: 
 380:     /**
 381:      * ISO B4 paper, 250 mm x 353 mm
 382:      */
 383:     public static final MediaSize B4 = new MediaSize(250, 353, MediaSize.MM, MediaSizeName.ISO_B4);
 384: 
 385:     /**
 386:      * ISO B5 paper, 176 mm x 250 mm
 387:      */
 388:     public static final MediaSize B5 = new MediaSize(176, 250, MediaSize.MM, MediaSizeName.ISO_B5);
 389: 
 390:     /**
 391:      * ISO B6 paper, 125 mm x 176 mm
 392:      */
 393:     public static final MediaSize B6 = new MediaSize(125, 176, MediaSize.MM, MediaSizeName.ISO_B6);
 394: 
 395:     /**
 396:      * ISO B7 paper, 88 mm x 125 mm
 397:      */
 398:     public static final MediaSize B7 = new MediaSize(88, 125, MediaSize.MM, MediaSizeName.ISO_B7);
 399: 
 400:     /**
 401:      * ISO B8 paper, 62 mm x 88 mm
 402:      */
 403:     public static final MediaSize B8 = new MediaSize(62, 88, MediaSize.MM, MediaSizeName.ISO_B8);
 404: 
 405:     /**
 406:      * ISO B9 paper, 44 mm x 62 mm
 407:      */
 408:     public static final MediaSize B9 = new MediaSize(44, 62, MediaSize.MM, MediaSizeName.ISO_B9);
 409: 
 410:     /**
 411:      * ISO B10 paper, 31 mm x 44 mm
 412:      */
 413:     public static final MediaSize B10 = new MediaSize(31, 44, MediaSize.MM, MediaSizeName.ISO_B10);
 414:     
 415:     /**
 416:      * ISO C3 envelope, 324 mm x 458 mm
 417:      */
 418:     public static final MediaSize C3 = new MediaSize(324, 458, MediaSize.MM, MediaSizeName.ISO_C3);
 419: 
 420:     /**
 421:      * ISO C4 envelope, 229 mm x 324 mm
 422:      */
 423:     public static final MediaSize C4 = new MediaSize(229, 324, MediaSize.MM, MediaSizeName.ISO_C4);
 424: 
 425:     /**
 426:      * ISO C5 envelope, 162 mm x 229 mm
 427:      */
 428:     public static final MediaSize C5 = new MediaSize(162, 229, MediaSize.MM, MediaSizeName.ISO_C5);
 429: 
 430:     /**
 431:      * ISO C6 envelope, 114 mm x 162 mm
 432:      */
 433:     public static final MediaSize C6 = new MediaSize(114, 162, MediaSize.MM, MediaSizeName.ISO_C6);
 434: 
 435:     /**
 436:      * ISO ISO Designated Long paper, 324 mm x 458 mm
 437:      */
 438:     public static final MediaSize DESIGNATED_LONG = 
 439:       new MediaSize(324, 458, MediaSize.MM, MediaSizeName.ISO_DESIGNATED_LONG);
 440:   } 
 441: 
 442:   /**
 443:    * Container class for predefined North American media sizes.
 444:    * 
 445:    * @author Sven de Marothy (sven@physto.se)
 446:    */
 447:   public static final class NA
 448:   {
 449:     private NA()
 450:     {
 451:       // prevent instantiation
 452:     }
 453:     
 454:     /**
 455:      * US Legal paper size, 8.5 inch x 14 inch
 456:      */
 457:     public static final MediaSize LEGAL = new MediaSize(8.5f, 14f, MediaSize.INCH, 
 458:                           MediaSizeName.NA_LEGAL);
 459: 
 460:     /**
 461:      * US Letter paper size, 8.5 inch x 11 inch
 462:      */
 463:     public static final MediaSize LETTER = new MediaSize(8.5f, 11f, MediaSize.INCH,
 464:                            MediaSizeName.NA_LETTER);
 465: 
 466:     /**
 467:      * 5 inch x 7 inch paper size.
 468:      */
 469:     public static final MediaSize NA_5X7 = new MediaSize(5, 7, MediaSize.INCH,
 470:                              MediaSizeName.NA_5X7);
 471: 
 472:     /**
 473:      * 8 inch x 10 inch paper size.
 474:      */
 475:     public static final MediaSize NA_8X10 = new MediaSize(8, 10, MediaSize.INCH,
 476:                               MediaSizeName.NA_8X10);
 477: 
 478:     /**
 479:      * 6 inch x 9 inch envelope size.
 480:      */
 481:     public static final MediaSize NA_6X9_ENVELOPE = new MediaSize(6f, 9f, 
 482:                                   MediaSize.INCH,
 483:                                   MediaSizeName.NA_6X9_ENVELOPE);
 484: 
 485:     /**
 486:      * 7 inch x 9 inch envelope size.
 487:      */
 488:     public static final MediaSize NA_7X9_ENVELOPE = new MediaSize(7f, 9f, 
 489:                                   MediaSize.INCH,
 490:                                   MediaSizeName.NA_7X9_ENVELOPE);
 491: 
 492:     /**
 493:      * 9 inch x 11 inch envelope size.
 494:      */
 495:     public static final MediaSize NA_9x11_ENVELOPE = new MediaSize(9f, 11f, 
 496:                                  MediaSize.INCH,
 497:                                  MediaSizeName.NA_9X11_ENVELOPE);
 498: 
 499:     /**
 500:      * 9 inch x 12 inch envelope size.
 501:      */
 502:     public static final MediaSize NA_9x12_ENVELOPE = new MediaSize(9f, 12f, 
 503:                                  MediaSize.INCH,
 504:                                  MediaSizeName.NA_9X12_ENVELOPE);
 505: 
 506: 
 507:     /**
 508:      * 10 inch x 13 inch envelope size.
 509:      */
 510:     public static final MediaSize NA_10x13_ENVELOPE = new MediaSize(10f, 13f, 
 511:                                   MediaSize.INCH,
 512:                                   MediaSizeName.NA_10X13_ENVELOPE);
 513: 
 514:     /**
 515:      * 10 inch x 14 inch envelope size.
 516:      */
 517:     public static final MediaSize NA_10x14_ENVELOPE = new MediaSize(10f, 14f, 
 518:                                   MediaSize.INCH,
 519:                                   MediaSizeName.NA_10X14_ENVELOPE);
 520: 
 521:     /**
 522:      * 10 inch x 15 inch envelope size.
 523:      */
 524:     public static final MediaSize NA_10X15_ENVELOPE = new MediaSize(10f, 15f, 
 525:                                   MediaSize.INCH,
 526:                                   MediaSizeName.NA_10X15_ENVELOPE);
 527: 
 528:     /**
 529:      * Number 9 envelope size. 4.5 inch x 10.375 inch
 530:      */
 531:     public static final MediaSize NA_NUMBER_9_ENVELOPE = new MediaSize(3.875f, 8.875f,
 532:                                  MediaSize.INCH,
 533:                                  MediaSizeName.NA_NUMBER_9_ENVELOPE);
 534: 
 535:     /**
 536:      * Number 10 envelope size. 4.125 inch x 9.5 inch
 537:      */
 538:     public static final MediaSize NA_NUMBER_10_ENVELOPE = 
 539:       new MediaSize(4.125f, 9.5f, MediaSize.INCH, MediaSizeName.NA_NUMBER_10_ENVELOPE);
 540: 
 541:     /**
 542:      * Number 11 envelope size. 4.5 inch x 10.375 inch
 543:      */
 544:     public static final MediaSize NA_NUMBER_11_ENVELOPE = new MediaSize(4.5f, 10.375f, MediaSize.INCH,
 545:                                   MediaSizeName.NA_NUMBER_11_ENVELOPE);
 546:     
 547:     /**
 548:      * Number 12 envelope size. 4.75 inch x 11 inch
 549:      */
 550:     public static final MediaSize NA_NUMBER_12_ENVELOPE = new MediaSize(4.75f, 11f, 
 551:                                   MediaSize.INCH,
 552:                                   MediaSizeName.NA_NUMBER_12_ENVELOPE);
 553: 
 554:   /**
 555:    * Number 14 envelope size. 5 inch x 11.5 inch
 556:    */
 557:   public static final MediaSize NA_NUMBER_14_ENVELOPE = new MediaSize(5f, 11.5f, 
 558:                                 MediaSize.INCH,
 559:                                 MediaSizeName.NA_NUMBER_14_ENVELOPE);
 560:   }
 561: 
 562:   /**
 563:    * Container class for predefined US Engineering media sizes.
 564:    * 
 565:    * @author Sven de Marothy (sven@physto.se)
 566:    */
 567:   public static final class Engineering 
 568:   {
 569:     private Engineering()
 570:     {
 571:       // prevent instantiation
 572:     }
 573:     
 574:     /**
 575:      * ANSI A paper size. 8.5 inch x 11 inch
 576:      */
 577:     public static final MediaSize A = new MediaSize(8.5f, 11f, 
 578:                           MediaSize.INCH, MediaSizeName.A);
 579: 
 580:     /**
 581:      * ANSI B paper size. 11 inch x 17 inch
 582:      */
 583:     public static final MediaSize B = new MediaSize(11f, 17f, 
 584:                           MediaSize.INCH, MediaSizeName.B);
 585: 
 586:     /**
 587:      * ANSI C paper size. 17 inch x 22 inch
 588:      */
 589:     public static final MediaSize C = new MediaSize(17f, 22f, 
 590:                           MediaSize.INCH, MediaSizeName.C);
 591: 
 592:     /**
 593:      * ANSI D paper size. 22 inch x 34 inch
 594:      */
 595:     public static final MediaSize D = new MediaSize(22f, 34f, 
 596:                           MediaSize.INCH, MediaSizeName.D);
 597: 
 598:     /**
 599:      * ANSI E paper size. 33 inch x 44 inch
 600:      */
 601:     public static final MediaSize E = new MediaSize(34f, 44f, 
 602:                           MediaSize.INCH, MediaSizeName.E);
 603:   }
 604: 
 605:   /**
 606:    * Container class for predefined Japanese JIS media sizes.
 607:    * 
 608:    * @author Sven de Marothy (sven@physto.se)
 609:    */
 610:   public static final class JIS 
 611:   {
 612:     private JIS()
 613:     {
 614:       // prevent instantiation
 615:     }
 616:     
 617:     /**
 618:      * JIS B0 paper. 1030 mm x 1456 mm
 619:      * Note: The JIS B-series is not identical to the ISO B-series.
 620:      */
 621:     public static final MediaSize B0 = new MediaSize(1030, 1456, MediaSize.MM, MediaSizeName.JIS_B0);
 622: 
 623:     /**
 624:      * JIS B1 paper. 1030 mm x 1456 mm
 625:      * Note: The JIS B-series is not identical to the ISO B-series.
 626:      */
 627:     public static final MediaSize B1 = new MediaSize(728, 1030, MediaSize.MM, MediaSizeName.JIS_B1);
 628: 
 629:     /**
 630:      * JIS B2 paper. 515 mm x 728 mm
 631:      * Note: The JIS B-series is not identical to the ISO B-series.
 632:      */
 633:     public static final MediaSize B2 = new MediaSize(515, 728, MediaSize.MM, MediaSizeName.JIS_B2);
 634: 
 635:     /**
 636:      * JIS B3 paper. 364 mm x 515 mm
 637:      * Note: The JIS B-series is not identical to the ISO B-series.
 638:      */
 639:     public static final MediaSize B3 = new MediaSize(364, 515, MediaSize.MM, MediaSizeName.JIS_B3);
 640: 
 641:     /**
 642:      * JIS B4 paper. 257 mm x 364 mm
 643:      * Note: The JIS B-series is not identical to the ISO B-series.
 644:      */
 645:     public static final MediaSize B4 = new MediaSize(257, 364, MediaSize.MM, MediaSizeName.JIS_B4);
 646: 
 647:     /**
 648:      * JIS B5 paper. 1030 mm x 1456 mm
 649:      * Note: The JIS B-series is not identical to the ISO B-series.
 650:      */
 651:     public static final MediaSize B5 = new MediaSize(182, 257, MediaSize.MM, MediaSizeName.JIS_B5);
 652: 
 653:     /**
 654:      * JIS B6 paper. 128 mm x 182 mm
 655:      * Note: The JIS B-series is not identical to the ISO B-series.
 656:      */
 657:     public static final MediaSize B6 = new MediaSize(128, 182, MediaSize.MM, MediaSizeName.JIS_B6);
 658: 
 659:     /**
 660:      * JIS B7 paper. 91 mm x 128 mm
 661:      * Note: The JIS B-series is not identical to the ISO B-series.
 662:      */
 663:     public static final MediaSize B7 = new MediaSize(91, 128, MediaSize.MM, MediaSizeName.JIS_B7);
 664: 
 665:     /**
 666:      * JIS B8 paper. 64 mm x 91 mm
 667:      * Note: The JIS B-series is not identical to the ISO B-series.
 668:      */
 669:     public static final MediaSize B8 = new MediaSize(64, 91, MediaSize.MM, MediaSizeName.JIS_B8);
 670: 
 671:     /**
 672:      * JIS B9 paper. 45 mm x 64 mm
 673:      * Note: The JIS B-series is not identical to the ISO B-series.
 674:      */
 675:     public static final MediaSize B9 = new MediaSize(45, 64, MediaSize.MM, MediaSizeName.JIS_B9);
 676: 
 677:     /**
 678:      * JIS B10 paper. 32 mm x 45 mm
 679:      * Note: The JIS B-series is not identical to the ISO B-series.
 680:      */
 681:     public static final MediaSize B10 = new MediaSize(32, 45, MediaSize.MM, MediaSizeName.JIS_B10);
 682: 
 683:     /**
 684:      * JIS chou #1 envelope size, 142 mm x 332 mm
 685:      */
 686:     public static final MediaSize CHOU_1 = new MediaSize(142, 332, MediaSize.MM);
 687: 
 688:     /**
 689:      * JIS chou #2 envelope size, 119 mm x 227 mm
 690:      */
 691:     public static final MediaSize CHOU_2 = new MediaSize(119, 227, MediaSize.MM);
 692: 
 693:     /**
 694:      * JIS chou #3 envelope size, 120 mm x 235 mm
 695:      */
 696:     public static final MediaSize CHOU_3 = new MediaSize(120, 235, MediaSize.MM);
 697: 
 698:     /**
 699:      * JIS chou #4 envelope size, 90 mm x 205 mm
 700:      */
 701:     public static final MediaSize CHOU_4 = new MediaSize(90, 205, MediaSize.MM);
 702: 
 703:     /**
 704:      * JIS chou #30 envelope size, 92 mm x 235 mm
 705:      */
 706:     public static final MediaSize CHOU_30 = new MediaSize(92, 235, MediaSize.MM);
 707: 
 708:     /**
 709:      * JIS chou #40 envelope size, 90 mm x 225 mm
 710:      */
 711:     public static final MediaSize CHOU_40 = new MediaSize(90, 225, MediaSize.MM);
 712: 
 713:     /**
 714:      * JIS kaku #0 envelope size, 287 mm x 382 mm
 715:      */
 716:     public static final MediaSize KAKU_0 = new MediaSize(287, 382, MediaSize.MM);
 717: 
 718:     /**
 719:      * JIS kaku #1 envelope size, 270 mm x 382 mm
 720:      */
 721:     public static final MediaSize KAKU_1 = new MediaSize(270, 382, MediaSize.MM);
 722: 
 723:     /**
 724:      * JIS kaku #2 envelope size, 240 mm x 332 mm
 725:      */
 726:     public static final MediaSize KAKU_2 = new MediaSize(240, 332, MediaSize.MM);
 727: 
 728:     /**
 729:      * JIS kaku #20 envelope size, 229 mm x 324 mm
 730:      */
 731:     public static final MediaSize KAKU_20 = new MediaSize(229, 324, MediaSize.MM);
 732: 
 733:     /**
 734:      * JIS kaku #3 envelope size, 216 mm x 227 mm
 735:      */
 736:     public static final MediaSize KAKU_3 = new MediaSize(216, 227, MediaSize.MM);
 737: 
 738:     /**
 739:      * JIS kaku #4 envelope size, 197 mm x 267 mm
 740:      */
 741:     public static final MediaSize KAKU_4 = new MediaSize(197, 267, MediaSize.MM);
 742: 
 743:     /**
 744:      * JIS kaku #5 envelope size, 190 mm x 240 mm
 745:      */
 746:     public static final MediaSize KAKU_5 = new MediaSize(190, 240, MediaSize.MM);
 747: 
 748:     /**
 749:      * JIS kaku #6 envelope size, 162 mm x 229 mm
 750:      */
 751:     public static final MediaSize KAKU_6 = new MediaSize(162, 229, MediaSize.MM);
 752: 
 753:     /**
 754:      * JIS kaku #7 envelope size, 142 mm x 205 mm
 755:      */
 756:     public static final MediaSize KAKU_7 = new MediaSize(142, 205, MediaSize.MM);
 757: 
 758:     /**
 759:      * JIS kaku #8 envelope size, 119 mm x 197 mm
 760:      */
 761:     public static final MediaSize KAKU_8 = new MediaSize(119, 197, MediaSize.MM);
 762: 
 763:     /**
 764:      * JIS kaku A4 envelope size, 228 mm x 312 mm
 765:      */
 766:     public static final MediaSize KAKU_A4 = new MediaSize(228, 312, MediaSize.MM);
 767: 
 768:     /**
 769:      * JIS you #1 envelope size, 120 mm x 176 mm
 770:      */
 771:     public static final MediaSize YOU_1 = new MediaSize(120, 176, MediaSize.MM);
 772: 
 773:     /**
 774:      * JIS you #2 envelope size, 114 mm x 162 mm
 775:      */
 776:     public static final MediaSize YOU_2 = new MediaSize(114, 162, MediaSize.MM);
 777: 
 778:     /**
 779:      * JIS you #3 envelope size, 98 mm x 148 mm
 780:      */
 781:     public static final MediaSize YOU_3 = new MediaSize(98, 148, MediaSize.MM);
 782: 
 783:     /**
 784:      * JIS you #4 envelope size, 105 mm x 235 mm
 785:      */
 786:     public static final MediaSize YOU_4 = new MediaSize(105, 235, MediaSize.MM);
 787: 
 788:     /**
 789:      * JIS you #5 envelope size, 95 mm x 217 mm
 790:      */
 791:     public static final MediaSize YOU_5 = new MediaSize(95, 217, MediaSize.MM);
 792: 
 793:     /**
 794:      * JIS you #6 envelope size, 98 mm x 190 mm
 795:      */
 796:     public static final MediaSize YOU_6 = new MediaSize(98, 190, MediaSize.MM);
 797: 
 798:     /**
 799:      * JIS you #7 envelope size, 92 mm x 165 mm
 800:      */
 801:     public static final MediaSize YOU_7 = new MediaSize(92, 165, MediaSize.MM);
 802:   }
 803: 
 804:   /**
 805:    * Container class for miscellaneous media sizes.
 806:    * 
 807:    * @author Sven de Marothy (sven@physto.se)
 808:    */
 809:   public static final class Other
 810:   {
 811:     private Other()
 812:     {
 813:       // prevent instantiation
 814:     }
 815:     
 816:     /**
 817:      * US Executive paper size, 7.25 inch x 10.5 inch
 818:      */
 819:     public static final MediaSize EXECUTIVE = new MediaSize(7.25f, 10.5f, 
 820:                               MediaSize.INCH, MediaSizeName.EXECUTIVE);
 821: 
 822:     /**
 823:      * US Folio paper size, 8.5 inch x 13 inch
 824:      */
 825:     public static final MediaSize FOLIO = new MediaSize(8.5f, 13f, MediaSize.INCH, MediaSizeName.FOLIO);
 826: 
 827:     /**
 828:      * US Quarto paper size, 8.5 inches by 10.83 inches.
 829:      */
 830:     public static final MediaSize QUARTO = new MediaSize(8.5f, 10.83f, MediaSize.INCH,
 831:                            MediaSizeName.QUARTO);
 832: 
 833:     /**
 834:      * US Invoice size, 5.5 inch x 8.5 inch
 835:      */
 836:     public static final MediaSize INVOICE = new MediaSize(5.5f, 8.5f, 
 837:                             MediaSize.INCH, MediaSizeName.INVOICE);
 838: 
 839:     /**
 840:      * US Ledger size, 11 inch x 17 inch
 841:      */
 842:     public static final MediaSize LEDGER = new MediaSize(11, 17, MediaSize.INCH, 
 843:                            MediaSizeName.LEDGER);
 844: 
 845:     /**
 846:      * Monarch (7 3/4) envelope size, 3.87 inch x 7.5 inch
 847:      */
 848:     public static final MediaSize MONARCH_ENVELOPE = new MediaSize(3.87f, 7.5f, 
 849:                                  MediaSize.INCH,
 850:                                  MediaSizeName.MONARCH_ENVELOPE);
 851: 
 852:     /**
 853:      * Personal envelope size, 3.625 inch x 6.5 inch.
 854:      */
 855:     public static final MediaSize PERSONAL_ENVELOPE = new MediaSize(3.625f, 6.5f, MediaSize.INCH,
 856:                                   MediaSizeName.PERSONAL_ENVELOPE);
 857: 
 858:     /**
 859:      * Italian envelope size, 110 mm x 230 mm
 860:      */
 861:     public static final MediaSize ITALY_ENVELOPE = new MediaSize(110, 230, 
 862:                                MediaSize.MM,
 863:                                MediaSizeName.ITALY_ENVELOPE);
 864: 
 865:     /**
 866:      * Japanese postcard, 100 mm x 148 mm
 867:      */
 868:     public static final MediaSize JAPANESE_POSTCARD = new MediaSize(100, 148, MediaSize.MM, MediaSizeName.JAPANESE_POSTCARD);
 869: 
 870:     /**
 871:      * Japanese double postcard, 148 mm x 200 mm
 872:      */
 873:     public static final MediaSize JAPANESE_DOUBLE_POSTCARD = new MediaSize(148, 200, MediaSize.MM, MediaSizeName.JAPANESE_DOUBLE_POSTCARD);
 874:     
 875:     /**
 876:      * Tabloid size, 11 inch x 17 inch.
 877:      * @since 1.5
 878:      */
 879:     public static final MediaSize TABLOID = 
 880:       new MediaSize(11, 17, Size2DSyntax.INCH, MediaSizeName.TABLOID);
 881:   }
 882: }