Source Code Cross Referenced for TextPagePrinter.java in  » UML » jrefactory » org » acm » seguin » print » text » 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 » UML » jrefactory » org.acm.seguin.print.text 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Author:  Chris Seguin
003:         *
004:         *  This software has been developed under the copyleft
005:         *  rules of the GNU General Public License.  Please
006:         *  consult the GNU General Public License for more
007:         *  details about use and distribution of this software.
008:         */
009:        package org.acm.seguin.print.text;
010:
011:        import java.awt.Color;
012:        import java.awt.Font;
013:        import java.awt.FontMetrics;
014:        import java.awt.Graphics;
015:        import java.awt.print.*;
016:        import org.acm.seguin.print.PagePrinter;
017:        import org.acm.seguin.print.PrintingSettings;
018:
019:        /**
020:         *  Handles printing the page 
021:         *
022:         *@author     Chris Seguin 
023:         *@created    August 6, 1999 
024:         */
025:        public class TextPagePrinter extends PagePrinter {
026:            private String filename;
027:            private LineSet lineSet;
028:            private LinePrinter linePrinter;
029:            private int textFontSize = 10;
030:            private int textSkip = 2;
031:
032:            private static int linesPerPage = -1;
033:
034:            /**
035:             *  Constructor for the UMLPagePrinter object 
036:             *
037:             *@param  initFilename  Description of Parameter 
038:             *@param  init          Description of Parameter 
039:             *@param  printer       Description of Parameter 
040:             */
041:            public TextPagePrinter(String initFilename, String init,
042:                    LinePrinter printer) {
043:                lineSet = new LineSet(init);
044:                linePrinter = printer;
045:                filename = initFilename;
046:            }
047:
048:            /**
049:             *  Sets the TextFontSize attribute of the TextPagePrinter object 
050:             *
051:             *@param  value  The new TextFontSize value 
052:             */
053:            public void setTextFontSize(int value) {
054:                textFontSize = value;
055:            }
056:
057:            /**
058:             *  Sets the BetweenLineSpacing attribute of the TextPagePrinter object 
059:             *
060:             *@param  value  The new BetweenLineSpacing value 
061:             */
062:            public void setBetweenLineSpacing(int value) {
063:                textSkip = value;
064:            }
065:
066:            /**
067:             *  Guess the number of pages 
068:             *
069:             *@param  pf  Description of Parameter 
070:             *@return     Description of the Returned Value 
071:             */
072:            public int calculatePageCount(PageFormat pf) {
073:                int pageHeight = (int) pf.getImageableHeight();
074:                int pageWidth = (int) pf.getImageableWidth();
075:
076:                int pagesHigh;
077:                int lpp = linesPerPage;
078:                int lineCount = lineSet.size();
079:                if (linesPerPage == -1) {
080:                    PrintingSettings ps = new PrintingSettings();
081:                    lpp = ps.getLinesPerPage();
082:                }
083:
084:                pagesHigh = lineCount / lpp;
085:                if (lineCount % lpp != 0) {
086:                    pagesHigh++;
087:                }
088:
089:                return pagesHigh;
090:            }
091:
092:            /**
093:             *  Print the page 
094:             *
095:             *@param  g           the graphics object 
096:             *@param  pf          the page format 
097:             *@param  pageNumber  the page number 
098:             *@return             Whether there is more pages or not 
099:             */
100:            public int print(Graphics g, PageFormat pf, int pageNumber) {
101:                int pageCount = calculatePageCount(pf);
102:                if (pageNumber > pageCount) {
103:                    return Printable.NO_SUCH_PAGE;
104:                }
105:
106:                linePrinter.setFontSize(textFontSize);
107:                int high = linePrinter.getLineHeight(g) + textSkip;
108:                if (linesPerPage == -1) {
109:                    int pageHeight = (int) pf.getImageableHeight()
110:                            - headerHeight;
111:                    linesPerPage = pageHeight / high;
112:                    PrintingSettings ps = new PrintingSettings();
113:                    ps.setLinesPerPage(linesPerPage);
114:                }
115:
116:                int startIndex = pageNumber * linesPerPage;
117:
118:                int xOffset = (int) pf.getImageableX();
119:                int yOffset = (int) pf.getImageableY() + headerHeight;
120:
121:                printHeader(g, filename, "" + (1 + pageNumber), "" + pageCount);
122:
123:                linePrinter.init(g);
124:                for (int ndx = 0; ndx < linesPerPage; ndx++) {
125:                    int index = ndx + pageNumber * linesPerPage;
126:                    String line = lineSet.getLine(index);
127:                    if (line == null) {
128:                        break;
129:                    }
130:
131:                    linePrinter.print(g, line, xOffset, yOffset + (1 + ndx)
132:                            * high, lineSet, index);
133:                }
134:
135:                return Printable.PAGE_EXISTS;
136:            }
137:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.