KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > chart > DefaultShapeFactory


1 /* ======================================
2  * JFreeChart : a free Java chart library
3  * ======================================
4  *
5  * Project Info: http://www.jfree.org/jfreechart/index.html
6  * Project Lead: David Gilbert (david.gilbert@object-refinery.com);
7  *
8  * (C) Copyright 2000-2003, by Object Refinery Limited and Contributors.
9  *
10  * This library is free software; you can redistribute it and/or modify it under the terms
11  * of the GNU Lesser General Public License as published by the Free Software Foundation;
12  * either version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License along with this
19  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20  * Boston, MA 02111-1307, USA.
21  *
22  * ------------------------
23  * DefaultShapeFactory.java
24  * ------------------------
25  * (C) Copyright 2002, 2003, by Jeremy Bowman.
26  *
27  * Original Author: Jeremy Bowman;
28  * Contributor(s): David Gilbert (for Object Refinery Limited);
29  *
30  * $Id: DefaultShapeFactory.java,v 1.3 2003/08/06 15:07:17 mungady Exp $
31  *
32  * Changes
33  * -------
34  * 13-May-2002 : Version 1 (JB);
35  * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG);
36  * 06-Aug-2003 : No longer required, so deprecated (DG);
37  *
38  */

39
40 package org.jfree.chart;
41
42 import java.awt.Shape JavaDoc;
43 import java.awt.geom.Ellipse2D JavaDoc;
44 import java.awt.geom.Rectangle2D JavaDoc;
45
46 /**
47  * Default provider of shapes for indicating data points on a Plot.
48  *
49  * @deprecated No longer used. Shapes are supplied by the DrawingSupplier if necessary.
50  *
51  * @author Jeremy Bowman
52  */

53 public class DefaultShapeFactory implements ShapeFactory {
54
55     /**
56      * Returns a Shape that can be used in plotting data. Used in XYPlots.
57      *
58      * @param series number of series.
59      * @param item index of the item. <i>Not used, i.e. redundant.</i>.
60      * @param x the centered x position of the shape.
61      * @param y the centered y position of the shape.
62      * @param scale the size of the shape (width and height, radius).
63      *
64      * @return a square for series == 0, a circle otherwise.
65      */

66     public Shape JavaDoc getShape(int series, int item, double x, double y, double scale) {
67
68         if (series == 0) {
69             return new Rectangle2D.Double JavaDoc(x - 0.5 * scale, y - 0.5 * scale, scale, scale);
70         }
71         else {
72             return new Ellipse2D.Double JavaDoc(x - 0.5 * scale, y - 0.5 * scale, scale, scale);
73         }
74
75     }
76
77     /**
78      * Returns a Shape that can be used in plotting data. Used in CategoryPlots.
79      *
80      * @param series number of series. <i>Not used, i.e. redundant</i>.
81      * @param category the category. <i>Not used, i.e. redundant</i>.
82      * @param x the centered x position of the shape.
83      * @param y the centered y position of the shape.
84      * @param scale the size of the shape (width and height, radius).
85      *
86      * @return a circle with the radius <code>scale</code> centered at (x,y).
87      */

88     public Shape JavaDoc getShape(int series, Object JavaDoc category, double x, double y, double scale) {
89
90         return new Ellipse2D.Double JavaDoc(x - 0.5 * scale, y - 0.5 * scale, scale, scale);
91
92     }
93 }
94
Popular Tags