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