Save This Page
Home » openjdk-7 » javax » print » attribute » standard » [javadoc | source]
    1   /*
    2    * Copyright 2000-2006 Sun Microsystems, Inc.  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.  Sun designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   22    * CA 95054 USA or visit www.sun.com if you need additional information or
   23    * have any 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)</code>
   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 & paginate printing.
   49    * <P>
   50    *
   51    * @author  Phil Race, Alan Kaminsky
   52    */
   53   public class MediaSize extends Size2DSyntax implements Attribute {
   54   
   55       private static final long serialVersionUID = -1967958664615414771L;
   56   
   57       private MediaSizeName mediaName;
   58   
   59       private static HashMap mediaMap = new HashMap(100, 10);
   60   
   61       private static Vector sizeVector = new Vector(100, 10);
   62   
   63       /**
   64        * Construct a new media size attribute from the given floating-point
   65        * values.
   66        *
   67        * @param  x  X dimension.
   68        * @param  y  Y dimension.
   69        * @param  units
   70        *     Unit conversion factor, e.g. <CODE>Size2DSyntax.INCH</CODE> or
   71        *     <CODE>Size2DSyntax.MM</CODE>.
   72        *
   73        * @exception  IllegalArgumentException
   74        *   (Unchecked exception) Thrown if <CODE>x</CODE> < 0 or <CODE>y</CODE>
   75        *     < 0 or <CODE>units</CODE> < 1 or <CODE>x</CODE> > <CODE>y</CODE>.
   76        */
   77       public MediaSize(float x, float y,int units) {
   78           super (x, y, units);
   79           if (x > y) {
   80               throw new IllegalArgumentException("X dimension > Y dimension");
   81           }
   82           sizeVector.add(this);
   83       }
   84   
   85       /**
   86        * Construct a new media size attribute from the given integer values.
   87        *
   88        * @param  x  X dimension.
   89        * @param  y  Y dimension.
   90        * @param  units
   91        *     Unit conversion factor, e.g. <CODE>Size2DSyntax.INCH</CODE> or
   92        *     <CODE>Size2DSyntax.MM</CODE>.
   93        *
   94        * @exception  IllegalArgumentException
   95        *   (Unchecked exception) Thrown if <CODE>x</CODE> < 0 or <CODE>y</CODE>
   96        *     < 0 or <CODE>units</CODE> < 1 or <CODE>x</CODE> > <CODE>y</CODE>.
   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  X dimension.
  111        * @param  y  Y dimension.
  112        * @param  units
  113        *     Unit conversion factor, e.g. <CODE>Size2DSyntax.INCH</CODE> or
  114        *     <CODE>Size2DSyntax.MM</CODE>.
  115        * @param media a media name to associate with this MediaSize
  116        *
  117        * @exception  IllegalArgumentException
  118        *   (Unchecked exception) Thrown if <CODE>x</CODE> < 0 or <CODE>y</CODE>
  119        *     < 0 or <CODE>units</CODE> < 1 or <CODE>x</CODE> > <CODE>y</CODE>.
  120        */
  121       public MediaSize(float x, float y,int units, MediaSizeName media) {
  122           super (x, y, units);
  123           if (x > y) {
  124               throw new IllegalArgumentException("X dimension > Y dimension");
  125           }
  126           mediaName = media;
  127           mediaMap.put(mediaName, this);
  128           sizeVector.add(this);
  129       }
  130   
  131       /**
  132        * Construct a new media size attribute from the given integer values.
  133        *
  134        * @param  x  X dimension.
  135        * @param  y  Y dimension.
  136        * @param  units
  137        *     Unit conversion factor, e.g. <CODE>Size2DSyntax.INCH</CODE> or
  138        *     <CODE>Size2DSyntax.MM</CODE>.
  139        * @param media a media name to associate with this MediaSize
  140        *
  141        * @exception  IllegalArgumentException
  142        *   (Unchecked exception) Thrown if <CODE>x</CODE> < 0 or <CODE>y</CODE>
  143        *     < 0 or <CODE>units</CODE> < 1 or <CODE>x</CODE> > <CODE>y</CODE>.
  144        */
  145       public MediaSize(int x, int y,int units, MediaSizeName media) {
  146           super (x, y, units);
  147           if (x > y) {
  148               throw new IllegalArgumentException("X dimension > Y dimension");
  149           }
  150           mediaName = media;
  151           mediaMap.put(mediaName, this);
  152           sizeVector.add(this);
  153       }
  154   
  155       /**
  156        * Get the media name, if any, for this size.
  157        *
  158        * @return the name for this media size, or null if no name was
  159        * associated with this size (an anonymous size).
  160        */
  161       public MediaSizeName getMediaSizeName() {
  162           return mediaName;
  163       }
  164   
  165       /**
  166        * Get the MediaSize for the specified named media.
  167        *
  168        * @param media - the name of the media for which the size is sought
  169        * @return size of the media, or null if this media is not associated
  170        * with any size.
  171        */
  172       public static MediaSize getMediaSizeForName(MediaSizeName media) {
  173           return (MediaSize)mediaMap.get(media);
  174       }
  175   
  176       /**
  177        * The specified dimensions are used to locate a matching MediaSize
  178        * instance from amongst all the standard MediaSize instances.
  179        * If there is no exact match, the closest match is used.
  180        * <p>
  181        * The MediaSize is in turn used to locate the MediaSizeName object.
  182        * This method may return null if the closest matching MediaSize
  183        * has no corresponding Media instance.
  184        * <p>
  185        * This method is useful for clients which have only dimensions and
  186        * want to find a Media which corresponds to the dimensions.
  187        * @param x - X dimension
  188        * @param y - Y dimension.
  189        * @param  units
  190        *     Unit conversion factor, e.g. <CODE>Size2DSyntax.INCH</CODE> or
  191        *     <CODE>Size2DSyntax.MM</CODE>
  192        * @return MediaSizeName matching these dimensions, or null.
  193        * @exception IllegalArgumentException if x <= 0, y <= 0, or units < 1
  194        *
  195        */
  196       public static MediaSizeName findMedia(float x, float y, int units) {
  197   
  198           MediaSize match = MediaSize.ISO.A4;
  199   
  200           if (x <= 0.0f || y <= 0.0f || units < 1) {
  201               throw new IllegalArgumentException("args must be +ve values");
  202           }
  203   
  204           double ls = x * x + y * y;
  205           double tmp_ls;
  206           float []dim;
  207           float diffx = x;
  208           float diffy = y;
  209   
  210           for (int i=0; i < sizeVector.size() ; i++) {
  211               MediaSize mediaSize = (MediaSize)sizeVector.elementAt(i);
  212               dim = mediaSize.getSize(units);
  213               if (x == dim[0] && y == dim[1]) {
  214                   match = mediaSize;
  215                   break;
  216               } else {
  217                   diffx = x - dim[0];
  218                   diffy = y - dim[1];
  219                   tmp_ls = diffx * diffx + diffy * diffy;
  220                   if (tmp_ls < ls) {
  221                       ls = tmp_ls;
  222                       match = mediaSize;
  223                   }
  224               }
  225           }
  226   
  227           return match.getMediaSizeName();
  228       }
  229   
  230       /**
  231        * Returns whether this media size attribute is equivalent to the passed
  232        * in object.
  233        * To be equivalent, all of the following conditions must be true:
  234        * <OL TYPE=1>
  235        * <LI>
  236        * <CODE>object</CODE> is not null.
  237        * <LI>
  238        * <CODE>object</CODE> is an instance of class MediaSize.
  239        * <LI>
  240        * This media size attribute's X dimension is equal to
  241        * <CODE>object</CODE>'s X dimension.
  242        * <LI>
  243        * This media size attribute's Y dimension is equal to
  244        * <CODE>object</CODE>'s Y dimension.
  245        * </OL>
  246        *
  247        * @param  object  Object to compare to.
  248        *
  249        * @return  True if <CODE>object</CODE> is equivalent to this media size
  250        *          attribute, false otherwise.
  251        */
  252       public boolean equals(Object object) {
  253           return (super.equals(object) && object instanceof MediaSize);
  254       }
  255   
  256       /**
  257        * Get the printing attribute class which is to be used as the "category"
  258        * for this printing attribute value.
  259        * <P>
  260        * For class MediaSize and any vendor-defined subclasses, the category is
  261        * class MediaSize itself.
  262        *
  263        * @return  Printing attribute class (category), an instance of class
  264        *          {@link java.lang.Class java.lang.Class}.
  265        */
  266       public final Class<? extends Attribute> getCategory() {
  267           return MediaSize.class;
  268       }
  269   
  270       /**
  271        * Get the name of the category of which this attribute value is an
  272        * instance.
  273        * <P>
  274        * For class MediaSize and any vendor-defined subclasses, the category
  275        * name is <CODE>"media-size"</CODE>.
  276        *
  277        * @return  Attribute category name.
  278        */
  279       public final String getName() {
  280           return "media-size";
  281       }
  282   
  283       /**
  284        * Class MediaSize.ISO includes {@link MediaSize MediaSize} values for ISO
  285        * media.
  286        * <P>
  287        */
  288       public final static class ISO {
  289           /**
  290            * Specifies the ISO A0 size, 841 mm by 1189 mm.
  291            */
  292           public static final MediaSize
  293               A0 = new MediaSize(841, 1189, Size2DSyntax.MM, MediaSizeName.ISO_A0);
  294           /**
  295            * Specifies the ISO A1 size, 594 mm by 841 mm.
  296            */
  297           public static final MediaSize
  298               A1 = new MediaSize(594, 841, Size2DSyntax.MM, MediaSizeName.ISO_A1);
  299           /**
  300            * Specifies the ISO A2 size, 420 mm by 594 mm.
  301            */
  302           public static final MediaSize
  303               A2 = new MediaSize(420, 594, Size2DSyntax.MM, MediaSizeName.ISO_A2);
  304           /**
  305            * Specifies the ISO A3 size, 297 mm by 420 mm.
  306            */
  307           public static final MediaSize
  308               A3 = new MediaSize(297, 420, Size2DSyntax.MM, MediaSizeName.ISO_A3);
  309           /**
  310            * Specifies the ISO A4 size, 210 mm by 297 mm.
  311            */
  312           public static final MediaSize
  313               A4 = new MediaSize(210, 297, Size2DSyntax.MM, MediaSizeName.ISO_A4);
  314           /**
  315            * Specifies the ISO A5 size, 148 mm by 210 mm.
  316            */
  317           public static final MediaSize
  318               A5 = new MediaSize(148, 210, Size2DSyntax.MM, MediaSizeName.ISO_A5);
  319           /**
  320            * Specifies the ISO A6 size, 105 mm by 148 mm.
  321            */
  322           public static final MediaSize
  323               A6 = new MediaSize(105, 148, Size2DSyntax.MM, MediaSizeName.ISO_A6);
  324           /**
  325            * Specifies the ISO A7 size, 74 mm by 105 mm.
  326            */
  327           public static final MediaSize
  328               A7 = new MediaSize(74, 105, Size2DSyntax.MM, MediaSizeName.ISO_A7);
  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            * Specifies the ISO A9 size, 37 mm by 52 mm.
  336            */
  337           public static final MediaSize
  338               A9 = new MediaSize(37, 52, Size2DSyntax.MM, MediaSizeName.ISO_A9);
  339           /**
  340            * Specifies the ISO A10 size, 26 mm by 37 mm.
  341            */
  342           public static final MediaSize
  343               A10 = new MediaSize(26, 37, Size2DSyntax.MM, MediaSizeName.ISO_A10);
  344           /**
  345            * Specifies the ISO B0 size, 1000 mm by 1414 mm.
  346            */
  347           public static final MediaSize
  348               B0 = new MediaSize(1000, 1414, Size2DSyntax.MM, MediaSizeName.ISO_B0);
  349           /**
  350            * Specifies the ISO B1 size, 707 mm by 1000 mm.
  351            */
  352           public static final MediaSize
  353               B1 = new MediaSize(707, 1000, Size2DSyntax.MM, MediaSizeName.ISO_B1);
  354           /**
  355            * Specifies the ISO B2 size, 500 mm by 707 mm.
  356            */
  357           public static final MediaSize
  358               B2 = new MediaSize(500, 707, Size2DSyntax.MM, MediaSizeName.ISO_B2);
  359           /**
  360            * Specifies the ISO B3 size, 353 mm by 500 mm.
  361            */
  362           public static final MediaSize
  363               B3 = new MediaSize(353, 500, Size2DSyntax.MM, MediaSizeName.ISO_B3);
  364           /**
  365            * Specifies the ISO B4 size, 250 mm by 353 mm.
  366            */
  367           public static final MediaSize
  368               B4 = new MediaSize(250, 353, Size2DSyntax.MM, MediaSizeName.ISO_B4);
  369           /**
  370            * Specifies the ISO B5 size, 176 mm by 250 mm.
  371            */
  372           public static final MediaSize
  373               B5 = new MediaSize(176, 250, Size2DSyntax.MM, MediaSizeName.ISO_B5);
  374           /**
  375            * Specifies the ISO B6 size, 125 mm by 176 mm.
  376            */
  377           public static final MediaSize
  378               B6 = new MediaSize(125, 176, Size2DSyntax.MM, MediaSizeName.ISO_B6);
  379           /**
  380            * Specifies the ISO B7 size, 88 mm by 125 mm.
  381            */
  382           public static final MediaSize
  383               B7 = new MediaSize(88, 125, Size2DSyntax.MM, MediaSizeName.ISO_B7);
  384           /**
  385            * Specifies the ISO B8 size, 62 mm by 88 mm.
  386            */
  387           public static final MediaSize
  388               B8 = new MediaSize(62, 88, Size2DSyntax.MM, MediaSizeName.ISO_B8);
  389           /**
  390            * Specifies the ISO B9 size, 44 mm by 62 mm.
  391            */
  392           public static final MediaSize
  393               B9 = new MediaSize(44, 62, Size2DSyntax.MM, MediaSizeName.ISO_B9);
  394           /**
  395            * Specifies the ISO B10 size, 31 mm by 44 mm.
  396            */
  397           public static final MediaSize
  398               B10 = new MediaSize(31, 44, Size2DSyntax.MM, MediaSizeName.ISO_B10);
  399           /**
  400            * Specifies the ISO C3 size, 324 mm by 458 mm.
  401            */
  402           public static final MediaSize
  403               C3 = new MediaSize(324, 458, Size2DSyntax.MM, MediaSizeName.ISO_C3);
  404           /**
  405            * Specifies the ISO C4 size, 229 mm by 324 mm.
  406            */
  407           public static final MediaSize
  408               C4 = new MediaSize(229, 324, Size2DSyntax.MM, MediaSizeName.ISO_C4);
  409           /**
  410            * Specifies the ISO C5 size, 162 mm by 229 mm.
  411            */
  412           public static final MediaSize
  413               C5 = new MediaSize(162, 229, Size2DSyntax.MM, MediaSizeName.ISO_C5);
  414           /**
  415            * Specifies the ISO C6 size, 114 mm by 162 mm.
  416            */
  417           public static final MediaSize
  418               C6 = new MediaSize(114, 162, Size2DSyntax.MM, MediaSizeName.ISO_C6);
  419           /**
  420            * Specifies the ISO Designated Long size, 110 mm by 220 mm.
  421            */
  422           public static final MediaSize
  423               DESIGNATED_LONG = new MediaSize(110, 220, Size2DSyntax.MM,
  424                                               MediaSizeName.ISO_DESIGNATED_LONG);
  425   
  426           /**
  427            * Hide all constructors.
  428            */
  429           private ISO() {
  430           }
  431       }
  432   
  433       /**
  434        * Class MediaSize.JIS includes {@link MediaSize MediaSize} values for JIS
  435        * (Japanese) media.      *
  436        */
  437       public final static class JIS {
  438   
  439           /**
  440            * Specifies the JIS B0 size, 1030 mm by 1456 mm.
  441            */
  442           public static final MediaSize
  443               B0 = new MediaSize(1030, 1456, Size2DSyntax.MM, MediaSizeName.JIS_B0);
  444           /**
  445            * Specifies the JIS B1 size, 728 mm by 1030 mm.
  446            */
  447           public static final MediaSize
  448               B1 = new MediaSize(728, 1030, Size2DSyntax.MM, MediaSizeName.JIS_B1);
  449           /**
  450            * Specifies the JIS B2 size, 515 mm by 728 mm.
  451            */
  452           public static final MediaSize
  453               B2 = new MediaSize(515, 728, Size2DSyntax.MM, MediaSizeName.JIS_B2);
  454           /**
  455            * Specifies the JIS B3 size, 364 mm by 515 mm.
  456            */
  457           public static final MediaSize
  458               B3 = new MediaSize(364, 515, Size2DSyntax.MM, MediaSizeName.JIS_B3);
  459           /**
  460            * Specifies the JIS B4 size, 257 mm by 364 mm.
  461            */
  462           public static final MediaSize
  463               B4 = new MediaSize(257, 364, Size2DSyntax.MM, MediaSizeName.JIS_B4);
  464           /**
  465            * Specifies the JIS B5 size, 182 mm by 257 mm.
  466            */
  467           public static final MediaSize
  468               B5 = new MediaSize(182, 257, Size2DSyntax.MM, MediaSizeName.JIS_B5);
  469           /**
  470            * Specifies the JIS B6 size, 128 mm by 182 mm.
  471            */
  472           public static final MediaSize
  473               B6 = new MediaSize(128, 182, Size2DSyntax.MM, MediaSizeName.JIS_B6);
  474           /**
  475            * Specifies the JIS B7 size, 91 mm by 128 mm.
  476            */
  477           public static final MediaSize
  478               B7 = new MediaSize(91, 128, Size2DSyntax.MM, MediaSizeName.JIS_B7);
  479           /**
  480            * Specifies the JIS B8 size, 64 mm by 91 mm.
  481            */
  482           public static final MediaSize
  483               B8 = new MediaSize(64, 91, Size2DSyntax.MM, MediaSizeName.JIS_B8);
  484           /**
  485            * Specifies the JIS B9 size, 45 mm by 64 mm.
  486            */
  487           public static final MediaSize
  488               B9 = new MediaSize(45, 64, Size2DSyntax.MM, MediaSizeName.JIS_B9);
  489           /**
  490            * Specifies the JIS B10 size, 32 mm by 45 mm.
  491            */
  492           public static final MediaSize
  493               B10 = new MediaSize(32, 45, Size2DSyntax.MM, MediaSizeName.JIS_B10);
  494           /**
  495            * Specifies the JIS Chou ("long") #1 envelope size, 142 mm by 332 mm.
  496            */
  497           public static final MediaSize CHOU_1 = new MediaSize(142, 332, Size2DSyntax.MM);
  498           /**
  499            * Specifies the JIS Chou ("long") #2 envelope size, 119 mm by 277 mm.
  500            */
  501           public static final MediaSize CHOU_2 = new MediaSize(119, 277, Size2DSyntax.MM);
  502           /**
  503            * Specifies the JIS Chou ("long") #3 envelope size, 120 mm by 235 mm.
  504            */
  505           public static final MediaSize CHOU_3 = new MediaSize(120, 235, Size2DSyntax.MM);
  506           /**
  507            * Specifies the JIS Chou ("long") #4 envelope size, 90 mm by 205 mm.
  508            */
  509           public static final MediaSize CHOU_4 = new MediaSize(90, 205, Size2DSyntax.MM);
  510           /**
  511            * Specifies the JIS Chou ("long") #30 envelope size, 92 mm by 235 mm.
  512            */
  513           public static final MediaSize CHOU_30 = new MediaSize(92, 235, Size2DSyntax.MM);
  514           /**
  515            * Specifies the JIS Chou ("long") #40 envelope size, 90 mm by 225 mm.
  516            */
  517           public static final MediaSize CHOU_40 = new MediaSize(90, 225, Size2DSyntax.MM);
  518           /**
  519            * Specifies the JIS Kaku ("square") #0 envelope size, 287 mm by 382 mm.
  520            */
  521           public static final MediaSize KAKU_0 = new MediaSize(287, 382, Size2DSyntax.MM);
  522           /**
  523            * Specifies the JIS Kaku ("square") #1 envelope size, 270 mm by 382 mm.
  524            */
  525           public static final MediaSize KAKU_1 = new MediaSize(270, 382, Size2DSyntax.MM);
  526           /**
  527            * Specifies the JIS Kaku ("square") #2 envelope size, 240 mm by 332 mm.
  528            */
  529           public static final MediaSize KAKU_2 = new MediaSize(240, 332, Size2DSyntax.MM);
  530           /**
  531            * Specifies the JIS Kaku ("square") #3 envelope size, 216 mm by 277 mm.
  532            */
  533           public static final MediaSize KAKU_3 = new MediaSize(216, 277, Size2DSyntax.MM);
  534           /**
  535            * Specifies the JIS Kaku ("square") #4 envelope size, 197 mm by 267 mm.
  536            */
  537           public static final MediaSize KAKU_4 = new MediaSize(197, 267, Size2DSyntax.MM);
  538           /**
  539            * Specifies the JIS Kaku ("square") #5 envelope size, 190 mm by 240 mm.
  540            */
  541           public static final MediaSize KAKU_5 = new MediaSize(190, 240, Size2DSyntax.MM);
  542           /**
  543            * Specifies the JIS Kaku ("square") #6 envelope size, 162 mm by 229 mm.
  544            */
  545           public static final MediaSize KAKU_6 = new MediaSize(162, 229, Size2DSyntax.MM);
  546           /**
  547            * Specifies the JIS Kaku ("square") #7 envelope size, 142 mm by 205 mm.
  548            */
  549           public static final MediaSize KAKU_7 = new MediaSize(142, 205, Size2DSyntax.MM);
  550           /**
  551            * Specifies the JIS Kaku ("square") #8 envelope size, 119 mm by 197 mm.
  552            */
  553           public static final MediaSize KAKU_8 = new MediaSize(119, 197, Size2DSyntax.MM);
  554           /**
  555            * Specifies the JIS Kaku ("square") #20 envelope size, 229 mm by 324 mm.
  556            */
  557           public static final MediaSize KAKU_20 = new MediaSize(229, 324, Size2DSyntax.MM);
  558           /**
  559            * Specifies the JIS Kaku ("square") A4 envelope size, 228 mm by 312 mm.
  560            */
  561           public static final MediaSize KAKU_A4 = new MediaSize(228, 312, Size2DSyntax.MM);
  562           /**
  563            * Specifies the JIS You ("Western") #1 envelope size, 120 mm by 176 mm.
  564            */
  565           public static final MediaSize YOU_1 = new MediaSize(120, 176, Size2DSyntax.MM);
  566           /**
  567            * Specifies the JIS You ("Western") #2 envelope size, 114 mm by 162 mm.
  568            */
  569           public static final MediaSize YOU_2 = new MediaSize(114, 162, Size2DSyntax.MM);
  570           /**
  571            * Specifies the JIS You ("Western") #3 envelope size, 98 mm by 148 mm.
  572            */
  573           public static final MediaSize YOU_3 = new MediaSize(98, 148, Size2DSyntax.MM);
  574           /**
  575            * Specifies the JIS You ("Western") #4 envelope size, 105 mm by 235 mm.
  576            */
  577           public static final MediaSize YOU_4 = new MediaSize(105, 235, Size2DSyntax.MM);
  578           /**
  579            * Specifies the JIS You ("Western") #5 envelope size, 95 mm by 217 mm.
  580            */
  581           public static final MediaSize YOU_5 = new MediaSize(95, 217, Size2DSyntax.MM);
  582           /**
  583            * Specifies the JIS You ("Western") #6 envelope size, 98 mm by 190 mm.
  584            */
  585           public static final MediaSize YOU_6 = new MediaSize(98, 190, Size2DSyntax.MM);
  586           /**
  587            * Specifies the JIS You ("Western") #7 envelope size, 92 mm by 165 mm.
  588            */
  589           public static final MediaSize YOU_7 = new MediaSize(92, 165, Size2DSyntax.MM);
  590           /**
  591            * Hide all constructors.
  592            */
  593           private JIS() {
  594           }
  595       }
  596   
  597       /**
  598        * Class MediaSize.NA includes {@link MediaSize MediaSize} values for North
  599        * American media.
  600        */
  601       public final static class NA {
  602   
  603           /**
  604            * Specifies the North American letter size, 8.5 inches by 11 inches.
  605            */
  606           public static final MediaSize
  607               LETTER = new MediaSize(8.5f, 11.0f, Size2DSyntax.INCH,
  608                                                   MediaSizeName.NA_LETTER);
  609           /**
  610            * Specifies the North American legal size, 8.5 inches by 14 inches.
  611            */
  612           public static final MediaSize
  613               LEGAL = new MediaSize(8.5f, 14.0f, Size2DSyntax.INCH,
  614                                                  MediaSizeName.NA_LEGAL);
  615           /**
  616            * Specifies the North American 5 inch by 7 inch paper.
  617            */
  618           public static final MediaSize
  619               NA_5X7 = new MediaSize(5, 7, Size2DSyntax.INCH,
  620                                      MediaSizeName.NA_5X7);
  621           /**
  622            * Specifies the North American 8 inch by 10 inch paper.
  623            */
  624           public static final MediaSize
  625               NA_8X10 = new MediaSize(8, 10, Size2DSyntax.INCH,
  626                                      MediaSizeName.NA_8X10);
  627           /**
  628            * Specifies the North American Number 9 business envelope size,
  629            * 3.875 inches by 8.875 inches.
  630            */
  631           public static final MediaSize
  632               NA_NUMBER_9_ENVELOPE =
  633               new MediaSize(3.875f, 8.875f, Size2DSyntax.INCH,
  634                             MediaSizeName.NA_NUMBER_9_ENVELOPE);
  635           /**
  636            * Specifies the North American Number 10 business envelope size,
  637            * 4.125 inches by 9.5 inches.
  638            */
  639           public static final MediaSize
  640               NA_NUMBER_10_ENVELOPE =
  641               new MediaSize(4.125f, 9.5f, Size2DSyntax.INCH,
  642                             MediaSizeName.NA_NUMBER_10_ENVELOPE);
  643           /**
  644            * Specifies the North American Number 11 business envelope size,
  645            * 4.5 inches by 10.375 inches.
  646            */
  647           public static final MediaSize
  648               NA_NUMBER_11_ENVELOPE =
  649               new MediaSize(4.5f, 10.375f, Size2DSyntax.INCH,
  650                             MediaSizeName.NA_NUMBER_11_ENVELOPE);
  651           /**
  652            * Specifies the North American Number 12 business envelope size,
  653            * 4.75 inches by 11 inches.
  654            */
  655           public static final MediaSize
  656               NA_NUMBER_12_ENVELOPE =
  657               new MediaSize(4.75f, 11.0f, Size2DSyntax.INCH,
  658                             MediaSizeName.NA_NUMBER_12_ENVELOPE);
  659           /**
  660            * Specifies the North American Number 14 business envelope size,
  661            * 5 inches by 11.5 inches.
  662            */
  663           public static final MediaSize
  664               NA_NUMBER_14_ENVELOPE =
  665               new MediaSize(5.0f, 11.5f, Size2DSyntax.INCH,
  666                             MediaSizeName.NA_NUMBER_14_ENVELOPE);
  667   
  668           /**
  669            * Specifies the North American 6 inch by 9 inch envelope size.
  670            */
  671           public static final MediaSize
  672               NA_6X9_ENVELOPE = new MediaSize(6.0f, 9.0f, Size2DSyntax.INCH,
  673                                               MediaSizeName.NA_6X9_ENVELOPE);
  674           /**
  675            * Specifies the North American 7 inch by 9 inch envelope size.
  676            */
  677           public static final MediaSize
  678               NA_7X9_ENVELOPE = new MediaSize(7.0f, 9.0f, Size2DSyntax.INCH,
  679                                               MediaSizeName.NA_7X9_ENVELOPE);
  680           /**
  681            * Specifies the North American 9 inch by 11 inch envelope size.
  682            */
  683           public static final MediaSize
  684               NA_9x11_ENVELOPE = new MediaSize(9.0f, 11.0f, Size2DSyntax.INCH,
  685                                                MediaSizeName.NA_9X11_ENVELOPE);
  686           /**
  687            * Specifies the North American 9 inch by 12 inch envelope size.
  688            */
  689           public static final MediaSize
  690               NA_9x12_ENVELOPE = new MediaSize(9.0f, 12.0f, Size2DSyntax.INCH,
  691                                                MediaSizeName.NA_9X12_ENVELOPE);
  692           /**
  693            * Specifies the North American 10 inch by 13 inch envelope size.
  694            */
  695           public static final MediaSize
  696               NA_10x13_ENVELOPE = new MediaSize(10.0f, 13.0f, Size2DSyntax.INCH,
  697                                                 MediaSizeName.NA_10X13_ENVELOPE);
  698           /**
  699            * Specifies the North American 10 inch by 14 inch envelope size.
  700            */
  701           public static final MediaSize
  702               NA_10x14_ENVELOPE = new MediaSize(10.0f, 14.0f, Size2DSyntax.INCH,
  703                                                 MediaSizeName.NA_10X14_ENVELOPE);
  704           /**
  705            * Specifies the North American 10 inch by 15 inch envelope size.
  706            */
  707           public static final MediaSize
  708               NA_10X15_ENVELOPE = new MediaSize(10.0f, 15.0f, Size2DSyntax.INCH,
  709                                                 MediaSizeName.NA_10X15_ENVELOPE);
  710           /**
  711            * Hide all constructors.
  712            */
  713           private NA() {
  714           }
  715       }
  716   
  717       /**
  718        * Class MediaSize.Engineering includes {@link MediaSize MediaSize} values
  719        * for engineering media.
  720        */
  721       public final static class Engineering {
  722   
  723           /**
  724            * Specifies the engineering A size, 8.5 inch by 11 inch.
  725            */
  726           public static final MediaSize
  727               A = new MediaSize(8.5f, 11.0f, Size2DSyntax.INCH,
  728                                 MediaSizeName.A);
  729           /**
  730            * Specifies the engineering B size, 11 inch by 17 inch.
  731            */
  732           public static final MediaSize
  733               B = new MediaSize(11.0f, 17.0f, Size2DSyntax.INCH,
  734                                 MediaSizeName.B);
  735           /**
  736            * Specifies the engineering C size, 17 inch by 22 inch.
  737            */
  738           public static final MediaSize
  739               C = new MediaSize(17.0f, 22.0f, Size2DSyntax.INCH,
  740                                 MediaSizeName.C);
  741           /**
  742            * Specifies the engineering D size, 22 inch by 34 inch.
  743            */
  744           public static final MediaSize
  745               D = new MediaSize(22.0f, 34.0f, Size2DSyntax.INCH,
  746                                 MediaSizeName.D);
  747           /**
  748            * Specifies the engineering E size, 34 inch by 44 inch.
  749            */
  750           public static final MediaSize
  751               E = new MediaSize(34.0f, 44.0f, Size2DSyntax.INCH,
  752                                 MediaSizeName.E);
  753           /**
  754            * Hide all constructors.
  755            */
  756           private Engineering() {
  757           }
  758       }
  759   
  760       /**
  761        * Class MediaSize.Other includes {@link MediaSize MediaSize} values for
  762        * miscellaneous media.
  763        */
  764       public final static class Other {
  765           /**
  766            * Specifies the executive size, 7.25 inches by 10.5 inches.
  767            */
  768           public static final MediaSize
  769               EXECUTIVE = new MediaSize(7.25f, 10.5f, Size2DSyntax.INCH,
  770                                         MediaSizeName.EXECUTIVE);
  771           /**
  772            * Specifies the ledger size, 11 inches by 17 inches.
  773            */
  774           public static final MediaSize
  775               LEDGER = new MediaSize(11.0f, 17.0f, Size2DSyntax.INCH,
  776                                      MediaSizeName.LEDGER);
  777   
  778           /**
  779            * Specifies the tabloid size, 11 inches by 17 inches.
  780            * @since 1.5
  781            */
  782           public static final MediaSize
  783               TABLOID = new MediaSize(11.0f, 17.0f, Size2DSyntax.INCH,
  784                                      MediaSizeName.TABLOID);
  785   
  786           /**
  787            * Specifies the invoice size, 5.5 inches by 8.5 inches.
  788            */
  789           public static final MediaSize
  790               INVOICE = new MediaSize(5.5f, 8.5f, Size2DSyntax.INCH,
  791                                 MediaSizeName.INVOICE);
  792           /**
  793            * Specifies the folio size, 8.5 inches by 13 inches.
  794            */
  795           public static final MediaSize
  796               FOLIO = new MediaSize(8.5f, 13.0f, Size2DSyntax.INCH,
  797                                     MediaSizeName.FOLIO);
  798           /**
  799            * Specifies the quarto size, 8.5 inches by 10.83 inches.
  800            */
  801           public static final MediaSize
  802               QUARTO = new MediaSize(8.5f, 10.83f, Size2DSyntax.INCH,
  803                                      MediaSizeName.QUARTO);
  804           /**
  805            * Specifies the Italy envelope size, 110 mm by 230 mm.
  806            */
  807           public static final MediaSize
  808           ITALY_ENVELOPE = new MediaSize(110, 230, Size2DSyntax.MM,
  809                                          MediaSizeName.ITALY_ENVELOPE);
  810           /**
  811            * Specifies the Monarch envelope size, 3.87 inch by 7.5 inch.
  812            */
  813           public static final MediaSize
  814           MONARCH_ENVELOPE = new MediaSize(3.87f, 7.5f, Size2DSyntax.INCH,
  815                                            MediaSizeName.MONARCH_ENVELOPE);
  816           /**
  817            * Specifies the Personal envelope size, 3.625 inch by 6.5 inch.
  818            */
  819           public static final MediaSize
  820           PERSONAL_ENVELOPE = new MediaSize(3.625f, 6.5f, Size2DSyntax.INCH,
  821                                            MediaSizeName.PERSONAL_ENVELOPE);
  822           /**
  823            * Specifies the Japanese postcard size, 100 mm by 148 mm.
  824            */
  825           public static final MediaSize
  826               JAPANESE_POSTCARD = new MediaSize(100, 148, Size2DSyntax.MM,
  827                                                 MediaSizeName.JAPANESE_POSTCARD);
  828           /**
  829            * Specifies the Japanese Double postcard size, 148 mm by 200 mm.
  830            */
  831           public static final MediaSize
  832               JAPANESE_DOUBLE_POSTCARD = new MediaSize(148, 200, Size2DSyntax.MM,
  833                                        MediaSizeName.JAPANESE_DOUBLE_POSTCARD);
  834           /**
  835            * Hide all constructors.
  836            */
  837           private Other() {
  838           }
  839       }
  840   
  841       /* force loading of all the subclasses so that the instances
  842        * are created and inserted into the hashmap.
  843        */
  844       static {
  845           MediaSize ISOA4 = ISO.A4;
  846           MediaSize JISB5 = JIS.B5;
  847           MediaSize NALETTER = NA.LETTER;
  848           MediaSize EngineeringC = Engineering.C;
  849           MediaSize OtherEXECUTIVE = Other.EXECUTIVE;
  850       }
  851   }

Save This Page
Home » openjdk-7 » javax » print » attribute » standard » [javadoc | source]