001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * PageSize.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.util;
030:
031: /**
032: * A class defining a page-dimension.
033: *
034: * @author Thomas Morgner
035: */
036: public final class PageSize {
037: /**
038: * A standard paper size.
039: */
040: public static final PageSize PAPER11X17 = new PageSize(792, 1224);
041:
042: /**
043: * A standard paper size.
044: */
045: public static final PageSize PAPER10X11 = new PageSize(720, 792);
046:
047: /**
048: * A standard paper size.
049: */
050: public static final PageSize PAPER10X13 = new PageSize(720, 936);
051:
052: /**
053: * A standard paper size.
054: */
055: public static final PageSize PAPER10X14 = new PageSize(720, 1008);
056:
057: /**
058: * A standard paper size.
059: */
060: public static final PageSize PAPER12X11 = new PageSize(864, 792);
061:
062: /**
063: * A standard paper size.
064: */
065: public static final PageSize PAPER15X11 = new PageSize(1080, 792);
066:
067: /**
068: * A standard paper size.
069: */
070: public static final PageSize PAPER7X9 = new PageSize(504, 648);
071:
072: /**
073: * A standard paper size.
074: */
075: public static final PageSize PAPER8X10 = new PageSize(576, 720);
076:
077: /**
078: * A standard paper size.
079: */
080: public static final PageSize PAPER9X11 = new PageSize(648, 792);
081:
082: /**
083: * A standard paper size.
084: */
085: public static final PageSize PAPER9X12 = new PageSize(648, 864);
086:
087: /**
088: * A standard paper size.
089: */
090: public static final PageSize A0 = new PageSize(2384, 3370);
091:
092: /**
093: * A standard paper size.
094: */
095: public static final PageSize A1 = new PageSize(1684, 2384);
096:
097: /**
098: * A standard paper size.
099: */
100: public static final PageSize A2 = new PageSize(1191, 1684);
101:
102: /**
103: * A standard paper size.
104: */
105: public static final PageSize A3 = new PageSize(842, 1191);
106:
107: /**
108: * A standard paper size.
109: */
110: public static final PageSize A3_TRANSVERSE = new PageSize(842, 1191);
111:
112: /**
113: * A standard paper size.
114: */
115: public static final PageSize A3_EXTRA = new PageSize(913, 1262);
116:
117: /**
118: * A standard paper size.
119: */
120: public static final PageSize A3_EXTRATRANSVERSE = new PageSize(913,
121: 1262);
122:
123: /**
124: * A standard paper size.
125: */
126: public static final PageSize A3_ROTATED = new PageSize(1191, 842);
127:
128: /**
129: * A standard paper size.
130: */
131: public static final PageSize A4 = new PageSize(595, 842);
132:
133: /**
134: * A standard paper size.
135: */
136: public static final PageSize A4_TRANSVERSE = new PageSize(595, 842);
137:
138: /**
139: * A standard paper size.
140: */
141: public static final PageSize A4_EXTRA = new PageSize(667, 914);
142:
143: /**
144: * A standard paper size.
145: */
146: public static final PageSize A4_PLUS = new PageSize(595, 936);
147:
148: /**
149: * A standard paper size.
150: */
151: public static final PageSize A4_ROTATED = new PageSize(842, 595);
152:
153: /**
154: * A standard paper size.
155: */
156: public static final PageSize A4_SMALL = new PageSize(595, 842);
157:
158: /**
159: * A standard paper size.
160: */
161: public static final PageSize A5 = new PageSize(420, 595);
162:
163: /**
164: * A standard paper size.
165: */
166: public static final PageSize A5_TRANSVERSE = new PageSize(420, 595);
167:
168: /**
169: * A standard paper size.
170: */
171: public static final PageSize A5_EXTRA = new PageSize(492, 668);
172:
173: /**
174: * A standard paper size.
175: */
176: public static final PageSize A5_ROTATED = new PageSize(595, 420);
177:
178: /**
179: * A standard paper size.
180: */
181: public static final PageSize A6 = new PageSize(297, 420);
182:
183: /**
184: * A standard paper size.
185: */
186: public static final PageSize A6_ROTATED = new PageSize(420, 297);
187:
188: /**
189: * A standard paper size.
190: */
191: public static final PageSize A7 = new PageSize(210, 297);
192:
193: /**
194: * A standard paper size.
195: */
196: public static final PageSize A8 = new PageSize(148, 210);
197:
198: /**
199: * A standard paper size.
200: */
201: public static final PageSize A9 = new PageSize(105, 148);
202:
203: /**
204: * A standard paper size.
205: */
206: public static final PageSize A10 = new PageSize(73, 105);
207:
208: /**
209: * A standard paper size.
210: */
211: public static final PageSize ANSIC = new PageSize(1224, 1584);
212:
213: /**
214: * A standard paper size.
215: */
216: public static final PageSize ANSID = new PageSize(1584, 2448);
217:
218: /**
219: * A standard paper size.
220: */
221: public static final PageSize ANSIE = new PageSize(2448, 3168);
222:
223: /**
224: * A standard paper size.
225: */
226: public static final PageSize ARCHA = new PageSize(648, 864);
227:
228: /**
229: * A standard paper size.
230: */
231: public static final PageSize ARCHB = new PageSize(864, 1296);
232:
233: /**
234: * A standard paper size.
235: */
236: public static final PageSize ARCHC = new PageSize(1296, 1728);
237:
238: /**
239: * A standard paper size.
240: */
241: public static final PageSize ARCHD = new PageSize(1728, 2592);
242:
243: /**
244: * A standard paper size.
245: */
246: public static final PageSize ARCHE = new PageSize(2592, 3456);
247:
248: /**
249: * A standard paper size.
250: */
251: public static final PageSize B0 = new PageSize(2920, 4127);
252:
253: /**
254: * A standard paper size.
255: */
256: public static final PageSize B1 = new PageSize(2064, 2920);
257:
258: /**
259: * A standard paper size.
260: */
261: public static final PageSize B2 = new PageSize(1460, 2064);
262:
263: /**
264: * A standard paper size.
265: */
266: public static final PageSize B3 = new PageSize(1032, 1460);
267:
268: /**
269: * A standard paper size.
270: */
271: public static final PageSize B4 = new PageSize(729, 1032);
272:
273: /**
274: * A standard paper size.
275: */
276: public static final PageSize B4_ROTATED = new PageSize(1032, 729);
277:
278: /**
279: * A standard paper size.
280: */
281: public static final PageSize B5 = new PageSize(516, 729);
282:
283: /**
284: * A standard paper size.
285: */
286: public static final PageSize B5_TRANSVERSE = new PageSize(516, 729);
287:
288: /**
289: * A standard paper size.
290: */
291: public static final PageSize B5_ROTATED = new PageSize(729, 516);
292:
293: /**
294: * A standard paper size.
295: */
296: public static final PageSize B6 = new PageSize(363, 516);
297:
298: /**
299: * A standard paper size.
300: */
301: public static final PageSize B6_ROTATED = new PageSize(516, 363);
302:
303: /**
304: * A standard paper size.
305: */
306: public static final PageSize B7 = new PageSize(258, 363);
307:
308: /**
309: * A standard paper size.
310: */
311: public static final PageSize B8 = new PageSize(181, 258);
312:
313: /**
314: * A standard paper size.
315: */
316: public static final PageSize B9 = new PageSize(127, 181);
317:
318: /**
319: * A standard paper size.
320: */
321: public static final PageSize B10 = new PageSize(91, 127);
322:
323: /**
324: * A standard paper size.
325: */
326: public static final PageSize C4 = new PageSize(649, 918);
327:
328: /**
329: * A standard paper size.
330: */
331: public static final PageSize C5 = new PageSize(459, 649);
332:
333: /**
334: * A standard paper size.
335: */
336: public static final PageSize C6 = new PageSize(323, 459);
337:
338: /**
339: * A standard paper size.
340: */
341: public static final PageSize COMM10 = new PageSize(297, 684);
342:
343: /**
344: * A standard paper size.
345: */
346: public static final PageSize DL = new PageSize(312, 624);
347:
348: /**
349: * A standard paper size.
350: */
351: public static final PageSize DOUBLEPOSTCARD = new PageSize(567, 419); // should be 419.5, but I ignore that..
352:
353: /**
354: * A standard paper size.
355: */
356: public static final PageSize DOUBLEPOSTCARD_ROTATED = new PageSize(
357: 419, 567);
358:
359: /**
360: * A standard paper size.
361: */
362: public static final PageSize ENV9 = new PageSize(279, 639);
363:
364: /**
365: * A standard paper size.
366: */
367: public static final PageSize ENV10 = new PageSize(297, 684);
368:
369: /**
370: * A standard paper size.
371: */
372: public static final PageSize ENV11 = new PageSize(324, 747);
373:
374: /**
375: * A standard paper size.
376: */
377: public static final PageSize ENV12 = new PageSize(342, 792);
378:
379: /**
380: * A standard paper size.
381: */
382: public static final PageSize ENV14 = new PageSize(360, 828);
383:
384: /**
385: * A standard paper size.
386: */
387: public static final PageSize ENVC0 = new PageSize(2599, 3676);
388:
389: /**
390: * A standard paper size.
391: */
392: public static final PageSize ENVC1 = new PageSize(1837, 2599);
393:
394: /**
395: * A standard paper size.
396: */
397: public static final PageSize ENVC2 = new PageSize(1298, 1837);
398:
399: /**
400: * A standard paper size.
401: */
402: public static final PageSize ENVC3 = new PageSize(918, 1296);
403:
404: /**
405: * A standard paper size.
406: */
407: public static final PageSize ENVC4 = new PageSize(649, 918);
408:
409: /**
410: * A standard paper size.
411: */
412: public static final PageSize ENVC5 = new PageSize(459, 649);
413:
414: /**
415: * A standard paper size.
416: */
417: public static final PageSize ENVC6 = new PageSize(323, 459);
418:
419: /**
420: * A standard paper size.
421: */
422: public static final PageSize ENVC65 = new PageSize(324, 648);
423:
424: /**
425: * A standard paper size.
426: */
427: public static final PageSize ENVC7 = new PageSize(230, 323);
428:
429: /**
430: * A standard paper size.
431: */
432: public static final PageSize ENVCHOU3 = new PageSize(340, 666);
433:
434: /**
435: * A standard paper size.
436: */
437: public static final PageSize ENVCHOU3_ROTATED = new PageSize(666,
438: 340);
439:
440: /**
441: * A standard paper size.
442: */
443: public static final PageSize ENVCHOU4 = new PageSize(255, 581);
444:
445: /**
446: * A standard paper size.
447: */
448: public static final PageSize ENVCHOU4_ROTATED = new PageSize(581,
449: 255);
450:
451: /**
452: * A standard paper size.
453: */
454: public static final PageSize ENVDL = new PageSize(312, 624);
455:
456: /**
457: * A standard paper size.
458: */
459: public static final PageSize ENVINVITE = new PageSize(624, 624);
460:
461: /**
462: * A standard paper size.
463: */
464: public static final PageSize ENVISOB4 = new PageSize(708, 1001);
465:
466: /**
467: * A standard paper size.
468: */
469: public static final PageSize ENVISOB5 = new PageSize(499, 709);
470:
471: /**
472: * A standard paper size.
473: */
474: public static final PageSize ENVISOB6 = new PageSize(499, 354);
475:
476: /**
477: * A standard paper size.
478: */
479: public static final PageSize ENVITALIAN = new PageSize(312, 652);
480:
481: /**
482: * A standard paper size.
483: */
484: public static final PageSize ENVELOPE = new PageSize(312, 652);
485:
486: /**
487: * A standard paper size.
488: */
489: public static final PageSize ENVKAKU2 = new PageSize(680, 941);
490:
491: /**
492: * A standard paper size.
493: */
494: public static final PageSize ENVKAKU2_ROTATED = new PageSize(941,
495: 680);
496:
497: /**
498: * A standard paper size.
499: */
500: public static final PageSize ENVKAKU3 = new PageSize(612, 785);
501:
502: /**
503: * A standard paper size.
504: */
505: public static final PageSize ENVKAKU3_ROTATED = new PageSize(785,
506: 612);
507:
508: /**
509: * A standard paper size.
510: */
511: public static final PageSize ENVMONARCH = new PageSize(279, 540);
512:
513: /**
514: * A standard paper size.
515: */
516: public static final PageSize ENVPERSONAL = new PageSize(261, 468);
517:
518: /**
519: * A standard paper size.
520: */
521: public static final PageSize ENVPRC1 = new PageSize(289, 468);
522:
523: /**
524: * A standard paper size.
525: */
526: public static final PageSize ENVPRC1_ROTATED = new PageSize(468,
527: 289);
528:
529: /**
530: * A standard paper size.
531: */
532: public static final PageSize ENVPRC2 = new PageSize(289, 499);
533:
534: /**
535: * A standard paper size.
536: */
537: public static final PageSize ENVPRC2_ROTATED = new PageSize(499,
538: 289);
539:
540: /**
541: * A standard paper size.
542: */
543: public static final PageSize ENVPRC3 = new PageSize(354, 499);
544:
545: /**
546: * A standard paper size.
547: */
548: public static final PageSize ENVPRC3_ROTATED = new PageSize(499,
549: 354);
550:
551: /**
552: * A standard paper size.
553: */
554: public static final PageSize ENVPRC4 = new PageSize(312, 590);
555:
556: /**
557: * A standard paper size.
558: */
559: public static final PageSize ENVPRC4_ROTATED = new PageSize(590,
560: 312);
561:
562: /**
563: * A standard paper size.
564: */
565: public static final PageSize ENVPRC5 = new PageSize(312, 624);
566:
567: /**
568: * A standard paper size.
569: */
570: public static final PageSize ENVPRC5_ROTATED = new PageSize(624,
571: 312);
572:
573: /**
574: * A standard paper size.
575: */
576: public static final PageSize ENVPRC6 = new PageSize(340, 652);
577:
578: /**
579: * A standard paper size.
580: */
581: public static final PageSize ENVPRC6_ROTATED = new PageSize(652,
582: 340);
583:
584: /**
585: * A standard paper size.
586: */
587: public static final PageSize ENVPRC7 = new PageSize(454, 652);
588:
589: /**
590: * A standard paper size.
591: */
592: public static final PageSize ENVPRC7_ROTATED = new PageSize(652,
593: 454);
594:
595: /**
596: * A standard paper size.
597: */
598: public static final PageSize ENVPRC8 = new PageSize(340, 876);
599:
600: /**
601: * A standard paper size.
602: */
603: public static final PageSize ENVPRC8_ROTATED = new PageSize(876,
604: 340);
605:
606: /**
607: * A standard paper size.
608: */
609: public static final PageSize ENVPRC9 = new PageSize(649, 918);
610:
611: /**
612: * A standard paper size.
613: */
614: public static final PageSize ENVPRC9_ROTATED = new PageSize(918,
615: 649);
616:
617: /**
618: * A standard paper size.
619: */
620: public static final PageSize ENVPRC10 = new PageSize(918, 1298);
621:
622: /**
623: * A standard paper size.
624: */
625: public static final PageSize ENVPRC10_ROTATED = new PageSize(1298,
626: 918);
627:
628: /**
629: * A standard paper size.
630: */
631: public static final PageSize ENVYOU4 = new PageSize(298, 666);
632:
633: /**
634: * A standard paper size.
635: */
636: public static final PageSize ENVYOU4_ROTATED = new PageSize(666,
637: 298);
638:
639: /**
640: * A standard paper size.
641: */
642: public static final PageSize EXECUTIVE = new PageSize(522, 756);
643:
644: /**
645: * A standard paper size.
646: */
647: public static final PageSize FANFOLDUS = new PageSize(1071, 792);
648:
649: /**
650: * A standard paper size.
651: */
652: public static final PageSize FANFOLDGERMAN = new PageSize(612, 864);
653:
654: /**
655: * A standard paper size.
656: */
657: public static final PageSize FANFOLDGERMANLEGAL = new PageSize(612,
658: 936);
659:
660: /**
661: * A standard paper size.
662: */
663: public static final PageSize FOLIO = new PageSize(595, 935);
664:
665: /**
666: * A standard paper size.
667: */
668: public static final PageSize ISOB0 = new PageSize(2835, 4008);
669:
670: /**
671: * A standard paper size.
672: */
673: public static final PageSize ISOB1 = new PageSize(2004, 2835);
674:
675: /**
676: * A standard paper size.
677: */
678: public static final PageSize ISOB2 = new PageSize(1417, 2004);
679:
680: /**
681: * A standard paper size.
682: */
683: public static final PageSize ISOB3 = new PageSize(1001, 1417);
684:
685: /**
686: * A standard paper size.
687: */
688: public static final PageSize ISOB4 = new PageSize(709, 1001);
689:
690: /**
691: * A standard paper size.
692: */
693: public static final PageSize ISOB5 = new PageSize(499, 709);
694:
695: /**
696: * A standard paper size.
697: */
698: public static final PageSize ISOB5_EXTRA = new PageSize(570, 782);
699:
700: /**
701: * A standard paper size.
702: */
703: public static final PageSize ISOB6 = new PageSize(354, 499);
704:
705: /**
706: * A standard paper size.
707: */
708: public static final PageSize ISOB7 = new PageSize(249, 354);
709:
710: /**
711: * A standard paper size.
712: */
713: public static final PageSize ISOB8 = new PageSize(176, 249);
714:
715: /**
716: * A standard paper size.
717: */
718: public static final PageSize ISOB9 = new PageSize(125, 176);
719:
720: /**
721: * A standard paper size.
722: */
723: public static final PageSize ISOB10 = new PageSize(88, 125);
724:
725: /**
726: * A standard paper size.
727: */
728: public static final PageSize LEDGER = new PageSize(1224, 792);
729:
730: /**
731: * A standard paper size.
732: */
733: public static final PageSize LEGAL = new PageSize(612, 1008);
734:
735: /**
736: * A standard paper size.
737: */
738: public static final PageSize LEGAL_EXTRA = new PageSize(684, 1080);
739:
740: /**
741: * A standard paper size.
742: */
743: public static final PageSize LETTER = new PageSize(612, 792);
744:
745: /**
746: * A standard paper size.
747: */
748: public static final PageSize LETTER_TRANSVERSE = new PageSize(612,
749: 792);
750:
751: /**
752: * A standard paper size.
753: */
754: public static final PageSize LETTER_EXTRA = new PageSize(684, 864);
755:
756: /**
757: * A standard paper size.
758: */
759: public static final PageSize LETTER_EXTRATRANSVERSE = new PageSize(
760: 684, 864);
761:
762: /**
763: * A standard paper size.
764: */
765: public static final PageSize LETTER_PLUS = new PageSize(612, 914);
766:
767: /**
768: * A standard paper size.
769: */
770: public static final PageSize LETTER_ROTATED = new PageSize(792, 612);
771:
772: /**
773: * A standard paper size.
774: */
775: public static final PageSize LETTER_SMALL = new PageSize(612, 792);
776:
777: /**
778: * A standard paper size.
779: */
780: public static final PageSize MONARCH = ENVMONARCH;
781:
782: /**
783: * A standard paper size.
784: */
785: public static final PageSize NOTE = new PageSize(612, 792);
786:
787: /**
788: * A standard paper size.
789: */
790: public static final PageSize POSTCARD = new PageSize(284, 419);
791:
792: /**
793: * A standard paper size.
794: */
795: public static final PageSize POSTCARD_ROTATED = new PageSize(419,
796: 284);
797:
798: /**
799: * A standard paper size.
800: */
801: public static final PageSize PRC16K = new PageSize(414, 610);
802:
803: /**
804: * A standard paper size.
805: */
806: public static final PageSize PRC16K_ROTATED = new PageSize(610, 414);
807:
808: /**
809: * A standard paper size.
810: */
811: public static final PageSize PRC32K = new PageSize(275, 428);
812:
813: /**
814: * A standard paper size.
815: */
816: public static final PageSize PRC32K_ROTATED = new PageSize(428, 275);
817:
818: /**
819: * A standard paper size.
820: */
821: public static final PageSize PRC32K_BIG = new PageSize(275, 428);
822:
823: /**
824: * A standard paper size.
825: */
826: public static final PageSize PRC32K_BIGROTATED = new PageSize(428,
827: 275);
828:
829: /**
830: * A standard paper size.
831: */
832: public static final PageSize QUARTO = new PageSize(610, 780);
833:
834: /**
835: * A standard paper size.
836: */
837: public static final PageSize STATEMENT = new PageSize(396, 612);
838:
839: /**
840: * A standard paper size.
841: */
842: public static final PageSize SUPERA = new PageSize(643, 1009);
843:
844: /**
845: * A standard paper size.
846: */
847: public static final PageSize SUPERB = new PageSize(864, 1380);
848:
849: /**
850: * A standard paper size.
851: */
852: public static final PageSize TABLOID = new PageSize(792, 1224);
853:
854: /**
855: * A standard paper size.
856: */
857: public static final PageSize TABLOIDEXTRA = new PageSize(864, 1296);
858:
859: /**
860: * The width of the page in point.
861: */
862: private double width;
863: /**
864: * The height of the page in point.
865: */
866: private double height;
867:
868: /**
869: * Creates a new page-size object with the given width and height.
870: *
871: * @param width the width in point.
872: * @param height the height in point.
873: */
874: public PageSize(final double width, final double height) {
875: this .width = width;
876: this .height = height;
877: }
878:
879: /**
880: * Returns the page's width.
881: *
882: * @return the width in point.
883: */
884: public double getWidth() {
885: return width;
886: }
887:
888: /**
889: * Returns the page's height.
890: *
891: * @return the height in point.
892: */
893: public double getHeight() {
894: return height;
895: }
896:
897: /**
898: * Compares this page size with the given object.
899: *
900: * @param o the other object.
901: * @return true, if the given object is also a PageSize object and has the same width and height, false otherwise.
902: */
903: public boolean equals(final Object o) {
904: if (this == o) {
905: return true;
906: }
907: if (o == null || getClass() != o.getClass()) {
908: return false;
909: }
910:
911: final PageSize pageSize = (PageSize) o;
912:
913: if (equal(pageSize.height, height) == false) {
914: return false;
915: }
916: if (equal(pageSize.width, width) == false) {
917: return false;
918: }
919:
920: return true;
921: }
922:
923: /**
924: * An internal helper method that compares two doubles for equality.
925: * @param d1 the one double.
926: * @param d2 the other double.
927: * @return true, if both doubles are binary equal, false otherwise.
928: */
929: private boolean equal(final double d1, final double d2) {
930: return Double.doubleToLongBits(d1) == Double
931: .doubleToLongBits(d2);
932: }
933:
934: /**
935: * Computes a hashcode for this page-size.
936: *
937: * @return the hashcode.
938: */
939: public int hashCode() {
940: long temp = width != +0.0d ? Double.doubleToLongBits(width)
941: : 0L;
942: int result = (int) (temp ^ (temp >>> 32));
943: temp = height != +0.0d ? Double.doubleToLongBits(height) : 0L;
944: result = 29 * result + (int) (temp ^ (temp >>> 32));
945: return result;
946: }
947: }
|