Source Code Cross Referenced for ClipPath.java in  » Chart » jfreechart » org » jfree » 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 » Chart » jfreechart » org.jfree.chart 
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:         * ClipPath.java
029:         * -------------
030:         * (C) Copyright 2003, 2004, 2007, by David M. O'Donnell and Contributors.
031:         *
032:         * Original Author:  David M. O'Donnell;
033:         * Contributor(s):   David Gilbert (for Object Refinery Limited);
034:         *                   Nicolas Brodu;
035:         *
036:         * $Id: ClipPath.java,v 1.2.2.3 2007/04/04 09:04:35 mungady Exp $
037:         *
038:         * Changes
039:         * -------
040:         * 22-Apr-2003 : Added standard header (DG);
041:         * 09-May-2003 : Added AxisLocation (DG);
042:         * 11-Sep-2003 : Implemented Cloneable (NB);
043:         * 21-Jan-2004 : Update for renamed method in ValueAxis (DG);
044:         * ------------- JFREECHART 1.0.x ---------------------------------------------
045:         * 31-Jan-2007 : Deprecated (DG);
046:         *
047:         */
048:
049:        package org.jfree.chart;
050:
051:        import java.awt.BasicStroke;
052:        import java.awt.Composite;
053:        import java.awt.Graphics2D;
054:        import java.awt.Paint;
055:        import java.awt.Stroke;
056:        import java.awt.geom.GeneralPath;
057:        import java.awt.geom.Rectangle2D;
058:
059:        import org.jfree.chart.axis.ValueAxis;
060:        import org.jfree.chart.plot.XYPlot;
061:        import org.jfree.chart.renderer.xy.XYBlockRenderer;
062:        import org.jfree.ui.RectangleEdge;
063:
064:        /**
065:         * This class would typically be used with a 
066:         * {@link org.jfree.chart.plot.ContourPlot}.  It allows the user to define a 
067:         * <code>GeneralPath</code> curve in plot coordinates.  This curve can then be 
068:         * used mask off or define regions within the contour plot.  The data must be 
069:         * sorted.
070:         * 
071:         * @deprecated This class is no longer supported (as of version 1.0.4).  If 
072:         *     you are creating contour plots, please try to use {@link XYPlot} and 
073:         *     {@link XYBlockRenderer}.
074:         */
075:        public class ClipPath implements  Cloneable {
076:
077:            /** The x values. */
078:            private double[] xValue = null;
079:
080:            /** The y values. */
081:            private double[] yValue = null;
082:
083:            /** Controls whether drawing will be clipped (
084:             * false would still allow the drawing or filling of path */
085:            private boolean clip = true;
086:
087:            /** Controls whether the path is drawn as an outline. */
088:            private boolean drawPath = false;
089:
090:            /** Controls whether the path is filled. */
091:            private boolean fillPath = false;
092:
093:            /** The fill paint. */
094:            private Paint fillPaint = null;
095:
096:            /** The draw paint. */
097:            private Paint drawPaint = null;
098:
099:            /** The draw stroke. */
100:            private Stroke drawStroke = null;
101:
102:            /** The composite. */
103:            private Composite composite = null;
104:
105:            /**
106:             * Constructor for ClipPath.
107:             */
108:            public ClipPath() {
109:                super ();
110:            }
111:
112:            /**
113:             * Constructor for ClipPath.
114:             * Default values are assumed for the fillPath and drawPath options as 
115:             * false and true respectively.  The fillPaint is set to Color.GRAY, the 
116:             * drawColor is Color.BLUE, the stroke is BasicStroke(1)
117:             * and the composite is AlphaComposite.Src.
118:             *
119:             * @param xValue  x coordinates of curved to be created
120:             * @param yValue  y coordinates of curved to be created
121:             */
122:            public ClipPath(double[] xValue, double[] yValue) {
123:                this (xValue, yValue, true, false, true);
124:            }
125:
126:            /**
127:             * Constructor for ClipPath.
128:             * The fillPaint is set to Color.GRAY, the drawColor is Color.BLUE, the 
129:             * stroke is BasicStroke(1) and the composite is AlphaComposite.Src.
130:             *
131:             * @param xValue  x coordinates of curved to be created
132:             * @param yValue  y coordinates of curved to be created
133:             * @param clip  clip?
134:             * @param fillPath  whether the path is to filled
135:             * @param drawPath  whether the path is to drawn as an outline
136:             */
137:            public ClipPath(double[] xValue, double[] yValue, boolean clip,
138:                    boolean fillPath, boolean drawPath) {
139:                this .xValue = xValue;
140:                this .yValue = yValue;
141:
142:                this .clip = clip;
143:                this .fillPath = fillPath;
144:                this .drawPath = drawPath;
145:
146:                this .fillPaint = java.awt.Color.gray;
147:                this .drawPaint = java.awt.Color.blue;
148:                this .drawStroke = new BasicStroke(1);
149:                this .composite = java.awt.AlphaComposite.Src;
150:            }
151:
152:            /**
153:             * Constructor for ClipPath.
154:             *
155:             * @param xValue  x coordinates of curved to be created
156:             * @param yValue  y coordinates of curved to be created
157:             * @param fillPath  whether the path is to filled
158:             * @param drawPath  whether the path is to drawn as an outline
159:             * @param fillPaint  the fill paint
160:             * @param drawPaint  the outline stroke color
161:             * @param drawStroke  the stroke style
162:             * @param composite  the composite rule
163:             */
164:            public ClipPath(double[] xValue, double[] yValue, boolean fillPath,
165:                    boolean drawPath, Paint fillPaint, Paint drawPaint,
166:                    Stroke drawStroke, Composite composite) {
167:
168:                this .xValue = xValue;
169:                this .yValue = yValue;
170:
171:                this .fillPath = fillPath;
172:                this .drawPath = drawPath;
173:
174:                this .fillPaint = fillPaint;
175:                this .drawPaint = drawPaint;
176:                this .drawStroke = drawStroke;
177:                this .composite = composite;
178:
179:            }
180:
181:            /**
182:             * Draws the clip path.
183:             *
184:             * @param g2  current graphics2D.
185:             * @param dataArea  the dataArea that the plot is being draw in.
186:             * @param horizontalAxis  the horizontal axis.
187:             * @param verticalAxis  the vertical axis.
188:             *
189:             * @return The GeneralPath defining the outline
190:             */
191:            public GeneralPath draw(Graphics2D g2, Rectangle2D dataArea,
192:                    ValueAxis horizontalAxis, ValueAxis verticalAxis) {
193:
194:                GeneralPath generalPath = generateClipPath(dataArea,
195:                        horizontalAxis, verticalAxis);
196:                if (this .fillPath || this .drawPath) {
197:                    Composite saveComposite = g2.getComposite();
198:                    Paint savePaint = g2.getPaint();
199:                    Stroke saveStroke = g2.getStroke();
200:
201:                    if (this .fillPaint != null) {
202:                        g2.setPaint(this .fillPaint);
203:                    }
204:                    if (this .composite != null) {
205:                        g2.setComposite(this .composite);
206:                    }
207:                    if (this .fillPath) {
208:                        g2.fill(generalPath);
209:                    }
210:
211:                    if (this .drawStroke != null) {
212:                        g2.setStroke(this .drawStroke);
213:                    }
214:                    if (this .drawPath) {
215:                        g2.draw(generalPath);
216:                    }
217:                    g2.setPaint(savePaint);
218:                    g2.setComposite(saveComposite);
219:                    g2.setStroke(saveStroke);
220:                }
221:                return generalPath;
222:
223:            }
224:
225:            /**
226:             * Generates the clip path.
227:             *
228:             * @param dataArea  the dataArea that the plot is being draw in.
229:             * @param horizontalAxis  the horizontal axis.
230:             * @param verticalAxis  the vertical axis.
231:             *
232:             * @return The GeneralPath defining the outline
233:             */
234:            public GeneralPath generateClipPath(Rectangle2D dataArea,
235:                    ValueAxis horizontalAxis, ValueAxis verticalAxis) {
236:
237:                GeneralPath generalPath = new GeneralPath();
238:                double transX = horizontalAxis.valueToJava2D(this .xValue[0],
239:                        dataArea, RectangleEdge.BOTTOM);
240:                double transY = verticalAxis.valueToJava2D(this .yValue[0],
241:                        dataArea, RectangleEdge.LEFT);
242:                generalPath.moveTo((float) transX, (float) transY);
243:                for (int k = 0; k < this .yValue.length; k++) {
244:                    transX = horizontalAxis.valueToJava2D(this .xValue[k],
245:                            dataArea, RectangleEdge.BOTTOM);
246:                    transY = verticalAxis.valueToJava2D(this .yValue[k],
247:                            dataArea, RectangleEdge.LEFT);
248:                    generalPath.lineTo((float) transX, (float) transY);
249:                }
250:                generalPath.closePath();
251:
252:                return generalPath;
253:
254:            }
255:
256:            /**
257:             * Returns the composite.
258:             * 
259:             * @return Composite
260:             */
261:            public Composite getComposite() {
262:                return this .composite;
263:            }
264:
265:            /**
266:             * Returns the drawPaint.
267:             * 
268:             * @return Paint
269:             */
270:            public Paint getDrawPaint() {
271:                return this .drawPaint;
272:            }
273:
274:            /**
275:             * Returns the drawPath.
276:             * 
277:             * @return boolean
278:             */
279:            public boolean isDrawPath() {
280:                return this .drawPath;
281:            }
282:
283:            /**
284:             * Returns the drawStroke.
285:             * 
286:             * @return Stroke
287:             */
288:            public Stroke getDrawStroke() {
289:                return this .drawStroke;
290:            }
291:
292:            /**
293:             * Returns the fillPaint.
294:             * 
295:             * @return Paint
296:             */
297:            public Paint getFillPaint() {
298:                return this .fillPaint;
299:            }
300:
301:            /**
302:             * Returns the fillPath.
303:             * 
304:             * @return boolean
305:             */
306:            public boolean isFillPath() {
307:                return this .fillPath;
308:            }
309:
310:            /**
311:             * Returns the xValue.
312:             * 
313:             * @return double[]
314:             */
315:            public double[] getXValue() {
316:                return this .xValue;
317:            }
318:
319:            /**
320:             * Returns the yValue.
321:             * 
322:             * @return double[]
323:             */
324:            public double[] getYValue() {
325:                return this .yValue;
326:            }
327:
328:            /**
329:             * Sets the composite.
330:             * 
331:             * @param composite The composite to set
332:             */
333:            public void setComposite(Composite composite) {
334:                this .composite = composite;
335:            }
336:
337:            /**
338:             * Sets the drawPaint.
339:             * 
340:             * @param drawPaint The drawPaint to set
341:             */
342:            public void setDrawPaint(Paint drawPaint) {
343:                this .drawPaint = drawPaint;
344:            }
345:
346:            /**
347:             * Sets the drawPath.
348:             * 
349:             * @param drawPath The drawPath to set
350:             */
351:            public void setDrawPath(boolean drawPath) {
352:                this .drawPath = drawPath;
353:            }
354:
355:            /**
356:             * Sets the drawStroke.
357:             * 
358:             * @param drawStroke The drawStroke to set
359:             */
360:            public void setDrawStroke(Stroke drawStroke) {
361:                this .drawStroke = drawStroke;
362:            }
363:
364:            /**
365:             * Sets the fillPaint.
366:             * 
367:             * @param fillPaint The fillPaint to set
368:             */
369:            public void setFillPaint(Paint fillPaint) {
370:                this .fillPaint = fillPaint;
371:            }
372:
373:            /**
374:             * Sets the fillPath.
375:             * 
376:             * @param fillPath The fillPath to set
377:             */
378:            public void setFillPath(boolean fillPath) {
379:                this .fillPath = fillPath;
380:            }
381:
382:            /**
383:             * Sets the xValue.
384:             * 
385:             * @param xValue The xValue to set
386:             */
387:            public void setXValue(double[] xValue) {
388:                this .xValue = xValue;
389:            }
390:
391:            /**
392:             * Sets the yValue.
393:             * 
394:             * @param yValue The yValue to set
395:             */
396:            public void setYValue(double[] yValue) {
397:                this .yValue = yValue;
398:            }
399:
400:            /**
401:             * Returns the clip.
402:             * 
403:             * @return boolean
404:             */
405:            public boolean isClip() {
406:                return this .clip;
407:            }
408:
409:            /**
410:             * Sets the clip.
411:             * 
412:             * @param clip The clip to set
413:             */
414:            public void setClip(boolean clip) {
415:                this .clip = clip;
416:            }
417:
418:            /** 
419:             * Returns a clone of the object (a deeper clone than default to avoid bugs 
420:             * when setting values in cloned object).
421:             * 
422:             * @return The clone.
423:             * 
424:             * @throws CloneNotSupportedException if cloning is not supported.
425:             */
426:            public Object clone() throws CloneNotSupportedException {
427:                ClipPath clone = (ClipPath) super .clone();
428:                clone.xValue = (double[]) this .xValue.clone();
429:                clone.yValue = (double[]) this.yValue.clone();
430:                return clone;
431:            }
432:
433:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.