Source for org.jfree.chart.entity.LegendItemEntity

   1: /* ===========================================================
   2:  * JFreeChart : a free chart library for the Java(tm) platform
   3:  * ===========================================================
   4:  *
   5:  * (C) Copyright 2000-2005, 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:  * LegendItemEntity.java
  29:  * ---------------------
  30:  * (C) Copyright 2003-2005, by Object Refinery Limited and Contributors.
  31:  *
  32:  * Original Author:  David Gilbert (for Object Refinery Limited);
  33:  * Contributor(s):   -;
  34:  *
  35:  * $Id: LegendItemEntity.java,v 1.3.2.1 2005/10/25 20:41:59 mungady Exp $
  36:  *
  37:  * Changes:
  38:  * --------
  39:  * 05-Jun-2003 : Version 1 (DG);
  40:  * 20-May-2004 : Added equals() method and implemented Cloneable and 
  41:  *               Serializable (DG);
  42:  *
  43:  */
  44: 
  45: package org.jfree.chart.entity;
  46: 
  47: import java.awt.Shape;
  48: import java.io.Serializable;
  49: 
  50: /**
  51:  * An entity that represents an item within a legend.
  52:  */
  53: public class LegendItemEntity extends ChartEntity 
  54:                               implements Cloneable, Serializable {
  55: 
  56:     /** For serialization. */
  57:     private static final long serialVersionUID = -7435683933545666702L;
  58:     
  59:     /** The series index. */
  60:     private int seriesIndex;
  61: 
  62:     /**
  63:      * Creates a legend item entity.
  64:      *
  65:      * @param area  the area.
  66:      */
  67:     public LegendItemEntity(Shape area) {
  68:         super(area);
  69:     }
  70: 
  71:     /**
  72:      * Returns the series index.
  73:      *
  74:      * @return The series index.
  75:      */
  76:     public int getSeriesIndex() {
  77:         return this.seriesIndex;
  78:     }
  79: 
  80:     /**
  81:      * Sets the series index.
  82:      *
  83:      * @param index  the series index.
  84:      */
  85:     public void setSeriesIndex(int index) {
  86:         this.seriesIndex = index;
  87:     }
  88:     
  89:     /**
  90:      * Tests this object for equality with an arbitrary object.
  91:      * 
  92:      * @param obj  the object (<code>null</code> permitted).
  93:      * 
  94:      * @return A boolean.
  95:      */
  96:     public boolean equals(Object obj) {
  97:         if (obj == this) {
  98:             return true;   
  99:         }
 100:         if (obj instanceof LegendItemEntity && super.equals(obj)) {
 101:             LegendItemEntity e = (LegendItemEntity) obj;
 102:             if (this.seriesIndex != e.seriesIndex) {
 103:                 return false;   
 104:             }
 105:             return true;   
 106:         }
 107:         return false;
 108:     }
 109:     
 110:     /**
 111:      * Returns a clone of the entity.
 112:      * 
 113:      * @return A clone.
 114:      * 
 115:      * @throws CloneNotSupportedException if there is a problem cloning the 
 116:      *         object.
 117:      */
 118:     public Object clone() throws CloneNotSupportedException {
 119:         return super.clone();   
 120:     }
 121: 
 122: }