Frames | No Frames |
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: * StandardContourToolTipGenerator.java 29: * ------------------------------------ 30: * (C) Copyright 2002-2007, by David M. O'Donnell and Contributors. 31: * 32: * Original Author: David M. O'Donnell; 33: * Contributor(s): David Gilbert (for Object Refinery Limited); 34: * 35: * $Id: StandardContourToolTipGenerator.java,v 1.4.2.3 2007/02/13 16:05:06 mungady Exp $ 36: * 37: * Changes 38: * ------- 39: * 23-Jan-2003 : Added standard header (DG); 40: * 21-Mar-2003 : Implemented Serializable (DG); 41: * 15-Jul-2004 : Switched the getZ() and getZValue() methods (DG); 42: * 19-Jan-2005 : Now accesses primitives only from dataset (DG); 43: * 44: */ 45: 46: package org.jfree.chart.labels; 47: 48: import java.io.Serializable; 49: import java.text.DecimalFormat; 50: import java.text.SimpleDateFormat; 51: import java.util.Date; 52: 53: import org.jfree.data.contour.ContourDataset; 54: 55: /** 56: * A standard tooltip generator for plots that use data from an 57: * {@link ContourDataset}. 58: * 59: * @deprecated This class is no longer supported (as of version 1.0.4). 60: */ 61: public class StandardContourToolTipGenerator implements ContourToolTipGenerator, 62: Serializable { 63: 64: /** For serialization. */ 65: private static final long serialVersionUID = -1881659351247502711L; 66: 67: /** The number formatter. */ 68: private DecimalFormat valueForm = new DecimalFormat("##.###"); 69: 70: /** 71: * Generates a tooltip text item for a particular item within a series. 72: * 73: * @param data the dataset. 74: * @param item the item index (zero-based). 75: * 76: * @return The tooltip text. 77: */ 78: public String generateToolTip(ContourDataset data, int item) { 79: 80: double x = data.getXValue(0, item); 81: double y = data.getYValue(0, item); 82: double z = data.getZValue(0, item); 83: String xString = null; 84: 85: if (data.isDateAxis(0)) { 86: SimpleDateFormat formatter 87: = new java.text.SimpleDateFormat("MM/dd/yyyy hh:mm:ss"); 88: StringBuffer strbuf = new StringBuffer(); 89: strbuf = formatter.format( 90: new Date((long) x), strbuf, new java.text.FieldPosition(0) 91: ); 92: xString = strbuf.toString(); 93: } 94: else { 95: xString = this.valueForm.format(x); 96: } 97: if (!Double.isNaN(z)) { 98: return "X: " + xString 99: + ", Y: " + this.valueForm.format(y) 100: + ", Z: " + this.valueForm.format(z); 101: } 102: else { 103: return "X: " + xString 104: + ", Y: " + this.valueForm.format(y) 105: + ", Z: no data"; 106: } 107: 108: } 109: 110: /** 111: * Tests if this object is equal to another. 112: * 113: * @param obj the other object. 114: * 115: * @return A boolean. 116: */ 117: public boolean equals(Object obj) { 118: 119: if (obj == this) { 120: return true; 121: } 122: 123: if (!(obj instanceof StandardContourToolTipGenerator)) { 124: return false; 125: } 126: StandardContourToolTipGenerator that 127: = (StandardContourToolTipGenerator) obj; 128: if (this.valueForm != null) { 129: return this.valueForm.equals(that.valueForm); 130: } 131: return false; 132: 133: } 134: 135: }