public void setTransform( float translationX, float translationY, int shadowsize, float magnification ) { if ( transform != null ) { // dispose of previous to prevent leaking of handles transform.dispose(); } transform = new Transform( gc.getDevice() ); transform.translate( translationX + shadowsize * magnification, translationY + shadowsize * magnification ); transform.scale( magnification, magnification ); gc.setTransform( transform ); currentMagnification = magnification; }
public void dispose() { gc.dispose(); if ( transform != null && transform.isDisposed() == false ) { transform.dispose(); } for ( Color color : colors ) { color.dispose(); } for ( Font font : fonts ) { font.dispose(); } }
if ( ( (Transform) object ).isDisposed() ) { return; String string = ( (Transform) object ).toString(); gc.drawString( string, 0, 0 ); return;
/** * Applies a translation. * * @param x the translation along the x-axis. * @param y the translation along the y-axis. */ @Override public void translate(int x, int y) { Transform swtTransform = new Transform(this.gc.getDevice()); this.gc.getTransform(swtTransform); swtTransform.translate(x, y); this.gc.setTransform(swtTransform); swtTransform.dispose(); }
/** * Returns a string containing a concise, human-readable * description of the receiver. * * @return a string representation of the receiver */ @Override public String toString() { if (isDisposed()) return "Transform {*DISPOSED*}"; float[] elements = new float[6]; getElements(elements); return "Transform {" + elements [0] + "," + elements [1] + "," +elements [2] + "," +elements [3] + "," +elements [4] + "," +elements [5] + "}"; }
/** * 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 ); } return Arrays.equals( elements, IDENTITY_MATRIX ); }
SWT.error( SWT.ERROR_NULL_ARGUMENT ); if( transform.isDisposed() ) { SWT.error( SWT.ERROR_INVALID_ARGUMENT ); transform.setElements( elements[ 0 ], elements[ 1 ], elements[ 2 ],
@Override public void drawText ( final String string, final int x, final int y, final Float rotate ) { final Transform t; if ( rotate != null ) { t = new Transform ( this.gc.getDevice () ); t.rotate ( rotate ); this.gc.setTransform ( t ); } else { t = null; } this.gc.drawText ( string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_TRANSPARENT ); if ( t != null ) { this.gc.setTransform ( null ); t.dispose (); } }
/** * Applies a scale transform. * * @param scaleX the scale factor along the x-axis. * @param scaleY the scale factor along the y-axis. */ @Override public void scale(double scaleX, double scaleY) { Transform swtTransform = new Transform(this.gc.getDevice()); this.gc.getTransform(swtTransform); swtTransform.scale((float) scaleX, (float) scaleY); this.gc.setTransform(swtTransform); swtTransform.dispose(); }
/** * Concatenates the specified transform to the existing transform. * * @param t the transform. */ @Override public void transform(AffineTransform t) { Transform swtTransform = new Transform(this.gc.getDevice()); this.gc.getTransform(swtTransform); swtTransform.multiply(getSwtTransformFromPool(t)); this.gc.setTransform(swtTransform); swtTransform.dispose(); }
/** * Internal method to convert a AWT transform object into * a SWT transform resource. If a corresponding SWT transform * instance is already in the pool, it will be used * instead of creating a new one. This is used in * {@link #setTransform()} for instance. * * @param awtTransform The AWT transform to convert. * @return A SWT transform instance. */ private Transform getSwtTransformFromPool(AffineTransform awtTransform) { Transform t = (Transform) this.transformsPool.get(awtTransform); if (t == null) { t = new Transform(this.gc.getDevice()); double[] matrix = new double[6]; awtTransform.getMatrix(matrix); t.setElements((float) matrix[0], (float) matrix[1], (float) matrix[2], (float) matrix[3], (float) matrix[4], (float) matrix[5]); addToResourcePool(t); this.transformsPool.put(awtTransform, t); } return t; }
if( isDisposed() ) { SWT.error( SWT.ERROR_GRAPHIC_DISPOSED ); SWT.error( SWT.ERROR_NULL_ARGUMENT ); if( matrix.isDisposed() ) { SWT.error( SWT.ERROR_INVALID_ARGUMENT ); matrix.getElements( elements ); multiply( elements[ 0 ], elements[ 1 ], elements[ 2 ],
/** * Returns the current transform. * * @return The current transform. */ @Override public AffineTransform getTransform() { Transform swtTransform = new Transform(this.gc.getDevice()); this.gc.getTransform(swtTransform); AffineTransform awtTransform = toAwtTransform(swtTransform); swtTransform.dispose(); return awtTransform; }
this (device, checkTransform(elements)[0], elements[1], elements[2], elements[3], elements[4], elements[5]);
public void translate(double tx, double ty) { if (_transform == null) { _transform = new Transform(_gc.getDevice()); } _transform.translate((int) tx, (int) ty); _gc.setTransform(_transform); if (_clippingArea != null) { AffineTransform t = new AffineTransform(); t.translate(-tx, -ty); _clippingArea.transform(t); } }
if (handle == null) SWT.error(SWT.ERROR_NO_HANDLES); handle.retain(); setElements(m11, m12, m21, m22, dx, dy); init(); } finally { if (pool != null) pool.release();
handle = Gdip.Matrix_new(m11, m12, m21, m22, DPIUtil.autoScaleUp(dx), DPIUtil.autoScaleUp(dy)); if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES); init();
/** * Constructor for SWTGraphics2D. * * @param gc The Eclipse Graphics Context onto which all Graphics2D * operations are delegating * @param device Device onto which ultimately all gc operations are drawn * onto */ public SWTGraphics2D(final GC gc, final Device device) { this.gc = gc; this.device = device; swtTransform = new Transform(device); gc.setAntialias(SWT.ON); }
/** * Converts an SWT transform into the equivalent AWT transform. * * @param swtTransform the SWT transform. * * @return The AWT transform. */ private AffineTransform toAwtTransform(Transform swtTransform) { float[] elements = new float[6]; swtTransform.getElements(elements); AffineTransform awtTransform = new AffineTransform(elements); return awtTransform; }