Source Code Cross Referenced for PlotRenderingInfo.java in  » Chart » jfreechart » org » jfree » chart » plot » 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 » Chart » jfreechart » org.jfree.chart.plot 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ===========================================================
002:         * JFreeChart : a free chart library for the Java(tm) platform
003:         * ===========================================================
004:         *
005:         * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
006:         *
007:         * Project Info:  http://www.jfree.org/jfreechart/index.html
008:         *
009:         * This library is free software; you can redistribute it and/or modify it 
010:         * under the terms of the GNU Lesser General Public License as published by 
011:         * the Free Software Foundation; either version 2.1 of the License, or 
012:         * (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful, but 
015:         * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
016:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
017:         * License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
022:         * USA.  
023:         *
024:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
025:         * in the United States and other countries.]
026:         *
027:         * ----------------------
028:         * PlotRenderingInfo.java
029:         * ----------------------
030:         * (C) Copyright 2003-2007, by Object Refinery Limited.
031:         *
032:         * Original Author:  David Gilbert (for Object Refinery Limited);
033:         * Contributor(s):   -;
034:         *
035:         * $Id: PlotRenderingInfo.java,v 1.5.2.4 2007/04/17 11:13:25 mungady Exp $
036:         *
037:         * Changes
038:         * -------
039:         * 16-Sep-2003 : Version 1 (DG);
040:         * 23-Sep-2003 : Added Javadocs (DG);
041:         * 12-Nov-2004 : Added getSubplotCount() and findSubplot() methods (DG);
042:         * 01-Nov-2005 : Made 'owner' non-transient to fix bug 1344048 (DG);
043:         * ------------- JFREECHART 1.0.x ---------------------------------------------
044:         * 01-Dec-2006 : Implemented clone() method properly (DG);
045:         * 17-Apr-2007 : Fixed bug 1698965 (NPE in CombinedDomainXYPlot) (DG);
046:         * 
047:         */
048:
049:        package org.jfree.chart.plot;
050:
051:        import java.awt.geom.Point2D;
052:        import java.awt.geom.Rectangle2D;
053:        import java.io.IOException;
054:        import java.io.ObjectInputStream;
055:        import java.io.ObjectOutputStream;
056:        import java.io.Serializable;
057:        import java.util.List;
058:
059:        import org.jfree.chart.ChartRenderingInfo;
060:        import org.jfree.io.SerialUtilities;
061:        import org.jfree.util.ObjectUtilities;
062:
063:        /**
064:         * Stores information about the dimensions of a plot and its subplots.
065:         */
066:        public class PlotRenderingInfo implements  Cloneable, Serializable {
067:
068:            /** For serialization. */
069:            private static final long serialVersionUID = 8446720134379617220L;
070:
071:            /** The owner of this info. */
072:            private ChartRenderingInfo owner;
073:
074:            /** The plot area. */
075:            private transient Rectangle2D plotArea;
076:
077:            /** The data area. */
078:            private transient Rectangle2D dataArea;
079:
080:            /**
081:             * Storage for the plot rendering info objects belonging to the subplots. 
082:             */
083:            private List subplotInfo;
084:
085:            /**
086:             * Creates a new instance.
087:             * 
088:             * @param owner  the owner (<code>null</code> permitted).
089:             */
090:            public PlotRenderingInfo(ChartRenderingInfo owner) {
091:                this .owner = owner;
092:                this .dataArea = new Rectangle2D.Double();
093:                this .subplotInfo = new java.util.ArrayList();
094:            }
095:
096:            /**
097:             * Returns the owner (as specified in the constructor).
098:             * 
099:             * @return The owner (possibly <code>null</code>).
100:             */
101:            public ChartRenderingInfo getOwner() {
102:                return this .owner;
103:            }
104:
105:            /**
106:             * Returns the plot area (in Java2D space).
107:             * 
108:             * @return The plot area (possibly <code>null</code>).
109:             *
110:             * @see #setPlotArea(Rectangle2D)
111:             */
112:            public Rectangle2D getPlotArea() {
113:                return this .plotArea;
114:            }
115:
116:            /**
117:             * Sets the plot area.
118:             * 
119:             * @param area  the plot area (in Java2D space, <code>null</code> 
120:             *     permitted but discouraged)
121:             * 
122:             * @see #getPlotArea()
123:             */
124:            public void setPlotArea(Rectangle2D area) {
125:                this .plotArea = area;
126:            }
127:
128:            /**
129:             * Returns the plot's data area (in Java2D space).
130:             * 
131:             * @return The data area (possibly <code>null</code>).
132:             * 
133:             * @see #setDataArea(Rectangle2D)
134:             */
135:            public Rectangle2D getDataArea() {
136:                return this .dataArea;
137:            }
138:
139:            /**
140:             * Sets the data area.
141:             * 
142:             * @param area  the data area (in Java2D space, <code>null</code> permitted
143:             *     but discouraged).
144:             * 
145:             * @see #getDataArea()
146:             */
147:            public void setDataArea(Rectangle2D area) {
148:                this .dataArea = area;
149:            }
150:
151:            /**
152:             * Returns the number of subplots (possibly zero).
153:             * 
154:             * @return The subplot count.
155:             */
156:            public int getSubplotCount() {
157:                return this .subplotInfo.size();
158:            }
159:
160:            /**
161:             * Adds the info for a subplot.
162:             * 
163:             * @param info  the subplot info.
164:             * 
165:             * @see #getSubplotInfo(int)
166:             */
167:            public void addSubplotInfo(PlotRenderingInfo info) {
168:                this .subplotInfo.add(info);
169:            }
170:
171:            /**
172:             * Returns the info for a subplot.
173:             * 
174:             * @param index  the subplot index.
175:             * 
176:             * @return The info.
177:             * 
178:             * @see #addSubplotInfo(PlotRenderingInfo)
179:             */
180:            public PlotRenderingInfo getSubplotInfo(int index) {
181:                return (PlotRenderingInfo) this .subplotInfo.get(index);
182:            }
183:
184:            /**
185:             * Returns the index of the subplot that contains the specified
186:             * (x, y) point (the "source" point).  The source point will usually
187:             * come from a mouse click on a {@link org.jfree.chart.ChartPanel},
188:             * and this method is then used to determine the subplot that 
189:             * contains the source point.
190:             * 
191:             * @param source  the source point (in Java2D space, <code>null</code> not
192:             * permitted).
193:             * 
194:             * @return The subplot index (or -1 if no subplot contains 
195:             *         <code>source</code>).
196:             */
197:            public int getSubplotIndex(Point2D source) {
198:                if (source == null) {
199:                    throw new IllegalArgumentException(
200:                            "Null 'source' argument.");
201:                }
202:                int subplotCount = getSubplotCount();
203:                for (int i = 0; i < subplotCount; i++) {
204:                    PlotRenderingInfo info = getSubplotInfo(i);
205:                    Rectangle2D area = info.getDataArea();
206:                    if (area.contains(source)) {
207:                        return i;
208:                    }
209:                }
210:                return -1;
211:            }
212:
213:            /**
214:             * Tests this instance for equality against an arbitrary object.
215:             * 
216:             * @param obj  the object (<code>null</code> permitted).
217:             * 
218:             * @return A boolean.
219:             */
220:            public boolean equals(Object obj) {
221:                if (this  == obj) {
222:                    return true;
223:                }
224:                if (!(obj instanceof  PlotRenderingInfo)) {
225:                    return false;
226:                }
227:                PlotRenderingInfo that = (PlotRenderingInfo) obj;
228:                if (!ObjectUtilities.equal(this .dataArea, that.dataArea)) {
229:                    return false;
230:                }
231:                if (!ObjectUtilities.equal(this .plotArea, that.plotArea)) {
232:                    return false;
233:                }
234:                if (!ObjectUtilities.equal(this .subplotInfo, that.subplotInfo)) {
235:                    return false;
236:                }
237:                return true;
238:            }
239:
240:            /**
241:             * Returns a clone of this object.
242:             * 
243:             * @return A clone.
244:             * 
245:             * @throws CloneNotSupportedException if there is a problem cloning.
246:             */
247:            public Object clone() throws CloneNotSupportedException {
248:                PlotRenderingInfo clone = (PlotRenderingInfo) super .clone();
249:                if (this .plotArea != null) {
250:                    clone.plotArea = (Rectangle2D) this .plotArea.clone();
251:                }
252:                if (this .dataArea != null) {
253:                    clone.dataArea = (Rectangle2D) this .dataArea.clone();
254:                }
255:                clone.subplotInfo = new java.util.ArrayList(this .subplotInfo
256:                        .size());
257:                for (int i = 0; i < this .subplotInfo.size(); i++) {
258:                    PlotRenderingInfo info = (PlotRenderingInfo) this .subplotInfo
259:                            .get(i);
260:                    clone.subplotInfo.add(info.clone());
261:                }
262:                return clone;
263:            }
264:
265:            /**
266:             * Provides serialization support.
267:             *
268:             * @param stream  the output stream.
269:             *
270:             * @throws IOException  if there is an I/O error.
271:             */
272:            private void writeObject(ObjectOutputStream stream)
273:                    throws IOException {
274:                stream.defaultWriteObject();
275:                SerialUtilities.writeShape(this .dataArea, stream);
276:                SerialUtilities.writeShape(this .plotArea, stream);
277:            }
278:
279:            /**
280:             * Provides serialization support.
281:             *
282:             * @param stream  the input stream.
283:             *
284:             * @throws IOException  if there is an I/O error.
285:             * @throws ClassNotFoundException  if there is a classpath problem.
286:             */
287:            private void readObject(ObjectInputStream stream)
288:                    throws IOException, ClassNotFoundException {
289:                stream.defaultReadObject();
290:                this .dataArea = (Rectangle2D) SerialUtilities.readShape(stream);
291:                this .plotArea = (Rectangle2D) SerialUtilities.readShape(stream);
292:            }
293:
294:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.