< prev index next >

src/java.desktop/share/classes/javax/print/attribute/standard/MediaSize.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */

  25 package javax.print.attribute.standard;
  26 
  27 import java.util.HashMap;
  28 import java.util.Vector;
  29 
  30 import javax.print.attribute.Size2DSyntax;
  31 import javax.print.attribute.Attribute;

  32 
  33 /**
  34  * Class MediaSize is a two-dimensional size valued printing attribute class
  35  * that indicates the dimensions of the medium in a portrait orientation, with
  36  * the X dimension running along the bottom edge and the Y dimension running
  37  * along the left edge. Thus, the Y dimension must be greater than or equal to
  38  * the X dimension. Class MediaSize declares many standard media size
  39  * values, organized into nested classes for ISO, JIS, North American,
  40  * engineering, and other media.
  41  * <P>
  42  * MediaSize is not yet used to specify media. Its current role is
  43  * as a mapping for named media (see {@link MediaSizeName MediaSizeName}).
  44  * Clients can use the mapping method
  45  * {@code MediaSize.getMediaSizeForName(MediaSizeName)}
  46  * to find the physical dimensions of the MediaSizeName instances
  47  * enumerated in this API. This is useful for clients which need this
  48  * information to format {@literal &} paginate printing.
  49  *
  50  * @author  Phil Race, Alan Kaminsky
  51  */
  52 public class MediaSize extends Size2DSyntax implements Attribute {
  53 



  54     private static final long serialVersionUID = -1967958664615414771L;
  55 



  56     private MediaSizeName mediaName;
  57 
  58     private static HashMap<MediaSizeName, MediaSize> mediaMap = new HashMap<>(100, 10);
  59 
  60     private static Vector<MediaSize> sizeVector = new Vector<>(100, 10);
  61 
  62     /**
  63      * Construct a new media size attribute from the given floating-point
  64      * values.
  65      *
  66      * @param  x  X dimension.
  67      * @param  y  Y dimension.
  68      * @param  units
  69      *     Unit conversion factor, e.g. {@code Size2DSyntax.INCH} or
  70      *     {@code Size2DSyntax.MM}.
  71      *
  72      * @exception  IllegalArgumentException
  73      *   (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or
  74      *   {@code units < 1} or {@code x > y}.
  75      */
  76     public MediaSize(float x, float y,int units) {
  77         super (x, y, units);
  78         if (x > y) {
  79             throw new IllegalArgumentException("X dimension > Y dimension");
  80         }
  81         sizeVector.add(this);
  82     }
  83 
  84     /**
  85      * Construct a new media size attribute from the given integer values.
  86      *
  87      * @param  x  X dimension.
  88      * @param  y  Y dimension.
  89      * @param  units
  90      *     Unit conversion factor, e.g. {@code Size2DSyntax.INCH} or
  91      *     {@code Size2DSyntax.MM}.
  92      *
  93      * @exception  IllegalArgumentException
  94      *   (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or
  95      *   {@code units < 1} or {@code x > y}.
  96      */
  97     public MediaSize(int x, int y,int units) {
  98         super (x, y, units);
  99         if (x > y) {
 100             throw new IllegalArgumentException("X dimension > Y dimension");
 101         }
 102         sizeVector.add(this);
 103     }
 104 
 105    /**
 106      * Construct a new media size attribute from the given floating-point
 107      * values.
 108      *
 109      * @param  x  X dimension.
 110      * @param  y  Y dimension.
 111      * @param  units
 112      *     Unit conversion factor, e.g. {@code Size2DSyntax.INCH} or
 113      *     {@code Size2DSyntax.MM}.
 114      * @param media a media name to associate with this MediaSize
 115      *
 116      * @exception  IllegalArgumentException
 117      *   (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or
 118      *   {@code units < 1} or {@code x > y}.
 119      */
 120     public MediaSize(float x, float y,int units, MediaSizeName media) {
 121         super (x, y, units);
 122         if (x > y) {
 123             throw new IllegalArgumentException("X dimension > Y dimension");
 124         }
 125         if (media != null && mediaMap.get(media) == null) {
 126             mediaName = media;
 127             mediaMap.put(mediaName, this);
 128         }
 129         sizeVector.add(this);
 130     }
 131 
 132     /**
 133      * Construct a new media size attribute from the given integer values.
 134      *
 135      * @param  x  X dimension.
 136      * @param  y  Y dimension.
 137      * @param  units
 138      *     Unit conversion factor, e.g. {@code Size2DSyntax.INCH} or
 139      *     {@code Size2DSyntax.MM}.
 140      * @param media a media name to associate with this MediaSize
 141      *
 142      * @exception  IllegalArgumentException
 143      *   (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or
 144      *   {@code units < 1} or {@code x > y}.
 145      */
 146     public MediaSize(int x, int y,int units, MediaSizeName media) {
 147         super (x, y, units);
 148         if (x > y) {
 149             throw new IllegalArgumentException("X dimension > Y dimension");
 150         }
 151         if (media != null && mediaMap.get(media) == null) {
 152             mediaName = media;
 153             mediaMap.put(mediaName, this);
 154         }
 155         sizeVector.add(this);
 156     }
 157 
 158     /**
 159      * Get the media name, if any, for this size.
 160      *
 161      * @return the name for this media size, or null if no name was
 162      * associated with this size (an anonymous size).
 163      */
 164     public MediaSizeName getMediaSizeName() {
 165         return mediaName;
 166     }
 167 
 168     /**
 169      * Get the MediaSize for the specified named media.
 170      *
 171      * @param media the name of the media for which the size is sought
 172      * @return size of the media, or null if this media is not associated
 173      * with any size.
 174      */
 175     public static MediaSize getMediaSizeForName(MediaSizeName media) {
 176         return mediaMap.get(media);
 177     }
 178 
 179     /**
 180      * The specified dimensions are used to locate a matching MediaSize
 181      * instance from amongst all the standard MediaSize instances.
 182      * If there is no exact match, the closest match is used.
 183      * <p>
 184      * The MediaSize is in turn used to locate the MediaSizeName object.
 185      * This method may return null if the closest matching MediaSize
 186      * has no corresponding Media instance.
 187      * <p>
 188      * This method is useful for clients which have only dimensions and
 189      * want to find a Media which corresponds to the dimensions.
 190      * @param x X dimension
 191      * @param y Y dimension.
 192      * @param  units
 193      *     Unit conversion factor, e.g. {@code Size2DSyntax.INCH} or
 194      *     {@code Size2DSyntax.MM}
 195      * @return MediaSizeName matching these dimensions, or null.
 196      * @exception IllegalArgumentException if {@code x <= 0},
 197      *      {@code y <= 0}, or {@code units < 1}.
 198      *







 199      */
 200     public static MediaSizeName findMedia(float x, float y, int units) {
 201 
 202         MediaSize match = MediaSize.ISO.A4;
 203 
 204         if (x <= 0.0f || y <= 0.0f || units < 1) {
 205             throw new IllegalArgumentException("args must be +ve values");
 206         }
 207 
 208         double ls = x * x + y * y;
 209         double tmp_ls;
 210         float []dim;
 211         float diffx = x;
 212         float diffy = y;
 213 
 214         for (int i=0; i < sizeVector.size() ; i++) {
 215             MediaSize mediaSize = sizeVector.elementAt(i);
 216             dim = mediaSize.getSize(units);
 217             if (x == dim[0] && y == dim[1]) {
 218                 match = mediaSize;
 219                 break;
 220             } else {
 221                 diffx = x - dim[0];
 222                 diffy = y - dim[1];
 223                 tmp_ls = diffx * diffx + diffy * diffy;
 224                 if (tmp_ls < ls) {
 225                     ls = tmp_ls;
 226                     match = mediaSize;
 227                 }
 228             }
 229         }
 230 
 231         return match.getMediaSizeName();
 232     }
 233 
 234     /**
 235      * Returns whether this media size attribute is equivalent to the passed
 236      * in object.
 237      * To be equivalent, all of the following conditions must be true:
 238      * <OL TYPE=1>
 239      * <LI>
 240      * {@code object} is not null.
 241      * <LI>
 242      * {@code object} is an instance of class MediaSize.
 243      * <LI>
 244      * This media size attribute's X dimension is equal to
 245      * {@code object}'s X dimension.
 246      * <LI>
 247      * This media size attribute's Y dimension is equal to
 248      * {@code object}'s Y dimension.
 249      * </OL>
 250      *
 251      * @param  object  Object to compare to.
 252      *
 253      * @return  True if {@code object} is equivalent to this media size
 254      *          attribute, false otherwise.
 255      */
 256     public boolean equals(Object object) {
 257         return (super.equals(object) && object instanceof MediaSize);
 258     }
 259 
 260     /**
 261      * Get the printing attribute class which is to be used as the "category"
 262      * for this printing attribute value.
 263      * <P>
 264      * For class MediaSize and any vendor-defined subclasses, the category is
 265      * class MediaSize itself.
 266      *
 267      * @return  Printing attribute class (category), an instance of class
 268      *          {@link java.lang.Class java.lang.Class}.
 269      */
 270     public final Class<? extends Attribute> getCategory() {
 271         return MediaSize.class;
 272     }
 273 
 274     /**
 275      * Get the name of the category of which this attribute value is an
 276      * instance.
 277      * <P>
 278      * For class MediaSize and any vendor-defined subclasses, the category
 279      * name is {@code "media-size"}.
 280      *
 281      * @return  Attribute category name.
 282      */
 283     public final String getName() {
 284         return "media-size";
 285     }
 286 
 287     /**
 288      * Class MediaSize.ISO includes {@link MediaSize MediaSize} values for ISO
 289      * media.
 290      */
 291     public static final class ISO {

 292         /**
 293          * Specifies the ISO A0 size, 841 mm by 1189 mm.
 294          */
 295         public static final MediaSize
 296             A0 = new MediaSize(841, 1189, Size2DSyntax.MM, MediaSizeName.ISO_A0);

 297         /**
 298          * Specifies the ISO A1 size, 594 mm by 841 mm.
 299          */
 300         public static final MediaSize
 301             A1 = new MediaSize(594, 841, Size2DSyntax.MM, MediaSizeName.ISO_A1);

 302         /**
 303          * Specifies the ISO A2 size, 420 mm by 594 mm.
 304          */
 305         public static final MediaSize
 306             A2 = new MediaSize(420, 594, Size2DSyntax.MM, MediaSizeName.ISO_A2);

 307         /**
 308          * Specifies the ISO A3 size, 297 mm by 420 mm.
 309          */
 310         public static final MediaSize
 311             A3 = new MediaSize(297, 420, Size2DSyntax.MM, MediaSizeName.ISO_A3);

 312         /**
 313          * Specifies the ISO A4 size, 210 mm by 297 mm.
 314          */
 315         public static final MediaSize
 316             A4 = new MediaSize(210, 297, Size2DSyntax.MM, MediaSizeName.ISO_A4);

 317         /**
 318          * Specifies the ISO A5 size, 148 mm by 210 mm.
 319          */
 320         public static final MediaSize
 321             A5 = new MediaSize(148, 210, Size2DSyntax.MM, MediaSizeName.ISO_A5);

 322         /**
 323          * Specifies the ISO A6 size, 105 mm by 148 mm.
 324          */
 325         public static final MediaSize
 326             A6 = new MediaSize(105, 148, Size2DSyntax.MM, MediaSizeName.ISO_A6);

 327         /**
 328          * Specifies the ISO A7 size, 74 mm by 105 mm.
 329          */
 330         public static final MediaSize
 331             A7 = new MediaSize(74, 105, Size2DSyntax.MM, MediaSizeName.ISO_A7);

 332         /**
 333          * Specifies the ISO A8 size, 52 mm by 74 mm.
 334          */
 335         public static final MediaSize
 336             A8 = new MediaSize(52, 74, Size2DSyntax.MM, MediaSizeName.ISO_A8);

 337         /**
 338          * Specifies the ISO A9 size, 37 mm by 52 mm.
 339          */
 340         public static final MediaSize
 341             A9 = new MediaSize(37, 52, Size2DSyntax.MM, MediaSizeName.ISO_A9);

 342         /**
 343          * Specifies the ISO A10 size, 26 mm by 37 mm.
 344          */
 345         public static final MediaSize
 346             A10 = new MediaSize(26, 37, Size2DSyntax.MM, MediaSizeName.ISO_A10);

 347         /**
 348          * Specifies the ISO B0 size, 1000 mm by 1414 mm.
 349          */
 350         public static final MediaSize
 351             B0 = new MediaSize(1000, 1414, Size2DSyntax.MM, MediaSizeName.ISO_B0);

 352         /**
 353          * Specifies the ISO B1 size, 707 mm by 1000 mm.
 354          */
 355         public static final MediaSize
 356             B1 = new MediaSize(707, 1000, Size2DSyntax.MM, MediaSizeName.ISO_B1);

 357         /**
 358          * Specifies the ISO B2 size, 500 mm by 707 mm.
 359          */
 360         public static final MediaSize
 361             B2 = new MediaSize(500, 707, Size2DSyntax.MM, MediaSizeName.ISO_B2);

 362         /**
 363          * Specifies the ISO B3 size, 353 mm by 500 mm.
 364          */
 365         public static final MediaSize
 366             B3 = new MediaSize(353, 500, Size2DSyntax.MM, MediaSizeName.ISO_B3);

 367         /**
 368          * Specifies the ISO B4 size, 250 mm by 353 mm.
 369          */
 370         public static final MediaSize
 371             B4 = new MediaSize(250, 353, Size2DSyntax.MM, MediaSizeName.ISO_B4);

 372         /**
 373          * Specifies the ISO B5 size, 176 mm by 250 mm.
 374          */
 375         public static final MediaSize
 376             B5 = new MediaSize(176, 250, Size2DSyntax.MM, MediaSizeName.ISO_B5);

 377         /**
 378          * Specifies the ISO B6 size, 125 mm by 176 mm.
 379          */
 380         public static final MediaSize
 381             B6 = new MediaSize(125, 176, Size2DSyntax.MM, MediaSizeName.ISO_B6);

 382         /**
 383          * Specifies the ISO B7 size, 88 mm by 125 mm.
 384          */
 385         public static final MediaSize
 386             B7 = new MediaSize(88, 125, Size2DSyntax.MM, MediaSizeName.ISO_B7);

 387         /**
 388          * Specifies the ISO B8 size, 62 mm by 88 mm.
 389          */
 390         public static final MediaSize
 391             B8 = new MediaSize(62, 88, Size2DSyntax.MM, MediaSizeName.ISO_B8);

 392         /**
 393          * Specifies the ISO B9 size, 44 mm by 62 mm.
 394          */
 395         public static final MediaSize
 396             B9 = new MediaSize(44, 62, Size2DSyntax.MM, MediaSizeName.ISO_B9);

 397         /**
 398          * Specifies the ISO B10 size, 31 mm by 44 mm.
 399          */
 400         public static final MediaSize
 401             B10 = new MediaSize(31, 44, Size2DSyntax.MM, MediaSizeName.ISO_B10);

 402         /**
 403          * Specifies the ISO C3 size, 324 mm by 458 mm.
 404          */
 405         public static final MediaSize
 406             C3 = new MediaSize(324, 458, Size2DSyntax.MM, MediaSizeName.ISO_C3);

 407         /**
 408          * Specifies the ISO C4 size, 229 mm by 324 mm.
 409          */
 410         public static final MediaSize
 411             C4 = new MediaSize(229, 324, Size2DSyntax.MM, MediaSizeName.ISO_C4);

 412         /**
 413          * Specifies the ISO C5 size, 162 mm by 229 mm.
 414          */
 415         public static final MediaSize
 416             C5 = new MediaSize(162, 229, Size2DSyntax.MM, MediaSizeName.ISO_C5);

 417         /**
 418          * Specifies the ISO C6 size, 114 mm by 162 mm.
 419          */
 420         public static final MediaSize
 421             C6 = new MediaSize(114, 162, Size2DSyntax.MM, MediaSizeName.ISO_C6);

 422         /**
 423          * Specifies the ISO Designated Long size, 110 mm by 220 mm.
 424          */
 425         public static final MediaSize
 426             DESIGNATED_LONG = new MediaSize(110, 220, Size2DSyntax.MM,
 427                                             MediaSizeName.ISO_DESIGNATED_LONG);
 428 
 429         /**
 430          * Hide all constructors.
 431          */
 432         private ISO() {
 433         }
 434     }
 435 
 436     /**
 437      * Class MediaSize.JIS includes {@link MediaSize MediaSize} values for JIS
 438      * (Japanese) media.      *
 439      */
 440     public static final class JIS {
 441 
 442         /**
 443          * Specifies the JIS B0 size, 1030 mm by 1456 mm.
 444          */
 445         public static final MediaSize
 446             B0 = new MediaSize(1030, 1456, Size2DSyntax.MM, MediaSizeName.JIS_B0);

 447         /**
 448          * Specifies the JIS B1 size, 728 mm by 1030 mm.
 449          */
 450         public static final MediaSize
 451             B1 = new MediaSize(728, 1030, Size2DSyntax.MM, MediaSizeName.JIS_B1);

 452         /**
 453          * Specifies the JIS B2 size, 515 mm by 728 mm.
 454          */
 455         public static final MediaSize
 456             B2 = new MediaSize(515, 728, Size2DSyntax.MM, MediaSizeName.JIS_B2);

 457         /**
 458          * Specifies the JIS B3 size, 364 mm by 515 mm.
 459          */
 460         public static final MediaSize
 461             B3 = new MediaSize(364, 515, Size2DSyntax.MM, MediaSizeName.JIS_B3);

 462         /**
 463          * Specifies the JIS B4 size, 257 mm by 364 mm.
 464          */
 465         public static final MediaSize
 466             B4 = new MediaSize(257, 364, Size2DSyntax.MM, MediaSizeName.JIS_B4);

 467         /**
 468          * Specifies the JIS B5 size, 182 mm by 257 mm.
 469          */
 470         public static final MediaSize
 471             B5 = new MediaSize(182, 257, Size2DSyntax.MM, MediaSizeName.JIS_B5);

 472         /**
 473          * Specifies the JIS B6 size, 128 mm by 182 mm.
 474          */
 475         public static final MediaSize
 476             B6 = new MediaSize(128, 182, Size2DSyntax.MM, MediaSizeName.JIS_B6);

 477         /**
 478          * Specifies the JIS B7 size, 91 mm by 128 mm.
 479          */
 480         public static final MediaSize
 481             B7 = new MediaSize(91, 128, Size2DSyntax.MM, MediaSizeName.JIS_B7);

 482         /**
 483          * Specifies the JIS B8 size, 64 mm by 91 mm.
 484          */
 485         public static final MediaSize
 486             B8 = new MediaSize(64, 91, Size2DSyntax.MM, MediaSizeName.JIS_B8);

 487         /**
 488          * Specifies the JIS B9 size, 45 mm by 64 mm.
 489          */
 490         public static final MediaSize
 491             B9 = new MediaSize(45, 64, Size2DSyntax.MM, MediaSizeName.JIS_B9);

 492         /**
 493          * Specifies the JIS B10 size, 32 mm by 45 mm.
 494          */
 495         public static final MediaSize
 496             B10 = new MediaSize(32, 45, Size2DSyntax.MM, MediaSizeName.JIS_B10);

 497         /**
 498          * Specifies the JIS Chou ("long") #1 envelope size, 142 mm by 332 mm.
 499          */
 500         public static final MediaSize CHOU_1 = new MediaSize(142, 332, Size2DSyntax.MM);

 501         /**
 502          * Specifies the JIS Chou ("long") #2 envelope size, 119 mm by 277 mm.
 503          */
 504         public static final MediaSize CHOU_2 = new MediaSize(119, 277, Size2DSyntax.MM);

 505         /**
 506          * Specifies the JIS Chou ("long") #3 envelope size, 120 mm by 235 mm.
 507          */
 508         public static final MediaSize CHOU_3 = new MediaSize(120, 235, Size2DSyntax.MM);

 509         /**
 510          * Specifies the JIS Chou ("long") #4 envelope size, 90 mm by 205 mm.
 511          */
 512         public static final MediaSize CHOU_4 = new MediaSize(90, 205, Size2DSyntax.MM);

 513         /**
 514          * Specifies the JIS Chou ("long") #30 envelope size, 92 mm by 235 mm.
 515          */
 516         public static final MediaSize CHOU_30 = new MediaSize(92, 235, Size2DSyntax.MM);

 517         /**
 518          * Specifies the JIS Chou ("long") #40 envelope size, 90 mm by 225 mm.
 519          */
 520         public static final MediaSize CHOU_40 = new MediaSize(90, 225, Size2DSyntax.MM);

 521         /**
 522          * Specifies the JIS Kaku ("square") #0 envelope size, 287 mm by 382 mm.
 523          */
 524         public static final MediaSize KAKU_0 = new MediaSize(287, 382, Size2DSyntax.MM);

 525         /**
 526          * Specifies the JIS Kaku ("square") #1 envelope size, 270 mm by 382 mm.
 527          */
 528         public static final MediaSize KAKU_1 = new MediaSize(270, 382, Size2DSyntax.MM);

 529         /**
 530          * Specifies the JIS Kaku ("square") #2 envelope size, 240 mm by 332 mm.
 531          */
 532         public static final MediaSize KAKU_2 = new MediaSize(240, 332, Size2DSyntax.MM);

 533         /**
 534          * Specifies the JIS Kaku ("square") #3 envelope size, 216 mm by 277 mm.
 535          */
 536         public static final MediaSize KAKU_3 = new MediaSize(216, 277, Size2DSyntax.MM);

 537         /**
 538          * Specifies the JIS Kaku ("square") #4 envelope size, 197 mm by 267 mm.
 539          */
 540         public static final MediaSize KAKU_4 = new MediaSize(197, 267, Size2DSyntax.MM);

 541         /**
 542          * Specifies the JIS Kaku ("square") #5 envelope size, 190 mm by 240 mm.
 543          */
 544         public static final MediaSize KAKU_5 = new MediaSize(190, 240, Size2DSyntax.MM);

 545         /**
 546          * Specifies the JIS Kaku ("square") #6 envelope size, 162 mm by 229 mm.
 547          */
 548         public static final MediaSize KAKU_6 = new MediaSize(162, 229, Size2DSyntax.MM);

 549         /**
 550          * Specifies the JIS Kaku ("square") #7 envelope size, 142 mm by 205 mm.
 551          */
 552         public static final MediaSize KAKU_7 = new MediaSize(142, 205, Size2DSyntax.MM);

 553         /**
 554          * Specifies the JIS Kaku ("square") #8 envelope size, 119 mm by 197 mm.
 555          */
 556         public static final MediaSize KAKU_8 = new MediaSize(119, 197, Size2DSyntax.MM);

 557         /**
 558          * Specifies the JIS Kaku ("square") #20 envelope size, 229 mm by 324 mm.

 559          */
 560         public static final MediaSize KAKU_20 = new MediaSize(229, 324, Size2DSyntax.MM);

 561         /**
 562          * Specifies the JIS Kaku ("square") A4 envelope size, 228 mm by 312 mm.
 563          */
 564         public static final MediaSize KAKU_A4 = new MediaSize(228, 312, Size2DSyntax.MM);

 565         /**
 566          * Specifies the JIS You ("Western") #1 envelope size, 120 mm by 176 mm.
 567          */
 568         public static final MediaSize YOU_1 = new MediaSize(120, 176, Size2DSyntax.MM);

 569         /**
 570          * Specifies the JIS You ("Western") #2 envelope size, 114 mm by 162 mm.
 571          */
 572         public static final MediaSize YOU_2 = new MediaSize(114, 162, Size2DSyntax.MM);

 573         /**
 574          * Specifies the JIS You ("Western") #3 envelope size, 98 mm by 148 mm.
 575          */
 576         public static final MediaSize YOU_3 = new MediaSize(98, 148, Size2DSyntax.MM);

 577         /**
 578          * Specifies the JIS You ("Western") #4 envelope size, 105 mm by 235 mm.
 579          */
 580         public static final MediaSize YOU_4 = new MediaSize(105, 235, Size2DSyntax.MM);

 581         /**
 582          * Specifies the JIS You ("Western") #5 envelope size, 95 mm by 217 mm.
 583          */
 584         public static final MediaSize YOU_5 = new MediaSize(95, 217, Size2DSyntax.MM);

 585         /**
 586          * Specifies the JIS You ("Western") #6 envelope size, 98 mm by 190 mm.
 587          */
 588         public static final MediaSize YOU_6 = new MediaSize(98, 190, Size2DSyntax.MM);

 589         /**
 590          * Specifies the JIS You ("Western") #7 envelope size, 92 mm by 165 mm.
 591          */
 592         public static final MediaSize YOU_7 = new MediaSize(92, 165, Size2DSyntax.MM);

 593         /**
 594          * Hide all constructors.
 595          */
 596         private JIS() {
 597         }
 598     }
 599 
 600     /**
 601      * Class MediaSize.NA includes {@link MediaSize MediaSize} values for North
 602      * American media.
 603      */
 604     public static final class NA {
 605 
 606         /**
 607          * Specifies the North American letter size, 8.5 inches by 11 inches.
 608          */
 609         public static final MediaSize
 610             LETTER = new MediaSize(8.5f, 11.0f, Size2DSyntax.INCH,
 611                                                 MediaSizeName.NA_LETTER);

 612         /**
 613          * Specifies the North American legal size, 8.5 inches by 14 inches.
 614          */
 615         public static final MediaSize
 616             LEGAL = new MediaSize(8.5f, 14.0f, Size2DSyntax.INCH,
 617                                                MediaSizeName.NA_LEGAL);

 618         /**
 619          * Specifies the North American 5 inch by 7 inch paper.
 620          */
 621         public static final MediaSize
 622             NA_5X7 = new MediaSize(5, 7, Size2DSyntax.INCH,
 623                                    MediaSizeName.NA_5X7);

 624         /**
 625          * Specifies the North American 8 inch by 10 inch paper.
 626          */
 627         public static final MediaSize
 628             NA_8X10 = new MediaSize(8, 10, Size2DSyntax.INCH,
 629                                    MediaSizeName.NA_8X10);

 630         /**
 631          * Specifies the North American Number 9 business envelope size,
 632          * 3.875 inches by 8.875 inches.
 633          */
 634         public static final MediaSize
 635             NA_NUMBER_9_ENVELOPE =
 636             new MediaSize(3.875f, 8.875f, Size2DSyntax.INCH,
 637                           MediaSizeName.NA_NUMBER_9_ENVELOPE);

 638         /**
 639          * Specifies the North American Number 10 business envelope size,
 640          * 4.125 inches by 9.5 inches.
 641          */
 642         public static final MediaSize
 643             NA_NUMBER_10_ENVELOPE =
 644             new MediaSize(4.125f, 9.5f, Size2DSyntax.INCH,
 645                           MediaSizeName.NA_NUMBER_10_ENVELOPE);

 646         /**
 647          * Specifies the North American Number 11 business envelope size,
 648          * 4.5 inches by 10.375 inches.
 649          */
 650         public static final MediaSize
 651             NA_NUMBER_11_ENVELOPE =
 652             new MediaSize(4.5f, 10.375f, Size2DSyntax.INCH,
 653                           MediaSizeName.NA_NUMBER_11_ENVELOPE);

 654         /**
 655          * Specifies the North American Number 12 business envelope size,
 656          * 4.75 inches by 11 inches.
 657          */
 658         public static final MediaSize
 659             NA_NUMBER_12_ENVELOPE =
 660             new MediaSize(4.75f, 11.0f, Size2DSyntax.INCH,
 661                           MediaSizeName.NA_NUMBER_12_ENVELOPE);

 662         /**
 663          * Specifies the North American Number 14 business envelope size,
 664          * 5 inches by 11.5 inches.
 665          */
 666         public static final MediaSize
 667             NA_NUMBER_14_ENVELOPE =
 668             new MediaSize(5.0f, 11.5f, Size2DSyntax.INCH,
 669                           MediaSizeName.NA_NUMBER_14_ENVELOPE);
 670 
 671         /**
 672          * Specifies the North American 6 inch by 9 inch envelope size.
 673          */
 674         public static final MediaSize
 675             NA_6X9_ENVELOPE = new MediaSize(6.0f, 9.0f, Size2DSyntax.INCH,
 676                                             MediaSizeName.NA_6X9_ENVELOPE);

 677         /**
 678          * Specifies the North American 7 inch by 9 inch envelope size.
 679          */
 680         public static final MediaSize
 681             NA_7X9_ENVELOPE = new MediaSize(7.0f, 9.0f, Size2DSyntax.INCH,
 682                                             MediaSizeName.NA_7X9_ENVELOPE);

 683         /**
 684          * Specifies the North American 9 inch by 11 inch envelope size.
 685          */
 686         public static final MediaSize
 687             NA_9x11_ENVELOPE = new MediaSize(9.0f, 11.0f, Size2DSyntax.INCH,
 688                                              MediaSizeName.NA_9X11_ENVELOPE);

 689         /**
 690          * Specifies the North American 9 inch by 12 inch envelope size.
 691          */
 692         public static final MediaSize
 693             NA_9x12_ENVELOPE = new MediaSize(9.0f, 12.0f, Size2DSyntax.INCH,
 694                                              MediaSizeName.NA_9X12_ENVELOPE);

 695         /**
 696          * Specifies the North American 10 inch by 13 inch envelope size.
 697          */
 698         public static final MediaSize
 699             NA_10x13_ENVELOPE = new MediaSize(10.0f, 13.0f, Size2DSyntax.INCH,
 700                                               MediaSizeName.NA_10X13_ENVELOPE);

 701         /**
 702          * Specifies the North American 10 inch by 14 inch envelope size.
 703          */
 704         public static final MediaSize
 705             NA_10x14_ENVELOPE = new MediaSize(10.0f, 14.0f, Size2DSyntax.INCH,
 706                                               MediaSizeName.NA_10X14_ENVELOPE);

 707         /**
 708          * Specifies the North American 10 inch by 15 inch envelope size.
 709          */
 710         public static final MediaSize
 711             NA_10X15_ENVELOPE = new MediaSize(10.0f, 15.0f, Size2DSyntax.INCH,
 712                                               MediaSizeName.NA_10X15_ENVELOPE);

 713         /**
 714          * Hide all constructors.
 715          */
 716         private NA() {
 717         }
 718     }
 719 
 720     /**
 721      * Class MediaSize.Engineering includes {@link MediaSize MediaSize} values
 722      * for engineering media.
 723      */
 724     public static final class Engineering {
 725 
 726         /**
 727          * Specifies the engineering A size, 8.5 inch by 11 inch.
 728          */
 729         public static final MediaSize
 730             A = new MediaSize(8.5f, 11.0f, Size2DSyntax.INCH,
 731                               MediaSizeName.A);

 732         /**
 733          * Specifies the engineering B size, 11 inch by 17 inch.
 734          */
 735         public static final MediaSize
 736             B = new MediaSize(11.0f, 17.0f, Size2DSyntax.INCH,
 737                               MediaSizeName.B);

 738         /**
 739          * Specifies the engineering C size, 17 inch by 22 inch.
 740          */
 741         public static final MediaSize
 742             C = new MediaSize(17.0f, 22.0f, Size2DSyntax.INCH,
 743                               MediaSizeName.C);

 744         /**
 745          * Specifies the engineering D size, 22 inch by 34 inch.
 746          */
 747         public static final MediaSize
 748             D = new MediaSize(22.0f, 34.0f, Size2DSyntax.INCH,
 749                               MediaSizeName.D);

 750         /**
 751          * Specifies the engineering E size, 34 inch by 44 inch.
 752          */
 753         public static final MediaSize
 754             E = new MediaSize(34.0f, 44.0f, Size2DSyntax.INCH,
 755                               MediaSizeName.E);

 756         /**
 757          * Hide all constructors.
 758          */
 759         private Engineering() {
 760         }
 761     }
 762 
 763     /**
 764      * Class MediaSize.Other includes {@link MediaSize MediaSize} values for
 765      * miscellaneous media.
 766      */
 767     public static final class Other {

 768         /**
 769          * Specifies the executive size, 7.25 inches by 10.5 inches.
 770          */
 771         public static final MediaSize
 772             EXECUTIVE = new MediaSize(7.25f, 10.5f, Size2DSyntax.INCH,
 773                                       MediaSizeName.EXECUTIVE);

 774         /**
 775          * Specifies the ledger size, 11 inches by 17 inches.
 776          */
 777         public static final MediaSize
 778             LEDGER = new MediaSize(11.0f, 17.0f, Size2DSyntax.INCH,
 779                                    MediaSizeName.LEDGER);
 780 
 781         /**
 782          * Specifies the tabloid size, 11 inches by 17 inches.

 783          * @since 1.5
 784          */
 785         public static final MediaSize
 786             TABLOID = new MediaSize(11.0f, 17.0f, Size2DSyntax.INCH,
 787                                    MediaSizeName.TABLOID);
 788 
 789         /**
 790          * Specifies the invoice size, 5.5 inches by 8.5 inches.
 791          */
 792         public static final MediaSize
 793             INVOICE = new MediaSize(5.5f, 8.5f, Size2DSyntax.INCH,
 794                               MediaSizeName.INVOICE);

 795         /**
 796          * Specifies the folio size, 8.5 inches by 13 inches.
 797          */
 798         public static final MediaSize
 799             FOLIO = new MediaSize(8.5f, 13.0f, Size2DSyntax.INCH,
 800                                   MediaSizeName.FOLIO);

 801         /**
 802          * Specifies the quarto size, 8.5 inches by 10.83 inches.
 803          */
 804         public static final MediaSize
 805             QUARTO = new MediaSize(8.5f, 10.83f, Size2DSyntax.INCH,
 806                                    MediaSizeName.QUARTO);

 807         /**
 808          * Specifies the Italy envelope size, 110 mm by 230 mm.
 809          */
 810         public static final MediaSize
 811         ITALY_ENVELOPE = new MediaSize(110, 230, Size2DSyntax.MM,
 812                                        MediaSizeName.ITALY_ENVELOPE);

 813         /**
 814          * Specifies the Monarch envelope size, 3.87 inch by 7.5 inch.
 815          */
 816         public static final MediaSize
 817         MONARCH_ENVELOPE = new MediaSize(3.87f, 7.5f, Size2DSyntax.INCH,
 818                                          MediaSizeName.MONARCH_ENVELOPE);

 819         /**
 820          * Specifies the Personal envelope size, 3.625 inch by 6.5 inch.
 821          */
 822         public static final MediaSize
 823         PERSONAL_ENVELOPE = new MediaSize(3.625f, 6.5f, Size2DSyntax.INCH,
 824                                          MediaSizeName.PERSONAL_ENVELOPE);

 825         /**
 826          * Specifies the Japanese postcard size, 100 mm by 148 mm.
 827          */
 828         public static final MediaSize
 829             JAPANESE_POSTCARD = new MediaSize(100, 148, Size2DSyntax.MM,
 830                                               MediaSizeName.JAPANESE_POSTCARD);

 831         /**
 832          * Specifies the Japanese Double postcard size, 148 mm by 200 mm.
 833          */
 834         public static final MediaSize
 835             JAPANESE_DOUBLE_POSTCARD = new MediaSize(148, 200, Size2DSyntax.MM,
 836                                      MediaSizeName.JAPANESE_DOUBLE_POSTCARD);

 837         /**
 838          * Hide all constructors.
 839          */
 840         private Other() {
 841         }
 842     }
 843 
 844     /* force loading of all the subclasses so that the instances
 845      * are created and inserted into the hashmap.

 846      */
 847     static {
 848         MediaSize ISOA4 = ISO.A4;
 849         MediaSize JISB5 = JIS.B5;
 850         MediaSize NALETTER = NA.LETTER;
 851         MediaSize EngineeringC = Engineering.C;
 852         MediaSize OtherEXECUTIVE = Other.EXECUTIVE;
 853     }
 854 }
   1 /*
   2  * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.print.attribute.standard;
  27 
  28 import java.util.HashMap;
  29 import java.util.Vector;
  30 

  31 import javax.print.attribute.Attribute;
  32 import javax.print.attribute.Size2DSyntax;
  33 
  34 /**
  35  * Class {@code MediaSize} is a two-dimensional size valued printing attribute
  36  * class that indicates the dimensions of the medium in a portrait orientation,
  37  * with the {@code X} dimension running along the bottom edge and the {@code Y}
  38  * dimension running along the left edge. Thus, the {@code Y} dimension must be
  39  * greater than or equal to the {@code X} dimension. Class {@code MediaSize}
  40  * declares many standard media size values, organized into nested classes for
  41  * ISO, JIS, North American, engineering, and other media.
  42  * <p>
  43  * {@code MediaSize} is not yet used to specify media. Its current role is as a
  44  * mapping for named media (see {@link MediaSizeName MediaSizeName}). Clients
  45  * can use the mapping method
  46  * {@code MediaSize.getMediaSizeForName(MediaSizeName)} to find the physical
  47  * dimensions of the {@code MediaSizeName} instances enumerated in this API.
  48  * This is useful for clients which need this information to format {@literal &}
  49  * paginate printing.
  50  *
  51  * @author Phil Race, Alan Kaminsky
  52  */
  53 public class MediaSize extends Size2DSyntax implements Attribute {
  54 
  55     /**
  56      * Use serialVersionUID from JDK 1.4 for interoperability.
  57      */
  58     private static final long serialVersionUID = -1967958664615414771L;
  59 
  60     /**
  61      * The media name.
  62      */
  63     private MediaSizeName mediaName;
  64 
  65     private static HashMap<MediaSizeName, MediaSize> mediaMap = new HashMap<>(100, 10);
  66 
  67     private static Vector<MediaSize> sizeVector = new Vector<>(100, 10);
  68 
  69     /**
  70      * Construct a new media size attribute from the given floating-point
  71      * values.
  72      *
  73      * @param  x {@code X} dimension
  74      * @param  y {@code Y} dimension
  75      * @param  units unit conversion factor, e.g. {@code Size2DSyntax.INCH} or
  76      *         {@code Size2DSyntax.MM}
  77      * @throws IllegalArgumentException if {@code x < 0} or {@code y < 0} or
  78      *         {@code units < 1} or {@code x > y}



  79      */
  80     public MediaSize(float x, float y,int units) {
  81         super (x, y, units);
  82         if (x > y) {
  83             throw new IllegalArgumentException("X dimension > Y dimension");
  84         }
  85         sizeVector.add(this);
  86     }
  87 
  88     /**
  89      * Construct a new media size attribute from the given integer values.
  90      *
  91      * @param  x {@code X} dimension
  92      * @param  y {@code Y} dimension
  93      * @param  units unit conversion factor, e.g. {@code Size2DSyntax.INCH} or
  94      *         {@code Size2DSyntax.MM}
  95      * @throws IllegalArgumentException if {@code x < 0} or {@code y < 0} or
  96      *         {@code units < 1} or {@code x > y}



  97      */
  98     public MediaSize(int x, int y,int units) {
  99         super (x, y, units);
 100         if (x > y) {
 101             throw new IllegalArgumentException("X dimension > Y dimension");
 102         }
 103         sizeVector.add(this);
 104     }
 105 
 106     /**
 107      * Construct a new media size attribute from the given floating-point
 108      * values.
 109      *
 110      * @param  x {@code X} dimension
 111      * @param  y {@code Y} dimension
 112      * @param  units unit conversion factor, e.g. {@code Size2DSyntax.INCH} or
 113      *         {@code Size2DSyntax.MM}
 114      * @param  media a media name to associate with this {@code MediaSize}
 115      * @throws IllegalArgumentException if {@code x < 0} or {@code y < 0} or
 116      *         {@code units < 1} or {@code x > y}



 117      */
 118     public MediaSize(float x, float y,int units, MediaSizeName media) {
 119         super (x, y, units);
 120         if (x > y) {
 121             throw new IllegalArgumentException("X dimension > Y dimension");
 122         }
 123         if (media != null && mediaMap.get(media) == null) {
 124             mediaName = media;
 125             mediaMap.put(mediaName, this);
 126         }
 127         sizeVector.add(this);
 128     }
 129 
 130     /**
 131      * Construct a new media size attribute from the given integer values.
 132      *
 133      * @param  x {@code X} dimension
 134      * @param  y {@code Y} dimension
 135      * @param  units unit conversion factor, e.g. {@code Size2DSyntax.INCH} or
 136      *         {@code Size2DSyntax.MM}
 137      * @param  media a media name to associate with this {@code MediaSize}
 138      * @throws IllegalArgumentException if {@code x < 0} or {@code y < 0} or
 139      *         {@code units < 1} or {@code x > y}



 140      */
 141     public MediaSize(int x, int y,int units, MediaSizeName media) {
 142         super (x, y, units);
 143         if (x > y) {
 144             throw new IllegalArgumentException("X dimension > Y dimension");
 145         }
 146         if (media != null && mediaMap.get(media) == null) {
 147             mediaName = media;
 148             mediaMap.put(mediaName, this);
 149         }
 150         sizeVector.add(this);
 151     }
 152 
 153     /**
 154      * Get the media name, if any, for this size.
 155      *
 156      * @return the name for this media size, or {@code null} if no name was
 157      *         associated with this size (an anonymous size)
 158      */
 159     public MediaSizeName getMediaSizeName() {
 160         return mediaName;
 161     }
 162 
 163     /**
 164      * Get the {@code MediaSize} for the specified named media.
 165      *
 166      * @param  media the name of the media for which the size is sought
 167      * @return size of the media, or {@code null} if this media is not
 168      *         associated with any size
 169      */
 170     public static MediaSize getMediaSizeForName(MediaSizeName media) {
 171         return mediaMap.get(media);
 172     }
 173 
 174     /**
 175      * The specified dimensions are used to locate a matching {@code MediaSize}
 176      * instance from amongst all the standard {@code MediaSize} instances. If
 177      * there is no exact match, the closest match is used.
 178      * <p>
 179      * The {@code MediaSize} is in turn used to locate the {@code MediaSizeName}
 180      * object. This method may return {@code null} if the closest matching
 181      * {@code MediaSize} has no corresponding {@code Media} instance.
 182      * <p>
 183      * This method is useful for clients which have only dimensions and want to
 184      * find a {@code Media} which corresponds to the dimensions.








 185      *
 186      * @param  x {@code X} dimension
 187      * @param  y {@code Y} dimension
 188      * @param  units unit conversion factor, e.g. {@code Size2DSyntax.INCH} or
 189      *         {@code Size2DSyntax.MM}
 190      * @return {@code MediaSizeName} matching these dimensions, or {@code null}
 191      * @throws IllegalArgumentException if {@code x <= 0}, {@code y <= 0}, or
 192      *         {@code units < 1}
 193      */
 194     public static MediaSizeName findMedia(float x, float y, int units) {
 195 
 196         MediaSize match = MediaSize.ISO.A4;
 197 
 198         if (x <= 0.0f || y <= 0.0f || units < 1) {
 199             throw new IllegalArgumentException("args must be +ve values");
 200         }
 201 
 202         double ls = x * x + y * y;
 203         double tmp_ls;
 204         float []dim;
 205         float diffx = x;
 206         float diffy = y;
 207 
 208         for (int i=0; i < sizeVector.size() ; i++) {
 209             MediaSize mediaSize = sizeVector.elementAt(i);
 210             dim = mediaSize.getSize(units);
 211             if (x == dim[0] && y == dim[1]) {
 212                 match = mediaSize;
 213                 break;
 214             } else {
 215                 diffx = x - dim[0];
 216                 diffy = y - dim[1];
 217                 tmp_ls = diffx * diffx + diffy * diffy;
 218                 if (tmp_ls < ls) {
 219                     ls = tmp_ls;
 220                     match = mediaSize;
 221                 }
 222             }
 223         }
 224 
 225         return match.getMediaSizeName();
 226     }
 227 
 228     /**
 229      * Returns whether this media size attribute is equivalent to the passed in
 230      * object. To be equivalent, all of the following conditions must be true:
 231      * <ol type=1>
 232      *   <li>{@code object} is not {@code null}.
 233      *   <li>{@code object} is an instance of class {@code MediaSize}.
 234      *   <li>This media size attribute's {@code X} dimension is equal to
 235      *   {@code object}'s {@code X} dimension.
 236      *   <li>This media size attribute's {@code Y} dimension is equal to
 237      *   {@code object}'s {@code Y} dimension.
 238      * </ol>
 239      *
 240      * @param  object {@code Object} to compare to
 241      * @return {@code true} if {@code object} is equivalent to this media size
 242      *         attribute, {@code false} otherwise






 243      */
 244     public boolean equals(Object object) {
 245         return (super.equals(object) && object instanceof MediaSize);
 246     }
 247 
 248     /**
 249      * Get the printing attribute class which is to be used as the "category"
 250      * for this printing attribute value.
 251      * <p>
 252      * For class {@code MediaSize} and any vendor-defined subclasses, the
 253      * category is class {@code MediaSize} itself.
 254      *
 255      * @return printing attribute class (category), an instance of class
 256      *         {@link Class java.lang.Class}
 257      */
 258     public final Class<? extends Attribute> getCategory() {
 259         return MediaSize.class;
 260     }
 261 
 262     /**
 263      * Get the name of the category of which this attribute value is an
 264      * instance.
 265      * <p>
 266      * For class {@code MediaSize} and any vendor-defined subclasses, the
 267      * category name is {@code "media-size"}.
 268      *
 269      * @return attribute category name
 270      */
 271     public final String getName() {
 272         return "media-size";
 273     }
 274 
 275     /**
 276      * Class {@code MediaSize.ISO} includes {@link MediaSize MediaSize} values
 277      * for ISO media.
 278      */
 279     public static final class ISO {
 280 
 281         /**
 282          * Specifies the ISO A0 size, 841 mm by 1189 mm.
 283          */
 284         public static final MediaSize
 285             A0 = new MediaSize(841, 1189, Size2DSyntax.MM, MediaSizeName.ISO_A0);
 286 
 287         /**
 288          * Specifies the ISO A1 size, 594 mm by 841 mm.
 289          */
 290         public static final MediaSize
 291             A1 = new MediaSize(594, 841, Size2DSyntax.MM, MediaSizeName.ISO_A1);
 292 
 293         /**
 294          * Specifies the ISO A2 size, 420 mm by 594 mm.
 295          */
 296         public static final MediaSize
 297             A2 = new MediaSize(420, 594, Size2DSyntax.MM, MediaSizeName.ISO_A2);
 298 
 299         /**
 300          * Specifies the ISO A3 size, 297 mm by 420 mm.
 301          */
 302         public static final MediaSize
 303             A3 = new MediaSize(297, 420, Size2DSyntax.MM, MediaSizeName.ISO_A3);
 304 
 305         /**
 306          * Specifies the ISO A4 size, 210 mm by 297 mm.
 307          */
 308         public static final MediaSize
 309             A4 = new MediaSize(210, 297, Size2DSyntax.MM, MediaSizeName.ISO_A4);
 310 
 311         /**
 312          * Specifies the ISO A5 size, 148 mm by 210 mm.
 313          */
 314         public static final MediaSize
 315             A5 = new MediaSize(148, 210, Size2DSyntax.MM, MediaSizeName.ISO_A5);
 316 
 317         /**
 318          * Specifies the ISO A6 size, 105 mm by 148 mm.
 319          */
 320         public static final MediaSize
 321             A6 = new MediaSize(105, 148, Size2DSyntax.MM, MediaSizeName.ISO_A6);
 322 
 323         /**
 324          * Specifies the ISO A7 size, 74 mm by 105 mm.
 325          */
 326         public static final MediaSize
 327             A7 = new MediaSize(74, 105, Size2DSyntax.MM, MediaSizeName.ISO_A7);
 328 
 329         /**
 330          * Specifies the ISO A8 size, 52 mm by 74 mm.
 331          */
 332         public static final MediaSize
 333             A8 = new MediaSize(52, 74, Size2DSyntax.MM, MediaSizeName.ISO_A8);
 334 
 335         /**
 336          * Specifies the ISO A9 size, 37 mm by 52 mm.
 337          */
 338         public static final MediaSize
 339             A9 = new MediaSize(37, 52, Size2DSyntax.MM, MediaSizeName.ISO_A9);
 340 
 341         /**
 342          * Specifies the ISO A10 size, 26 mm by 37 mm.
 343          */
 344         public static final MediaSize
 345             A10 = new MediaSize(26, 37, Size2DSyntax.MM, MediaSizeName.ISO_A10);
 346 
 347         /**
 348          * Specifies the ISO B0 size, 1000 mm by 1414 mm.
 349          */
 350         public static final MediaSize
 351             B0 = new MediaSize(1000, 1414, Size2DSyntax.MM, MediaSizeName.ISO_B0);
 352 
 353         /**
 354          * Specifies the ISO B1 size, 707 mm by 1000 mm.
 355          */
 356         public static final MediaSize
 357             B1 = new MediaSize(707, 1000, Size2DSyntax.MM, MediaSizeName.ISO_B1);
 358 
 359         /**
 360          * Specifies the ISO B2 size, 500 mm by 707 mm.
 361          */
 362         public static final MediaSize
 363             B2 = new MediaSize(500, 707, Size2DSyntax.MM, MediaSizeName.ISO_B2);
 364 
 365         /**
 366          * Specifies the ISO B3 size, 353 mm by 500 mm.
 367          */
 368         public static final MediaSize
 369             B3 = new MediaSize(353, 500, Size2DSyntax.MM, MediaSizeName.ISO_B3);
 370 
 371         /**
 372          * Specifies the ISO B4 size, 250 mm by 353 mm.
 373          */
 374         public static final MediaSize
 375             B4 = new MediaSize(250, 353, Size2DSyntax.MM, MediaSizeName.ISO_B4);
 376 
 377         /**
 378          * Specifies the ISO B5 size, 176 mm by 250 mm.
 379          */
 380         public static final MediaSize
 381             B5 = new MediaSize(176, 250, Size2DSyntax.MM, MediaSizeName.ISO_B5);
 382 
 383         /**
 384          * Specifies the ISO B6 size, 125 mm by 176 mm.
 385          */
 386         public static final MediaSize
 387             B6 = new MediaSize(125, 176, Size2DSyntax.MM, MediaSizeName.ISO_B6);
 388 
 389         /**
 390          * Specifies the ISO B7 size, 88 mm by 125 mm.
 391          */
 392         public static final MediaSize
 393             B7 = new MediaSize(88, 125, Size2DSyntax.MM, MediaSizeName.ISO_B7);
 394 
 395         /**
 396          * Specifies the ISO B8 size, 62 mm by 88 mm.
 397          */
 398         public static final MediaSize
 399             B8 = new MediaSize(62, 88, Size2DSyntax.MM, MediaSizeName.ISO_B8);
 400 
 401         /**
 402          * Specifies the ISO B9 size, 44 mm by 62 mm.
 403          */
 404         public static final MediaSize
 405             B9 = new MediaSize(44, 62, Size2DSyntax.MM, MediaSizeName.ISO_B9);
 406 
 407         /**
 408          * Specifies the ISO B10 size, 31 mm by 44 mm.
 409          */
 410         public static final MediaSize
 411             B10 = new MediaSize(31, 44, Size2DSyntax.MM, MediaSizeName.ISO_B10);
 412 
 413         /**
 414          * Specifies the ISO C3 size, 324 mm by 458 mm.
 415          */
 416         public static final MediaSize
 417             C3 = new MediaSize(324, 458, Size2DSyntax.MM, MediaSizeName.ISO_C3);
 418 
 419         /**
 420          * Specifies the ISO C4 size, 229 mm by 324 mm.
 421          */
 422         public static final MediaSize
 423             C4 = new MediaSize(229, 324, Size2DSyntax.MM, MediaSizeName.ISO_C4);
 424 
 425         /**
 426          * Specifies the ISO C5 size, 162 mm by 229 mm.
 427          */
 428         public static final MediaSize
 429             C5 = new MediaSize(162, 229, Size2DSyntax.MM, MediaSizeName.ISO_C5);
 430 
 431         /**
 432          * Specifies the ISO C6 size, 114 mm by 162 mm.
 433          */
 434         public static final MediaSize
 435             C6 = new MediaSize(114, 162, Size2DSyntax.MM, MediaSizeName.ISO_C6);
 436 
 437         /**
 438          * Specifies the ISO Designated Long size, 110 mm by 220 mm.
 439          */
 440         public static final MediaSize
 441             DESIGNATED_LONG = new MediaSize(110, 220, Size2DSyntax.MM,
 442                                             MediaSizeName.ISO_DESIGNATED_LONG);
 443 
 444         /**
 445          * Hide all constructors.
 446          */
 447         private ISO() {
 448         }
 449     }
 450 
 451     /**
 452      * Class {@code MediaSize.JIS} includes {@link MediaSize MediaSize} values
 453      * for JIS (Japanese) media.
 454      */
 455     public static final class JIS {
 456 
 457         /**
 458          * Specifies the JIS B0 size, 1030 mm by 1456 mm.
 459          */
 460         public static final MediaSize
 461             B0 = new MediaSize(1030, 1456, Size2DSyntax.MM, MediaSizeName.JIS_B0);
 462 
 463         /**
 464          * Specifies the JIS B1 size, 728 mm by 1030 mm.
 465          */
 466         public static final MediaSize
 467             B1 = new MediaSize(728, 1030, Size2DSyntax.MM, MediaSizeName.JIS_B1);
 468 
 469         /**
 470          * Specifies the JIS B2 size, 515 mm by 728 mm.
 471          */
 472         public static final MediaSize
 473             B2 = new MediaSize(515, 728, Size2DSyntax.MM, MediaSizeName.JIS_B2);
 474 
 475         /**
 476          * Specifies the JIS B3 size, 364 mm by 515 mm.
 477          */
 478         public static final MediaSize
 479             B3 = new MediaSize(364, 515, Size2DSyntax.MM, MediaSizeName.JIS_B3);
 480 
 481         /**
 482          * Specifies the JIS B4 size, 257 mm by 364 mm.
 483          */
 484         public static final MediaSize
 485             B4 = new MediaSize(257, 364, Size2DSyntax.MM, MediaSizeName.JIS_B4);
 486 
 487         /**
 488          * Specifies the JIS B5 size, 182 mm by 257 mm.
 489          */
 490         public static final MediaSize
 491             B5 = new MediaSize(182, 257, Size2DSyntax.MM, MediaSizeName.JIS_B5);
 492 
 493         /**
 494          * Specifies the JIS B6 size, 128 mm by 182 mm.
 495          */
 496         public static final MediaSize
 497             B6 = new MediaSize(128, 182, Size2DSyntax.MM, MediaSizeName.JIS_B6);
 498 
 499         /**
 500          * Specifies the JIS B7 size, 91 mm by 128 mm.
 501          */
 502         public static final MediaSize
 503             B7 = new MediaSize(91, 128, Size2DSyntax.MM, MediaSizeName.JIS_B7);
 504 
 505         /**
 506          * Specifies the JIS B8 size, 64 mm by 91 mm.
 507          */
 508         public static final MediaSize
 509             B8 = new MediaSize(64, 91, Size2DSyntax.MM, MediaSizeName.JIS_B8);
 510 
 511         /**
 512          * Specifies the JIS B9 size, 45 mm by 64 mm.
 513          */
 514         public static final MediaSize
 515             B9 = new MediaSize(45, 64, Size2DSyntax.MM, MediaSizeName.JIS_B9);
 516 
 517         /**
 518          * Specifies the JIS B10 size, 32 mm by 45 mm.
 519          */
 520         public static final MediaSize
 521             B10 = new MediaSize(32, 45, Size2DSyntax.MM, MediaSizeName.JIS_B10);
 522 
 523         /**
 524          * Specifies the JIS Chou ("long") #1 envelope size, 142 mm by 332 mm.
 525          */
 526         public static final MediaSize CHOU_1 = new MediaSize(142, 332, Size2DSyntax.MM);
 527 
 528         /**
 529          * Specifies the JIS Chou ("long") #2 envelope size, 119 mm by 277 mm.
 530          */
 531         public static final MediaSize CHOU_2 = new MediaSize(119, 277, Size2DSyntax.MM);
 532 
 533         /**
 534          * Specifies the JIS Chou ("long") #3 envelope size, 120 mm by 235 mm.
 535          */
 536         public static final MediaSize CHOU_3 = new MediaSize(120, 235, Size2DSyntax.MM);
 537 
 538         /**
 539          * Specifies the JIS Chou ("long") #4 envelope size, 90 mm by 205 mm.
 540          */
 541         public static final MediaSize CHOU_4 = new MediaSize(90, 205, Size2DSyntax.MM);
 542 
 543         /**
 544          * Specifies the JIS Chou ("long") #30 envelope size, 92 mm by 235 mm.
 545          */
 546         public static final MediaSize CHOU_30 = new MediaSize(92, 235, Size2DSyntax.MM);
 547 
 548         /**
 549          * Specifies the JIS Chou ("long") #40 envelope size, 90 mm by 225 mm.
 550          */
 551         public static final MediaSize CHOU_40 = new MediaSize(90, 225, Size2DSyntax.MM);
 552 
 553         /**
 554          * Specifies the JIS Kaku ("square") #0 envelope size, 287 mm by 382 mm.
 555          */
 556         public static final MediaSize KAKU_0 = new MediaSize(287, 382, Size2DSyntax.MM);
 557 
 558         /**
 559          * Specifies the JIS Kaku ("square") #1 envelope size, 270 mm by 382 mm.
 560          */
 561         public static final MediaSize KAKU_1 = new MediaSize(270, 382, Size2DSyntax.MM);
 562 
 563         /**
 564          * Specifies the JIS Kaku ("square") #2 envelope size, 240 mm by 332 mm.
 565          */
 566         public static final MediaSize KAKU_2 = new MediaSize(240, 332, Size2DSyntax.MM);
 567 
 568         /**
 569          * Specifies the JIS Kaku ("square") #3 envelope size, 216 mm by 277 mm.
 570          */
 571         public static final MediaSize KAKU_3 = new MediaSize(216, 277, Size2DSyntax.MM);
 572 
 573         /**
 574          * Specifies the JIS Kaku ("square") #4 envelope size, 197 mm by 267 mm.
 575          */
 576         public static final MediaSize KAKU_4 = new MediaSize(197, 267, Size2DSyntax.MM);
 577 
 578         /**
 579          * Specifies the JIS Kaku ("square") #5 envelope size, 190 mm by 240 mm.
 580          */
 581         public static final MediaSize KAKU_5 = new MediaSize(190, 240, Size2DSyntax.MM);
 582 
 583         /**
 584          * Specifies the JIS Kaku ("square") #6 envelope size, 162 mm by 229 mm.
 585          */
 586         public static final MediaSize KAKU_6 = new MediaSize(162, 229, Size2DSyntax.MM);
 587 
 588         /**
 589          * Specifies the JIS Kaku ("square") #7 envelope size, 142 mm by 205 mm.
 590          */
 591         public static final MediaSize KAKU_7 = new MediaSize(142, 205, Size2DSyntax.MM);
 592 
 593         /**
 594          * Specifies the JIS Kaku ("square") #8 envelope size, 119 mm by 197 mm.
 595          */
 596         public static final MediaSize KAKU_8 = new MediaSize(119, 197, Size2DSyntax.MM);
 597 
 598         /**
 599          * Specifies the JIS Kaku ("square") #20 envelope size, 229 mm by 324
 600          * mm.
 601          */
 602         public static final MediaSize KAKU_20 = new MediaSize(229, 324, Size2DSyntax.MM);
 603 
 604         /**
 605          * Specifies the JIS Kaku ("square") A4 envelope size, 228 mm by 312 mm.
 606          */
 607         public static final MediaSize KAKU_A4 = new MediaSize(228, 312, Size2DSyntax.MM);
 608 
 609         /**
 610          * Specifies the JIS You ("Western") #1 envelope size, 120 mm by 176 mm.
 611          */
 612         public static final MediaSize YOU_1 = new MediaSize(120, 176, Size2DSyntax.MM);
 613 
 614         /**
 615          * Specifies the JIS You ("Western") #2 envelope size, 114 mm by 162 mm.
 616          */
 617         public static final MediaSize YOU_2 = new MediaSize(114, 162, Size2DSyntax.MM);
 618 
 619         /**
 620          * Specifies the JIS You ("Western") #3 envelope size, 98 mm by 148 mm.
 621          */
 622         public static final MediaSize YOU_3 = new MediaSize(98, 148, Size2DSyntax.MM);
 623 
 624         /**
 625          * Specifies the JIS You ("Western") #4 envelope size, 105 mm by 235 mm.
 626          */
 627         public static final MediaSize YOU_4 = new MediaSize(105, 235, Size2DSyntax.MM);
 628 
 629         /**
 630          * Specifies the JIS You ("Western") #5 envelope size, 95 mm by 217 mm.
 631          */
 632         public static final MediaSize YOU_5 = new MediaSize(95, 217, Size2DSyntax.MM);
 633 
 634         /**
 635          * Specifies the JIS You ("Western") #6 envelope size, 98 mm by 190 mm.
 636          */
 637         public static final MediaSize YOU_6 = new MediaSize(98, 190, Size2DSyntax.MM);
 638 
 639         /**
 640          * Specifies the JIS You ("Western") #7 envelope size, 92 mm by 165 mm.
 641          */
 642         public static final MediaSize YOU_7 = new MediaSize(92, 165, Size2DSyntax.MM);
 643 
 644         /**
 645          * Hide all constructors.
 646          */
 647         private JIS() {
 648         }
 649     }
 650 
 651     /**
 652      * Class {@code MediaSize.NA} includes {@link MediaSize MediaSize} values
 653      * for North American media.
 654      */
 655     public static final class NA {
 656 
 657         /**
 658          * Specifies the North American letter size, 8.5 inches by 11 inches.
 659          */
 660         public static final MediaSize
 661             LETTER = new MediaSize(8.5f, 11.0f, Size2DSyntax.INCH,
 662                                                 MediaSizeName.NA_LETTER);
 663 
 664         /**
 665          * Specifies the North American legal size, 8.5 inches by 14 inches.
 666          */
 667         public static final MediaSize
 668             LEGAL = new MediaSize(8.5f, 14.0f, Size2DSyntax.INCH,
 669                                                MediaSizeName.NA_LEGAL);
 670 
 671         /**
 672          * Specifies the North American 5 inch by 7 inch paper.
 673          */
 674         public static final MediaSize
 675             NA_5X7 = new MediaSize(5, 7, Size2DSyntax.INCH,
 676                                    MediaSizeName.NA_5X7);
 677 
 678         /**
 679          * Specifies the North American 8 inch by 10 inch paper.
 680          */
 681         public static final MediaSize
 682             NA_8X10 = new MediaSize(8, 10, Size2DSyntax.INCH,
 683                                    MediaSizeName.NA_8X10);
 684 
 685         /**
 686          * Specifies the North American Number 9 business envelope size, 3.875
 687          * inches by 8.875 inches.
 688          */
 689         public static final MediaSize
 690             NA_NUMBER_9_ENVELOPE =
 691             new MediaSize(3.875f, 8.875f, Size2DSyntax.INCH,
 692                           MediaSizeName.NA_NUMBER_9_ENVELOPE);
 693 
 694         /**
 695          * Specifies the North American Number 10 business envelope size, 4.125
 696          * inches by 9.5 inches.
 697          */
 698         public static final MediaSize
 699             NA_NUMBER_10_ENVELOPE =
 700             new MediaSize(4.125f, 9.5f, Size2DSyntax.INCH,
 701                           MediaSizeName.NA_NUMBER_10_ENVELOPE);
 702 
 703         /**
 704          * Specifies the North American Number 11 business envelope size, 4.5
 705          * inches by 10.375 inches.
 706          */
 707         public static final MediaSize
 708             NA_NUMBER_11_ENVELOPE =
 709             new MediaSize(4.5f, 10.375f, Size2DSyntax.INCH,
 710                           MediaSizeName.NA_NUMBER_11_ENVELOPE);
 711 
 712         /**
 713          * Specifies the North American Number 12 business envelope size, 4.75
 714          * inches by 11 inches.
 715          */
 716         public static final MediaSize
 717             NA_NUMBER_12_ENVELOPE =
 718             new MediaSize(4.75f, 11.0f, Size2DSyntax.INCH,
 719                           MediaSizeName.NA_NUMBER_12_ENVELOPE);
 720 
 721         /**
 722          * Specifies the North American Number 14 business envelope size, 5
 723          * inches by 11.5 inches.
 724          */
 725         public static final MediaSize
 726             NA_NUMBER_14_ENVELOPE =
 727             new MediaSize(5.0f, 11.5f, Size2DSyntax.INCH,
 728                           MediaSizeName.NA_NUMBER_14_ENVELOPE);
 729 
 730         /**
 731          * Specifies the North American 6 inch by 9 inch envelope size.
 732          */
 733         public static final MediaSize
 734             NA_6X9_ENVELOPE = new MediaSize(6.0f, 9.0f, Size2DSyntax.INCH,
 735                                             MediaSizeName.NA_6X9_ENVELOPE);
 736 
 737         /**
 738          * Specifies the North American 7 inch by 9 inch envelope size.
 739          */
 740         public static final MediaSize
 741             NA_7X9_ENVELOPE = new MediaSize(7.0f, 9.0f, Size2DSyntax.INCH,
 742                                             MediaSizeName.NA_7X9_ENVELOPE);
 743 
 744         /**
 745          * Specifies the North American 9 inch by 11 inch envelope size.
 746          */
 747         public static final MediaSize
 748             NA_9x11_ENVELOPE = new MediaSize(9.0f, 11.0f, Size2DSyntax.INCH,
 749                                              MediaSizeName.NA_9X11_ENVELOPE);
 750 
 751         /**
 752          * Specifies the North American 9 inch by 12 inch envelope size.
 753          */
 754         public static final MediaSize
 755             NA_9x12_ENVELOPE = new MediaSize(9.0f, 12.0f, Size2DSyntax.INCH,
 756                                              MediaSizeName.NA_9X12_ENVELOPE);
 757 
 758         /**
 759          * Specifies the North American 10 inch by 13 inch envelope size.
 760          */
 761         public static final MediaSize
 762             NA_10x13_ENVELOPE = new MediaSize(10.0f, 13.0f, Size2DSyntax.INCH,
 763                                               MediaSizeName.NA_10X13_ENVELOPE);
 764 
 765         /**
 766          * Specifies the North American 10 inch by 14 inch envelope size.
 767          */
 768         public static final MediaSize
 769             NA_10x14_ENVELOPE = new MediaSize(10.0f, 14.0f, Size2DSyntax.INCH,
 770                                               MediaSizeName.NA_10X14_ENVELOPE);
 771 
 772         /**
 773          * Specifies the North American 10 inch by 15 inch envelope size.
 774          */
 775         public static final MediaSize
 776             NA_10X15_ENVELOPE = new MediaSize(10.0f, 15.0f, Size2DSyntax.INCH,
 777                                               MediaSizeName.NA_10X15_ENVELOPE);
 778 
 779         /**
 780          * Hide all constructors.
 781          */
 782         private NA() {
 783         }
 784     }
 785 
 786     /**
 787      * Class {@code MediaSize.Engineering} includes {@link MediaSize MediaSize}
 788      * values for engineering media.
 789      */
 790     public static final class Engineering {
 791 
 792         /**
 793          * Specifies the engineering A size, 8.5 inch by 11 inch.
 794          */
 795         public static final MediaSize
 796             A = new MediaSize(8.5f, 11.0f, Size2DSyntax.INCH,
 797                               MediaSizeName.A);
 798 
 799         /**
 800          * Specifies the engineering B size, 11 inch by 17 inch.
 801          */
 802         public static final MediaSize
 803             B = new MediaSize(11.0f, 17.0f, Size2DSyntax.INCH,
 804                               MediaSizeName.B);
 805 
 806         /**
 807          * Specifies the engineering C size, 17 inch by 22 inch.
 808          */
 809         public static final MediaSize
 810             C = new MediaSize(17.0f, 22.0f, Size2DSyntax.INCH,
 811                               MediaSizeName.C);
 812 
 813         /**
 814          * Specifies the engineering D size, 22 inch by 34 inch.
 815          */
 816         public static final MediaSize
 817             D = new MediaSize(22.0f, 34.0f, Size2DSyntax.INCH,
 818                               MediaSizeName.D);
 819 
 820         /**
 821          * Specifies the engineering E size, 34 inch by 44 inch.
 822          */
 823         public static final MediaSize
 824             E = new MediaSize(34.0f, 44.0f, Size2DSyntax.INCH,
 825                               MediaSizeName.E);
 826 
 827         /**
 828          * Hide all constructors.
 829          */
 830         private Engineering() {
 831         }
 832     }
 833 
 834     /**
 835      * Class {@code MediaSize.Other} includes {@link MediaSize MediaSize} values
 836      * for miscellaneous media.
 837      */
 838     public static final class Other {
 839 
 840         /**
 841          * Specifies the executive size, 7.25 inches by 10.5 inches.
 842          */
 843         public static final MediaSize
 844             EXECUTIVE = new MediaSize(7.25f, 10.5f, Size2DSyntax.INCH,
 845                                       MediaSizeName.EXECUTIVE);
 846 
 847         /**
 848          * Specifies the ledger size, 11 inches by 17 inches.
 849          */
 850         public static final MediaSize
 851             LEDGER = new MediaSize(11.0f, 17.0f, Size2DSyntax.INCH,
 852                                    MediaSizeName.LEDGER);
 853 
 854         /**
 855          * Specifies the tabloid size, 11 inches by 17 inches.
 856          *
 857          * @since 1.5
 858          */
 859         public static final MediaSize
 860             TABLOID = new MediaSize(11.0f, 17.0f, Size2DSyntax.INCH,
 861                                    MediaSizeName.TABLOID);
 862 
 863         /**
 864          * Specifies the invoice size, 5.5 inches by 8.5 inches.
 865          */
 866         public static final MediaSize
 867             INVOICE = new MediaSize(5.5f, 8.5f, Size2DSyntax.INCH,
 868                               MediaSizeName.INVOICE);
 869 
 870         /**
 871          * Specifies the folio size, 8.5 inches by 13 inches.
 872          */
 873         public static final MediaSize
 874             FOLIO = new MediaSize(8.5f, 13.0f, Size2DSyntax.INCH,
 875                                   MediaSizeName.FOLIO);
 876 
 877         /**
 878          * Specifies the quarto size, 8.5 inches by 10.83 inches.
 879          */
 880         public static final MediaSize
 881             QUARTO = new MediaSize(8.5f, 10.83f, Size2DSyntax.INCH,
 882                                    MediaSizeName.QUARTO);
 883 
 884         /**
 885          * Specifies the Italy envelope size, 110 mm by 230 mm.
 886          */
 887         public static final MediaSize
 888         ITALY_ENVELOPE = new MediaSize(110, 230, Size2DSyntax.MM,
 889                                        MediaSizeName.ITALY_ENVELOPE);
 890 
 891         /**
 892          * Specifies the Monarch envelope size, 3.87 inch by 7.5 inch.
 893          */
 894         public static final MediaSize
 895         MONARCH_ENVELOPE = new MediaSize(3.87f, 7.5f, Size2DSyntax.INCH,
 896                                          MediaSizeName.MONARCH_ENVELOPE);
 897 
 898         /**
 899          * Specifies the Personal envelope size, 3.625 inch by 6.5 inch.
 900          */
 901         public static final MediaSize
 902         PERSONAL_ENVELOPE = new MediaSize(3.625f, 6.5f, Size2DSyntax.INCH,
 903                                          MediaSizeName.PERSONAL_ENVELOPE);
 904 
 905         /**
 906          * Specifies the Japanese postcard size, 100 mm by 148 mm.
 907          */
 908         public static final MediaSize
 909             JAPANESE_POSTCARD = new MediaSize(100, 148, Size2DSyntax.MM,
 910                                               MediaSizeName.JAPANESE_POSTCARD);
 911 
 912         /**
 913          * Specifies the Japanese Double postcard size, 148 mm by 200 mm.
 914          */
 915         public static final MediaSize
 916             JAPANESE_DOUBLE_POSTCARD = new MediaSize(148, 200, Size2DSyntax.MM,
 917                                      MediaSizeName.JAPANESE_DOUBLE_POSTCARD);
 918 
 919         /**
 920          * Hide all constructors.
 921          */
 922         private Other() {
 923         }
 924     }
 925 
 926     /*
 927      * force loading of all the subclasses so that the instances are created and
 928      * inserted into the hashmap.
 929      */
 930     static {
 931         MediaSize ISOA4 = ISO.A4;
 932         MediaSize JISB5 = JIS.B5;
 933         MediaSize NALETTER = NA.LETTER;
 934         MediaSize EngineeringC = Engineering.C;
 935         MediaSize OtherEXECUTIVE = Other.EXECUTIVE;
 936     }
 937 }
< prev index next >