001    /* ===========================================================
002     * JFreeChart : a free chart library for the Java(tm) platform
003     * ===========================================================
004     *
005     * (C) Copyright 2000-2005, 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     * LegendItemEntity.java
029     * ---------------------
030     * (C) Copyright 2003-2005, by Object Refinery Limited and Contributors.
031     *
032     * Original Author:  David Gilbert (for Object Refinery Limited);
033     * Contributor(s):   -;
034     *
035     * $Id: LegendItemEntity.java,v 1.3.2.1 2005/10/25 20:41:59 mungady Exp $
036     *
037     * Changes:
038     * --------
039     * 05-Jun-2003 : Version 1 (DG);
040     * 20-May-2004 : Added equals() method and implemented Cloneable and 
041     *               Serializable (DG);
042     *
043     */
044    
045    package org.jfree.chart.entity;
046    
047    import java.awt.Shape;
048    import java.io.Serializable;
049    
050    /**
051     * An entity that represents an item within a legend.
052     */
053    public class LegendItemEntity extends ChartEntity 
054                                  implements Cloneable, Serializable {
055    
056        /** For serialization. */
057        private static final long serialVersionUID = -7435683933545666702L;
058        
059        /** The series index. */
060        private int seriesIndex;
061    
062        /**
063         * Creates a legend item entity.
064         *
065         * @param area  the area.
066         */
067        public LegendItemEntity(Shape area) {
068            super(area);
069        }
070    
071        /**
072         * Returns the series index.
073         *
074         * @return The series index.
075         */
076        public int getSeriesIndex() {
077            return this.seriesIndex;
078        }
079    
080        /**
081         * Sets the series index.
082         *
083         * @param index  the series index.
084         */
085        public void setSeriesIndex(int index) {
086            this.seriesIndex = index;
087        }
088        
089        /**
090         * Tests this object for equality with an arbitrary object.
091         * 
092         * @param obj  the object (<code>null</code> permitted).
093         * 
094         * @return A boolean.
095         */
096        public boolean equals(Object obj) {
097            if (obj == this) {
098                return true;   
099            }
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    }