Source Code Cross Referenced for TextFieldElementFactory.java in  » Report » pentaho-report » org » jfree » report » elementfactory » 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.elementfactory 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:         * TextFieldElementFactory.java
027:         * ------------
028:         * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029:         */package org.jfree.report.elementfactory;
030:
031:        import java.awt.Color;
032:        import java.awt.geom.Rectangle2D;
033:
034:        import org.jfree.report.Element;
035:        import org.jfree.report.ElementAlignment;
036:        import org.jfree.report.TextElement;
037:        import org.jfree.report.filter.templates.StringFieldTemplate;
038:        import org.jfree.report.style.ElementStyleSheet;
039:        import org.jfree.report.style.FontDefinition;
040:
041:        /**
042:         * A factory to define text fields. Text fields read their content from the dataRow and
043:         * try to print it as plain text (using toString() if required).
044:         *
045:         * @author Thomas Morgner
046:         */
047:        public class TextFieldElementFactory extends TextElementFactory {
048:            /**
049:             * The fieldname of the datarow from where to read the content.
050:             */
051:            private String fieldname;
052:
053:            /**
054:             * The nullstring of the text element if the value in the datasource was null.
055:             */
056:            private String nullString;
057:
058:            /**
059:             * The value-formula that computes the value for this element.
060:             */
061:            private String formula;
062:
063:            /**
064:             * DefaultConstructor.
065:             */
066:            public TextFieldElementFactory() {
067:            }
068:
069:            /**
070:             * Returns the field name from where to read the content of the element.
071:             *
072:             * @return the field name.
073:             */
074:            public String getFieldname() {
075:                return fieldname;
076:            }
077:
078:            /**
079:             * Defines the field name from where to read the content of the element. The field name
080:             * is the name of a datarow column.
081:             *
082:             * @param fieldname the field name.
083:             */
084:            public void setFieldname(final String fieldname) {
085:                this .fieldname = fieldname;
086:            }
087:
088:            /**
089:             * Returns the formula that should be used to compute the value of the field.
090:             * The formula must be valid according to the OpenFormula
091:             * specifications.
092:             *
093:             * @return the formula as string.
094:             */
095:            public String getFormula() {
096:                return formula;
097:            }
098:
099:            /**
100:             * Assigns a formula to the element to compute the value for this element.
101:             * If a formula is defined, it will override the 'field' property.
102:             *
103:             * @param formula the formula as a string.
104:             */
105:            public void setFormula(final String formula) {
106:                this .formula = formula;
107:            }
108:
109:            /**
110:             * Returns the null string for the text element. The null string is used when no content
111:             * is found for that element.
112:             *
113:             * @return the null string.
114:             */
115:            public String getNullString() {
116:                return nullString;
117:            }
118:
119:            /**
120:             * Defines the null string for the text element. The null string is used when no content
121:             * is found for that element. The nullstring itself can be null.
122:             *
123:             * @param nullString the null string.
124:             */
125:            public void setNullString(final String nullString) {
126:                this .nullString = nullString;
127:            }
128:
129:            /**
130:             * Creates the text field element.
131:             *
132:             * @return the generated text field element
133:             *
134:             * @throws IllegalStateException if the fieldname is null.
135:             * @see org.jfree.report.elementfactory.ElementFactory#createElement()
136:             */
137:            public Element createElement() {
138:                final StringFieldTemplate template = new StringFieldTemplate();
139:                if (getFormula() != null) {
140:                    template.setFormula(getFormula());
141:                } else {
142:                    template.setField(getFieldname());
143:                }
144:
145:                if (getNullString() != null) {
146:                    template.setNullValue(getNullString());
147:                }
148:
149:                final TextElement element = new TextElement();
150:                applyElementName(element);
151:                element.setDataSource(template);
152:                final ElementStyleSheet style = element.getStyle();
153:                applyStyle(style);
154:                return element;
155:            }
156:
157:            /**
158:             * Creates a new TextElement without any additional filtering.
159:             *
160:             * @param name       the name of the new element
161:             * @param bounds     the bounds of the new element
162:             * @param paint      the text color of this text element
163:             * @param alignment  the horizontal text alignment.
164:             * @param font       the font for this element
165:             * @param nullString the text used when the value of this element is null
166:             * @param field      the field in the datamodel to retrieve values from
167:             * @return a report element for displaying <code>String</code> objects.
168:             *
169:             * @throws NullPointerException     if bounds, name or function are null
170:             * @throws IllegalArgumentException if the given alignment is invalid
171:             */
172:            public static TextElement createStringElement(final String name,
173:                    final Rectangle2D bounds, final Color paint,
174:                    final ElementAlignment alignment,
175:                    final FontDefinition font, final String nullString,
176:                    final String field) {
177:                return createStringElement(name, bounds, paint, alignment,
178:                        ElementAlignment.TOP, font, nullString, field);
179:            }
180:
181:            /**
182:             * Creates a new TextElement without any additional filtering.
183:             *
184:             * @param name       the name of the new element
185:             * @param bounds     the bounds of the new element
186:             * @param paint      the text color of this text element
187:             * @param alignment  the horizontal text alignment.
188:             * @param valign     the vertical alignment.
189:             * @param font       the font for this element
190:             * @param nullString the text used when the value of this element is null
191:             * @param field      the field in the datamodel to retrieve values from
192:             * @return a report element for displaying <code>String</code> objects.
193:             *
194:             * @throws NullPointerException     if bounds, name or function are null
195:             * @throws IllegalArgumentException if the given alignment is invalid
196:             */
197:            public static TextElement createStringElement(final String name,
198:                    final Rectangle2D bounds, final Color paint,
199:                    final ElementAlignment alignment,
200:                    final ElementAlignment valign, final FontDefinition font,
201:                    final String nullString, final String field) {
202:                final TextFieldElementFactory factory = new TextFieldElementFactory();
203:                factory.setX(new Float(bounds.getX()));
204:                factory.setY(new Float(bounds.getY()));
205:                factory.setMinimumWidth(new Float(bounds.getWidth()));
206:                factory.setMinimumHeight(new Float(bounds.getHeight()));
207:                factory.setName(name);
208:                factory.setColor(paint);
209:                factory.setHorizontalAlignment(alignment);
210:                factory.setVerticalAlignment(valign);
211:
212:                if (font != null) {
213:                    factory.setFontName(font.getFontName());
214:                    factory.setFontSize(new Integer(font.getFontSize()));
215:                    factory.setBold(ElementFactory.getBooleanValue(font
216:                            .isBold()));
217:                    factory.setItalic(ElementFactory.getBooleanValue(font
218:                            .isItalic()));
219:                    factory.setEncoding(font.getFontEncoding(null));
220:                    factory.setUnderline(ElementFactory.getBooleanValue(font
221:                            .isUnderline()));
222:                    factory.setStrikethrough(ElementFactory
223:                            .getBooleanValue(font.isStrikeThrough()));
224:                    factory.setEmbedFont(ElementFactory.getBooleanValue(font
225:                            .isEmbeddedFont()));
226:                }
227:                factory.setFieldname(field);
228:                factory.setNullString(nullString);
229:                return (TextElement) factory.createElement();
230:            }
231:
232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.