Source Code Cross Referenced for BasicSingleValueDatasetBasedCharts.java in  » ESB » open-esb » org » openesb » tools » extchart » jfchart » 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 » ESB » open esb » org.openesb.tools.extchart.jfchart 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * BEGIN_HEADER - DO NOT EDIT
003:         *
004:         * The contents of this file are subject to the terms
005:         * of the Common Development and Distribution License
006:         * (the "License").  You may not use this file except
007:         * in compliance with the License.
008:         *
009:         * You can obtain a copy of the license at
010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011:         * See the License for the specific language governing
012:         * permissions and limitations under the License.
013:         *
014:         * When distributing Covered Code, include this CDDL
015:         * HEADER in each file and include the License file at
016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017:         * If applicable add the following below this CDDL HEADER,
018:         * with the fields enclosed by brackets "[]" replaced with
019:         * your own identifying information: Portions Copyright
020:         * [year] [name of copyright owner]
021:         */
022:
023:        /*
024:         * @(#)BasicSingleValueDatasetBasedCharts.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package org.openesb.tools.extchart.jfchart;
030:
031:        import org.openesb.tools.extchart.exception.ChartException;
032:        import org.openesb.tools.extchart.jfchart.data.DataAccess;
033:        import org.openesb.tools.extchart.property.ChartConstants;
034:        import org.openesb.tools.extchart.property.ChartDefaults;
035:        import org.openesb.tools.extchart.property.JFChartConstants;
036:        import org.openesb.tools.extchart.property.meter.MeterProperties;
037:        import org.openesb.tools.extpropertysheet.IExtPropertyGroup;
038:        import org.openesb.tools.extpropertysheet.IExtPropertyGroupsBean;
039:        import com.sun.web.ui.component.Property;
040:        import java.awt.BasicStroke;
041:        import java.awt.Color;
042:        import java.awt.Font;
043:        import java.awt.Paint;
044:        import java.text.DecimalFormat;
045:        import java.util.HashMap;
046:        import java.util.Map;
047:        import java.util.Properties;
048:        import java.util.logging.Logger;
049:        import org.jfree.chart.JFreeChart;
050:        import org.jfree.chart.plot.DialShape;
051:        import org.jfree.chart.plot.MeterInterval;
052:        import org.jfree.chart.plot.MeterPlot;
053:        import org.jfree.chart.plot.ThermometerPlot;
054:        import org.jfree.data.Range;
055:        import org.jfree.data.general.ValueDataset;
056:        import org.jfree.data.xy.XYDataset;
057:        import org.jfree.ui.RectangleInsets;
058:
059:        /**
060:         *
061:         * @author rdwivedi
062:         */
063:        public class BasicSingleValueDatasetBasedCharts extends Chart {
064:
065:            private IExtPropertyGroupsBean propGrps = null;
066:            private DataAccess mDA = null;
067:            private static Logger mLogger = Logger
068:                    .getLogger(BasicSingleValueDatasetBasedCharts.class
069:                            .getName());
070:            private static String METER_CHART = "meterChart";
071:            private static String THERMO_CHART = "thermoChart";
072:
073:            public static Map getAllAllowedCharts() {
074:                HashMap map = new HashMap();
075:                map.put(METER_CHART, "Meter Chart");
076:                map.put(THERMO_CHART, "Thermo Chart");
077:
078:                return map;
079:            }
080:
081:            /** Creates a new instance of BasicCategoryDatasetBasedCharts */
082:            public BasicSingleValueDatasetBasedCharts(
083:                    IExtPropertyGroupsBean pg, DataAccess da) {
084:                propGrps = pg;
085:                mDA = da;
086:            }
087:
088:            public ChartDefaults getChartDefaults() {
089:                IExtPropertyGroup p = propGrps
090:                        .getGroupByName(JFChartConstants.CHART_COMMON_PROPERTIES);
091:                return (ChartDefaults) p;
092:            }
093:
094:            private IExtPropertyGroupsBean getChartPropertiesGroup() {
095:                return propGrps;
096:            }
097:
098:            private IExtPropertyGroup getSpecificProperties() {
099:                return getChartPropertiesGroup().getGroupByName(
100:                        JFChartConstants.CHART_SPECIFIC_PROPERTIES);
101:            }
102:
103:            public JFreeChart createChart() throws ChartException {
104:                ValueDataset dataset = null;
105:                JFreeChart chart = null;
106:                dataset = (ValueDataset) mDA.getDataSet();
107:                chart = generateChart(dataset);
108:
109:                return chart;
110:            }
111:
112:            private JFreeChart generateChart(ValueDataset ds) {
113:                JFreeChart chart = null;
114:                ChartDefaults p = getChartDefaults();
115:                String type = (String) p.getProperty(
116:                        JFChartConstants.CHART_TYPE).getValue();
117:                if (type.equals(METER_CHART)) {
118:                    chart = createMeterChart(ds);
119:                } else if (type.equals(THERMO_CHART)) {
120:                    chart = createThermoChart(ds);
121:                } else {
122:                    mLogger.info("Chart type" + type + "  not supported.");
123:                }
124:
125:                chart.setBackgroundPaint(this .getChartDefaults()
126:                        .getBackgroundColor());
127:                super .setTitle(chart);
128:                super .setLegend(chart);
129:                super .setBorder(chart);
130:
131:                return chart;
132:            }
133:
134:            private JFreeChart createMeterChart(ValueDataset ds) {
135:                JFreeChart chart = null;
136:
137:                MeterPlot plot = null;
138:
139:                MeterProperties meterProp = (MeterProperties) getSpecificProperties();
140:                ChartDefaults def = this .getChartDefaults();
141:                plot = new MeterPlot(ds);
142:                DecimalFormat df = new DecimalFormat(def.getRealNumberFormat());
143:                plot.setTickLabelFormat(df);
144:                plot.setUnits(meterProp.getUnits());
145:                Range range = new Range(meterProp.getMinimumValue(), meterProp
146:                        .getMaximumValue());
147:                plot.setRange(range);
148:
149:                Range normalRange = new Range(
150:                        meterProp.getMinimumNormalValue(), meterProp
151:                                .getMaximumNormalValue());
152:                MeterInterval normal = new MeterInterval("Normal", normalRange,
153:                        meterProp.getNormalPaint(), new BasicStroke(2.0f), null);
154:                plot.addInterval(normal);
155:
156:                Range warningRange = new Range(meterProp
157:                        .getMinimumWarningValue(), meterProp
158:                        .getMaximumWarningValue());
159:                MeterInterval warning = new MeterInterval("Warning",
160:                        warningRange, meterProp.getWarningPaint(),
161:                        new BasicStroke(2.0f), null);
162:                plot.addInterval(warning);
163:
164:                Range criticalRange = new Range(meterProp
165:                        .getMinimumCriticalValue(), meterProp
166:                        .getMaximumCriticalValue());
167:                MeterInterval critical = new MeterInterval("Critical",
168:                        criticalRange, meterProp.getCriticalPaint(),
169:                        new BasicStroke(2.0f), null);
170:
171:                plot.addInterval(critical);
172:
173:                double maxValue = Math.max(meterProp.getMaximumCriticalValue(),
174:                        meterProp.getMaximumValue());
175:
176:                int dialType = meterProp.getDialType();
177:                switch (dialType) {
178:                case MeterProperties.DIALTYPE_PIE:
179:                    plot.setDialShape(DialShape.PIE);
180:                    break;
181:                case MeterProperties.DIALTYPE_CHORD:
182:                    plot.setDialShape(DialShape.CHORD);
183:                    break;
184:                default:
185:                    plot.setDialShape(DialShape.CIRCLE);
186:                }
187:
188:                int tickLabelType = meterProp.getTickLabelType();
189:                if (tickLabelType == MeterProperties.TICK_NO_LABELS) {
190:                    plot.setTickLabelsVisible(false);
191:                }
192:
193:                Font tickLabelFont = meterProp.getTickLabelFont();
194:                if (tickLabelFont != null) {
195:                    plot.setTickLabelFont(tickLabelFont);
196:                }
197:
198:                plot.setDrawBorder(meterProp.isDrawBorder());
199:                plot.setDialBackgroundPaint(meterProp.getDialBackgroundPaint());
200:                plot
201:                        .setDialOutlinePaint((Paint) meterProp
202:                                .getDialBorderColor());
203:                plot.setNeedlePaint(meterProp.getNeedlePaint());
204:                plot.setValuePaint(meterProp.getValuePaint());
205:                //plot.setMeterAngle(meterProp.getMeterAngle());
206:                Font valueFont = meterProp.getValueFont();
207:                if (valueFont != null) {
208:                    plot.setValueFont(valueFont);
209:                }
210:
211:                plot.setInsets(new RectangleInsets(5, 5, 5, 5));
212:                String title = null;
213:                String sNoData = "No Data";
214:
215:                chart = new JFreeChart(title, def.getTitleFont(), plot, def
216:                        .isIncludeLegend());
217:                return chart;
218:            }
219:
220:            private JFreeChart createThermoChart(ValueDataset ds) {
221:                MeterProperties meterProp = (MeterProperties) getSpecificProperties();
222:                ChartDefaults def = this .getChartDefaults();
223:                boolean includeLegend = def.isIncludeLegend();
224:                boolean is3D = def.is3D();
225:                String title = def.getTitle();
226:                boolean bUseTooltips = true;
227:                boolean bDrilldownEnabled = false;
228:                ThermometerPlot plot = new ThermometerPlot(ds);
229:                JFreeChart chart = new JFreeChart("Thermometer Demo 1", // chart title
230:                        JFreeChart.DEFAULT_TITLE_FONT, plot, // plot
231:                        false // no legend
232:                );
233:
234:                // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
235:                plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
236:                plot.setThermometerStroke(new BasicStroke(2.0f));
237:                plot.setThermometerPaint(Color.lightGray);
238:                // OPTIONAL CUSTOMISATION COMPLETED.
239:
240:                return chart;
241:            }
242:
243:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.