Path: blob/trunk/java/src/org/openqa/selenium/Rectangle.java
3991 views
// Licensed to the Software Freedom Conservancy (SFC) under one1// or more contributor license agreements. See the NOTICE file2// distributed with this work for additional information3// regarding copyright ownership. The SFC licenses this file4// to you under the Apache License, Version 2.0 (the5// "License"); you may not use this file except in compliance6// with the License. You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing,11// software distributed under the License is distributed on an12// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13// KIND, either express or implied. See the License for the14// specific language governing permissions and limitations15// under the License.1617package org.openqa.selenium;1819import java.util.Map;20import java.util.Objects;21import org.jspecify.annotations.Nullable;2223public class Rectangle {2425public final int x;26public final int y;27public final int height;28public final int width;2930public Rectangle(int x, int y, int height, int width) {31this.x = x;32this.y = y;33this.height = height;34this.width = width;35}3637public Rectangle(Point p, Dimension d) {38x = p.x;39y = p.y;40height = d.height;41width = d.width;42}4344public int getX() {45return x;46}4748public int getY() {49return y;50}5152public int getHeight() {53return height;54}5556public int getWidth() {57return width;58}5960public Point getPoint() {61return new Point(x, y);62}6364public Dimension getDimension() {65return new Dimension(width, height);66}6768private Map<String, Object> toJson() {69return Map.of("width", width, "height", height, "x", x, "y", y);70}7172@Override73public boolean equals(@Nullable Object o) {74if (this == o) {75return true;76}77if (o == null || getClass() != o.getClass()) {78return false;79}8081Rectangle rectangle = (Rectangle) o;8283return x == rectangle.x84&& y == rectangle.y85&& height == rectangle.height86&& width == rectangle.width;87}8889@Override90public int hashCode() {91return Objects.hash(x, y, height, width);92}93}949596