    001/* ===========================================================
    002 * Orson Charts : a 3D chart library for the Java(tm) platform
    003 * ===========================================================
    004 *
    005 * (C)opyright 2013-2022, by David Gilbert.  All rights reserved.
    006 *
    007 * https://github.com/jfree/orson-charts
    008 *
    009 * This program is free software: you can redistribute it and/or modify
    010 * it under the terms of the GNU General Public License as published by
    011 * the Free Software Foundation, either version 3 of the License, or
    012 * (at your option) any later version.
    013 *
    014 * This program is distributed in the hope that it will be useful,
    015 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    017 * GNU General Public License for more details.
    018 *
    019 * You should have received a copy of the GNU General Public License
    020 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    021 *
    022 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    023 * Other names may be trademarks of their respective owners.]
    024 *
    025 * If you do not wish to be bound by the terms of the GPL, an alternative
    026 * commercial license can be purchased.  For details, please see visit the
    027 * Orson Charts home page:
    028 *
    029 * http://www.object-refinery.com/orsoncharts/index.html
    030 *
    031 */
    032
    033package org.jfree.chart3d.data.xyz;
    034
    035import java.io.Serializable;
    036
    037/**
    038 * Represents a single {@code (x, y, z)} data item, which can be added to
    039 * a {@link XYZSeries}.  Instances of this class are immutable.
    040 * <br><br>
    041 * NOTE: This class is serializable, but the serialization format is subject
    042 * to change in future releases and should not be relied upon for persisting
    043 * instances of this class.
    044 */
    045@SuppressWarnings("serial")
    046public class XYZDataItem implements Serializable {
    047
    048    /** The x-value. */
    049    private final double x;
    050
    051    /** The y-value. */
    052    private final double y;
    053
    054    /** The z-value. */
    055    private final double z;
    056
    057    /**
    058     * Creates a new (immutable) instance.
    059     *
    060     * @param x  the x-value.
    061     * @param y  the y-value.
    062     * @param z  the z-value.
    063     */
    064    public XYZDataItem(double x, double y, double z) {
    065        this.x = x;
    066        this.y = y;
    067        this.z = z;
    068    }
    069
    070    /**
    071     * Returns the x-value.
    072     *
    073     * @return The x-value.
    074     */
    075    public double getX() {
    076        return x;
    077    }
    078
    079    /**
    080     * Returns the y-value.
    081     *
    082     * @return The y-value.
    083     */
    084    public double getY() {
    085        return y;
    086    }
    087
    088    /**
    089     * Returns the z-value.
    090     *
    091     * @return The z-value.
    092     */
    093    public double getZ() {
    094        return z;
    095    }
    096
    097    /**
    098     * Tests this instance for equality with an arbitrary object.
    099     *
    100     * @param obj  the object ({@code null} permitted).
    101     *
    102     * @return A boolean.
    103     */
    104    @Override
    105    public boolean equals(Object obj) {
    106        if (obj == this) {
    107            return true;
    108        }
    109        if (!(obj instanceof XYZDataItem)) {
    110            return false;
    111        }
    112        XYZDataItem that = (XYZDataItem) obj;
    113        if (this.x != that.x) {
    114            return false;
    115        }
    116        if (this.y != that.y) {
    117            return false;
    118        }
    119        if (this.z != that.z) {
    120            return false;
    121        }
    122        return true;
    123    }
    124
    125    @Override
    126    public int hashCode() {
    127        int hash = 5;
    128        hash = 79 * hash + (int) (Double.doubleToLongBits(this.x)
    129                ^ (Double.doubleToLongBits(this.x) >>> 32));
    130        hash = 79 * hash + (int) (Double.doubleToLongBits(this.y)
    131                ^ (Double.doubleToLongBits(this.y) >>> 32));
    132        hash = 79 * hash + (int) (Double.doubleToLongBits(this.z)
    133                ^ (Double.doubleToLongBits(this.z) >>> 32));
    134        return hash;
    135    }
    136
    137}