2018-10-28 09:10:56 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Player Analytics (Plan).
|
|
|
|
*
|
|
|
|
* Plan is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License v3 as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Plan is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2019-08-30 22:14:54 +02:00
|
|
|
package com.djrapitops.plan.delivery.rendering.json.graphs.line;
|
2017-07-22 10:33:38 +02:00
|
|
|
|
2021-01-29 10:58:06 +01:00
|
|
|
import com.djrapitops.plan.delivery.domain.DateObj;
|
|
|
|
|
2017-08-31 20:39:38 +02:00
|
|
|
import java.util.Objects;
|
2017-08-23 17:43:52 +02:00
|
|
|
|
2017-07-22 10:33:38 +02:00
|
|
|
/**
|
2021-02-13 14:16:03 +01:00
|
|
|
* @author AuroraLS3
|
2017-07-22 10:33:38 +02:00
|
|
|
*/
|
|
|
|
public class Point {
|
|
|
|
private final double x;
|
2021-01-29 10:58:06 +01:00
|
|
|
private Double y;
|
2017-07-22 10:33:38 +02:00
|
|
|
|
2018-03-12 11:33:00 +01:00
|
|
|
public Point(double x, Double y) {
|
2017-07-22 10:33:38 +02:00
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
|
|
|
}
|
|
|
|
|
2021-01-29 10:58:06 +01:00
|
|
|
public <V extends Number> Point(double x, V y) {
|
|
|
|
this.x = x;
|
|
|
|
this.y = y == null ? null : y.doubleValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static <V extends Number> Point fromDateObj(DateObj<V> dateObj) {
|
|
|
|
V value = dateObj.getValue();
|
|
|
|
return new Point(dateObj.getDate(), value != null ? value.doubleValue() : null);
|
2018-03-12 11:55:24 +01:00
|
|
|
}
|
|
|
|
|
2017-07-22 10:33:38 +02:00
|
|
|
public double getX() {
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2018-03-12 11:33:00 +01:00
|
|
|
public Double getY() {
|
2017-07-22 10:33:38 +02:00
|
|
|
return y;
|
|
|
|
}
|
2017-07-25 16:55:10 +02:00
|
|
|
|
2021-01-29 10:58:06 +01:00
|
|
|
public void setY(Double y) {
|
|
|
|
this.y = y;
|
|
|
|
}
|
|
|
|
|
2017-08-23 17:43:52 +02:00
|
|
|
@Override
|
|
|
|
public boolean equals(Object o) {
|
|
|
|
if (this == o) return true;
|
|
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
|
|
Point point = (Point) o;
|
|
|
|
return Double.compare(point.x, x) == 0 &&
|
|
|
|
Double.compare(point.y, y) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
2017-08-31 20:39:38 +02:00
|
|
|
return Objects.hash(x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
2018-01-28 13:21:45 +01:00
|
|
|
return "Point{" +
|
|
|
|
"x=" + x + ", " +
|
|
|
|
"y=" + y + '}';
|
2017-08-23 17:43:52 +02:00
|
|
|
}
|
2019-07-13 10:28:59 +02:00
|
|
|
|
2024-03-05 19:10:20 +01:00
|
|
|
public Number[] toArray() {
|
|
|
|
return new Number[]{x, y};
|
2019-07-13 10:28:59 +02:00
|
|
|
}
|
2017-07-22 10:33:38 +02:00
|
|
|
}
|