![JAR search and dependency download from the Maven repository](/logo.png)
com.extjs.gxt.ui.client.util.Rectangle Maven / Gradle / Ivy
/*
* Sencha GXT 2.3.1a - Sencha for GWT
* Copyright(c) 2007-2013, Sencha, Inc.
* [email protected]
*
* http://www.sencha.com/products/gxt/license/
*/
package com.extjs.gxt.ui.client.util;
/**
* Represents an area in a coordinate system.
*
* @see Point
*/
public class Rectangle {
/**
* The x coordinate.
*/
public int x;
/**
* The y coordinate.
*/
public int y;
/**
* The width of the rectangle.
*/
public int width;
/**
* The height of the rectangle.
*/
public int height;
/**
* Create a new rectangle instance.
*/
public Rectangle() {
}
/**
* Creates a new rectangle instance.
*
* @param x the x value
* @param y the y value
* @param width the rectangle's width
* @param height the rectangle's height
*/
public Rectangle(int x, int y, int width, int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
/**
* Returns true if the point is within the rectangle's region.
*
* @param x the x coordinate value
* @param y the y coordinate value
* @return true if xy is contained within the rectangle
*/
public boolean contains(int x, int y) {
return (x >= this.x) && (y >= this.y) && ((x - this.x) < width) && ((y - this.y) < height);
}
/**
* Returns true if the point is within the rectangle.
*
* @param p the point
* @return true if the point is contained within the rectangle
*/
public boolean contains(Point p) {
return contains(p.x, p.y);
}
public String toString() {
return "left: " + x + " top: " + y + " width: " + width + " height: " + height;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy