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