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; }
@Override protected Image renderRotated( Device device, int width, int height, double angleRadians ) { Image result = new Image( device, width * 2, height * 2 ); GC gc = new GC( result ); int bw = bitmap.getBounds().width; int bh = bitmap.getBounds().height; Transform affineTransform = new Transform( device ); affineTransform.translate( width, height ); affineTransform.rotate( (float) Math.toDegrees( angleRadians ) ); affineTransform.scale( (float) 1.0 * width / bw, (float) 1.0 * height / bh ); gc.setTransform( affineTransform ); gc.drawImage( bitmap, 0, 0, bw, bh, -bw / 2, -bh / 2, bw, bh ); gc.dispose(); return result; } }
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); } }
/** * 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(); }
for (int i = 0; i < ballCollection.prevx.size(); i++) { Transform transform = new Transform(device); transform.translate(ballCollection.prevx.get(ballCollection.prevx.size() - (i + 1)).floatValue(), ballCollection.prevy .get(ballCollection.prevy.size() - (i + 1)).floatValue());
transform.translate((int)movClubX, (int)movClubY); transform.scale(scaleWidth, scaleWidth); transform.translate(rect.width/2, rect.height/2); transform.rotate(rotationAngle); transform.translate(-rect.width/2, -rect.height/2); transform.translate((int)movDiamondX, (int)movDiamondY); transform.scale(scaleWidth, scaleWidth); gc.setTransform(transform); transform.translate(movHeart, height/2); transform.scale(heartScale, 0.5f*scale); gc.setTransform(transform); transform.translate(movSpade, movSpade); transform.scale(0.5f*scale, spadeScale); gc.setTransform(transform);
transform.translate((width-bounds.width)/2, (height-bounds.height)/2); transform.scale(1, -1); gc.setTransform(transform); transform.translate((width-bounds.width)/2, 2*bounds.height + (height-bounds.height)/2); transform.scale(1, -1); gc.setTransform(transform); transform.translate((width-bounds.width)/2, (height-bounds.height)/2); transform.scale(-1, 1); gc.setTransform(transform); transform.translate(2*bounds.width + (width-bounds.width)/2, (height-bounds.height)/2); transform.scale(-1, 1); gc.setTransform(transform);
transform.translate((width-250)/4, height/2-150); gc.setTransform(transform); transform.dispose();
if (orientation == SWT.VERTICAL) { transform = new Transform(event.display); transform.translate(TrimUtil.TRIM_DEFAULT_HEIGHT, 0); transform.rotate(90);
GC gc = event.gc; Transform tr = new Transform(display); tr.translate(rect.width / 4, rect.height / 2); tr.rotate(-30); if (image != null) {
@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(); } }
transform.translate(width/2, height/2); transform.rotate(angle); gc.setTransform(transform);
for (int i=0; i < n; i++) { transform = new Transform(device); transform.translate(width/2, height/2); transform.rotate(-(angle + 360/n * i)); gc.setTransform(transform);
@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(); } }