1 /* ===========================================================
2  * JFreeChart : a free chart library for the Java(tm) platform
3  * ===========================================================
4  *
5  * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
6  *
7  * Project Info:  http://www.jfree.org/jfreechart/index.html
8  *
9  * This library is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
22  * USA.
23  *
24  * [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
25  * Other names may be trademarks of their respective owners.]
26  *
27  * -----------------------
28  * DrawableLegendItem.java
29  * -----------------------
30  * (C) Copyright 2002-2008, by Object Refinery Limited and Contributors.
31  *
32  * Original Author:  David Gilbert (for Object Refinery Limited);
33  * Contributor(s):   Luke Quinane;
34  *                   Barak Naveh;
35  *
36  * Changes
37  * -------
38  * 07-Feb-2002 : Version 1 (DG);
39  * 23-Sep-2002 : Renamed LegendItem --> DrawableLegendItem (DG);
40  * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG);
41  * 08-Oct-2003 : Applied patch for displaying series line style, contributed by
42  *               Luke Quinane (DG);
43  * 27-Mar-2004 : Added getMaxX() and getMaxY() methods (BN);
44  * 27-Jan-2005 : Cleared out code that belongs in the LegendItem class (DG);
45  *
46  */
47 
48 package org.jfree.chart;
49 
50 import java.awt.Shape;
51 import java.awt.geom.Line2D;
52 import java.awt.geom.Point2D;
53 
54 /**
55  * This class contains a single legend item along with position details for
56  * drawing the item on a particular chart.
57  *
58  * @deprecated This class is not used by JFreeChart.
59  */
60 public class DrawableLegendItem {
61 
62     /**
63      * The legend item (encapsulates information about the label, color and
64      * shape).
65      */
66     private LegendItem item;
67 
68     /** The x-coordinate for the item's location. */
69     private double x;
70 
71     /** The y-coordinate for the item's location. */
72     private double y;
73 
74     /** The width of the item. */
75     private double width;
76 
77     /** The height of the item. */
78     private double height;
79 
80     /** A shape used to indicate color on the legend. */
81     private Shape marker;
82 
83     /** A line used to indicate the series stroke on the legend */
84     private Line2D line;
85 
86     /** The label position within the item. */
87     private Point2D labelPosition;
88 
89     /**
90      * Create a legend item.
91      *
92      * @param item  the legend item for display.
93      */
DrawableLegendItem(LegendItem item)94     public DrawableLegendItem(LegendItem item) {
95         this.item = item;
96     }
97 
98     /**
99      * Returns the legend item.
100      *
101      * @return The legend item.
102      */
getItem()103     public LegendItem getItem() {
104         return this.item;
105     }
106 
107     /**
108      * Get the x-coordinate for the item's location.
109      *
110      * @return The x-coordinate for the item's location.
111      */
getX()112     public double getX() {
113         return this.x;
114     }
115 
116     /**
117      * Set the x-coordinate for the item's location.
118      *
119      * @param x  the x-coordinate.
120      */
setX(double x)121     public void setX(double x) {
122         this.x = x;
123     }
124 
125     /**
126      * Get the y-coordinate for the item's location.
127      *
128      * @return The y-coordinate for the item's location.
129      */
getY()130     public double getY() {
131         return this.y;
132     }
133 
134     /**
135      * Set the y-coordinate for the item's location.
136      *
137      * @param y  the y-coordinate.
138      */
setY(double y)139     public void setY(double y) {
140         this.y = y;
141     }
142 
143     /**
144      * Get the width of this item.
145      *
146      * @return The width.
147      */
getWidth()148     public double getWidth() {
149         return this.width;
150     }
151 
152     /**
153      * Get the height of this item.
154      *
155      * @return The height.
156      */
getHeight()157     public double getHeight() {
158         return this.height;
159     }
160 
161     /**
162      * Returns the largest X coordinate of the framing rectangle of this legend
163      * item.
164      *
165      * @return The largest x coordinate of the framing rectangle of this legend
166      *         item.
167      */
getMaxX()168     public double getMaxX() {
169         return getX() + getWidth();
170     }
171 
172     /**
173      * Returns the largest Y coordinate of the framing rectangle of this legend
174      * item.
175      *
176      * @return The largest Y coordinate of the framing rectangle of this legend
177      *         item.
178      */
getMaxY()179     public double getMaxY() {
180         return getY() + getHeight();
181     }
182 
183     /**
184      * Get the marker.
185      *
186      * @return The shape used to indicate color on the legend for this item.
187      */
getMarker()188     public Shape getMarker() {
189         return this.marker;
190     }
191 
192     /**
193      * Set the marker.
194      *
195      * @param marker  a shape used to indicate color on the legend for this
196      *                item.
197      */
setMarker(Shape marker)198     public void setMarker(Shape marker) {
199         this.marker = marker;
200     }
201 
202     /**
203      * Sets the line used to label this series.
204      *
205      * @param l the new line to use.
206      */
setLine(Line2D l)207     public void setLine(Line2D l) {
208         this.line = l;
209     }
210 
211     /**
212      * Returns the list.
213      *
214      * @return The line.
215      */
getLine()216     public Line2D getLine() {
217         return this.line;
218     }
219 
220     /**
221      * Returns the label position.
222      *
223      * @return The label position.
224      */
getLabelPosition()225     public Point2D getLabelPosition() {
226         return this.labelPosition;
227     }
228 
229     /**
230      * Sets the label position.
231      *
232      * @param position  the label position.
233      */
setLabelPosition(Point2D position)234     public void setLabelPosition(Point2D position) {
235         this.labelPosition = position;
236     }
237 
238     /**
239      * Set the bounds of this item.
240      *
241      * @param x  x-coordinate for the item's location.
242      * @param y  y-coordinate for the item's location.
243      * @param width  the width of this item.
244      * @param height  the height of this item.
245      */
setBounds(double x, double y, double width, double height)246     public void setBounds(double x, double y, double width, double height) {
247         this.x = x;
248         this.y = y;
249         this.width = width;
250         this.height = height;
251     }
252 
253 }
254