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 * YInterval.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-interval.  This class is used internally by the
043 * {@link YIntervalDataItem} class.
044 */
045public class YInterval implements Serializable {
046
047    /** The y-value. */
048    private double y;
049
050    /** The lower bound of the y-interval. */
051    private double yLow;
052
053    /** The upper bound of the y-interval. */
054    private double yHigh;
055
056    /**
057     * Creates a new instance of {@code YInterval}.
058     *
059     * @param y  the y-value.
060     * @param yLow  the lower bound of the y-interval.
061     * @param yHigh  the upper bound of the y-interval.
062     */
063    public YInterval(double y, double yLow, double yHigh) {
064        this.y = y;
065        this.yLow = yLow;
066        this.yHigh = yHigh;
067    }
068
069    /**
070     * Returns the y-value.
071     *
072     * @return The y-value.
073     */
074    public double getY() {
075        return this.y;
076    }
077
078    /**
079     * Returns the lower bound of the y-interval.
080     *
081     * @return The lower bound of the y-interval.
082     */
083    public double getYLow() {
084        return this.yLow;
085    }
086
087    /**
088     * Returns the upper bound of the y-interval.
089     *
090     * @return The upper bound of the y-interval.
091     */
092    public double getYHigh() {
093        return this.yHigh;
094    }
095
096    /**
097     * Tests this instance for equality with an arbitrary object.
098     *
099     * @param obj  the object ({@code null} permitted).
100     *
101     * @return A boolean.
102     */
103    @Override
104    public boolean equals(Object obj) {
105        if (obj == this) {
106            return true;
107        }
108        if (!(obj instanceof YInterval)) {
109            return false;
110        }
111        YInterval that = (YInterval) obj;
112        if (this.y != that.y) {
113            return false;
114        }
115        if (this.yLow != that.yLow) {
116            return false;
117        }
118        if (this.yHigh != that.yHigh) {
119            return false;
120        }
121        return true;
122    }
123
124}