Source Code Cross Referenced for PageFormatFactory.java in  » Report » pentaho-report » org » jfree » report » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » pentaho report » org.jfree.report.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /**
0002:         * ===========================================
0003:         * JFreeReport : a free Java reporting library
0004:         * ===========================================
0005:         *
0006:         * Project Info:  http://reporting.pentaho.org/
0007:         *
0008:         * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
0009:         *
0010:         * This library is free software; you can redistribute it and/or modify it under the terms
0011:         * of the GNU Lesser General Public License as published by the Free Software Foundation;
0012:         * either version 2.1 of the License, or (at your option) any later version.
0013:         *
0014:         * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
0015:         * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0016:         * See the GNU Lesser General Public License for more details.
0017:         *
0018:         * You should have received a copy of the GNU Lesser General Public License along with this
0019:         * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
0020:         * Boston, MA 02111-1307, USA.
0021:         *
0022:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
0023:         * in the United States and other countries.]
0024:         *
0025:         * ------------
0026:         * PageFormatFactory.java
0027:         * ------------
0028:         * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
0029:         */package org.jfree.report.util;
0030:
0031:        import java.awt.Insets;
0032:        import java.awt.print.PageFormat;
0033:        import java.awt.print.Paper;
0034:        import java.lang.reflect.Field;
0035:
0036:        import org.jfree.util.Log;
0037:
0038:        /**
0039:         * The PageFormatFactory is used to create PageFormats on a higher level. The Factory contains templates for all
0040:         * PageSizes defined by Adobe:
0041:         * <p/>
0042:         * <a href="http://partners.adobe.com/asn/developer/pdfs/tn/5003.PPD_Spec_v4.3.pdf" >Postscript Specifications</a>
0043:         * <p/>
0044:         * Usage for creating an printjob on A4 paper with 2.5 cm border:
0045:         * <pre>
0046:         * Paper paper = PageFormatFactory.createPaper (PageSize.A4);
0047:         * PageFormatFactory.setBordersMm (paper, 25, 25, 25, 25);
0048:         * PageFormat format = PageFormatFactory.createPageFormat (paper, PageFormat.PORTRAIT);
0049:         * </code>
0050:         * <p/>
0051:         * Defining a pageformat can be an ugly task and full of dependencies. The call to
0052:         * PageFormatFactory.setBorders(...) will setup the paper's border and always assumes
0053:         * that the paper is laid out in Portrait.
0054:         * <p/>
0055:         * Changing the PageFormat's orientation does not change the PageFormat's paper object,
0056:         * but it changes the way, how the paper object is interpreted.
0057:         *
0058:         * @author Thomas Morgner
0059:         */
0060:        public final class PageFormatFactory {
0061:
0062:            /**
0063:             * Constant for dots per inch.
0064:             *
0065:             * @deprecated Not used anywhere.
0066:             */
0067:            public static final int DOTS_PER_INCH = 72;
0068:
0069:            /**
0070:             * A standard paper size.
0071:             *
0072:             * @deprecated Using public static arrays is dangerous.
0073:             */
0074:            public static final int[] PAPER11X17 = { 792, 1224 };
0075:
0076:            /**
0077:             * A standard paper size.
0078:             *
0079:             * @deprecated Using public static arrays is dangerous.
0080:             */
0081:            public static final int[] PAPER10X11 = { 720, 792 };
0082:
0083:            /**
0084:             * A standard paper size.
0085:             *
0086:             * @deprecated Using public static arrays is dangerous.
0087:             */
0088:            public static final int[] PAPER10X13 = { 720, 936 };
0089:
0090:            /**
0091:             * A standard paper size.
0092:             *
0093:             * @deprecated Using public static arrays is dangerous.
0094:             */
0095:            public static final int[] PAPER10X14 = { 720, 1008 };
0096:
0097:            /**
0098:             * A standard paper size.
0099:             *
0100:             * @deprecated Using public static arrays is dangerous.
0101:             */
0102:            public static final int[] PAPER12X11 = { 864, 792 };
0103:
0104:            /**
0105:             * A standard paper size.
0106:             *
0107:             * @deprecated Using public static arrays is dangerous.
0108:             */
0109:            public static final int[] PAPER15X11 = { 1080, 792 };
0110:
0111:            /**
0112:             * A standard paper size.
0113:             *
0114:             * @deprecated Using public static arrays is dangerous.
0115:             */
0116:            public static final int[] PAPER7X9 = { 504, 648 };
0117:
0118:            /**
0119:             * A standard paper size.
0120:             *
0121:             * @deprecated Using public static arrays is dangerous.
0122:             */
0123:            public static final int[] PAPER8X10 = { 576, 720 };
0124:
0125:            /**
0126:             * A standard paper size.
0127:             *
0128:             * @deprecated Using public static arrays is dangerous.
0129:             */
0130:            public static final int[] PAPER9X11 = { 648, 792 };
0131:
0132:            /**
0133:             * A standard paper size.
0134:             *
0135:             * @deprecated Using public static arrays is dangerous.
0136:             */
0137:            public static final int[] PAPER9X12 = { 648, 864 };
0138:
0139:            /**
0140:             * A standard paper size.
0141:             *
0142:             * @deprecated Using public static arrays is dangerous.
0143:             */
0144:            public static final int[] A0 = { 2384, 3370 };
0145:
0146:            /**
0147:             * A standard paper size.
0148:             *
0149:             * @deprecated Using public static arrays is dangerous.
0150:             */
0151:            public static final int[] A1 = { 1684, 2384 };
0152:
0153:            /**
0154:             * A standard paper size.
0155:             *
0156:             * @deprecated Using public static arrays is dangerous.
0157:             */
0158:            public static final int[] A2 = { 1191, 1684 };
0159:
0160:            /**
0161:             * A standard paper size.
0162:             *
0163:             * @deprecated Using public static arrays is dangerous.
0164:             */
0165:            public static final int[] A3 = { 842, 1191 };
0166:
0167:            /**
0168:             * A standard paper size.
0169:             *
0170:             * @deprecated Using public static arrays is dangerous.
0171:             */
0172:            public static final int[] A3_TRANSVERSE = { 842, 1191 };
0173:
0174:            /**
0175:             * A standard paper size.
0176:             *
0177:             * @deprecated Using public static arrays is dangerous.
0178:             */
0179:            public static final int[] A3_EXTRA = { 913, 1262 };
0180:
0181:            /**
0182:             * A standard paper size.
0183:             *
0184:             * @deprecated Using public static arrays is dangerous.
0185:             */
0186:            public static final int[] A3_EXTRATRANSVERSE = { 913, 1262 };
0187:
0188:            /**
0189:             * A standard paper size.
0190:             *
0191:             * @deprecated Using public static arrays is dangerous.
0192:             */
0193:            public static final int[] A3_ROTATED = { 1191, 842 };
0194:
0195:            /**
0196:             * A standard paper size.
0197:             *
0198:             * @deprecated Using public static arrays is dangerous.
0199:             */
0200:            public static final int[] A4 = { 595, 842 };
0201:
0202:            /**
0203:             * A standard paper size.
0204:             *
0205:             * @deprecated Using public static arrays is dangerous.
0206:             */
0207:            public static final int[] A4_TRANSVERSE = { 595, 842 };
0208:
0209:            /**
0210:             * A standard paper size.
0211:             *
0212:             * @deprecated Using public static arrays is dangerous.
0213:             */
0214:            public static final int[] A4_EXTRA = { 667, 914 };
0215:
0216:            /**
0217:             * A standard paper size.
0218:             *
0219:             * @deprecated Using public static arrays is dangerous.
0220:             */
0221:            public static final int[] A4_PLUS = { 595, 936 };
0222:
0223:            /**
0224:             * A standard paper size.
0225:             *
0226:             * @deprecated Using public static arrays is dangerous.
0227:             */
0228:            public static final int[] A4_ROTATED = { 842, 595 };
0229:
0230:            /**
0231:             * A standard paper size.
0232:             *
0233:             * @deprecated Using public static arrays is dangerous.
0234:             */
0235:            public static final int[] A4_SMALL = { 595, 842 };
0236:
0237:            /**
0238:             * A standard paper size.
0239:             *
0240:             * @deprecated Using public static arrays is dangerous.
0241:             */
0242:            public static final int[] A5 = { 420, 595 };
0243:
0244:            /**
0245:             * A standard paper size.
0246:             *
0247:             * @deprecated Using public static arrays is dangerous.
0248:             */
0249:            public static final int[] A5_TRANSVERSE = { 420, 595 };
0250:
0251:            /**
0252:             * A standard paper size.
0253:             *
0254:             * @deprecated Using public static arrays is dangerous.
0255:             */
0256:            public static final int[] A5_EXTRA = { 492, 668 };
0257:
0258:            /**
0259:             * A standard paper size.
0260:             *
0261:             * @deprecated Using public static arrays is dangerous.
0262:             */
0263:            public static final int[] A5_ROTATED = { 595, 420 };
0264:
0265:            /**
0266:             * A standard paper size.
0267:             *
0268:             * @deprecated Using public static arrays is dangerous.
0269:             */
0270:            public static final int[] A6 = { 297, 420 };
0271:
0272:            /**
0273:             * A standard paper size.
0274:             *
0275:             * @deprecated Using public static arrays is dangerous.
0276:             */
0277:            public static final int[] A6_ROTATED = { 420, 297 };
0278:
0279:            /**
0280:             * A standard paper size.
0281:             *
0282:             * @deprecated Using public static arrays is dangerous.
0283:             */
0284:            public static final int[] A7 = { 210, 297 };
0285:
0286:            /**
0287:             * A standard paper size.
0288:             *
0289:             * @deprecated Using public static arrays is dangerous.
0290:             */
0291:            public static final int[] A8 = { 148, 210 };
0292:
0293:            /**
0294:             * A standard paper size.
0295:             *
0296:             * @deprecated Using public static arrays is dangerous.
0297:             */
0298:            public static final int[] A9 = { 105, 148 };
0299:
0300:            /**
0301:             * A standard paper size.
0302:             *
0303:             * @deprecated Using public static arrays is dangerous.
0304:             */
0305:            public static final int[] A10 = { 73, 105 };
0306:
0307:            /**
0308:             * A standard paper size.
0309:             *
0310:             * @deprecated Using public static arrays is dangerous.
0311:             */
0312:            public static final int[] ANSIC = { 1224, 1584 };
0313:
0314:            /**
0315:             * A standard paper size.
0316:             *
0317:             * @deprecated Using public static arrays is dangerous.
0318:             */
0319:            public static final int[] ANSID = { 1584, 2448 };
0320:
0321:            /**
0322:             * A standard paper size.
0323:             *
0324:             * @deprecated Using public static arrays is dangerous.
0325:             */
0326:            public static final int[] ANSIE = { 2448, 3168 };
0327:
0328:            /**
0329:             * A standard paper size.
0330:             *
0331:             * @deprecated Using public static arrays is dangerous.
0332:             */
0333:            public static final int[] ARCHA = { 648, 864 };
0334:
0335:            /**
0336:             * A standard paper size.
0337:             *
0338:             * @deprecated Using public static arrays is dangerous.
0339:             */
0340:            public static final int[] ARCHB = { 864, 1296 };
0341:
0342:            /**
0343:             * A standard paper size.
0344:             *
0345:             * @deprecated Using public static arrays is dangerous.
0346:             */
0347:            public static final int[] ARCHC = { 1296, 1728 };
0348:
0349:            /**
0350:             * A standard paper size.
0351:             *
0352:             * @deprecated Using public static arrays is dangerous.
0353:             */
0354:            public static final int[] ARCHD = { 1728, 2592 };
0355:
0356:            /**
0357:             * A standard paper size.
0358:             *
0359:             * @deprecated Using public static arrays is dangerous.
0360:             */
0361:            public static final int[] ARCHE = { 2592, 3456 };
0362:
0363:            /**
0364:             * A standard paper size.
0365:             *
0366:             * @deprecated Using public static arrays is dangerous.
0367:             */
0368:            public static final int[] B0 = { 2920, 4127 };
0369:
0370:            /**
0371:             * A standard paper size.
0372:             *
0373:             * @deprecated Using public static arrays is dangerous.
0374:             */
0375:            public static final int[] B1 = { 2064, 2920 };
0376:
0377:            /**
0378:             * A standard paper size.
0379:             *
0380:             * @deprecated Using public static arrays is dangerous.
0381:             */
0382:            public static final int[] B2 = { 1460, 2064 };
0383:
0384:            /**
0385:             * A standard paper size.
0386:             *
0387:             * @deprecated Using public static arrays is dangerous.
0388:             */
0389:            public static final int[] B3 = { 1032, 1460 };
0390:
0391:            /**
0392:             * A standard paper size.
0393:             *
0394:             * @deprecated Using public static arrays is dangerous.
0395:             */
0396:            public static final int[] B4 = { 729, 1032 };
0397:
0398:            /**
0399:             * A standard paper size.
0400:             *
0401:             * @deprecated Using public static arrays is dangerous.
0402:             */
0403:            public static final int[] B4_ROTATED = { 1032, 729 };
0404:
0405:            /**
0406:             * A standard paper size.
0407:             *
0408:             * @deprecated Using public static arrays is dangerous.
0409:             */
0410:            public static final int[] B5 = { 516, 729 };
0411:
0412:            /**
0413:             * A standard paper size.
0414:             *
0415:             * @deprecated Using public static arrays is dangerous.
0416:             */
0417:            public static final int[] B5_TRANSVERSE = { 516, 729 };
0418:
0419:            /**
0420:             * A standard paper size.
0421:             *
0422:             * @deprecated Using public static arrays is dangerous.
0423:             */
0424:            public static final int[] B5_ROTATED = { 729, 516 };
0425:
0426:            /**
0427:             * A standard paper size.
0428:             *
0429:             * @deprecated Using public static arrays is dangerous.
0430:             */
0431:            public static final int[] B6 = { 363, 516 };
0432:
0433:            /**
0434:             * A standard paper size.
0435:             *
0436:             * @deprecated Using public static arrays is dangerous.
0437:             */
0438:            public static final int[] B6_ROTATED = { 516, 363 };
0439:
0440:            /**
0441:             * A standard paper size.
0442:             *
0443:             * @deprecated Using public static arrays is dangerous.
0444:             */
0445:            public static final int[] B7 = { 258, 363 };
0446:
0447:            /**
0448:             * A standard paper size.
0449:             *
0450:             * @deprecated Using public static arrays is dangerous.
0451:             */
0452:            public static final int[] B8 = { 181, 258 };
0453:
0454:            /**
0455:             * A standard paper size.
0456:             *
0457:             * @deprecated Using public static arrays is dangerous.
0458:             */
0459:            public static final int[] B9 = { 127, 181 };
0460:
0461:            /**
0462:             * A standard paper size.
0463:             *
0464:             * @deprecated Using public static arrays is dangerous.
0465:             */
0466:            public static final int[] B10 = { 91, 127 };
0467:
0468:            /**
0469:             * A standard paper size.
0470:             *
0471:             * @deprecated Using public static arrays is dangerous.
0472:             */
0473:            public static final int[] C4 = { 649, 918 };
0474:
0475:            /**
0476:             * A standard paper size.
0477:             *
0478:             * @deprecated Using public static arrays is dangerous.
0479:             */
0480:            public static final int[] C5 = { 459, 649 };
0481:
0482:            /**
0483:             * A standard paper size.
0484:             *
0485:             * @deprecated Using public static arrays is dangerous.
0486:             */
0487:            public static final int[] C6 = { 323, 459 };
0488:
0489:            /**
0490:             * A standard paper size.
0491:             *
0492:             * @deprecated Using public static arrays is dangerous.
0493:             */
0494:            public static final int[] COMM10 = { 297, 684 };
0495:
0496:            /**
0497:             * A standard paper size.
0498:             *
0499:             * @deprecated Using public static arrays is dangerous.
0500:             */
0501:            public static final int[] DL = { 312, 624 };
0502:
0503:            /**
0504:             * A standard paper size.
0505:             *
0506:             * @deprecated Using public static arrays is dangerous.
0507:             */
0508:            public static final int[] DOUBLEPOSTCARD = { 567, 419 }; // should be 419.5, but I ignore that..
0509:
0510:            /**
0511:             * A standard paper size.
0512:             *
0513:             * @deprecated Using public static arrays is dangerous.
0514:             */
0515:            public static final int[] DOUBLEPOSTCARD_ROTATED = { 419, 567 };
0516:
0517:            /**
0518:             * A standard paper size.
0519:             *
0520:             * @deprecated Using public static arrays is dangerous.
0521:             */
0522:            public static final int[] ENV9 = { 279, 639 };
0523:
0524:            /**
0525:             * A standard paper size.
0526:             *
0527:             * @deprecated Using public static arrays is dangerous.
0528:             */
0529:            public static final int[] ENV10 = { 297, 684 };
0530:
0531:            /**
0532:             * A standard paper size.
0533:             *
0534:             * @deprecated Using public static arrays is dangerous.
0535:             */
0536:            public static final int[] ENV11 = { 324, 747 };
0537:
0538:            /**
0539:             * A standard paper size.
0540:             *
0541:             * @deprecated Using public static arrays is dangerous.
0542:             */
0543:            public static final int[] ENV12 = { 342, 792 };
0544:
0545:            /**
0546:             * A standard paper size.
0547:             *
0548:             * @deprecated Using public static arrays is dangerous.
0549:             */
0550:            public static final int[] ENV14 = { 360, 828 };
0551:
0552:            /**
0553:             * A standard paper size.
0554:             *
0555:             * @deprecated Using public static arrays is dangerous.
0556:             */
0557:            public static final int[] ENVC0 = { 2599, 3676 };
0558:
0559:            /**
0560:             * A standard paper size.
0561:             *
0562:             * @deprecated Using public static arrays is dangerous.
0563:             */
0564:            public static final int[] ENVC1 = { 1837, 2599 };
0565:
0566:            /**
0567:             * A standard paper size.
0568:             *
0569:             * @deprecated Using public static arrays is dangerous.
0570:             */
0571:            public static final int[] ENVC2 = { 1298, 1837 };
0572:
0573:            /**
0574:             * A standard paper size.
0575:             *
0576:             * @deprecated Using public static arrays is dangerous.
0577:             */
0578:            public static final int[] ENVC3 = { 918, 1296 };
0579:
0580:            /**
0581:             * A standard paper size.
0582:             *
0583:             * @deprecated Using public static arrays is dangerous.
0584:             */
0585:            public static final int[] ENVC4 = { 649, 918 };
0586:
0587:            /**
0588:             * A standard paper size.
0589:             *
0590:             * @deprecated Using public static arrays is dangerous.
0591:             */
0592:            public static final int[] ENVC5 = { 459, 649 };
0593:
0594:            /**
0595:             * A standard paper size.
0596:             *
0597:             * @deprecated Using public static arrays is dangerous.
0598:             */
0599:            public static final int[] ENVC6 = { 323, 459 };
0600:
0601:            /**
0602:             * A standard paper size.
0603:             *
0604:             * @deprecated Using public static arrays is dangerous.
0605:             */
0606:            public static final int[] ENVC65 = { 324, 648 };
0607:
0608:            /**
0609:             * A standard paper size.
0610:             *
0611:             * @deprecated Using public static arrays is dangerous.
0612:             */
0613:            public static final int[] ENVC7 = { 230, 323 };
0614:
0615:            /**
0616:             * A standard paper size.
0617:             *
0618:             * @deprecated Using public static arrays is dangerous.
0619:             */
0620:            public static final int[] ENVCHOU3 = { 340, 666 };
0621:
0622:            /**
0623:             * A standard paper size.
0624:             *
0625:             * @deprecated Using public static arrays is dangerous.
0626:             */
0627:            public static final int[] ENVCHOU3_ROTATED = { 666, 340 };
0628:
0629:            /**
0630:             * A standard paper size.
0631:             *
0632:             * @deprecated Using public static arrays is dangerous.
0633:             */
0634:            public static final int[] ENVCHOU4 = { 255, 581 };
0635:
0636:            /**
0637:             * A standard paper size.
0638:             *
0639:             * @deprecated Using public static arrays is dangerous.
0640:             */
0641:            public static final int[] ENVCHOU4_ROTATED = { 581, 255 };
0642:
0643:            /**
0644:             * A standard paper size.
0645:             *
0646:             * @deprecated Using public static arrays is dangerous.
0647:             */
0648:            public static final int[] ENVDL = { 312, 624 };
0649:
0650:            /**
0651:             * A standard paper size.
0652:             *
0653:             * @deprecated Using public static arrays is dangerous.
0654:             */
0655:            public static final int[] ENVINVITE = { 624, 624 };
0656:
0657:            /**
0658:             * A standard paper size.
0659:             *
0660:             * @deprecated Using public static arrays is dangerous.
0661:             */
0662:            public static final int[] ENVISOB4 = { 708, 1001 };
0663:
0664:            /**
0665:             * A standard paper size.
0666:             *
0667:             * @deprecated Using public static arrays is dangerous.
0668:             */
0669:            public static final int[] ENVISOB5 = { 499, 709 };
0670:
0671:            /**
0672:             * A standard paper size.
0673:             *
0674:             * @deprecated Using public static arrays is dangerous.
0675:             */
0676:            public static final int[] ENVISOB6 = { 499, 354 };
0677:
0678:            /**
0679:             * A standard paper size.
0680:             *
0681:             * @deprecated Using public static arrays is dangerous.
0682:             */
0683:            public static final int[] ENVITALIAN = { 312, 652 };
0684:
0685:            /**
0686:             * A standard paper size.
0687:             *
0688:             * @deprecated Using public static arrays is dangerous.
0689:             */
0690:            public static final int[] ENVELOPE = { 312, 652 };
0691:
0692:            /**
0693:             * A standard paper size.
0694:             *
0695:             * @deprecated Using public static arrays is dangerous.
0696:             */
0697:            public static final int[] ENVKAKU2 = { 680, 941 };
0698:
0699:            /**
0700:             * A standard paper size.
0701:             *
0702:             * @deprecated Using public static arrays is dangerous.
0703:             */
0704:            public static final int[] ENVKAKU2_ROTATED = { 941, 680 };
0705:
0706:            /**
0707:             * A standard paper size.
0708:             *
0709:             * @deprecated Using public static arrays is dangerous.
0710:             */
0711:            public static final int[] ENVKAKU3 = { 612, 785 };
0712:
0713:            /**
0714:             * A standard paper size.
0715:             *
0716:             * @deprecated Using public static arrays is dangerous.
0717:             */
0718:            public static final int[] ENVKAKU3_ROTATED = { 785, 612 };
0719:
0720:            /**
0721:             * A standard paper size.
0722:             *
0723:             * @deprecated Using public static arrays is dangerous.
0724:             */
0725:            public static final int[] ENVMONARCH = { 279, 540 };
0726:
0727:            /**
0728:             * A standard paper size.
0729:             *
0730:             * @deprecated Using public static arrays is dangerous.
0731:             */
0732:            public static final int[] ENVPERSONAL = { 261, 468 };
0733:
0734:            /**
0735:             * A standard paper size.
0736:             *
0737:             * @deprecated Using public static arrays is dangerous.
0738:             */
0739:            public static final int[] ENVPRC1 = { 289, 468 };
0740:
0741:            /**
0742:             * A standard paper size.
0743:             *
0744:             * @deprecated Using public static arrays is dangerous.
0745:             */
0746:            public static final int[] ENVPRC1_ROTATED = { 468, 289 };
0747:
0748:            /**
0749:             * A standard paper size.
0750:             *
0751:             * @deprecated Using public static arrays is dangerous.
0752:             */
0753:            public static final int[] ENVPRC2 = { 289, 499 };
0754:
0755:            /**
0756:             * A standard paper size.
0757:             *
0758:             * @deprecated Using public static arrays is dangerous.
0759:             */
0760:            public static final int[] ENVPRC2_ROTATED = { 499, 289 };
0761:
0762:            /**
0763:             * A standard paper size.
0764:             *
0765:             * @deprecated Using public static arrays is dangerous.
0766:             */
0767:            public static final int[] ENVPRC3 = { 354, 499 };
0768:
0769:            /**
0770:             * A standard paper size.
0771:             *
0772:             * @deprecated Using public static arrays is dangerous.
0773:             */
0774:            public static final int[] ENVPRC3_ROTATED = { 499, 354 };
0775:
0776:            /**
0777:             * A standard paper size.
0778:             *
0779:             * @deprecated Using public static arrays is dangerous.
0780:             */
0781:            public static final int[] ENVPRC4 = { 312, 590 };
0782:
0783:            /**
0784:             * A standard paper size.
0785:             *
0786:             * @deprecated Using public static arrays is dangerous.
0787:             */
0788:            public static final int[] ENVPRC4_ROTATED = { 590, 312 };
0789:
0790:            /**
0791:             * A standard paper size.
0792:             *
0793:             * @deprecated Using public static arrays is dangerous.
0794:             */
0795:            public static final int[] ENVPRC5 = { 312, 624 };
0796:
0797:            /**
0798:             * A standard paper size.
0799:             *
0800:             * @deprecated Using public static arrays is dangerous.
0801:             */
0802:            public static final int[] ENVPRC5_ROTATED = { 624, 312 };
0803:
0804:            /**
0805:             * A standard paper size.
0806:             *
0807:             * @deprecated Using public static arrays is dangerous.
0808:             */
0809:            public static final int[] ENVPRC6 = { 340, 652 };
0810:
0811:            /**
0812:             * A standard paper size.
0813:             *
0814:             * @deprecated Using public static arrays is dangerous.
0815:             */
0816:            public static final int[] ENVPRC6_ROTATED = { 652, 340 };
0817:
0818:            /**
0819:             * A standard paper size.
0820:             *
0821:             * @deprecated Using public static arrays is dangerous.
0822:             */
0823:            public static final int[] ENVPRC7 = { 454, 652 };
0824:
0825:            /**
0826:             * A standard paper size.
0827:             *
0828:             * @deprecated Using public static arrays is dangerous.
0829:             */
0830:            public static final int[] ENVPRC7_ROTATED = { 652, 454 };
0831:
0832:            /**
0833:             * A standard paper size.
0834:             *
0835:             * @deprecated Using public static arrays is dangerous.
0836:             */
0837:            public static final int[] ENVPRC8 = { 340, 876 };
0838:
0839:            /**
0840:             * A standard paper size.
0841:             *
0842:             * @deprecated Using public static arrays is dangerous.
0843:             */
0844:            public static final int[] ENVPRC8_ROTATED = { 876, 340 };
0845:
0846:            /**
0847:             * A standard paper size.
0848:             *
0849:             * @deprecated Using public static arrays is dangerous.
0850:             */
0851:            public static final int[] ENVPRC9 = { 649, 918 };
0852:
0853:            /**
0854:             * A standard paper size.
0855:             *
0856:             * @deprecated Using public static arrays is dangerous.
0857:             */
0858:            public static final int[] ENVPRC9_ROTATED = { 918, 649 };
0859:
0860:            /**
0861:             * A standard paper size.
0862:             *
0863:             * @deprecated Using public static arrays is dangerous.
0864:             */
0865:            public static final int[] ENVPRC10 = { 918, 1298 };
0866:
0867:            /**
0868:             * A standard paper size.
0869:             *
0870:             * @deprecated Using public static arrays is dangerous.
0871:             */
0872:            public static final int[] ENVPRC10_ROTATED = { 1298, 918 };
0873:
0874:            /**
0875:             * A standard paper size.
0876:             *
0877:             * @deprecated Using public static arrays is dangerous.
0878:             */
0879:            public static final int[] ENVYOU4 = { 298, 666 };
0880:
0881:            /**
0882:             * A standard paper size.
0883:             *
0884:             * @deprecated Using public static arrays is dangerous.
0885:             */
0886:            public static final int[] ENVYOU4_ROTATED = { 666, 298 };
0887:
0888:            /**
0889:             * A standard paper size.
0890:             *
0891:             * @deprecated Using public static arrays is dangerous.
0892:             */
0893:            public static final int[] EXECUTIVE = { 522, 756 };
0894:
0895:            /**
0896:             * A standard paper size.
0897:             *
0898:             * @deprecated Using public static arrays is dangerous.
0899:             */
0900:            public static final int[] FANFOLDUS = { 1071, 792 };
0901:
0902:            /**
0903:             * A standard paper size.
0904:             *
0905:             * @deprecated Using public static arrays is dangerous.
0906:             */
0907:            public static final int[] FANFOLDGERMAN = { 612, 864 };
0908:
0909:            /**
0910:             * A standard paper size.
0911:             *
0912:             * @deprecated Using public static arrays is dangerous.
0913:             */
0914:            public static final int[] FANFOLDGERMANLEGAL = { 612, 936 };
0915:
0916:            /**
0917:             * A standard paper size.
0918:             *
0919:             * @deprecated Using public static arrays is dangerous.
0920:             */
0921:            public static final int[] FOLIO = { 595, 935 };
0922:
0923:            /**
0924:             * A standard paper size.
0925:             *
0926:             * @deprecated Using public static arrays is dangerous.
0927:             */
0928:            public static final int[] ISOB0 = { 2835, 4008 };
0929:
0930:            /**
0931:             * A standard paper size.
0932:             *
0933:             * @deprecated Using public static arrays is dangerous.
0934:             */
0935:            public static final int[] ISOB1 = { 2004, 2835 };
0936:
0937:            /**
0938:             * A standard paper size.
0939:             *
0940:             * @deprecated Using public static arrays is dangerous.
0941:             */
0942:            public static final int[] ISOB2 = { 1417, 2004 };
0943:
0944:            /**
0945:             * A standard paper size.
0946:             *
0947:             * @deprecated Using public static arrays is dangerous.
0948:             */
0949:            public static final int[] ISOB3 = { 1001, 1417 };
0950:
0951:            /**
0952:             * A standard paper size.
0953:             *
0954:             * @deprecated Using public static arrays is dangerous.
0955:             */
0956:            public static final int[] ISOB4 = { 709, 1001 };
0957:
0958:            /**
0959:             * A standard paper size.
0960:             *
0961:             * @deprecated Using public static arrays is dangerous.
0962:             */
0963:            public static final int[] ISOB5 = { 499, 709 };
0964:
0965:            /**
0966:             * A standard paper size.
0967:             *
0968:             * @deprecated Using public static arrays is dangerous.
0969:             */
0970:            public static final int[] ISOB5_EXTRA = { 570, 782 };
0971:
0972:            /**
0973:             * A standard paper size.
0974:             *
0975:             * @deprecated Using public static arrays is dangerous.
0976:             */
0977:            public static final int[] ISOB6 = { 354, 499 };
0978:
0979:            /**
0980:             * A standard paper size.
0981:             *
0982:             * @deprecated Using public static arrays is dangerous.
0983:             */
0984:            public static final int[] ISOB7 = { 249, 354 };
0985:
0986:            /**
0987:             * A standard paper size.
0988:             *
0989:             * @deprecated Using public static arrays is dangerous.
0990:             */
0991:            public static final int[] ISOB8 = { 176, 249 };
0992:
0993:            /**
0994:             * A standard paper size.
0995:             *
0996:             * @deprecated Using public static arrays is dangerous.
0997:             */
0998:            public static final int[] ISOB9 = { 125, 176 };
0999:
1000:            /**
1001:             * A standard paper size.
1002:             *
1003:             * @deprecated Using public static arrays is dangerous.
1004:             */
1005:            public static final int[] ISOB10 = { 88, 125 };
1006:
1007:            /**
1008:             * A standard paper size.
1009:             *
1010:             * @deprecated Using public static arrays is dangerous.
1011:             */
1012:            public static final int[] LEDGER = { 1224, 792 };
1013:
1014:            /**
1015:             * A standard paper size.
1016:             *
1017:             * @deprecated Using public static arrays is dangerous.
1018:             */
1019:            public static final int[] LEGAL = { 612, 1008 };
1020:
1021:            /**
1022:             * A standard paper size.
1023:             *
1024:             * @deprecated Using public static arrays is dangerous.
1025:             */
1026:            public static final int[] LEGAL_EXTRA = { 684, 1080 };
1027:
1028:            /**
1029:             * A standard paper size.
1030:             *
1031:             * @deprecated Using public static arrays is dangerous.
1032:             */
1033:            public static final int[] LETTER = { 612, 792 };
1034:
1035:            /**
1036:             * A standard paper size.
1037:             *
1038:             * @deprecated Using public static arrays is dangerous.
1039:             */
1040:            public static final int[] LETTER_TRANSVERSE = { 612, 792 };
1041:
1042:            /**
1043:             * A standard paper size.
1044:             *
1045:             * @deprecated Using public static arrays is dangerous.
1046:             */
1047:            public static final int[] LETTER_EXTRA = { 684, 864 };
1048:
1049:            /**
1050:             * A standard paper size.
1051:             *
1052:             * @deprecated Using public static arrays is dangerous.
1053:             */
1054:            public static final int[] LETTER_EXTRATRANSVERSE = { 684, 864 };
1055:
1056:            /**
1057:             * A standard paper size.
1058:             *
1059:             * @deprecated Using public static arrays is dangerous.
1060:             */
1061:            public static final int[] LETTER_PLUS = { 612, 914 };
1062:
1063:            /**
1064:             * A standard paper size.
1065:             *
1066:             * @deprecated Using public static arrays is dangerous.
1067:             */
1068:            public static final int[] LETTER_ROTATED = { 792, 612 };
1069:
1070:            /**
1071:             * A standard paper size.
1072:             *
1073:             * @deprecated Using public static arrays is dangerous.
1074:             */
1075:            public static final int[] LETTER_SMALL = { 612, 792 };
1076:
1077:            /**
1078:             * A standard paper size.
1079:             *
1080:             * @deprecated Using public static arrays is dangerous.
1081:             */
1082:            public static final int[] MONARCH = ENVMONARCH;
1083:
1084:            /**
1085:             * A standard paper size.
1086:             *
1087:             * @deprecated Using public static arrays is dangerous.
1088:             */
1089:            public static final int[] NOTE = { 612, 792 };
1090:
1091:            /**
1092:             * A standard paper size.
1093:             *
1094:             * @deprecated Using public static arrays is dangerous.
1095:             */
1096:            public static final int[] POSTCARD = { 284, 419 };
1097:
1098:            /**
1099:             * A standard paper size.
1100:             *
1101:             * @deprecated Using public static arrays is dangerous.
1102:             */
1103:            public static final int[] POSTCARD_ROTATED = { 419, 284 };
1104:
1105:            /**
1106:             * A standard paper size.
1107:             *
1108:             * @deprecated Using public static arrays is dangerous.
1109:             */
1110:            public static final int[] PRC16K = { 414, 610 };
1111:
1112:            /**
1113:             * A standard paper size.
1114:             *
1115:             * @deprecated Using public static arrays is dangerous.
1116:             */
1117:            public static final int[] PRC16K_ROTATED = { 610, 414 };
1118:
1119:            /**
1120:             * A standard paper size.
1121:             *
1122:             * @deprecated Using public static arrays is dangerous.
1123:             */
1124:            public static final int[] PRC32K = { 275, 428 };
1125:
1126:            /**
1127:             * A standard paper size.
1128:             *
1129:             * @deprecated Using public static arrays is dangerous.
1130:             */
1131:            public static final int[] PRC32K_ROTATED = { 428, 275 };
1132:
1133:            /**
1134:             * A standard paper size.
1135:             *
1136:             * @deprecated Using public static arrays is dangerous.
1137:             */
1138:            public static final int[] PRC32K_BIG = { 275, 428 };
1139:
1140:            /**
1141:             * A standard paper size.
1142:             *
1143:             * @deprecated Using public static arrays is dangerous.
1144:             */
1145:            public static final int[] PRC32K_BIGROTATED = { 428, 275 };
1146:
1147:            /**
1148:             * A standard paper size.
1149:             *
1150:             * @deprecated Using public static arrays is dangerous.
1151:             */
1152:            public static final int[] QUARTO = { 610, 780 };
1153:
1154:            /**
1155:             * A standard paper size.
1156:             *
1157:             * @deprecated Using public static arrays is dangerous.
1158:             */
1159:            public static final int[] STATEMENT = { 396, 612 };
1160:
1161:            /**
1162:             * A standard paper size.
1163:             *
1164:             * @deprecated Using public static arrays is dangerous.
1165:             */
1166:            public static final int[] SUPERA = { 643, 1009 };
1167:
1168:            /**
1169:             * A standard paper size.
1170:             *
1171:             * @deprecated Using public static arrays is dangerous.
1172:             */
1173:            public static final int[] SUPERB = { 864, 1380 };
1174:
1175:            /**
1176:             * A standard paper size.
1177:             *
1178:             * @deprecated Using public static arrays is dangerous.
1179:             */
1180:            public static final int[] TABLOID = { 792, 1224 };
1181:
1182:            /**
1183:             * A standard paper size.
1184:             *
1185:             * @deprecated Using public static arrays is dangerous.
1186:             */
1187:            public static final int[] TABLOIDEXTRA = { 864, 1296 };
1188:
1189:            /**
1190:             * A single instance of the factory.
1191:             */
1192:            private static PageFormatFactory singleton;
1193:
1194:            /**
1195:             * Default constructor.
1196:             */
1197:            private PageFormatFactory() {
1198:            }
1199:
1200:            /**
1201:             * Returns a single instance of the factory.
1202:             *
1203:             * @return an instance of a PageFormatFactory.
1204:             */
1205:            public static PageFormatFactory getInstance() {
1206:                if (singleton == null) {
1207:                    singleton = new PageFormatFactory();
1208:                }
1209:                return singleton;
1210:            }
1211:
1212:            /**
1213:             * Creates a paper by using the paper size in points found in the int-array. The array must have a length of 2 and the
1214:             * first value of this array has to contain the width and the second the height parameter. The created Paper has no
1215:             * ImagableArea defined.
1216:             *
1217:             * @param papersize the definition of the papersize in a 2-element int-array
1218:             * @return the created paper
1219:             */
1220:            public Paper createPaper(final int[] papersize) {
1221:                if (papersize.length != 2) {
1222:                    throw new IllegalArgumentException(
1223:                            "Paper must have a width and a height");
1224:                }
1225:
1226:                return createPaper(papersize[0], papersize[1]);
1227:            }
1228:
1229:            /**
1230:             * Creates a paper by using the paper size in points found in the int-array. The array must have a length of 2 and the
1231:             * first value of this array has to contain the width and the second the height parameter. The created Paper has no
1232:             * ImagableArea defined.
1233:             *
1234:             * @param papersize the definition of the papersize in a 2-element int-array
1235:             * @return the created paper
1236:             */
1237:            public Paper createPaper(final PageSize papersize) {
1238:                return createPaper(papersize.getWidth(), papersize.getHeight());
1239:            }
1240:
1241:            /**
1242:             * Creates a paper by using the paper size in points. The created Paper has no ImagableArea defined.
1243:             *
1244:             * @param width  the width of the paper in points
1245:             * @param height the height of the paper in points
1246:             * @return the created paper
1247:             * @deprecated Use the double version instead.
1248:             */
1249:            public Paper createPaper(final int width, final int height) {
1250:                return createPaper((double) width, (double) height);
1251:            }
1252:
1253:            /**
1254:             * Creates a paper by using the paper size in points. The created Paper has no ImagableArea defined.
1255:             *
1256:             * @param width  the width of the paper in points
1257:             * @param height the height of the paper in points
1258:             * @return the created paper
1259:             */
1260:            public Paper createPaper(final double width, final double height) {
1261:                final Paper p = new Paper();
1262:                p.setSize(width, height);
1263:                setBorders(p, 0, 0, 0, 0);
1264:                return p;
1265:            }
1266:
1267:            /**
1268:             * Defines the imageable area of the given paper by adjusting the border around the imagable area. The bordersizes are
1269:             * given in points.
1270:             *
1271:             * @param paper  the paper that should be modified
1272:             * @param top    the bordersize of the top-border
1273:             * @param left   the border in points in the left
1274:             * @param bottom the border in points in the bottom
1275:             * @param right  the border in points in the right
1276:             */
1277:            public void setBorders(final Paper paper, final double top,
1278:                    final double left, final double bottom, final double right) {
1279:                final double w = paper.getWidth() - (right + left);
1280:                final double h = paper.getHeight() - (bottom + top);
1281:                paper.setImageableArea(left, top, w, h);
1282:            }
1283:
1284:            /**
1285:             * Defines the imageable area of the given paper by adjusting the border around the imagable area. The bordersizes are
1286:             * given in inches.
1287:             *
1288:             * @param paper  the paper that should be modified
1289:             * @param top    the bordersize of the top-border
1290:             * @param left   the border in points in the left
1291:             * @param bottom the border in points in the bottom
1292:             * @param right  the border in points in the right
1293:             */
1294:            public void setBordersInch(final Paper paper, final double top,
1295:                    final double left, final double bottom, final double right) {
1296:                setBorders(paper, convertInchToPoints(top),
1297:                        convertInchToPoints(left), convertInchToPoints(bottom),
1298:                        convertInchToPoints(right));
1299:            }
1300:
1301:            /**
1302:             * Defines the imageable area of the given paper by adjusting the border around the imagable area. The bordersizes are
1303:             * given in millimeters.
1304:             *
1305:             * @param paper  the paper that should be modified
1306:             * @param top    the bordersize of the top-border
1307:             * @param left   the border in points in the left
1308:             * @param bottom the border in points in the bottom
1309:             * @param right  the border in points in the right
1310:             */
1311:            public void setBordersMm(final Paper paper, final double top,
1312:                    final double left, final double bottom, final double right) {
1313:                setBorders(paper, convertMmToPoints(top),
1314:                        convertMmToPoints(left), convertMmToPoints(bottom),
1315:                        convertMmToPoints(right));
1316:            }
1317:
1318:            /**
1319:             * Converts the given inch value to a valid point-value.
1320:             *
1321:             * @param inches the size in inch
1322:             * @return the size in points
1323:             */
1324:            public double convertInchToPoints(final double inches) {
1325:                return inches * 72.0f;
1326:            }
1327:
1328:            /**
1329:             * Converts the given millimeter value to a valid point-value.
1330:             *
1331:             * @param mm the size in inch
1332:             * @return the size in points
1333:             */
1334:            public double convertMmToPoints(final double mm) {
1335:                return mm * (72.0d / 254.0d) * 10;
1336:            }
1337:
1338:            /**
1339:             * Creates a new pageformat using the given paper and the given orientation.
1340:             *
1341:             * @param paper       the paper to use in the new pageformat
1342:             * @param orientation one of PageFormat.PORTRAIT, PageFormat.LANDSCAPE or PageFormat.REVERSE_LANDSCAPE
1343:             * @return the created Pageformat
1344:             * @throws NullPointerException if the paper given was null
1345:             */
1346:            public PageFormat createPageFormat(final Paper paper,
1347:                    final int orientation) {
1348:                if (paper == null) {
1349:                    throw new NullPointerException(
1350:                            "Paper given must not be null");
1351:                }
1352:                final PageFormat pf = new PageFormat();
1353:                pf.setPaper(paper);
1354:                pf.setOrientation(orientation);
1355:                return pf;
1356:            }
1357:
1358:            /**
1359:             * Creates a paper by looking up the given Uppercase name in this classes defined constants. The value if looked up by
1360:             * introspection, if the value is not defined in this class, null is returned.
1361:             *
1362:             * @param name the name of the constant defining the papersize
1363:             * @return the defined paper or null, if the name was invalid.
1364:             */
1365:            public Paper createPaper(final String name) {
1366:                try {
1367:                    final Field f = PageSize.class.getDeclaredField(name);
1368:                    final Object o = f.get(null);
1369:                    if (o instanceof  PageSize == false) {
1370:                        // Log.debug ("Is no valid pageformat definition");
1371:                        return null;
1372:                    }
1373:                    final PageSize pageformat = (PageSize) o;
1374:                    return createPaper(pageformat);
1375:                } catch (NoSuchFieldException nfe) {
1376:                    // Log.debug ("There is no pageformat " + name + " defined.");
1377:                    return null;
1378:                } catch (IllegalAccessException aie) {
1379:                    // Log.debug ("There is no pageformat " + name + " accessible.");
1380:                    return null;
1381:                }
1382:            }
1383:
1384:            /**
1385:             * Logs the page format.
1386:             *
1387:             * @param pf the page format.
1388:             */
1389:            public static void logPageFormat(final PageFormat pf) {
1390:                org.jfree.util.Log.debug("PageFormat: Width: " + pf.getWidth()
1391:                        + " Height: " + pf.getHeight());
1392:                Log.debug("PageFormat: Image: X " + pf.getImageableX() + " Y "
1393:                        + pf.getImageableY() + " W: " + pf.getImageableWidth()
1394:                        + " H: " + pf.getImageableHeight());
1395:                Log.debug("PageFormat: Margins: X " + pf.getImageableX()
1396:                        + " Y " + pf.getImageableY() + " X2: "
1397:                        + (pf.getImageableWidth() + pf.getImageableX())
1398:                        + " Y2: "
1399:                        + (pf.getImageableHeight() + pf.getImageableY()));
1400:            }
1401:
1402:            /**
1403:             * Logs the paper size.
1404:             *
1405:             * @param pf the paper size.
1406:             */
1407:            public static void logPaper(final Paper pf) {
1408:                Log.debug("Paper: Width: " + pf.getWidth() + " Height: "
1409:                        + pf.getHeight());
1410:                Log.debug("Paper: Image: X " + pf.getImageableX() + " Y "
1411:                        + pf.getImageableY() + " H: " + pf.getImageableHeight()
1412:                        + " W: " + pf.getImageableWidth());
1413:            }
1414:
1415:            /**
1416:             * Tests, whether the given two page format objects are equal.
1417:             *
1418:             * @param pf1 the first page format that should be compared.
1419:             * @param pf2 the second page format that should be compared.
1420:             * @return true, if both page formats are equal, false otherwise.
1421:             */
1422:            public static boolean isEqual(final PageFormat pf1,
1423:                    final PageFormat pf2) {
1424:                if (pf1 == pf2) {
1425:                    return true;
1426:                }
1427:                if (pf1 == null || pf2 == null) {
1428:                    return false;
1429:                }
1430:
1431:                if (pf1.getOrientation() != pf2.getOrientation()) {
1432:                    return false;
1433:                }
1434:                final Paper p1 = pf1.getPaper();
1435:                final Paper p2 = pf2.getPaper();
1436:
1437:                if (p1.getWidth() != p2.getWidth()) {
1438:                    return false;
1439:                }
1440:                if (p1.getHeight() != p2.getHeight()) {
1441:                    return false;
1442:                }
1443:                if (p1.getImageableX() != p2.getImageableX()) {
1444:                    return false;
1445:                }
1446:                if (p1.getImageableY() != p2.getImageableY()) {
1447:                    return false;
1448:                }
1449:                if (p1.getImageableWidth() != p2.getImageableWidth()) {
1450:                    return false;
1451:                }
1452:                if (p1.getImageableHeight() != p2.getImageableHeight()) {
1453:                    return false;
1454:                }
1455:                return true;
1456:            }
1457:
1458:            /**
1459:             * Returns the left border of the given paper.
1460:             *
1461:             * @param p the paper that defines the borders.
1462:             * @return the left border.
1463:             */
1464:            public double getLeftBorder(final Paper p) {
1465:                return p.getImageableX();
1466:            }
1467:
1468:            /**
1469:             * Returns the right border of the given paper.
1470:             *
1471:             * @param p the paper that defines the borders.
1472:             * @return the right border.
1473:             */
1474:            public double getRightBorder(final Paper p) {
1475:                return p.getWidth()
1476:                        - (p.getImageableX() + p.getImageableWidth());
1477:            }
1478:
1479:            /**
1480:             * Returns the top border of the given paper.
1481:             *
1482:             * @param p the paper that defines the borders.
1483:             * @return the top border.
1484:             */
1485:            public double getTopBorder(final Paper p) {
1486:                return p.getImageableY();
1487:            }
1488:
1489:            /**
1490:             * Returns the bottom border of the given paper.
1491:             *
1492:             * @param p the paper that defines the borders.
1493:             * @return the bottom border.
1494:             */
1495:            public double getBottomBorder(final Paper p) {
1496:                return p.getHeight()
1497:                        - (p.getImageableY() + p.getImageableHeight());
1498:            }
1499:
1500:            /**
1501:             * Resolves a page format, so that the result can be serialized.
1502:             *
1503:             * @param format the page format that should be prepared for serialisation.
1504:             * @return the prepared page format data.
1505:             * @deprecated This functionality is part of JCommon-Serializer
1506:             */
1507:            public Object[] resolvePageFormat(final PageFormat format) {
1508:                final Integer orientation = new Integer(format.getOrientation());
1509:                final Paper p = format.getPaper();
1510:                final float[] fdim = new float[] { (float) p.getWidth(),
1511:                        (float) p.getHeight() };
1512:                final float[] rect = new float[] { (float) p.getImageableX(),
1513:                        (float) p.getImageableY(),
1514:                        (float) p.getImageableWidth(),
1515:                        (float) p.getImageableHeight() };
1516:                return new Object[] { orientation, fdim, rect };
1517:            }
1518:
1519:            /**
1520:             * Restores a page format after it has been serialized.
1521:             *
1522:             * @param data the serialized page format data.
1523:             * @return the restored page format.
1524:             * @deprecated This functionality is part of JCommon-Serializer
1525:             */
1526:            public PageFormat createPageFormat(final Object[] data) {
1527:                final Integer orientation = (Integer) data[0];
1528:                final float[] dim = (float[]) data[1];
1529:                final float[] rect = (float[]) data[2];
1530:                final Paper p = new Paper();
1531:                p.setSize(dim[0], dim[1]);
1532:                p.setImageableArea(rect[0], rect[1], rect[2], rect[3]);
1533:                final PageFormat format = new PageFormat();
1534:                format.setPaper(p);
1535:                format.setOrientation(orientation.intValue());
1536:                return format;
1537:            }
1538:
1539:            public Insets getPageMargins(final PageFormat format) {
1540:
1541:                final int marginLeft = (int) format.getImageableX();
1542:                final int marginRight = (int) (format.getWidth()
1543:                        - format.getImageableWidth() - format.getImageableX());
1544:                final int marginTop = (int) (format.getImageableY());
1545:                final int marginBottom = (int) (format.getHeight()
1546:                        - format.getImageableHeight() - format.getImageableY());
1547:                return new Insets(marginTop, marginLeft, marginBottom,
1548:                        marginRight);
1549:            }
1550:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.