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


001:        /*
002:         * Copyright 2006 Pentaho Corporation.  All rights reserved. 
003:         * This software was developed by Pentaho Corporation and is provided under the terms 
004:         * of the Mozilla Public License, Version 1.1, or any later version. You may not use 
005:         * this file except in compliance with the license. If you need a copy of the license, 
006:         * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho 
007:         * BI Platform.  The Initial Developer is Pentaho Corporation.
008:         *
009:         * Software distributed under the Mozilla Public License is distributed on an "AS IS" 
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to 
011:         * the license for the specific language governing your rights and limitations.
012:         *
013:         * @created Apr 17, 2006 
014:         * @author James Dixon
015:         */
016:
017:        package org.pentaho.ui;
018:
019:        import java.io.File;
020:        import java.util.ArrayList;
021:        import java.util.StringTokenizer;
022:
023:        import org.pentaho.core.session.IPentahoSession;
024:        import org.pentaho.core.solution.HttpRequestParameterProvider;
025:        import org.pentaho.core.solution.IParameterProvider;
026:        import org.pentaho.core.system.PentahoSystem;
027:        import org.pentaho.core.ui.SimpleUrlFactory;
028:        import org.pentaho.core.util.UIUtil;
029:        import org.pentaho.messages.Messages;
030:        import org.pentaho.ui.component.charting.FlashChartComponent;
031:        import org.pentaho.util.logging.ILogger;
032:
033:        /**
034:         * This class provides wrapper functions to make it easier to generate flash 
035:         * charts within a dashboard environment.
036:         */
037:        public class FlashChartHelper {
038:
039:            /**
040:             * doFlashChart generates a flash media player chart.  It provides a simple
041:             * wrapper around the com.pentaho.ui.charting.FlashChartComponent
042:             * 
043:             * @param solutionName the solution name
044:             * @param actionPath the action path
045:             * @param chartName the xml file describing the chart
046:             * @param parameterProvider the collection of parameters to customize the chart
047:             * @param outputStream the output string buffer for the content
048:             * @param userSession the user session object
049:             * @param messages a collection to store error and logging messages
050:             * @param logger logging object
051:             * 
052:             * @return true if successful
053:             */
054:            public static boolean doFlashChart(String solutionName,
055:                    String actionPath, String chartName,
056:                    IParameterProvider parameterProvider,
057:                    StringBuffer outputStream, IPentahoSession userSession,
058:                    ArrayList messages, ILogger logger) {
059:
060:                boolean result = true;
061:                String outerParams = parameterProvider.getStringParameter(
062:                        "outer-params", null); //$NON-NLS-1$
063:                String innerParam = parameterProvider.getStringParameter(
064:                        "inner-param", null); //$NON-NLS-1$
065:
066:                String urlDrillTemplate = parameterProvider.getStringParameter(
067:                        "drill-url", null); //$NON-NLS-1$
068:                String imageUrl = parameterProvider.getStringParameter(
069:                        "image-url", null); //$NON-NLS-1$
070:                if (imageUrl == null) {
071:                    imageUrl = PentahoSystem.getApplicationContext()
072:                            .getBaseUrl();
073:                }
074:
075:                if (urlDrillTemplate == null) {
076:                    urlDrillTemplate = ""; //$NON-NLS-1$
077:                }
078:
079:                int width = (int) parameterProvider.getLongParameter(
080:                        "image-width", 150); //$NON-NLS-1$
081:                int height = (int) parameterProvider.getLongParameter(
082:                        "image-height", 150); //$NON-NLS-1$
083:                int topX = (int) parameterProvider.getLongParameter("topX", -1); //$NON-NLS-1$
084:
085:                SimpleUrlFactory urlFactory = new SimpleUrlFactory(
086:                        urlDrillTemplate);
087:
088:                FlashChartComponent chartComponent = null;
089:                try {
090:                    String chartDefinitionStr = solutionName + File.separator
091:                            + actionPath + File.separator + chartName;
092:                    chartComponent = new FlashChartComponent(
093:                            chartDefinitionStr, width, height, urlFactory,
094:                            messages);
095:                    if (logger != null) {
096:                        chartComponent
097:                                .setLoggingLevel(logger.getLoggingLevel());
098:                    }
099:                    chartComponent.validate(userSession, null);
100:                    chartComponent.setUrlTemplate(urlDrillTemplate);
101:                    if (outerParams != null) {
102:                        StringTokenizer tokenizer = new StringTokenizer(
103:                                outerParams, ";"); //$NON-NLS-1$
104:                        while (tokenizer.hasMoreTokens()) {
105:                            chartComponent.addOuterParamName(tokenizer
106:                                    .nextToken());
107:                        }
108:                    }
109:                    chartComponent.setParamName(innerParam);
110:                    chartComponent.setTopX(topX);
111:
112:                    chartComponent.setDataAction(chartDefinitionStr);
113:
114:                    chartComponent.setParameterProvider(
115:                            HttpRequestParameterProvider.SCOPE_REQUEST,
116:                            parameterProvider);
117:
118:                    String content = chartComponent.getContent("text/html"); //$NON-NLS-1$
119:
120:                    if (content == null || content.equals("")) { //$NON-NLS-1$
121:                        content = " "; //$NON-NLS-1$
122:                    }
123:                    if (content == null) {
124:                        StringBuffer buffer = new StringBuffer();
125:                        UIUtil
126:                                .formatErrorMessage(
127:                                        "text/html", Messages.getString("Widget.ERROR_0001_COULD_NOT_CREATE_WIDGET"), messages, buffer); //$NON-NLS-1$ //$NON-NLS-2$
128:                        content = buffer.toString();
129:                        result = false;
130:                    }
131:
132:                    outputStream.append(content);
133:
134:                } finally {
135:                    if (chartComponent != null)
136:                        chartComponent.dispose();
137:                }
138:                return result;
139:
140:            }
141:
142:            /**
143:             * doFlashDial generates a flash media player dial.  It provides a simple
144:             * wrapper around the com.pentaho.ui.charting.FlashChartComponent
145:             * 
146:             * @param solutionName the solution name
147:             * @param actionPath the action path
148:             * @param chartName the xml file describing the chart
149:             * @param parameterProvider the collection of parameters to customize the chart
150:             * @param outputStream the output string buffer for the content
151:             * @param userSession the user session object
152:             * @param messages a collection to store error and logging messages
153:             * @param logger logging object
154:             * 
155:             * @return true if successful
156:             */
157:            public static boolean doFlashDial(String solutionName,
158:                    String actionPath, String actionName,
159:                    IParameterProvider parameterProvider,
160:                    StringBuffer outputStream, IPentahoSession userSession,
161:                    ArrayList messages, ILogger logger) {
162:
163:                boolean result = true;
164:                String urlDrillTemplate = parameterProvider.getStringParameter(
165:                        "drill-url", null); //$NON-NLS-1$
166:                String imageUrl = parameterProvider.getStringParameter(
167:                        "image-url", null); //$NON-NLS-1$
168:                if (imageUrl == null) {
169:                    imageUrl = PentahoSystem.getApplicationContext()
170:                            .getBaseUrl();
171:                }
172:
173:                if (urlDrillTemplate == null) {
174:                    urlDrillTemplate = ""; //$NON-NLS-1$
175:                }
176:
177:                int width = (int) parameterProvider.getLongParameter(
178:                        "image-width", 150); //$NON-NLS-1$
179:                int height = (int) parameterProvider.getLongParameter(
180:                        "image-height", 150); //$NON-NLS-1$
181:                int topX = (int) parameterProvider.getLongParameter("topX", -1); //$NON-NLS-1$
182:
183:                SimpleUrlFactory urlFactory = new SimpleUrlFactory(
184:                        urlDrillTemplate);
185:
186:                FlashChartComponent chartComponent = null;
187:                try {
188:                    String chartDefinitionStr = solutionName + File.separator
189:                            + actionPath + File.separator + actionName;
190:                    chartComponent = new FlashChartComponent(
191:                            chartDefinitionStr, width, height, urlFactory,
192:                            messages);
193:                    if (logger != null) {
194:                        chartComponent
195:                                .setLoggingLevel(logger.getLoggingLevel());
196:                    }
197:                    chartComponent.validate(userSession, null);
198:                    chartComponent.setUrlTemplate(urlDrillTemplate);
199:                    chartComponent.setTopX(topX);
200:
201:                    chartComponent.setDataAction(chartDefinitionStr);
202:
203:                    chartComponent.setParameterProvider(
204:                            HttpRequestParameterProvider.SCOPE_REQUEST,
205:                            parameterProvider);
206:
207:                    String content = chartComponent.getDialContent("text/html"); //$NON-NLS-1$
208:
209:                    if (content == null || content.equals("")) { //$NON-NLS-1$
210:                        content = " "; //$NON-NLS-1$
211:                    }
212:
213:                    if (content == null) {
214:                        StringBuffer buffer = new StringBuffer();
215:                        UIUtil
216:                                .formatErrorMessage(
217:                                        "text/html", Messages.getString("Widget.ERROR_0001_COULD_NOT_CREATE_WIDGET"), messages, buffer); //$NON-NLS-1$ //$NON-NLS-2$
218:                        content = buffer.toString();
219:                        result = false;
220:                    }
221:
222:                    outputStream.append(content);
223:
224:                } finally {
225:                    if (chartComponent != null)
226:                        chartComponent.dispose();
227:                }
228:                return result;
229:            }
230:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.