void uncheckGC(NSAutoreleasePool pool) { if (data.flippedContext != null && data.restoreContext) { NSGraphicsContext.static_restoreGraphicsState(); data.restoreContext = false; } NSView view = data.view; if (view != null && data.paintRect == null) { if (data.thread != Thread.currentThread()) flush(); } if (pool != null) pool.release(); }
void removePool () { NSAutoreleasePool pool = pools [poolCount - 1]; pools [--poolCount] = null; if (poolCount == 0) { NSMutableDictionary dictionary = NSThread.currentThread().threadDictionary(); dictionary.removeObjectForKey(NSString.stringWith("SWT_NSAutoreleasePool")); } pool.release (); }
protected void init () { NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { super.init(); } finally { if (pool != null) pool.release(); } }
void add(int[] pointArray, int count) { count = count / 2 * 2; if (count <= 2) return; NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { long /*int*/ polyRgn = polyRgn(pointArray, count); OS.UnionRgn(handle, polyRgn, handle); OS.DisposeRgn(polyRgn); } finally { if (pool != null) pool.release(); } }
/** * Returns <code>true</code> if the Transform represents the identity matrix * and false otherwise. * * @return <code>true</code> if the receiver is an identity Transform, and <code>false</code> otherwise */ public boolean isIdentity() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { NSAffineTransformStruct struct = handle.transformStruct(); return struct.m11 == 1 && struct.m12 == 0 && struct.m21 == 0 && struct.m22 == 1 && struct.tX == 0 && struct.tY == 0; } finally { if (pool != null) pool.release(); } }
/** * Returns the receiver's line count. This includes lines caused * by wrapping. * * @return the line count * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public int getLineCount() { checkLayout (); NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { computeRuns(); return lineOffsets.length - 1; } finally { if (pool != null) pool.release(); } }
/** * Modifies the receiver so that it represents a transformation that is * equivalent to its previous transformation scaled by (scaleX, scaleY). * * @param scaleX the amount to scale in the X direction * @param scaleY the amount to scale in the Y direction * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public void scale(float scaleX, float scaleY) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { handle.scaleXBy(scaleX, scaleY); } finally { if (pool != null) pool.release(); } }
/** * Cancels a print job in progress. * * @exception SWTException <ul> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */ public void cancelJob() { checkDevice(); NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { operation.destroyContext(); operation.cleanUpOperation(); } finally { if (pool != null) pool.release(); } }
/** * Closes the current sub path by adding to the receiver a line * from the current point of the path back to the starting point * of the sub path. * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public void close() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { handle.closePath(); closed = true; } finally { if (pool != null) pool.release(); } }
/** * Modifies the receiver so that it represents a transformation that is * equivalent to its previous transformation translated by (offsetX, offsetY). * * @param offsetX the distance to translate in the X direction * @param offsetY the distance to translate in the Y direction * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public void translate(float offsetX, float offsetY) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { handle.translateXBy(offsetX, offsetY); } finally { if (pool != null) pool.release(); } }
/** * 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); NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { return OS.EmptyRgn(handle); } finally { if (pool != null) pool.release(); } }
/** * Sets the line spacing of the receiver. The line spacing * is the space left between lines. * * @param spacing the new line spacing * * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_ARGUMENT - if the spacing is negative</li> * </ul> * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public void setSpacing (int spacing) { checkLayout(); if (spacing < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); if (this.spacing == spacing) return; NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { freeRuns(); this.spacing = spacing; } finally { if (pool != null) pool.release(); } }
/** * Returns a <code>PrinterData</code> object representing * the default printer or <code>null</code> if there is no * default printer. * * @return the default printer data or null * * @since 2.1 */ public static PrinterData getDefaultPrinterData() { NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { NSPrinter printer = NSPrintInfo.defaultPrinter(); if (printer == null) return null; NSString str = printer.name(); return new PrinterData(DRIVER, str.getString()); } finally { if (pool != null) pool.release(); } }
/** * Modifies the receiver such that the matrix it represents becomes the * identity matrix. * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> * * @since 3.4 */ public void identity() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { NSAffineTransformStruct struct = new NSAffineTransformStruct(); struct.m11 = 1; struct.m22 = 1; handle.setTransformStruct(struct); } finally { if (pool != null) pool.release(); } }
/** * Adds to the receiver a line from the current point to * the point specified by (x, y). * * @param x the x coordinate of the end of the line to add * @param y the y coordinate of the end of the line to add * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public void lineTo(float x, float y) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { NSPoint pt = new NSPoint(); pt.x = x; pt.y = y; handle.lineToPoint(pt); closed = false; } finally { if (pool != null) pool.release(); } }
/** * Ends the current page. * * @exception SWTException <ul> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see #startPage * @see #startJob * @see #endJob */ public void endPage() { checkDevice(); NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { operation.context().restoreGraphicsState(); view.endPage(); } finally { if (pool != null) pool.release(); } }
/** * Modifies the receiver such that the matrix it represents becomes * the mathematical inverse of the matrix it previously represented. * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_CANNOT_INVERT_MATRIX - if the matrix is not invertible</li> * </ul> */ public void invert() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { NSAffineTransformStruct struct = handle.transformStruct(); if ((struct.m11 * struct.m22 - struct.m12 * struct.m21) == 0) { SWT.error(SWT.ERROR_CANNOT_INVERT_MATRIX); } handle.invert(); } finally { if (pool != null) pool.release(); } }
/** * Adds the given rectangle to the collection of polygons * the receiver maintains to describe its area. * * @param rect the rectangle to merge 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> */ public void add(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); NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { add (rect.x, rect.y, rect.width, rect.height); } finally { if (pool != null) pool.release(); } }
/** * Adds to the receiver the path described by the parameter. * * @param path the path to add to the receiver * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the parameter is null</li> * <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li> * </ul> * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public void addPath(Path path) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (path == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (path.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { handle.appendBezierPath(path.handle); closed = path.closed; } finally { if (pool != null) pool.release(); } }
static long /*int*/ polyRgn(int[] pointArray, int count) { NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { long /*int*/ polyRgn; if (C.PTR_SIZEOF == 4) { polyRgn = OS.NewRgn(); OS.OpenRgn(); OS.MoveTo((short)pointArray[0], (short)pointArray[1]); for (int i = 1; i < count / 2; i++) { OS.LineTo((short)pointArray[2 * i], (short)pointArray[2 * i + 1]); } OS.LineTo((short)pointArray[0], (short)pointArray[1]); OS.CloseRgn(polyRgn); } else { polyRgn = polyToRgn(pointArray, count); } return polyRgn; } finally { if (pool != null) pool.release(); } }