Source for org.jfree.chart.entity.CategoryLabelEntity

   1: /* ===========================================================
   2:  * JFreeChart : a free chart library for the Java(tm) platform
   3:  * ===========================================================
   4:  *
   5:  * (C) Copyright 2000-2006, 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:  * CategoryLabelEntity.java
  29:  * ------------------------
  30:  * (C) Copyright 2006, by Object Refinery Limited and Contributors.
  31:  *
  32:  * Original Author:  David Gilbert (for Object Refinery Limited);
  33:  * Contributor(s):   -;
  34:  *
  35:  * $Id: CategoryLabelEntity.java,v 1.1.2.2 2006/10/03 16:21:43 mungady Exp $
  36:  *
  37:  * Changes:
  38:  * --------
  39:  * 02-Oct-2006 : Version 1 (DG);
  40:  *
  41:  */
  42: 
  43: package org.jfree.chart.entity;
  44: 
  45: import java.awt.Shape;
  46: 
  47: import org.jfree.chart.axis.CategoryAxis;
  48: 
  49: /**
  50:  * An entity to represent the labels on a {@link CategoryAxis}.
  51:  * 
  52:  * @since 1.0.3
  53:  */
  54: public class CategoryLabelEntity extends TickLabelEntity {
  55:     
  56:     /** The category key. */
  57:     private Comparable key;
  58:     
  59:     /**
  60:      * Creates a new entity.
  61:      * 
  62:      * @param key  the category key.
  63:      * @param area  the hotspot.
  64:      * @param toolTipText  the tool tip text.
  65:      * @param urlText  the URL text.
  66:      */
  67:     public CategoryLabelEntity(Comparable key, Shape area, 
  68:             String toolTipText, String urlText) {
  69:         super(area, toolTipText, urlText);
  70:         this.key = key;
  71:     }
  72:     
  73:     /**
  74:      * Returns the category key.
  75:      * 
  76:      * @return The category key.
  77:      */
  78:     public Comparable getKey() {
  79:         return this.key;
  80:     }
  81:     
  82:     /**
  83:      * Returns a string representation of this entity.  This is primarily 
  84:      * useful for debugging.
  85:      * 
  86:      * @return A string representation of this entity.
  87:      */
  88:     public String toString() {
  89:         StringBuffer buf = new StringBuffer("CategoryLabelEntity: ");
  90:         buf.append("category=");
  91:         buf.append(this.key);
  92:         buf.append(", tooltip=" + getToolTipText());
  93:         buf.append(", url=" + getURLText());
  94:         return buf.toString();
  95:     }
  96: }