⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 region.java

📁 源码为Eclipse开源开发平台桌面开发工具SWT的源代码,
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/** * Returns an integer hash code for the receiver. Any two  * objects which return <code>true</code> when passed to  * <code>equals</code> must return the same value for this * method. * * @return the receiver's hash * * @see #equals */public int hashCode () {	return handle;}/** * Intersects the given rectangle to the collection of rectangles * the receiver maintains to describe its area. * * @param rect the rectangle to intersect with the receiver * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li> *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li> * </ul> * @exception SWTException <ul> *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> *  * @since 3.0 */public void intersect (Rectangle rect) {	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);	if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);	if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);		int rectRgn = OS.CreateRectRgn (rect.x, rect.y, rect.x + rect.width, rect.y + rect.height);	OS.CombineRgn (handle, handle, rectRgn, OS.RGN_AND);	OS.DeleteObject (rectRgn);}/** * Intersects all of the rectangles which make up the area covered * by the argument to the collection of rectangles the receiver * maintains to describe its area. * * @param region the region to intersect * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li> *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> * </ul> * @exception SWTException <ul> *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> *  * @since 3.0 */public void intersect (Region region) {	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);	if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);	if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);	OS.CombineRgn (handle, handle, region.handle, OS.RGN_AND);}/** * Returns <code>true</code> if the rectangle described by the * arguments intersects with any of the rectangles the receiver * mainains to describe its area, and <code>false</code> otherwise. * * @param x the x coordinate of the origin of the rectangle * @param y the y coordinate of the origin of the rectangle * @param width the width of the rectangle * @param height the height of the rectangle * @return <code>true</code> if the rectangle intersects with the receiver, and <code>false</code> otherwise * * @exception SWTException <ul> *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see Rectangle#intersects */public boolean intersects (int x, int y, int width, int height) {	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);	RECT r = new RECT ();	OS.SetRect (r, x, y, x + width, y + height);	return OS.RectInRegion (handle, r);}/** * Returns <code>true</code> if the given rectangle intersects * with any of the rectangles the receiver mainains to describe * its area and <code>false</code> otherwise. * * @param rect the rectangle to test for intersection * @return <code>true</code> if the rectangle intersects with the receiver, and <code>false</code> otherwise * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li> * </ul> * @exception SWTException <ul> *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see Rectangle#intersects */public boolean intersects (Rectangle rect) {	if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);	return intersects(rect.x, rect.y, rect.width, rect.height);}/** * Returns <code>true</code> if the region has been disposed, * and <code>false</code> otherwise. * <p> * This method gets the dispose state for the region. * When a region has been disposed, it is an error to * invoke any other method using the region. * * @return <code>true</code> when the region is disposed, and <code>false</code> otherwise */public boolean isDisposed() {	return handle == 0;}/** * Returns <code>true</code> if the receiver does not cover any * area in the (x, y) coordinate plane, and <code>false</code> if * the receiver does cover some area in the plane. * * @return <code>true</code> if the receiver is empty, and <code>false</code> otherwise * * @exception SWTException <ul> *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */public boolean isEmpty () {	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);	RECT rect = new RECT ();	int result = OS.GetRgnBox (handle, rect);	if (result == OS.NULLREGION) return true;	return ((rect.right - rect.left) <= 0) || ((rect.bottom - rect.top) <= 0);}/** * Subtracts the given polygon from the collection of rectangles * the receiver maintains to describe its area. * * @param pointArray points that describe the polygon to merge with the receiver * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li> * </ul> * @exception SWTException <ul> *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> *  * @since 3.0 */public void subtract (int[] pointArray) {	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);	if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);	if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);	int polyRgn = OS.CreatePolygonRgn(pointArray, pointArray.length / 2, OS.ALTERNATE);	OS.CombineRgn (handle, handle, polyRgn, OS.RGN_DIFF);	OS.DeleteObject (polyRgn);}/** * Subtracts the given rectangle from the collection of rectangles * the receiver maintains to describe its area. * * @param rect the rectangle to subtract from the receiver * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li> *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li> * </ul> * @exception SWTException <ul> *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> *  * @since 3.0 */public void subtract (Rectangle rect) {	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);	if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);	if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);		int rectRgn = OS.CreateRectRgn (rect.x, rect.y, rect.x + rect.width, rect.y + rect.height);	OS.CombineRgn (handle, handle, rectRgn, OS.RGN_DIFF);	OS.DeleteObject (rectRgn);}/** * Subtracts all of the rectangles which make up the area covered * by the argument from the collection of rectangles the receiver * maintains to describe its area. * * @param region the region to subtract * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li> *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> * </ul> * @exception SWTException <ul> *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> *  * @since 3.0 */public void subtract (Region region) {	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);	if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);	if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);	OS.CombineRgn (handle, handle, region.handle, OS.RGN_DIFF);}/**	  * Invokes platform specific functionality to allocate a new region. * <p> * <b>IMPORTANT:</b> This method is <em>not</em> part of the public * API for <code>Region</code>. It is marked public only so that it * can be shared within the packages provided by SWT. It is not * available on all platforms, and should never be called from * application code. * </p> * * @param device the device on which to allocate the region * @param handle the handle for the region * @return a new region object containing the specified device and handle */public static Region win32_new(Device device, int handle) {	return new Region(device, handle);}/** * Returns a string containing a concise, human-readable * description of the receiver. * * @return a string representation of the receiver */public String toString () {	if (isDisposed()) return "Region {*DISPOSED*}";	return "Region {" + handle + "}";}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -