Source for org.jfree.chart.DrawableLegendItem

   1: /* ===========================================================
   2:  * JFreeChart : a free chart library for the Java(tm) platform
   3:  * ===========================================================
   4:  *
   5:  * (C) Copyright 2000-2006, 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:  * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
  25:  * in the United States and other countries.]
  26:  *
  27:  * -----------------------
  28:  * DrawableLegendItem.java
  29:  * -----------------------
  30:  * (C) Copyright 2002-2006, 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:  * $Id: DrawableLegendItem.java,v 1.3.2.2 2006/08/01 16:10:44 mungady Exp $
  37:  *
  38:  * Changes
  39:  * -------
  40:  * 07-Feb-2002 : Version 1 (DG);
  41:  * 23-Sep-2002 : Renamed LegendItem --> DrawableLegendItem (DG);
  42:  * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG);
  43:  * 08-Oct-2003 : Applied patch for displaying series line style, contributed by 
  44:  *               Luke Quinane (DG);
  45:  * 27-Mar-2004 : Added getMaxX() and getMaxY() methods (BN);
  46:  * 27-Jan-2005 : Cleared out code that belongs in the LegendItem class (DG);
  47:  * 
  48:  */
  49: 
  50: package org.jfree.chart;
  51: 
  52: import java.awt.Shape;
  53: import java.awt.geom.Line2D;
  54: import java.awt.geom.Point2D;
  55: 
  56: /**
  57:  * This class contains a single legend item along with position details for 
  58:  * drawing the item on a particular chart.
  59:  * 
  60:  * @deprecated This class is not used by JFreeChart.
  61:  */
  62: public class DrawableLegendItem {
  63: 
  64:     /** 
  65:      * The legend item (encapsulates information about the label, color and 
  66:      * shape). 
  67:      */
  68:     private LegendItem item;
  69: 
  70:     /** The x-coordinate for the item's location. */
  71:     private double x;
  72: 
  73:     /** The y-coordinate for the item's location. */
  74:     private double y;
  75: 
  76:     /** The width of the item. */
  77:     private double width;
  78: 
  79:     /** The height of the item. */
  80:     private double height;
  81: 
  82:     /** A shape used to indicate color on the legend. */
  83:     private Shape marker;
  84:     
  85:     /** A line used to indicate the series stroke on the legend */
  86:     private Line2D line;
  87: 
  88:     /** The label position within the item. */
  89:     private Point2D labelPosition;
  90: 
  91:     /**
  92:      * Create a legend item.
  93:      *
  94:      * @param item  the legend item for display.
  95:      */
  96:     public DrawableLegendItem(LegendItem item) {
  97:         this.item = item;
  98:     }
  99: 
 100:     /**
 101:      * Returns the legend item.
 102:      *
 103:      * @return The legend item.
 104:      */
 105:     public LegendItem getItem() {
 106:         return this.item;
 107:     }
 108: 
 109:     /**
 110:      * Get the x-coordinate for the item's location.
 111:      *
 112:      * @return The x-coordinate for the item's location.
 113:      */
 114:     public double getX() {
 115:         return this.x;
 116:     }
 117: 
 118:     /**
 119:      * Set the x-coordinate for the item's location.
 120:      *
 121:      * @param x  the x-coordinate.
 122:      */
 123:     public void setX(double x) {
 124:         this.x = x;
 125:     }
 126: 
 127:     /**
 128:      * Get the y-coordinate for the item's location.
 129:      *
 130:      * @return The y-coordinate for the item's location.
 131:      */
 132:     public double getY() {
 133:         return this.y;
 134:     }
 135: 
 136:     /**
 137:      * Set the y-coordinate for the item's location.
 138:      *
 139:      * @param y  the y-coordinate.
 140:      */
 141:     public void setY(double y) {
 142:         this.y = y;
 143:     }
 144: 
 145:     /**
 146:      * Get the width of this item.
 147:      *
 148:      * @return The width.
 149:      */
 150:     public double getWidth() {
 151:         return this.width;
 152:     }
 153: 
 154:     /**
 155:      * Get the height of this item.
 156:      *
 157:      * @return The height.
 158:      */
 159:     public double getHeight() {
 160:         return this.height;
 161:     }
 162: 
 163:     /**
 164:      * Returns the largest X coordinate of the framing rectangle of this legend 
 165:      * item.
 166:      * 
 167:      * @return The largest x coordinate of the framing rectangle of this legend 
 168:      *         item.
 169:      */
 170:     public double getMaxX() {
 171:         return getX() + getWidth();
 172:     }
 173: 
 174:     /**
 175:      * Returns the largest Y coordinate of the framing rectangle of this legend 
 176:      * item.
 177:      * 
 178:      * @return The largest Y coordinate of the framing rectangle of this legend 
 179:      *         item.
 180:      */
 181:     public double getMaxY() {
 182:         return getY() + getHeight();
 183:     }
 184:     
 185:     /**
 186:      * Get the marker.
 187:      *
 188:      * @return The shape used to indicate color on the legend for this item.
 189:      */
 190:     public Shape getMarker() {
 191:         return this.marker;
 192:     }
 193: 
 194:     /**
 195:      * Set the marker.
 196:      *
 197:      * @param marker  a shape used to indicate color on the legend for this 
 198:      *                item.
 199:      */
 200:     public void setMarker(Shape marker) {
 201:         this.marker = marker;
 202:     }
 203:     
 204:     /**
 205:      * Sets the line used to label this series.
 206:      *
 207:      * @param l the new line to use.
 208:      */
 209:     public void setLine(Line2D l) {
 210:         this.line = l;
 211:     }
 212: 
 213:     /**
 214:      * Returns the list.
 215:      * 
 216:      * @return The line.
 217:      */
 218:     public Line2D getLine() {
 219:         return this.line;
 220:     }
 221: 
 222:     /**
 223:      * Returns the label position.
 224:      *
 225:      * @return The label position.
 226:      */
 227:     public Point2D getLabelPosition() {
 228:         return this.labelPosition;
 229:     }
 230: 
 231:     /**
 232:      * Sets the label position.
 233:      *
 234:      * @param position  the label position.
 235:      */
 236:     public void setLabelPosition(Point2D position) {
 237:         this.labelPosition = position;
 238:     }
 239: 
 240:     /**
 241:      * Set the bounds of this item.
 242:      *
 243:      * @param x  x-coordinate for the item's location.
 244:      * @param y  y-coordinate for the item's location.
 245:      * @param width  the width of this item.
 246:      * @param height  the height of this item.
 247:      */
 248:     public void setBounds(double x, double y, double width, double height) {
 249:         this.x = x;
 250:         this.y = y;
 251:         this.width = width;
 252:         this.height = height;
 253:     }
 254: 
 255: }