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 * XYAnnotationEntity.java 029 * ----------------------- 030 * (C) Copyright 2004, by Object Refinery Limited. 031 * 032 * Original Author: David Gilbert (for Object Refinery Limited); 033 * Contributor(s): -; 034 * 035 * $Id: XYAnnotationEntity.java,v 1.3.2.1 2005/10/25 20:41:59 mungady Exp $ 036 * 037 * Changes: 038 * -------- 039 * 29-Sep-2004 : Version 1 (DG); 040 * 041 */ 042 043 package org.jfree.chart.entity; 044 045 import java.awt.Shape; 046 import java.io.Serializable; 047 048 /** 049 * A chart entity that represents an annotation on an 050 * {@link org.jfree.chart.plot.XYPlot}. 051 */ 052 public class XYAnnotationEntity extends ChartEntity 053 implements Serializable { 054 055 /** For serialization. */ 056 private static final long serialVersionUID = 2340334068383660799L; 057 058 /** The renderer index. */ 059 private int rendererIndex; 060 061 /** 062 * Creates a new entity. 063 * 064 * @param hotspot the area. 065 * @param rendererIndex the rendererIndex (zero-based index). 066 * @param toolTipText the tool tip text. 067 * @param urlText the URL text for HTML image maps. 068 */ 069 public XYAnnotationEntity(Shape hotspot, int rendererIndex, 070 String toolTipText, String urlText) { 071 super(hotspot, toolTipText, urlText); 072 this.rendererIndex = rendererIndex; 073 } 074 075 /** 076 * Returns the renderer index. 077 * 078 * @return The renderer index. 079 */ 080 public int getRendererIndex() { 081 return this.rendererIndex; 082 } 083 084 /** 085 * Sets the renderer index. 086 * 087 * @param index the item index (zero-based). 088 */ 089 public void setRendererIndex(int index) { 090 this.rendererIndex = index; 091 } 092 093 /** 094 * Tests the entity for equality with an arbitrary object. 095 * 096 * @param obj the object (<code>null</code> permitted). 097 * 098 * @return A boolean. 099 */ 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 }