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(); } }
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(); } }
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 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; }
/** * 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; }
public Image getIcon(Icon id) { Image image = icons.get(id); if (image == null) { String vectorResName = "/icons/ic_" + id.name().toLowerCase() + (dark ? "_white_24dp.xml" : "_black_24dp.xml"); InputStream is = getClass().getResourceAsStream(vectorResName); int expectedSize = Math.round(24 * pixelPerDp); AndroidVectorDrawable avd = AndroidVectorDrawable.read(display, is, pixelPerDp); image = new Image(display, expectedSize, expectedSize); GC gc = new GC(image); if (expectedSize != 24) { Transform transform = new Transform(display); gc.getTransform(transform); transform.scale(expectedSize/24f, expectedSize/24f); gc.setTransform(transform); transform.dispose(); } avd.draw(gc); icons.put(id, image); } return image; }
/** * Clean used resources. */ public void clean() { if (_clippingPath != null) { _gc.setClipping((Rectangle) null); _clippingPath.dispose(); _clippingPath = null; _clippingArea = null; } if (_color != null) { _color.dispose(); _color = null; } if (_transform != null) { _gc.setTransform(null); _transform.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(); }
/** * 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(); }
/** * 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(); }
@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 (); } }
@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 (); } }
.get(ballCollection.prevy.size() - (i + 1)).floatValue()); gc.setTransform(transform); transform.dispose();
@ActionParams(names="canvas,gc,shape") public static void draw(Canvas canvas, GC gc, SimpleShape shape, ActionContext actionContext) { Control control = (Control) shape.getData(KEY); if(control != null && !control.isDisposed()) { int offset = shape.isSelected() ? 12 : 0; //System.out.println("ControlShape, selected=" + shape.isSelected()); Point clientSize = new Point(shape.getWidth() - offset, shape.getHeight() -offset); control.setSize(clientSize); control.setLocation(shape.getX() + offset/2, shape.getY() + offset/2); //Point size = control.getSize(); //System.out.println(bounds[0] + "," + bounds[1] + "," + bounds[2] + "," + bounds[3]); Transform oldTransform = new Transform(gc.getDevice()); gc.getTransform(oldTransform); Transform transform = new Transform(gc.getDevice()); transform.translate(shape.getX() + offset/2, shape.getY() + offset/2); //transform.scale(1f * shape.getWidth() / (clientSize.x), 1f * shape.getHeight() / (clientSize.y)); //transform.multiply(oldTransform); gc.setTransform(transform); control.print(gc); gc.setTransform(oldTransform); transform.dispose(); oldTransform.dispose(); } }
@ActionParams(names="canvas,gc,shape") public static void draw(Canvas canvas, GC gc, SimpleShape shape, ActionContext actionContext) { Control control = (Control) shape.getData(KEY); if(control != null && !control.isDisposed()) { int offset = shape.isSelected() ? 12 : 0; //System.out.println("ControlShape, selected=" + shape.isSelected()); Point clientSize = new Point(shape.getWidth() - offset, shape.getHeight() -offset); control.setSize(clientSize); control.setLocation(shape.getX() + offset/2, shape.getY() + offset/2); //Point size = control.getSize(); //System.out.println(bounds[0] + "," + bounds[1] + "," + bounds[2] + "," + bounds[3]); Transform oldTransform = new Transform(gc.getDevice()); gc.getTransform(oldTransform); Transform transform = new Transform(gc.getDevice()); transform.translate(shape.getX() + offset/2, shape.getY() + offset/2); //transform.scale(1f * shape.getWidth() / (clientSize.x), 1f * shape.getHeight() / (clientSize.y)); //transform.multiply(oldTransform); gc.setTransform(transform); control.print(gc); gc.setTransform(oldTransform); transform.dispose(); oldTransform.dispose(); } }
@ActionParams(names="canvas,gc,shape") public static void draw(Canvas canvas, GC gc, SimpleShape shape, ActionContext actionContext) { Thing thing = shape.getThing(); Path path = (Path) shape.getData(PATH); if(path != null && !path.isDisposed()) { float bounds[] = new float[4]; path.getBounds(bounds); //System.out.println(bounds[0] + "," + bounds[1] + "," + bounds[2] + "," + bounds[3]); Transform oldTransform = new Transform(gc.getDevice()); gc.getTransform(oldTransform); Transform transform = new Transform(gc.getDevice()); transform.translate(shape.getX(), shape.getY()); transform.scale(shape.getWidth() / (bounds[0] + bounds[2]), shape.getHeight() / (bounds[1] + bounds[3])); //transform.multiply(oldTransform); gc.setTransform(transform); if(thing.getBoolean("fill")) { gc.fillPath(path); }else { gc.drawPath(path); } gc.setTransform(oldTransform); transform.dispose(); oldTransform.dispose(); } }
gc.drawImage(image, 0, 0); transform.dispose(); image.dispose();
gc.fillPath(path); gc.drawPath(path); tr.dispose(); path.dispose(); });
gc.setTransform(transform); gc.drawArc(0, 0, width/3, height/6, 0, 180); transform.dispose();
transform.translate(-width/2, -height/2); gc.setTransform(transform); transform.dispose();