Source Code Cross Referenced for SimpleXYModel.java in  » Ajax » zk » org » zkoss » zul » 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 » Ajax » zk » org.zkoss.zul 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* SimpleXYModel.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Thu Aug 14 11:30:51     2006, Created by henrichen
010:        }}IS_NOTE
011:
012:        Copyright (C) 2006 Potix Corporation. All Rights Reserved.
013:
014:        {{IS_RIGHT
015:        	This program is distributed under GPL Version 2.0 in the hope that
016:        	it will be useful, but WITHOUT ANY WARRANTY.
017:        }}IS_RIGHT
018:         */
019:        package org.zkoss.zul;
020:
021:        import org.zkoss.lang.Objects;
022:        import org.zkoss.zul.event.ChartDataEvent;
023:        import org.zkoss.zul.event.ChartDataListener;
024:
025:        import java.util.Map;
026:        import java.util.List;
027:        import java.util.HashMap;
028:        import java.util.Iterator;
029:        import java.util.ArrayList;
030:        import java.util.Collection;
031:
032:        /**
033:         * A XY data model implementation of {@link XYModel}.
034:         * A XY model is an N series of (X, Y) data objects .
035:         *
036:         * @author henrichen
037:         * @see XYModel
038:         * @see Chart
039:         */
040:        public class SimpleXYModel extends AbstractChartModel implements 
041:                XYModel {
042:            private Map _seriesMap = new HashMap(13); //(series, SimplePieModel)
043:            private List _seriesList = new ArrayList(13);
044:            private boolean _autoSort = true;
045:
046:            //-- XYModel --//
047:            public Comparable getSeries(int index) {
048:                return (Comparable) _seriesList.get(index);
049:            }
050:
051:            public Collection getSeries() {
052:                return _seriesList;
053:            }
054:
055:            public int getDataCount(Comparable series) {
056:                final List xyPairs = (List) _seriesMap.get(series);
057:                return xyPairs != null ? xyPairs.size() : 0;
058:            }
059:
060:            public Number getX(Comparable series, int index) {
061:                final List xyPairs = (List) _seriesMap.get(series);
062:
063:                if (xyPairs != null) {
064:                    return ((XYPair) xyPairs.get(index)).getX();
065:                }
066:                return null;
067:            }
068:
069:            public Number getY(Comparable series, int index) {
070:                final List xyPairs = (List) _seriesMap.get(series);
071:
072:                if (xyPairs != null) {
073:                    return ((XYPair) xyPairs.get(index)).getY();
074:                }
075:                return null;
076:            }
077:
078:            public void addValue(Comparable series, Number x, Number y) {
079:                List xyPairs = (List) _seriesMap.get(series);
080:                if (xyPairs == null) {
081:                    xyPairs = new ArrayList(13);
082:                    _seriesMap.put(series, xyPairs);
083:                    _seriesList.add(series);
084:                }
085:                xyPairs.add(new XYPair(x, y));
086:                fireEvent(ChartDataEvent.CHANGED, series, null);
087:            }
088:
089:            public void setAutoSort(boolean auto) {
090:                _autoSort = auto;
091:            }
092:
093:            public boolean isAutoSort() {
094:                return _autoSort;
095:            }
096:
097:            public void removeSeries(Comparable series) {
098:                _seriesMap.remove(series);
099:                _seriesList.remove(series);
100:                fireEvent(ChartDataEvent.REMOVED, (String) series, null);
101:            }
102:
103:            public void removeValue(Comparable series, int index) {
104:                List xyPairs = (List) _seriesMap.get(series);
105:                if (xyPairs == null) {
106:                    return;
107:                }
108:                xyPairs.remove(index);
109:                fireEvent(ChartDataEvent.REMOVED, series, null);
110:            }
111:
112:            public void clear() {
113:                _seriesMap.clear();
114:                _seriesList.clear();
115:                fireEvent(ChartDataEvent.REMOVED, null, null);
116:            }
117:
118:            //-- internal class --//
119:            private static class XYPair {
120:                private Number _x;
121:                private Number _y;
122:
123:                private XYPair(Number x, Number y) {
124:                    _x = x;
125:                    _y = y;
126:                }
127:
128:                private Number getX() {
129:                    return _x;
130:                }
131:
132:                private Number getY() {
133:                    return _y;
134:                }
135:            }
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.