MediaSize.java 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884
  1. /* MediaSize.java --
  2. Copyright (C) 2005, 2006 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package javax.print.attribute.standard;
  32. import java.util.ArrayList;
  33. import javax.print.attribute.Attribute;
  34. import javax.print.attribute.Size2DSyntax;
  35. /**
  36. * The <code>MediaSize</code> printing attribute class specifies the size
  37. * of a printing media. The size is defined in portrait orientation with
  38. * x at the bottom edge and y at the left edge.
  39. * <p>
  40. * There are several media sizes predefined through the nested classes. Further
  41. * sizes may be provided by the application. <code>MediaSize</code> is not used
  42. * as a printing attribute currently. It may be used to get the actual sizes
  43. * for a named media or to find a suitable <code>MediaSizeName</code> instance
  44. * by querying with the needed sizes.
  45. * </p>
  46. * <p>
  47. * <b>IPP Compatibility:</b> MediaSize is not an IPP 1.1 attribute.
  48. * </p>
  49. * @see javax.print.attribute.standard.MediaSizeName
  50. *
  51. * @author Michael Koch (konqueror@gmx.de)
  52. * @author Wolfgang Baer (WBaer@gmx.de)
  53. */
  54. public class MediaSize extends Size2DSyntax
  55. implements Attribute
  56. {
  57. private static final long serialVersionUID = -1967958664615414771L;
  58. private static ArrayList<MediaSize> mediaCache;
  59. static
  60. {
  61. mediaCache = new ArrayList<MediaSize>();
  62. // We call one instance of every container class to make sure it gets
  63. // loaded during class initialization and therefore all other static
  64. // fields of this container class also.
  65. // This is needed to put all MediaSize instance into the mediaCache
  66. // for use by the static methods in this class.
  67. MediaSize tmp = MediaSize.ISO.A0;
  68. tmp = MediaSize.JIS.B0;
  69. tmp = MediaSize.Engineering.A;
  70. tmp = MediaSize.NA.LEGAL;
  71. tmp = MediaSize.Other.EXECUTIVE;
  72. }
  73. private MediaSizeName mediaName;
  74. /**
  75. * Creates a <code>MediaSize</code> object. The created object will be added
  76. * to an internal cache used in the static methods of this class for lookup
  77. * of available <code>MediaSize</code> instances.
  78. *
  79. * @param x the size in x direction
  80. * @param y the size in y direction
  81. * @param units the units to use for the sizes
  82. *
  83. * @exception IllegalArgumentException if x or y &lt; 0 or units &lt; 1
  84. *
  85. * @see #findMedia(float, float, int)
  86. * @see #getMediaSizeForName(MediaSizeName)
  87. */
  88. public MediaSize(float x, float y, int units)
  89. {
  90. super(x, y, units);
  91. mediaCache.add(this);
  92. }
  93. /**
  94. * Creates a <code>MediaSize</code> object associated with the given
  95. * media name. The created object will be added to an internal cache used
  96. * in the static methods of this class for lookup of available
  97. * <code>MediaSize</code> instances.
  98. *
  99. * @param x the size in x direction
  100. * @param y the size in y direction
  101. * @param units the units to use for the sizes
  102. * @param media the media name to associate
  103. *
  104. * @exception IllegalArgumentException if x or y &lt; 0 or units &lt; 1
  105. *
  106. * @see #findMedia(float, float, int)
  107. * @see #getMediaSizeForName(MediaSizeName)
  108. */
  109. public MediaSize(float x, float y, int units, MediaSizeName media)
  110. {
  111. super(x, y, units);
  112. mediaName = media;
  113. mediaCache.add(this);
  114. }
  115. /**
  116. * Creates a <code>MediaSize</code> object. The created object will be added
  117. * to an internal cache used in the static methods of this class for lookup
  118. * of available <code>MediaSize</code> instances.
  119. *
  120. * @param x the size in x direction
  121. * @param y the size in y direction
  122. * @param units the units to use for the sizes
  123. *
  124. * @exception IllegalArgumentException if x or y &lt; 0 or units &lt; 1
  125. *
  126. * @see #findMedia(float, float, int)
  127. * @see #getMediaSizeForName(MediaSizeName)
  128. */
  129. public MediaSize(int x, int y, int units)
  130. {
  131. super(x, y, units);
  132. mediaCache.add(this);
  133. }
  134. /**
  135. * Creates a <code>MediaSize</code> object associated with the given
  136. * media name. The created object will be added to an internal cache used
  137. * in the static methods of this class for lookup of available
  138. * <code>MediaSize</code> instances.
  139. *
  140. * @param x the size in x direction
  141. * @param y the size in y direction
  142. * @param units the units to use for the sizes
  143. * @param media the media name to associate
  144. *
  145. * @exception IllegalArgumentException if x or y &lt; 0 or units &lt; 1
  146. *
  147. * @see #findMedia(float, float, int)
  148. * @see #getMediaSizeForName(MediaSizeName)
  149. */
  150. public MediaSize(int x, int y, int units, MediaSizeName media)
  151. {
  152. super(x, y, units);
  153. mediaName = media;
  154. mediaCache.add(this);
  155. }
  156. /**
  157. * Returns category of this class.
  158. *
  159. * @return The class <code>MediaSize</code> itself.
  160. */
  161. public Class< ? extends Attribute> getCategory()
  162. {
  163. return MediaSize.class;
  164. }
  165. /**
  166. * Searches for a MediaSize object with the given dimensions.
  167. * If none is found with exact dimensions, the closest match is used.
  168. * Afterwards the MediaSizeName of the found MediaSize object is
  169. * returned - which might be null if none is specified.
  170. *
  171. * @param x the dimension for x
  172. * @param y the dimension for y
  173. * @param units the units to be used for comparison
  174. * @return the corresponding MediaSizeName object, or null
  175. */
  176. public static MediaSizeName findMedia(float x, float y, int units)
  177. {
  178. if (x <= 0.0f || y <= 0.0f)
  179. throw new IllegalArgumentException(
  180. "x and/or y may not be less or equal 0");
  181. if (units < 1)
  182. throw new IllegalArgumentException("units may not be less then 1");
  183. MediaSize bestMatch = null;
  184. int bestDistance = Integer.MAX_VALUE;
  185. int xMicro = (int) x * units;
  186. int yMicro = (int) y * units;
  187. for (int i = 0; i < mediaCache.size(); i++)
  188. {
  189. MediaSize size = mediaCache.get(i);
  190. int dist = (Math.abs(size.getXMicrometers() - xMicro)
  191. + Math.abs(size.getYMicrometers() - yMicro));
  192. if (dist < bestDistance)
  193. {
  194. bestMatch = size;
  195. bestDistance = dist;
  196. }
  197. }
  198. return bestMatch.getMediaSizeName();
  199. }
  200. /**
  201. * Returns the associated <code>MediaSize</code> instance for the
  202. * given named media <code>MediaSizeName</code> instance.
  203. *
  204. * @param media the named media to search for.
  205. * @return The corresponding <code>MediaSize</code> instance or
  206. * <code>null</code> if none found.
  207. */
  208. public static MediaSize getMediaSizeForName(MediaSizeName media)
  209. {
  210. for (int i = 0; i < mediaCache.size(); i++)
  211. {
  212. MediaSize size = mediaCache.get(i);
  213. if (size.getMediaSizeName().equals(media))
  214. return size;
  215. }
  216. return null;
  217. }
  218. /**
  219. * Tests if the given object is equal to this object.
  220. *
  221. * @param obj the object to test
  222. *
  223. * @return <code>true</code> if both objects are equal,
  224. * <code>false</code> otherwise.
  225. */
  226. public boolean equals(Object obj)
  227. {
  228. if (!(obj instanceof MediaSize))
  229. return false;
  230. MediaSize tmp = (MediaSize) obj;
  231. return (tmp.getXMicrometers() == this.getXMicrometers()
  232. && tmp.getYMicrometers() == this.getYMicrometers());
  233. }
  234. /**
  235. * Returns the media name of this size.
  236. *
  237. * @return The media name.
  238. */
  239. public MediaSizeName getMediaSizeName()
  240. {
  241. return mediaName;
  242. }
  243. /**
  244. * Returns the name of this attribute.
  245. *
  246. * @return The name "media-size".
  247. */
  248. public final String getName()
  249. {
  250. return "media-size";
  251. }
  252. /**
  253. * Container class for predefined ISO media sizes.
  254. *
  255. * @author Sven de Marothy (sven@physto.se)
  256. */
  257. public static final class ISO
  258. {
  259. private ISO()
  260. {
  261. // prevent instantiation
  262. }
  263. /**
  264. * ISO A0 paper, 841 mm x 1189 mm.
  265. */
  266. public static final MediaSize A0 = new MediaSize(841, 1189,
  267. MediaSize.MM,
  268. MediaSizeName.ISO_A0);
  269. /**
  270. * ISO A1 paper, 594 mm x 841 mm
  271. */
  272. public static final MediaSize A1 = new MediaSize(594, 841, MediaSize.MM,
  273. MediaSizeName.ISO_A1);
  274. /**
  275. * ISO A2 paper, 420 mm x 594 mm
  276. */
  277. public static final MediaSize A2 = new MediaSize(420, 594, MediaSize.MM, MediaSizeName.ISO_A2);
  278. /**
  279. * ISO A3 paper, 297 mm x 420 mm
  280. */
  281. public static final MediaSize A3 = new MediaSize(297, 420, MediaSize.MM, MediaSizeName.ISO_A3);
  282. /**
  283. * ISO A4 paper, 210 mm x 297 mm
  284. */
  285. public static final MediaSize A4 = new MediaSize(210, 297, MediaSize.MM, MediaSizeName.ISO_A4);
  286. /**
  287. * ISO A5 paper, 148 mm x 210 mm
  288. */
  289. public static final MediaSize A5 = new MediaSize(148, 210, MediaSize.MM, MediaSizeName.ISO_A5);
  290. /**
  291. * ISO A6 paper, 105 mm x 148 mm
  292. */
  293. public static final MediaSize A6 = new MediaSize(105, 148, MediaSize.MM, MediaSizeName.ISO_A6);
  294. /**
  295. * ISO A7 paper, 74 mm x 105 mm
  296. */
  297. public static final MediaSize A7 = new MediaSize(74, 105, MediaSize.MM, MediaSizeName.ISO_A7);
  298. /**
  299. * ISO A8 paper, 52 mm x 74 mm
  300. */
  301. public static final MediaSize A8 = new MediaSize(52, 74, MediaSize.MM, MediaSizeName.ISO_A8);
  302. /**
  303. * ISO A9 paper, 37 mm x 52 mm
  304. */
  305. public static final MediaSize A9 = new MediaSize(37, 52, MediaSize.MM, MediaSizeName.ISO_A9);
  306. /**
  307. * ISO A10 paper, 26 mm x 37 mm
  308. */
  309. public static final MediaSize A10 = new MediaSize(26, 37, MediaSize.MM, MediaSizeName.ISO_A10);
  310. /**
  311. * ISO B0 paper, 1000 mm x 1414 mm
  312. */
  313. public static final MediaSize B0 = new MediaSize(1000, 1414, MediaSize.MM, MediaSizeName.ISO_B0);
  314. /**
  315. * ISO B1 paper, 707 mm x 1000 mm
  316. */
  317. public static final MediaSize B1 = new MediaSize(707, 1000, MediaSize.MM, MediaSizeName.ISO_B1);
  318. /**
  319. * ISO B2 paper, 500 mm x 707 mm
  320. */
  321. public static final MediaSize B2 = new MediaSize(500, 707, MediaSize.MM, MediaSizeName.ISO_B2);
  322. /**
  323. * ISO B3 paper, 353 mm x 500 mm
  324. */
  325. public static final MediaSize B3 = new MediaSize(353, 500, MediaSize.MM, MediaSizeName.ISO_B3);
  326. /**
  327. * ISO B4 paper, 250 mm x 353 mm
  328. */
  329. public static final MediaSize B4 = new MediaSize(250, 353, MediaSize.MM, MediaSizeName.ISO_B4);
  330. /**
  331. * ISO B5 paper, 176 mm x 250 mm
  332. */
  333. public static final MediaSize B5 = new MediaSize(176, 250, MediaSize.MM, MediaSizeName.ISO_B5);
  334. /**
  335. * ISO B6 paper, 125 mm x 176 mm
  336. */
  337. public static final MediaSize B6 = new MediaSize(125, 176, MediaSize.MM, MediaSizeName.ISO_B6);
  338. /**
  339. * ISO B7 paper, 88 mm x 125 mm
  340. */
  341. public static final MediaSize B7 = new MediaSize(88, 125, MediaSize.MM, MediaSizeName.ISO_B7);
  342. /**
  343. * ISO B8 paper, 62 mm x 88 mm
  344. */
  345. public static final MediaSize B8 = new MediaSize(62, 88, MediaSize.MM, MediaSizeName.ISO_B8);
  346. /**
  347. * ISO B9 paper, 44 mm x 62 mm
  348. */
  349. public static final MediaSize B9 = new MediaSize(44, 62, MediaSize.MM, MediaSizeName.ISO_B9);
  350. /**
  351. * ISO B10 paper, 31 mm x 44 mm
  352. */
  353. public static final MediaSize B10 = new MediaSize(31, 44, MediaSize.MM, MediaSizeName.ISO_B10);
  354. /**
  355. * ISO C3 envelope, 324 mm x 458 mm
  356. */
  357. public static final MediaSize C3 = new MediaSize(324, 458, MediaSize.MM, MediaSizeName.ISO_C3);
  358. /**
  359. * ISO C4 envelope, 229 mm x 324 mm
  360. */
  361. public static final MediaSize C4 = new MediaSize(229, 324, MediaSize.MM, MediaSizeName.ISO_C4);
  362. /**
  363. * ISO C5 envelope, 162 mm x 229 mm
  364. */
  365. public static final MediaSize C5 = new MediaSize(162, 229, MediaSize.MM, MediaSizeName.ISO_C5);
  366. /**
  367. * ISO C6 envelope, 114 mm x 162 mm
  368. */
  369. public static final MediaSize C6 = new MediaSize(114, 162, MediaSize.MM, MediaSizeName.ISO_C6);
  370. /**
  371. * ISO ISO Designated Long paper, 324 mm x 458 mm
  372. */
  373. public static final MediaSize DESIGNATED_LONG =
  374. new MediaSize(324, 458, MediaSize.MM, MediaSizeName.ISO_DESIGNATED_LONG);
  375. }
  376. /**
  377. * Container class for predefined North American media sizes.
  378. *
  379. * @author Sven de Marothy (sven@physto.se)
  380. */
  381. public static final class NA
  382. {
  383. private NA()
  384. {
  385. // prevent instantiation
  386. }
  387. /**
  388. * US Legal paper size, 8.5 inch x 14 inch
  389. */
  390. public static final MediaSize LEGAL = new MediaSize(8.5f, 14f, MediaSize.INCH,
  391. MediaSizeName.NA_LEGAL);
  392. /**
  393. * US Letter paper size, 8.5 inch x 11 inch
  394. */
  395. public static final MediaSize LETTER = new MediaSize(8.5f, 11f, MediaSize.INCH,
  396. MediaSizeName.NA_LETTER);
  397. /**
  398. * 5 inch x 7 inch paper size.
  399. */
  400. public static final MediaSize NA_5X7 = new MediaSize(5, 7, MediaSize.INCH,
  401. MediaSizeName.NA_5X7);
  402. /**
  403. * 8 inch x 10 inch paper size.
  404. */
  405. public static final MediaSize NA_8X10 = new MediaSize(8, 10, MediaSize.INCH,
  406. MediaSizeName.NA_8X10);
  407. /**
  408. * 6 inch x 9 inch envelope size.
  409. */
  410. public static final MediaSize NA_6X9_ENVELOPE = new MediaSize(6f, 9f,
  411. MediaSize.INCH,
  412. MediaSizeName.NA_6X9_ENVELOPE);
  413. /**
  414. * 7 inch x 9 inch envelope size.
  415. */
  416. public static final MediaSize NA_7X9_ENVELOPE = new MediaSize(7f, 9f,
  417. MediaSize.INCH,
  418. MediaSizeName.NA_7X9_ENVELOPE);
  419. /**
  420. * 9 inch x 11 inch envelope size.
  421. */
  422. public static final MediaSize NA_9x11_ENVELOPE = new MediaSize(9f, 11f,
  423. MediaSize.INCH,
  424. MediaSizeName.NA_9X11_ENVELOPE);
  425. /**
  426. * 9 inch x 12 inch envelope size.
  427. */
  428. public static final MediaSize NA_9x12_ENVELOPE = new MediaSize(9f, 12f,
  429. MediaSize.INCH,
  430. MediaSizeName.NA_9X12_ENVELOPE);
  431. /**
  432. * 10 inch x 13 inch envelope size.
  433. */
  434. public static final MediaSize NA_10x13_ENVELOPE = new MediaSize(10f, 13f,
  435. MediaSize.INCH,
  436. MediaSizeName.NA_10X13_ENVELOPE);
  437. /**
  438. * 10 inch x 14 inch envelope size.
  439. */
  440. public static final MediaSize NA_10x14_ENVELOPE = new MediaSize(10f, 14f,
  441. MediaSize.INCH,
  442. MediaSizeName.NA_10X14_ENVELOPE);
  443. /**
  444. * 10 inch x 15 inch envelope size.
  445. */
  446. public static final MediaSize NA_10X15_ENVELOPE = new MediaSize(10f, 15f,
  447. MediaSize.INCH,
  448. MediaSizeName.NA_10X15_ENVELOPE);
  449. /**
  450. * Number 9 envelope size. 4.5 inch x 10.375 inch
  451. */
  452. public static final MediaSize NA_NUMBER_9_ENVELOPE = new MediaSize(3.875f, 8.875f,
  453. MediaSize.INCH,
  454. MediaSizeName.NA_NUMBER_9_ENVELOPE);
  455. /**
  456. * Number 10 envelope size. 4.125 inch x 9.5 inch
  457. */
  458. public static final MediaSize NA_NUMBER_10_ENVELOPE =
  459. new MediaSize(4.125f, 9.5f, MediaSize.INCH, MediaSizeName.NA_NUMBER_10_ENVELOPE);
  460. /**
  461. * Number 11 envelope size. 4.5 inch x 10.375 inch
  462. */
  463. public static final MediaSize NA_NUMBER_11_ENVELOPE = new MediaSize(4.5f, 10.375f, MediaSize.INCH,
  464. MediaSizeName.NA_NUMBER_11_ENVELOPE);
  465. /**
  466. * Number 12 envelope size. 4.75 inch x 11 inch
  467. */
  468. public static final MediaSize NA_NUMBER_12_ENVELOPE = new MediaSize(4.75f, 11f,
  469. MediaSize.INCH,
  470. MediaSizeName.NA_NUMBER_12_ENVELOPE);
  471. /**
  472. * Number 14 envelope size. 5 inch x 11.5 inch
  473. */
  474. public static final MediaSize NA_NUMBER_14_ENVELOPE = new MediaSize(5f, 11.5f,
  475. MediaSize.INCH,
  476. MediaSizeName.NA_NUMBER_14_ENVELOPE);
  477. }
  478. /**
  479. * Container class for predefined US Engineering media sizes.
  480. *
  481. * @author Sven de Marothy (sven@physto.se)
  482. */
  483. public static final class Engineering
  484. {
  485. private Engineering()
  486. {
  487. // prevent instantiation
  488. }
  489. /**
  490. * ANSI A paper size. 8.5 inch x 11 inch
  491. */
  492. public static final MediaSize A = new MediaSize(8.5f, 11f,
  493. MediaSize.INCH, MediaSizeName.A);
  494. /**
  495. * ANSI B paper size. 11 inch x 17 inch
  496. */
  497. public static final MediaSize B = new MediaSize(11f, 17f,
  498. MediaSize.INCH, MediaSizeName.B);
  499. /**
  500. * ANSI C paper size. 17 inch x 22 inch
  501. */
  502. public static final MediaSize C = new MediaSize(17f, 22f,
  503. MediaSize.INCH, MediaSizeName.C);
  504. /**
  505. * ANSI D paper size. 22 inch x 34 inch
  506. */
  507. public static final MediaSize D = new MediaSize(22f, 34f,
  508. MediaSize.INCH, MediaSizeName.D);
  509. /**
  510. * ANSI E paper size. 33 inch x 44 inch
  511. */
  512. public static final MediaSize E = new MediaSize(34f, 44f,
  513. MediaSize.INCH, MediaSizeName.E);
  514. }
  515. /**
  516. * Container class for predefined Japanese JIS media sizes.
  517. *
  518. * @author Sven de Marothy (sven@physto.se)
  519. */
  520. public static final class JIS
  521. {
  522. private JIS()
  523. {
  524. // prevent instantiation
  525. }
  526. /**
  527. * JIS B0 paper. 1030 mm x 1456 mm
  528. * Note: The JIS B-series is not identical to the ISO B-series.
  529. */
  530. public static final MediaSize B0 = new MediaSize(1030, 1456, MediaSize.MM, MediaSizeName.JIS_B0);
  531. /**
  532. * JIS B1 paper. 1030 mm x 1456 mm
  533. * Note: The JIS B-series is not identical to the ISO B-series.
  534. */
  535. public static final MediaSize B1 = new MediaSize(728, 1030, MediaSize.MM, MediaSizeName.JIS_B1);
  536. /**
  537. * JIS B2 paper. 515 mm x 728 mm
  538. * Note: The JIS B-series is not identical to the ISO B-series.
  539. */
  540. public static final MediaSize B2 = new MediaSize(515, 728, MediaSize.MM, MediaSizeName.JIS_B2);
  541. /**
  542. * JIS B3 paper. 364 mm x 515 mm
  543. * Note: The JIS B-series is not identical to the ISO B-series.
  544. */
  545. public static final MediaSize B3 = new MediaSize(364, 515, MediaSize.MM, MediaSizeName.JIS_B3);
  546. /**
  547. * JIS B4 paper. 257 mm x 364 mm
  548. * Note: The JIS B-series is not identical to the ISO B-series.
  549. */
  550. public static final MediaSize B4 = new MediaSize(257, 364, MediaSize.MM, MediaSizeName.JIS_B4);
  551. /**
  552. * JIS B5 paper. 1030 mm x 1456 mm
  553. * Note: The JIS B-series is not identical to the ISO B-series.
  554. */
  555. public static final MediaSize B5 = new MediaSize(182, 257, MediaSize.MM, MediaSizeName.JIS_B5);
  556. /**
  557. * JIS B6 paper. 128 mm x 182 mm
  558. * Note: The JIS B-series is not identical to the ISO B-series.
  559. */
  560. public static final MediaSize B6 = new MediaSize(128, 182, MediaSize.MM, MediaSizeName.JIS_B6);
  561. /**
  562. * JIS B7 paper. 91 mm x 128 mm
  563. * Note: The JIS B-series is not identical to the ISO B-series.
  564. */
  565. public static final MediaSize B7 = new MediaSize(91, 128, MediaSize.MM, MediaSizeName.JIS_B7);
  566. /**
  567. * JIS B8 paper. 64 mm x 91 mm
  568. * Note: The JIS B-series is not identical to the ISO B-series.
  569. */
  570. public static final MediaSize B8 = new MediaSize(64, 91, MediaSize.MM, MediaSizeName.JIS_B8);
  571. /**
  572. * JIS B9 paper. 45 mm x 64 mm
  573. * Note: The JIS B-series is not identical to the ISO B-series.
  574. */
  575. public static final MediaSize B9 = new MediaSize(45, 64, MediaSize.MM, MediaSizeName.JIS_B9);
  576. /**
  577. * JIS B10 paper. 32 mm x 45 mm
  578. * Note: The JIS B-series is not identical to the ISO B-series.
  579. */
  580. public static final MediaSize B10 = new MediaSize(32, 45, MediaSize.MM, MediaSizeName.JIS_B10);
  581. /**
  582. * JIS chou #1 envelope size, 142 mm x 332 mm
  583. */
  584. public static final MediaSize CHOU_1 = new MediaSize(142, 332, MediaSize.MM);
  585. /**
  586. * JIS chou #2 envelope size, 119 mm x 227 mm
  587. */
  588. public static final MediaSize CHOU_2 = new MediaSize(119, 227, MediaSize.MM);
  589. /**
  590. * JIS chou #3 envelope size, 120 mm x 235 mm
  591. */
  592. public static final MediaSize CHOU_3 = new MediaSize(120, 235, MediaSize.MM);
  593. /**
  594. * JIS chou #4 envelope size, 90 mm x 205 mm
  595. */
  596. public static final MediaSize CHOU_4 = new MediaSize(90, 205, MediaSize.MM);
  597. /**
  598. * JIS chou #30 envelope size, 92 mm x 235 mm
  599. */
  600. public static final MediaSize CHOU_30 = new MediaSize(92, 235, MediaSize.MM);
  601. /**
  602. * JIS chou #40 envelope size, 90 mm x 225 mm
  603. */
  604. public static final MediaSize CHOU_40 = new MediaSize(90, 225, MediaSize.MM);
  605. /**
  606. * JIS kaku #0 envelope size, 287 mm x 382 mm
  607. */
  608. public static final MediaSize KAKU_0 = new MediaSize(287, 382, MediaSize.MM);
  609. /**
  610. * JIS kaku #1 envelope size, 270 mm x 382 mm
  611. */
  612. public static final MediaSize KAKU_1 = new MediaSize(270, 382, MediaSize.MM);
  613. /**
  614. * JIS kaku #2 envelope size, 240 mm x 332 mm
  615. */
  616. public static final MediaSize KAKU_2 = new MediaSize(240, 332, MediaSize.MM);
  617. /**
  618. * JIS kaku #20 envelope size, 229 mm x 324 mm
  619. */
  620. public static final MediaSize KAKU_20 = new MediaSize(229, 324, MediaSize.MM);
  621. /**
  622. * JIS kaku #3 envelope size, 216 mm x 227 mm
  623. */
  624. public static final MediaSize KAKU_3 = new MediaSize(216, 227, MediaSize.MM);
  625. /**
  626. * JIS kaku #4 envelope size, 197 mm x 267 mm
  627. */
  628. public static final MediaSize KAKU_4 = new MediaSize(197, 267, MediaSize.MM);
  629. /**
  630. * JIS kaku #5 envelope size, 190 mm x 240 mm
  631. */
  632. public static final MediaSize KAKU_5 = new MediaSize(190, 240, MediaSize.MM);
  633. /**
  634. * JIS kaku #6 envelope size, 162 mm x 229 mm
  635. */
  636. public static final MediaSize KAKU_6 = new MediaSize(162, 229, MediaSize.MM);
  637. /**
  638. * JIS kaku #7 envelope size, 142 mm x 205 mm
  639. */
  640. public static final MediaSize KAKU_7 = new MediaSize(142, 205, MediaSize.MM);
  641. /**
  642. * JIS kaku #8 envelope size, 119 mm x 197 mm
  643. */
  644. public static final MediaSize KAKU_8 = new MediaSize(119, 197, MediaSize.MM);
  645. /**
  646. * JIS kaku A4 envelope size, 228 mm x 312 mm
  647. */
  648. public static final MediaSize KAKU_A4 = new MediaSize(228, 312, MediaSize.MM);
  649. /**
  650. * JIS you #1 envelope size, 120 mm x 176 mm
  651. */
  652. public static final MediaSize YOU_1 = new MediaSize(120, 176, MediaSize.MM);
  653. /**
  654. * JIS you #2 envelope size, 114 mm x 162 mm
  655. */
  656. public static final MediaSize YOU_2 = new MediaSize(114, 162, MediaSize.MM);
  657. /**
  658. * JIS you #3 envelope size, 98 mm x 148 mm
  659. */
  660. public static final MediaSize YOU_3 = new MediaSize(98, 148, MediaSize.MM);
  661. /**
  662. * JIS you #4 envelope size, 105 mm x 235 mm
  663. */
  664. public static final MediaSize YOU_4 = new MediaSize(105, 235, MediaSize.MM);
  665. /**
  666. * JIS you #5 envelope size, 95 mm x 217 mm
  667. */
  668. public static final MediaSize YOU_5 = new MediaSize(95, 217, MediaSize.MM);
  669. /**
  670. * JIS you #6 envelope size, 98 mm x 190 mm
  671. */
  672. public static final MediaSize YOU_6 = new MediaSize(98, 190, MediaSize.MM);
  673. /**
  674. * JIS you #7 envelope size, 92 mm x 165 mm
  675. */
  676. public static final MediaSize YOU_7 = new MediaSize(92, 165, MediaSize.MM);
  677. }
  678. /**
  679. * Container class for miscellaneous media sizes.
  680. *
  681. * @author Sven de Marothy (sven@physto.se)
  682. */
  683. public static final class Other
  684. {
  685. private Other()
  686. {
  687. // prevent instantiation
  688. }
  689. /**
  690. * US Executive paper size, 7.25 inch x 10.5 inch
  691. */
  692. public static final MediaSize EXECUTIVE = new MediaSize(7.25f, 10.5f,
  693. MediaSize.INCH, MediaSizeName.EXECUTIVE);
  694. /**
  695. * US Folio paper size, 8.5 inch x 13 inch
  696. */
  697. public static final MediaSize FOLIO = new MediaSize(8.5f, 13f, MediaSize.INCH, MediaSizeName.FOLIO);
  698. /**
  699. * US Quarto paper size, 8.5 inches by 10.83 inches.
  700. */
  701. public static final MediaSize QUARTO = new MediaSize(8.5f, 10.83f, MediaSize.INCH,
  702. MediaSizeName.QUARTO);
  703. /**
  704. * US Invoice size, 5.5 inch x 8.5 inch
  705. */
  706. public static final MediaSize INVOICE = new MediaSize(5.5f, 8.5f,
  707. MediaSize.INCH, MediaSizeName.INVOICE);
  708. /**
  709. * US Ledger size, 11 inch x 17 inch
  710. */
  711. public static final MediaSize LEDGER = new MediaSize(11, 17, MediaSize.INCH,
  712. MediaSizeName.LEDGER);
  713. /**
  714. * Monarch (7 3/4) envelope size, 3.87 inch x 7.5 inch
  715. */
  716. public static final MediaSize MONARCH_ENVELOPE = new MediaSize(3.87f, 7.5f,
  717. MediaSize.INCH,
  718. MediaSizeName.MONARCH_ENVELOPE);
  719. /**
  720. * Personal envelope size, 3.625 inch x 6.5 inch.
  721. */
  722. public static final MediaSize PERSONAL_ENVELOPE = new MediaSize(3.625f, 6.5f, MediaSize.INCH,
  723. MediaSizeName.PERSONAL_ENVELOPE);
  724. /**
  725. * Italian envelope size, 110 mm x 230 mm
  726. */
  727. public static final MediaSize ITALY_ENVELOPE = new MediaSize(110, 230,
  728. MediaSize.MM,
  729. MediaSizeName.ITALY_ENVELOPE);
  730. /**
  731. * Japanese postcard, 100 mm x 148 mm
  732. */
  733. public static final MediaSize JAPANESE_POSTCARD = new MediaSize(100, 148, MediaSize.MM, MediaSizeName.JAPANESE_POSTCARD);
  734. /**
  735. * Japanese double postcard, 148 mm x 200 mm
  736. */
  737. public static final MediaSize JAPANESE_DOUBLE_POSTCARD = new MediaSize(148, 200, MediaSize.MM, MediaSizeName.JAPANESE_DOUBLE_POSTCARD);
  738. /**
  739. * Tabloid size, 11 inch x 17 inch.
  740. * @since 1.5
  741. */
  742. public static final MediaSize TABLOID =
  743. new MediaSize(11, 17, Size2DSyntax.INCH, MediaSizeName.TABLOID);
  744. }
  745. }