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