001/* =========================================================== 002 * JFreeChart : a free chart library for the Java(tm) platform 003 * =========================================================== 004 * 005 * (C) Copyright 2000-present, by David Gilbert 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 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. 025 * Other names may be trademarks of their respective owners.] 026 * 027 * ------------------- 028 * YWithXInterval.java 029 * ------------------- 030 * (C) Copyright 2006-present, by David Gilbert. 031 * 032 * Original Author: David Gilbert; 033 * Contributor(s): -; 034 * 035 */ 036 037package org.jfree.data.xy; 038 039import java.io.Serializable; 040 041/** 042 * A y-value plus the bounds for the related x-interval. This curious 043 * combination exists as an implementation detail, to fit into the structure 044 * of the ComparableObjectSeries class. It would have been possible to 045 * simply reuse the {@link YInterval} class by assuming that the y-interval 046 * in fact represents the x-interval, however I decided it was better to 047 * duplicate some code in order to document the real intent. 048 */ 049public class YWithXInterval implements Serializable { 050 051 /** The y-value. */ 052 private double y; 053 054 /** The lower bound of the x-interval. */ 055 private double xLow; 056 057 /** The upper bound of the x-interval. */ 058 private double xHigh; 059 060 /** 061 * Creates a new instance of {@code YWithXInterval}. 062 * 063 * @param y the y-value. 064 * @param xLow the lower bound of the x-interval. 065 * @param xHigh the upper bound of the x-interval. 066 */ 067 public YWithXInterval(double y, double xLow, double xHigh) { 068 this.y = y; 069 this.xLow = xLow; 070 this.xHigh = xHigh; 071 } 072 073 /** 074 * Returns the y-value. 075 * 076 * @return The y-value. 077 */ 078 public double getY() { 079 return this.y; 080 } 081 082 /** 083 * Returns the lower bound of the x-interval. 084 * 085 * @return The lower bound of the x-interval. 086 */ 087 public double getXLow() { 088 return this.xLow; 089 } 090 091 /** 092 * Returns the upper bound of the x-interval. 093 * 094 * @return The upper bound of the x-interval. 095 */ 096 public double getXHigh() { 097 return this.xHigh; 098 } 099 100 /** 101 * Tests this instance for equality with an arbitrary object. 102 * 103 * @param obj the object ({@code null} permitted). 104 * 105 * @return A boolean. 106 */ 107 @Override 108 public boolean equals(Object obj) { 109 if (obj == this) { 110 return true; 111 } 112 if (!(obj instanceof YWithXInterval)) { 113 return false; 114 } 115 YWithXInterval that = (YWithXInterval) obj; 116 if (this.y != that.y) { 117 return false; 118 } 119 if (this.xLow != that.xLow) { 120 return false; 121 } 122 if (this.xHigh != that.xHigh) { 123 return false; 124 } 125 return true; 126 } 127 128}