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