Source for org.jfree.data.xy.YWithXInterval

   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:  * YWithXInterval.java
  29:  * -------------------
  30:  * (C) Copyright 2006, by Object Refinery Limited.
  31:  *
  32:  * Original Author:  David Gilbert (for Object Refinery Limited);
  33:  * Contributor(s):   -;
  34:  *
  35:  * $Id: YWithXInterval.java,v 1.1.2.1 2006/10/20 15:23:22 mungady Exp $
  36:  *
  37:  * Changes
  38:  * -------
  39:  * 20-Oct-2006 : Version 1 (DG);
  40:  *
  41:  */
  42: 
  43: package org.jfree.data.xy;
  44: 
  45: import java.io.Serializable;
  46: 
  47: /**
  48:  * A y-value plus the bounds for the related x-interval.  This curious 
  49:  * combination exists as an implementation detail, to fit into the structure
  50:  * of the ComparableObjectSeries class.  It would have been possible to 
  51:  * simply reuse the {@link YInterval} class by assuming that the y-interval
  52:  * in fact represents the x-interval, however I decided it was better to
  53:  * duplicate some code in order to document the real intent.
  54:  *
  55:  * @since 1.0.3
  56:  */
  57: public class YWithXInterval implements Serializable {
  58:     
  59:     /** The y-value. */
  60:     private double y;
  61:     
  62:     /** The lower bound of the x-interval. */
  63:     private double xLow;
  64:     
  65:     /** The upper bound of the x-interval. */
  66:     private double xHigh;
  67:     
  68:     /** 
  69:      * Creates a new instance of <code>YWithXInterval</code>.
  70:      *
  71:      * @param y  the y-value.
  72:      * @param xLow  the lower bound of the x-interval.
  73:      * @param xHigh  the upper bound of the x-interval.  
  74:      */
  75:     public YWithXInterval(double y, double xLow, double xHigh) {
  76:         this.y = y;
  77:         this.xLow = xLow;
  78:         this.xHigh = xHigh;
  79:     }
  80:     
  81:     /**
  82:      * Returns the y-value.
  83:      *
  84:      * @return The y-value.
  85:      */
  86:     public double getY() {
  87:         return this.y;
  88:     }
  89:     
  90:     /**
  91:      * Returns the lower bound of the x-interval.
  92:      *
  93:      * @return The lower bound of the x-interval.
  94:      */
  95:     public double getXLow() {
  96:         return this.xLow;
  97:     }
  98:     
  99:     /**
 100:      * Returns the upper bound of the x-interval.
 101:      *
 102:      * @return The upper bound of the x-interval.
 103:      */
 104:     public double getXHigh() {
 105:         return this.xHigh;
 106:     }
 107:     
 108:     /**
 109:      * Tests this instance for equality with an arbitrary object.
 110:      *
 111:      * @param obj  the object (<code>null</code> permitted).
 112:      *
 113:      * @return A boolean.
 114:      */
 115:     public boolean equals(Object obj) {
 116:         if (obj == this) {
 117:             return true;
 118:         }
 119:         if (!(obj instanceof YWithXInterval)) {
 120:             return false;
 121:         }
 122:         YWithXInterval that = (YWithXInterval) obj;
 123:         if (this.y != that.y) {
 124:             return false;
 125:         }
 126:         if (this.xLow != that.xLow) {
 127:             return false;
 128:         }
 129:         if (this.xHigh != that.xHigh) {
 130:             return false;
 131:         }
 132:         return true;
 133:     }
 134: 
 135: }