1 /*
2 * Copyright (c) 2002-2026 Gargoyle Software Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * https://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 package org.htmlunit.util.geometry;
16
17 import java.util.Objects;
18
19 /**
20 * Simple 2D point.
21 *
22 * @author Ronald Brill
23 */
24 public class Point2D {
25 private final double myX_;
26 private final double myY_;
27
28 /**
29 * Ctor.
30 * @param x x value
31 * @param y y value
32 */
33 public Point2D(final double x, final double y) {
34 myX_ = x;
35 myY_ = y;
36 }
37
38 /**
39 * @return the x value
40 */
41 public double getX() {
42 return myX_;
43 }
44
45 /**
46 * @return the y value
47 */
48 public double getY() {
49 return myY_;
50 }
51
52 @Override
53 public String toString() {
54 return "Point2D (" + myX_ + ", " + myY_ + ")";
55 }
56
57 @Override
58 public boolean equals(final Object o) {
59 if (o == null || getClass() != o.getClass()) {
60 return false;
61 }
62
63 final Point2D point2D = (Point2D) o;
64 return Double.compare(myX_, point2D.myX_) == 0 && Double.compare(myY_, point2D.myY_) == 0;
65 }
66
67 @Override
68 public int hashCode() {
69 return Objects.hash(myX_, myY_);
70 }
71 }