001 /* =========================================================== 002 * JFreeChart : a free chart library for the Java(tm) platform 003 * =========================================================== 004 * 005 * (C) Copyright 2000-2008, 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 * YWithXInterval.java 029 * ------------------- 030 * (C) Copyright 2006-2008, by Object Refinery Limited. 031 * 032 * Original Author: David Gilbert (for Object Refinery Limited); 033 * Contributor(s): -; 034 * 035 * Changes 036 * ------- 037 * 20-Oct-2006 : Version 1 (DG); 038 * 039 */ 040 041 package org.jfree.data.xy; 042 043 import java.io.Serializable; 044 045 /** 046 * A y-value plus the bounds for the related x-interval. This curious 047 * combination exists as an implementation detail, to fit into the structure 048 * of the ComparableObjectSeries class. It would have been possible to 049 * simply reuse the {@link YInterval} class by assuming that the y-interval 050 * in fact represents the x-interval, however I decided it was better to 051 * duplicate some code in order to document the real intent. 052 * 053 * @since 1.0.3 054 */ 055 public class YWithXInterval implements Serializable { 056 057 /** The y-value. */ 058 private double y; 059 060 /** The lower bound of the x-interval. */ 061 private double xLow; 062 063 /** The upper bound of the x-interval. */ 064 private double xHigh; 065 066 /** 067 * Creates a new instance of <code>YWithXInterval</code>. 068 * 069 * @param y the y-value. 070 * @param xLow the lower bound of the x-interval. 071 * @param xHigh the upper bound of the x-interval. 072 */ 073 public YWithXInterval(double y, double xLow, double xHigh) { 074 this.y = y; 075 this.xLow = xLow; 076 this.xHigh = xHigh; 077 } 078 079 /** 080 * Returns the y-value. 081 * 082 * @return The y-value. 083 */ 084 public double getY() { 085 return this.y; 086 } 087 088 /** 089 * Returns the lower bound of the x-interval. 090 * 091 * @return The lower bound of the x-interval. 092 */ 093 public double getXLow() { 094 return this.xLow; 095 } 096 097 /** 098 * Returns the upper bound of the x-interval. 099 * 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 }