Source Code Cross Referenced for PrintingSettings.java in  » UML » jrefactory » org » acm » seguin » print » 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 
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;
010:
011:        import java.io.File;
012:        import java.io.FileWriter;
013:        import java.io.PrintWriter;
014:        import java.io.IOException;
015:        import org.acm.seguin.util.FileSettings;
016:        import org.acm.seguin.util.MissingSettingsException;
017:        import org.acm.seguin.awt.ExceptionPrinter;
018:
019:        /**
020:         *  Stores the pretty printer settings. Allows the user to reload or write
021:         *  them to a file.
022:         *
023:         *@author    Chris Seguin
024:         */
025:        public class PrintingSettings {
026:            private int textFontSize;
027:            private int textSpace;
028:            private int headerBlock;
029:            private int filenameFont;
030:            private int dateFont;
031:            private int linesPerPage;
032:
033:            /**
034:             *  Constructor for the PrintingSettings object
035:             */
036:            public PrintingSettings() {
037:                init();
038:            }
039:
040:            /**
041:             *  Sets the TextFontSize attribute of the PrintingSettings object
042:             *
043:             *@param  value  The new TextFontSize value
044:             */
045:            public void setTextFontSize(int value) {
046:                if (value != textFontSize) {
047:                    textFontSize = value;
048:                    save();
049:                }
050:            }
051:
052:            /**
053:             *  Sets the TextSpace attribute of the PrintingSettings object
054:             *
055:             *@param  value  The new TextSpace value
056:             */
057:            public void setTextSpace(int value) {
058:                if (value != textSpace) {
059:                    textSpace = value;
060:                    save();
061:                }
062:            }
063:
064:            /**
065:             *  Sets the HeaderBlockHeight attribute of the PrintingSettings object
066:             *
067:             *@param  value  The new HeaderBlockHeight value
068:             */
069:            public void setHeaderBlockHeight(int value) {
070:                if (value != headerBlock) {
071:                    headerBlock = value;
072:                    save();
073:                }
074:            }
075:
076:            /**
077:             *  Sets the FilenameFontSize attribute of the PrintingSettings object
078:             *
079:             *@param  value  The new FilenameFontSize value
080:             */
081:            public void setFilenameFontSize(int value) {
082:                if (value != filenameFont) {
083:                    filenameFont = value;
084:                    save();
085:                }
086:            }
087:
088:            /**
089:             *  Sets the DateFontSize attribute of the PrintingSettings object
090:             *
091:             *@param  value  The new DateFontSize value
092:             */
093:            public void setDateFontSize(int value) {
094:                if (value != dateFont) {
095:                    dateFont = value;
096:                    save();
097:                }
098:            }
099:
100:            /**
101:             *  Sets the LinesPerPage attribute of the PrintingSettings object
102:             *
103:             *@param  value  The new LinesPerPage value
104:             */
105:            public void setLinesPerPage(int value) {
106:                if (linesPerPage != value) {
107:                    linesPerPage = value;
108:                    save();
109:                }
110:            }
111:
112:            /**
113:             *  Gets the TextFontSize attribute of the PrintingSettings object
114:             *
115:             *@return    The TextFontSize value
116:             */
117:            public int getTextFontSize() {
118:                return textFontSize;
119:            }
120:
121:            /**
122:             *  Gets the TextSpace attribute of the PrintingSettings object
123:             *
124:             *@return    The TextSpace value
125:             */
126:            public int getTextSpace() {
127:                return textSpace;
128:            }
129:
130:            /**
131:             *  Gets the HeaderBlockHeight attribute of the PrintingSettings object
132:             *
133:             *@return    The HeaderBlockHeight value
134:             */
135:            public int getHeaderBlockHeight() {
136:                return headerBlock;
137:            }
138:
139:            /**
140:             *  Gets the FilenameFontSize attribute of the PrintingSettings object
141:             *
142:             *@return    The FilenameFontSize value
143:             */
144:            public int getFilenameFontSize() {
145:                return filenameFont;
146:            }
147:
148:            /**
149:             *  Gets the DateFontSize attribute of the PrintingSettings object
150:             *
151:             *@return    The DateFontSize value
152:             */
153:            public int getDateFontSize() {
154:                return dateFont;
155:            }
156:
157:            /**
158:             *  Gets the LinesPerPage attribute of the PrintingSettings object
159:             *
160:             *@return    The LinesPerPage value
161:             */
162:            public int getLinesPerPage() {
163:                return linesPerPage;
164:            }
165:
166:            /**
167:             *  Description of the Method
168:             */
169:            public void save() {
170:                try {
171:                    File directory = FileSettings.getRefactorySettingsRoot();
172:                    if (!directory.exists()) {
173:                        directory.mkdirs();
174:                    }
175:
176:                    FileWriter output = new FileWriter(new File(directory,
177:                            "printing.settings"));
178:                    PrintWriter printer = new PrintWriter(output);
179:                    write(printer);
180:                    printer.close();
181:                    output.close();
182:                    init();
183:                } catch (IOException ioe) {
184:                    ExceptionPrinter.print(ioe, false);
185:                }
186:            }
187:
188:            /**
189:             *  Description of the Method
190:             */
191:            private void defaults() {
192:                textFontSize = 10;
193:                textSpace = 0;
194:                headerBlock = 30;
195:                filenameFont = 14;
196:                dateFont = 8;
197:                linesPerPage = 36;
198:            }
199:
200:            /**
201:             *  Sets the default values for these
202:             */
203:            private void init() {
204:                defaults();
205:
206:                try {
207:                    FileSettings setting = FileSettings
208:                            .getRefactorySettings("printing");
209:                    setting.setReloadNow(true);
210:
211:                    textFontSize = setting.getInteger("text.font.size");
212:                    textSpace = setting.getInteger("text.space");
213:                    headerBlock = setting.getInteger("header.space");
214:                    filenameFont = setting.getInteger("filename.font.size");
215:                    dateFont = setting.getInteger("date.font.size");
216:                    linesPerPage = setting.getInteger("lines.per.page");
217:                } catch (MissingSettingsException mse) {
218:                    //  Expected
219:                }
220:            }
221:
222:            /**
223:             *  Writes the values back to the disk
224:             *
225:             *@param  printer  the output writer
226:             */
227:            private void write(PrintWriter printer) {
228:                printer
229:                        .println("#  This is the font size for the text of the file");
230:                printer.println("text.font.size=" + textFontSize);
231:                printer.println(" ");
232:                printer
233:                        .println("#  This is the number of pixels to skip between");
234:                printer.println("#  lines in the text of the file");
235:                printer.println("text.space=" + textSpace);
236:                printer.println(" ");
237:                printer.println("#  The header block is 30 pixels high");
238:                printer.println("header.space=" + headerBlock);
239:                printer.println(" ");
240:                printer
241:                        .println("#  The name of the file is specified with this parameter");
242:                printer.println("filename.font.size=" + filenameFont);
243:                printer.println(" ");
244:                printer
245:                        .println("#  The date that the file was printed and the number");
246:                printer.println("#  of pages is in this font size");
247:                printer.println("date.font.size=" + dateFont);
248:                printer.println(" ");
249:                printer
250:                        .println("#  The number of lines on a page.  This is an estimate");
251:                printer
252:                        .println("#  that is updated by the software each time a new set of");
253:                printer.println("#  values is changed");
254:                printer.println("lines.per.page=" + linesPerPage);
255:            }
256:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.