private void defineRegion() { Region rgn = new Region(); for (Rectangle r : rects) { rgn.add(r); rgn.subtract(r.x + 2, r.y + 2, r.width - 4, r.height - 4); } if (feedbackShell.getRegion() != null && !feedbackShell.getRegion().isDisposed()) feedbackShell.getRegion().dispose(); feedbackShell.setRegion(rgn); feedbackShell.redraw(); display.update(); }
protected void packPopup() { popupLayout.marginTop = HAH; popupLayout.marginBottom = 0; popup.pack(); Region oldRegion = region; region = new Region(); region.add(getPolygon(false)); popup.setRegion(region); Rectangle bounds = region.getBounds(); popup.setSize(bounds.width, bounds.height + 2); if (oldRegion != null) { oldRegion.dispose(); } }
if ( ( (Region) object ).isDisposed() ) { return; String string = ( (Region) object ).getBounds().toString(); gc.drawString( string, 0, 0 ); return;
@Override public void dispose() { super.dispose(); if (!shellRegion.isDisposed()) shellRegion.dispose(); }
if (handle == null) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { region.subtract(region); NSRect rect = null; if (data.view != null) { region.add((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height); NSRect paintRect = data.paintRect; if (paintRect != null) { region.intersect((int)paintRect.x, (int)paintRect.y, (int)paintRect.width, (int)paintRect.height); int count = (int)/*64*/clip.elementCount(); int pointCount = 0; Region clipRgn = new Region(device); int[] pointArray = new int[count * 2]; long /*int*/ points = OS.malloc(NSPoint.sizeof); switch (element) { case OS.NSMoveToBezierPathElement: if (pointCount != 0) clipRgn.add(pointArray, pointCount); pointCount = 0; OS.memmove(pt, points, NSPoint.sizeof); break; case OS.NSClosePathBezierPathElement:
/** * Hides the rubberband (but does not eliminate it). * <p> * Increments by one the rubberband "hide" nesting count. The rubberband * is hidden from view (but remains active) if it wasn't already hidden. * </p> */ public void hideRubberband() { if (rubberbandHiddenNestingCount++ <= 0) { Region region = new Region(); rubberband.addDamagedRegion(displayFDC, region); Rectangle r = region.getBounds(); paintCanvas.redraw(r.x, r.y, r.width, r.height, true); region.dispose(); } }
@Override public void addDamagedRegion(FigureDrawContext fdc, Region region) { region.add(fdc.toClientRectangle(x1, y1, x2, y2)); } }
static Region mirrorRegion (Region region) { if (region == null) return null; Region mirrored = new Region (region.getDevice ()); long /*int*/ rgn = region.handle; int [] nRects = new int [1]; long /*int*/ [] rects = new long /*int*/ [1]; gdk_region_get_rectangles (rgn, rects, nRects); Rectangle bounds = DPIUtil.autoScaleUp(region.getBounds ()); GdkRectangle rect = new GdkRectangle (); for (int i = 0; i < nRects [0]; i++) { OS.memmove (rect, rects[0] + (i * GdkRectangle.sizeof), GdkRectangle.sizeof); rect.x = bounds.x + bounds.width - rect.x - rect.width; OS.gdk_region_union_with_rect (mirrored.handle, rect); } if (rects [0] != 0) OS.g_free (rects [0]); return mirrored; }
/** * Subtracts the given rectangle from the collection of polygons * 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); subtract (rect.x, rect.y, rect.width, rect.height); }
/** * Intersects the given rectangle to the collection of polygons * 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); intersect (rect.x, rect.y, rect.width, rect.height); }
void dispose() { if (!hoverShell.isDisposed()) { hoverShell.dispose(); } if (region != null) { region.dispose(); } }
/** * Returns <code>true</code> if the point specified by the * arguments is inside the area specified by the receiver, * and <code>false</code> otherwise. * * @param x the x coordinate of the point to test for containment * @param y the y coordinate of the point to test for containment * @return <code>true</code> if the region contains the point and <code>false</code> otherwise * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public boolean contains(int x, int y) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); return contains(new Point(x, y)); } boolean containsInPixels(int x, int y) {
/** * 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 + "}"; } }
@Override public void initialize(AnimationEngine engine) { Color color = getAnimationShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW); getAnimationShell().setBackground(color); // Ensure that the background won't show on the initial display shellRegion = new Region(getAnimationShell().getDisplay()); getAnimationShell().setRegion(shellRegion); }
/** * Translate all of the polygons the receiver maintains to describe * its area by the specified point. * * @param x the x coordinate of the point to translate * @param y the y coordinate of the point to translate * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> * * @since 3.1 */ public void translate (int x, int y) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); translate(new Point(x, y)); }
/** * Returns <code>true</code> if the given point is inside the * area specified by the receiver, and <code>false</code> * otherwise. * * @param pt the point to test for containment * @return <code>true</code> if the region contains the point 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> */ public boolean contains(Point pt) { if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); return contains(pt.x, pt.y); }