Source Code Cross Referenced for JDBCPieDataset.java in  » Portal » stringbeans-3.5 » com » nabhinc » portlet » chart » 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 » Portal » stringbeans 3.5 » com.nabhinc.portlet.chart 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * (C) Copyright 2000 - 2003 Nabh Information Systems, Inc. 
003:         * 
004:         * This program is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU General Public License 
006:         * as published by the Free Software Foundation; either version 2
007:         * of the License, or (at your option) any later version.
008:         * 
009:         * This program is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of 
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
012:         * GNU General Public License for more details.
013:         * 
014:         * You should have received a copy of the GNU General Public License
015:         * along with this program; if not, write to the Free Software 
016:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:         * 
018:         */
019:
020:        package com.nabhinc.portlet.chart;
021:
022:        import java.util.List;
023:        import java.sql.Connection;
024:        import java.sql.PreparedStatement;
025:        import java.sql.ResultSet;
026:
027:        import javax.portlet.PortletException;
028:
029:        import org.jfree.chart.tooltips.PieToolTipGenerator;
030:        import org.jfree.chart.urls.PieURLGenerator;
031:        import org.jfree.data.DefaultKeyedValues;
032:        import org.jfree.data.PieDataset;
033:
034:        import com.nabhinc.util.db.DBUtil;
035:
036:        /**
037:         * 
038:         *
039:         * @author Padmanabh Dabke
040:         * (c) 2002, 2003 Nabh Information Systems, Inc. All Rights Reserved.
041:         */
042:        public class JDBCPieDataset extends BaseJDBCDataset implements 
043:                PieDataset, PieToolTipGenerator, PieURLGenerator {
044:
045:            private static final long serialVersionUID = -2779799940607207488L;
046:
047:            private DefaultKeyedValues jpdsPieData = null;
048:
049:            /**
050:             * Dummy data.
051:             */
052:            private String[] jpdsDummyData = { "mon", "tue", "wed", "thu",
053:                    "fri", "sat", "sun" };
054:
055:            /**
056:             * Categories specified in configuration.
057:             * @see com.nabhinc.core.XMLInitable#init(Element)
058:             */
059:            private String[] jpdsConfiguredCategories = null;
060:
061:            /**
062:             * @see com.nabhinc.portal.charting.BaseJDBCDataSet#createDummyData()
063:             */
064:            public void createDummyData() {
065:                if (jpdsPieData == null) {
066:                    jpdsPieData = new DefaultKeyedValues();
067:                    for (int i = 0; i < jpdsDummyData.length; i++) {
068:                        jpdsPieData.setValue(jpdsDummyData[i], new Integer(i
069:                                * i - i + 1));
070:                    }
071:                }
072:            }
073:
074:            /**
075:             * @see com.nabhinc.portal.charting.AbstractDataSet#executeQuery()
076:             */
077:            public void executeQuery() throws PortletException {
078:                Object xObject = null;
079:                int column = 0;
080:                int numberOfColumns = 0;
081:                int numberOfValidColumns = 0;
082:                int columnTypes[] = null;
083:
084:                jpdsPieData = new DefaultKeyedValues();
085:                Connection connection = null;
086:                ResultSet resultSet = null;
087:                PreparedStatement statement = null;
088:                try {
089:                    connection = DBUtil.getConnection(bjdsDataSource);
090:                    statement = connection.prepareStatement(bjdsSQL);
091:                    resultSet = statement.executeQuery();
092:                    /// might need to add, to free memory from any previous result sets
093:                    int counter = 0;
094:                    while (resultSet.next()) {
095:                        Object category = null;
096:                        Number value = null;
097:                        if (jpdsConfiguredCategories == null) {
098:                            category = resultSet.getString(1);
099:                            //System.out.println("Category = " + category);
100:                            value = (Number) resultSet.getObject(2);
101:                        } else {
102:                            category = jpdsConfiguredCategories[counter];
103:                            counter++;
104:                            value = (Number) resultSet.getObject(1);
105:                        }
106:                        jpdsPieData.setValue((Comparable) category, value);
107:
108:                    }
109:
110:                    fireDatasetChanged();
111:
112:                } catch (Exception ex) {
113:                    throw new PortletException("Database exception.", ex);
114:                } finally {
115:                    DBUtil.close(resultSet);
116:                    DBUtil.close(statement);
117:                    DBUtil.close(connection);
118:                }
119:            }
120:
121:            /**
122:             * @see de.laures.cewolf.PieSectionLinkGenerator#generateLink(java.lang.Object, java.lang.Object)
123:             */
124:            public String generateLink(Object dataset, Object category) {
125:                return "";
126:            }
127:
128:            /**
129:             * @see org.jfree.chart.tooltips.PieToolTipGenerator#generateToolTip(com.jrefinery.data.PieDataset, java.lang.Object)
130:             */
131:            public String generateToolTip(PieDataset data, Object category) {
132:                return category.toString();
133:            }
134:
135:            /**
136:             * @see org.jfree.chart.urls.PieURLGenerator#generateURL(com.jrefinery.data.PieDataset, java.lang.Object)
137:             */
138:            public String generateURL(PieDataset data, Object category) {
139:                return "http://java.sun.com?cat=" + category.toString();
140:            }
141:
142:            /* (non-Javadoc)
143:             * @see org.jfree.data.KeyedValues#getKey(int)
144:             */
145:            public Comparable getKey(int arg0) {
146:                return jpdsPieData.getKey(arg0);
147:            }
148:
149:            /* (non-Javadoc)
150:             * @see org.jfree.data.KeyedValues#getIndex(java.lang.Comparable)
151:             */
152:            public int getIndex(Comparable arg0) {
153:                return jpdsPieData.getIndex(arg0);
154:            }
155:
156:            /* (non-Javadoc)
157:             * @see org.jfree.data.KeyedValues#getValue(java.lang.Comparable)
158:             */
159:            public Number getValue(Comparable arg0) {
160:                return jpdsPieData.getValue(arg0);
161:            }
162:
163:            /* (non-Javadoc)
164:             * @see org.jfree.data.Values#getItemCount()
165:             */
166:            public int getItemCount() {
167:                return jpdsPieData.getItemCount();
168:
169:            }
170:
171:            /* (non-Javadoc)
172:             * @see org.jfree.chart.tooltips.PieToolTipGenerator#generateToolTip(org.jfree.data.PieDataset, java.lang.Comparable, int)
173:             */
174:            public String generateToolTip(PieDataset arg0, Comparable arg1,
175:                    int arg2) {
176:                return "";
177:            }
178:
179:            /* (non-Javadoc)
180:             * @see org.jfree.chart.urls.PieURLGenerator#generateURL(org.jfree.data.PieDataset, java.lang.Comparable, int)
181:             */
182:            public String generateURL(PieDataset arg0, Comparable arg1, int arg2) {
183:                return "";
184:            }
185:
186:            /* (non-Javadoc)
187:             * @see org.jfree.data.KeyedValues#getKeys()
188:             */
189:            public List getKeys() {
190:                return jpdsPieData.getKeys();
191:
192:            }
193:
194:            /* (non-Javadoc)
195:             * @see org.jfree.data.Values#getValue(int)
196:             */
197:            public Number getValue(int item) {
198:                return jpdsPieData.getValue(item);
199:            }
200:
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.