Source Code Cross Referenced for MessageFieldElementFactory.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:         * MessageFieldElementFactory.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:        import java.text.MessageFormat;
034:
035:        import org.jfree.report.Element;
036:        import org.jfree.report.ElementAlignment;
037:        import org.jfree.report.TextElement;
038:        import org.jfree.report.filter.templates.MessageFieldTemplate;
039:        import org.jfree.report.style.FontDefinition;
040:
041:        /**
042:         * The message format factory can be used to create formatted text elements using the
043:         * format defined for {@link MessageFormat}. These text elements have special abilities to
044:         * format numeric values and dates based on the MessageFormat string.
045:         * <p/>
046:         * Once the desired properties are set, the factory can be reused to create similiar text
047:         * elements.
048:         *
049:         * @author J&ouml;rg Schaible
050:         */
051:        public class MessageFieldElementFactory extends TextElementFactory {
052:            /**
053:             * The message format instance used to format the text element.
054:             */
055:            private String formatString;
056:            /**
057:             * The nullstring of the text element if the value in the datasource was null.
058:             */
059:            private String nullString;
060:
061:            /**
062:             * Creates a new message field element factory.
063:             */
064:            public MessageFieldElementFactory() {
065:            }
066:
067:            /**
068:             * Returns the format string of the used message format.
069:             *
070:             * @return the formatstring of the number format instance.
071:             */
072:            public String getFormatString() {
073:                return formatString;
074:            }
075:
076:            /**
077:             * Defines the format string of the used message format. The format string should
078:             * contain a format for the element 0. This method will replace the message format
079:             * instance of this factory.
080:             *
081:             * @param formatString the formatstring of the message format instance.
082:             */
083:            public void setFormatString(final String formatString) {
084:                this .formatString = formatString;
085:            }
086:
087:            /**
088:             * Returns the null string for the text element. The null string is used when no content
089:             * is found for that element.
090:             *
091:             * @return the null string.
092:             */
093:            public String getNullString() {
094:                return nullString;
095:            }
096:
097:            /**
098:             * Defines the null string for the text element. The null string is used when no content
099:             * is found for that element. The nullstring itself can be null.
100:             *
101:             * @param nullString the null string.
102:             */
103:            public void setNullString(final String nullString) {
104:                this .nullString = nullString;
105:            }
106:
107:            /**
108:             * Creates the message text element based on the defined settings. Undefined properties
109:             * will not be set in the generated element.
110:             *
111:             * @return the generated numberic text element
112:             *
113:             * @see org.jfree.report.elementfactory.ElementFactory#createElement()
114:             */
115:            public Element createElement() {
116:                final MessageFieldTemplate messageFieldTemplate = new MessageFieldTemplate();
117:                messageFieldTemplate.setFormat(getFormatString());
118:                messageFieldTemplate.setNullValue(getNullString());
119:
120:                final TextElement element = new TextElement();
121:                applyElementName(element);
122:                element.setDataSource(messageFieldTemplate);
123:                applyStyle(element.getStyle());
124:
125:                return element;
126:            }
127:
128:            /**
129:             * Creates a new TextElement containing a message filter structure.
130:             *
131:             * @param name       the name of the new element
132:             * @param bounds     the bounds of the new element
133:             * @param paint      the text color of this text element
134:             * @param alignment  the horizontal text alignment.
135:             * @param font       the font for this element
136:             * @param nullString the text used when the value of this element is null
137:             * @param format     the format string used in this message element
138:             * @return a report element for displaying <code>Number</code> objects.
139:             *
140:             * @throws NullPointerException     if bounds, name or function are null
141:             * @throws IllegalArgumentException if the given alignment is invalid
142:             */
143:            public static TextElement createMessageElement(final String name,
144:                    final Rectangle2D bounds, final Color paint,
145:                    final ElementAlignment alignment,
146:                    final FontDefinition font, final String nullString,
147:                    final String format) {
148:                return createMessageElement(name, bounds, paint, alignment,
149:                        ElementAlignment.TOP, font, nullString, format);
150:            }
151:
152:            /**
153:             * Creates a new TextElement containing a message filter structure.
154:             *
155:             * @param name         the name of the new element.
156:             * @param bounds       the bounds of the new element.
157:             * @param color        the text color of this text element.
158:             * @param alignment    the horizontal text alignment.
159:             * @param valign       the vertical alignment.
160:             * @param font         the font for this element.
161:             * @param nullString   the text used when the value of this element is null.
162:             * @param formatString the MessageFormat used in this number element.
163:             * @return a report element for displaying <code>Number</code> objects.
164:             *
165:             * @throws NullPointerException     if bounds, name or function are null
166:             * @throws IllegalArgumentException if the given alignment is invalid
167:             */
168:            public static TextElement createMessageElement(final String name,
169:                    final Rectangle2D bounds, final Color color,
170:                    final ElementAlignment alignment,
171:                    final ElementAlignment valign, final FontDefinition font,
172:                    final String nullString, final String formatString) {
173:
174:                final MessageFieldElementFactory factory = new MessageFieldElementFactory();
175:                factory.setX(new Float(bounds.getX()));
176:                factory.setY(new Float(bounds.getY()));
177:                factory.setMinimumWidth(new Float(bounds.getWidth()));
178:                factory.setMinimumHeight(new Float(bounds.getHeight()));
179:                factory.setName(name);
180:                factory.setColor(color);
181:                factory.setHorizontalAlignment(alignment);
182:                factory.setVerticalAlignment(valign);
183:
184:                if (font != null) {
185:                    factory.setFontName(font.getFontName());
186:                    factory.setFontSize(new Integer(font.getFontSize()));
187:                    factory.setBold(ElementFactory.getBooleanValue(font
188:                            .isBold()));
189:                    factory.setItalic(ElementFactory.getBooleanValue(font
190:                            .isItalic()));
191:                    factory.setEncoding(font.getFontEncoding(null));
192:                    factory.setUnderline(ElementFactory.getBooleanValue(font
193:                            .isUnderline()));
194:                    factory.setStrikethrough(ElementFactory
195:                            .getBooleanValue(font.isStrikeThrough()));
196:                    factory.setEmbedFont(ElementFactory.getBooleanValue(font
197:                            .isEmbeddedFont()));
198:                }
199:                factory.setNullString(nullString);
200:                factory.setFormatString(formatString);
201:                return (TextElement) factory.createElement();
202:            }
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.