Source for org.jfree.chart.entity.XYAnnotationEntity

   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:  * XYAnnotationEntity.java
  29:  * -----------------------
  30:  * (C) Copyright 2004, by Object Refinery Limited.
  31:  *
  32:  * Original Author:  David Gilbert (for Object Refinery Limited);
  33:  * Contributor(s):   -;
  34:  *
  35:  * $Id: XYAnnotationEntity.java,v 1.3.2.1 2005/10/25 20:41:59 mungady Exp $
  36:  *
  37:  * Changes:
  38:  * --------
  39:  * 29-Sep-2004 : Version 1 (DG);
  40:  *
  41:  */
  42: 
  43: package org.jfree.chart.entity;
  44: 
  45: import java.awt.Shape;
  46: import java.io.Serializable;
  47: 
  48: /**
  49:  * A chart entity that represents an annotation on an 
  50:  * {@link org.jfree.chart.plot.XYPlot}.
  51:  */
  52: public class XYAnnotationEntity extends ChartEntity
  53:                                 implements Serializable {
  54:     
  55:     /** For serialization. */
  56:     private static final long serialVersionUID = 2340334068383660799L;
  57:     
  58:     /** The renderer index. */
  59:     private int rendererIndex;
  60: 
  61:     /**
  62:      * Creates a new entity.
  63:      *
  64:      * @param hotspot  the area.
  65:      * @param rendererIndex  the rendererIndex (zero-based index).
  66:      * @param toolTipText  the tool tip text.
  67:      * @param urlText  the URL text for HTML image maps.
  68:      */
  69:     public XYAnnotationEntity(Shape hotspot, int rendererIndex,
  70:                               String toolTipText, String urlText) {
  71:         super(hotspot, toolTipText, urlText);
  72:         this.rendererIndex = rendererIndex;
  73:     }
  74: 
  75:     /**
  76:      * Returns the renderer index.
  77:      *
  78:      * @return The renderer index.
  79:      */
  80:     public int getRendererIndex() {
  81:         return this.rendererIndex;
  82:     }
  83: 
  84:     /**
  85:      * Sets the renderer index.
  86:      *
  87:      * @param index  the item index (zero-based).
  88:      */
  89:     public void setRendererIndex(int index) {
  90:         this.rendererIndex = index;
  91:     }
  92: 
  93:     /**
  94:      * Tests the entity for equality with an arbitrary object.
  95:      * 
  96:      * @param obj  the object (<code>null</code> permitted).
  97:      * 
  98:      * @return A boolean.
  99:      */
 100:     public boolean equals(Object obj) {
 101:         if (obj == this) {
 102:             return true;      
 103:         }
 104:         if (!super.equals(obj)) {
 105:             return false;
 106:         }
 107:         if (!(obj instanceof XYAnnotationEntity)) {
 108:             return false;
 109:         }
 110:         XYAnnotationEntity that = (XYAnnotationEntity) obj;
 111:         if (this.rendererIndex != that.rendererIndex) {
 112:             return false;   
 113:         }
 114:         return true;
 115:     }
 116: 
 117: }