org.eclipse.swt.graphics.Transform Java Examples
The following examples show how to use
org.eclipse.swt.graphics.Transform.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SWTStrokeCanvas.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Creates a new instance. * * @param parent the parent. * @param style the style. */ public SWTStrokeCanvas(Composite parent, int style) { super(parent, style); addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { BasicStroke stroke = (BasicStroke) getStroke(); if (stroke != null) { int x, y; Rectangle rect = getClientArea(); x = (rect.width - 100) / 2; y = (rect.height - 16) / 2; Transform swtTransform = new Transform(e.gc.getDevice()); e.gc.getTransform(swtTransform); swtTransform.translate(x, y); e.gc.setTransform(swtTransform); swtTransform.dispose(); e.gc.setBackground(getDisplay().getSystemColor( SWT.COLOR_BLACK)); e.gc.setLineWidth((int) stroke.getLineWidth()); e.gc.drawLine(10, 8, 90, 8); } } }); }
Example #2
Source File: RotatePiece.java From nebula with Eclipse Public License 2.0 | 6 votes |
private void rotateTransform(Transform transform) { switch (angle) { case 90: transform.translate(0, size.y); break; case 180: transform.translate(size.x, size.y); break; case 270: transform.translate(size.x, 0); break; default: PaperClips.error(SWT.ERROR_INVALID_ARGUMENT, "Rotation angle must be 90, 180 or 270."); //$NON-NLS-1$ } transform.rotate(-angle); // reverse the angle since Transform.rotate // goes clockwise }
Example #3
Source File: SWTStrokeCanvas.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Creates a new instance. * * @param parent the parent. * @param style the style. */ public SWTStrokeCanvas(Composite parent, int style) { super(parent, style); addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { BasicStroke stroke = (BasicStroke) getStroke(); if (stroke != null) { int x, y; Rectangle rect = getClientArea(); x = (rect.width - 100) / 2; y = (rect.height - 16) / 2; Transform swtTransform = new Transform(e.gc.getDevice()); e.gc.getTransform(swtTransform); swtTransform.translate(x, y); e.gc.setTransform(swtTransform); swtTransform.dispose(); e.gc.setBackground(getDisplay().getSystemColor( SWT.COLOR_BLACK)); e.gc.setLineWidth((int) stroke.getLineWidth()); e.gc.drawLine(10, 8, 90, 8); } } }); }
Example #4
Source File: SWTChartEditor.java From gama with GNU General Public License v3.0 | 6 votes |
/** * Creates a new instance. * * @param parent * the parent. * @param style * the style. */ public SWTStrokeCanvas(final Composite parent, final int style) { super(parent, style); addPaintListener(e -> { final BasicStroke stroke = getStroke(); if (stroke != null) { int x, y; final Rectangle rect = getClientArea(); x = (rect.width - 100) / 2; y = (rect.height - 16) / 2; final Transform swtTransform = new Transform(e.gc.getDevice()); e.gc.getTransform(swtTransform); swtTransform.translate(x, y); e.gc.setTransform(swtTransform); swtTransform.dispose(); e.gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_BLACK)); e.gc.setLineWidth((int) stroke.getLineWidth()); e.gc.drawLine(10, 8, 90, 8); } }); }
Example #5
Source File: SwtUniversalImageBitmap.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@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; }
Example #6
Source File: SWTStrokeCanvas.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Creates a new instance. * * @param parent the parent. * @param style the style. */ public SWTStrokeCanvas(Composite parent, int style) { super(parent, style); addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { BasicStroke stroke = (BasicStroke) getStroke(); if (stroke != null) { int x, y; Rectangle rect = getClientArea(); x = (rect.width - 100) / 2; y = (rect.height - 16) / 2; Transform swtTransform = new Transform(e.gc.getDevice()); e.gc.getTransform(swtTransform); swtTransform.translate(x, y); e.gc.setTransform(swtTransform); swtTransform.dispose(); e.gc.setBackground(getDisplay().getSystemColor( SWT.COLOR_BLACK)); e.gc.setLineWidth((int) stroke.getLineWidth()); e.gc.drawLine(10, 8, 90, 8); } } }); }
Example #7
Source File: SwtUniversalImageBitmap.java From hop with Apache License 2.0 | 6 votes |
@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) zoomFactor * width / bw, (float) zoomFactor * height / bh ); gc.setTransform( affineTransform ); gc.drawImage( bitmap, 0, 0, bw, bh, -bw / 2, -bh / 2, bw, bh ); gc.dispose(); return result; }
Example #8
Source File: SWTStrokeCanvas.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Creates a new instance. * * @param parent the parent. * @param style the style. */ public SWTStrokeCanvas(Composite parent, int style) { super(parent, style); addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { BasicStroke stroke = (BasicStroke) getStroke(); if (stroke != null) { int x, y; Rectangle rect = getClientArea(); x = (rect.width - 100) / 2; y = (rect.height - 16) / 2; Transform swtTransform = new Transform(e.gc.getDevice()); e.gc.getTransform(swtTransform); swtTransform.translate(x, y); e.gc.setTransform(swtTransform); swtTransform.dispose(); e.gc.setBackground(getDisplay().getSystemColor( SWT.COLOR_BLACK)); e.gc.setLineWidth((int) stroke.getLineWidth()); e.gc.drawLine(10, 8, 90, 8); } } }); }
Example #9
Source File: TagCloud.java From gef with Eclipse Public License 2.0 | 6 votes |
private void zoom(double s) { checkWidget(); if (selectionLayerImage == null) return; if (s < 0.1) s = 0.1; if (s > 3) s = 3; int width = (int) (selectionLayerImage.getBounds().width * s); int height = (int) (selectionLayerImage.getBounds().height * s); if (width == 0 || height == 0) return; zoomLayerImage = new Image(getDisplay(), width, height); Transform tf = new Transform(getDisplay()); tf.scale((float) s, (float) s); GC gc = new GC(zoomLayerImage); gc.setTransform(tf); gc.drawImage(selectionLayerImage, 0, 0); gc.dispose(); tf.dispose(); currentZoom = s; updateScrollbars(); redraw(); }
Example #10
Source File: SWTStrokeCanvas.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * Creates a new instance. * * @param parent the parent. * @param style the style. */ public SWTStrokeCanvas(Composite parent, int style) { super(parent, style); addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { BasicStroke stroke = (BasicStroke) getStroke(); if (stroke != null) { int x, y; Rectangle rect = getClientArea(); x = (rect.width - 100) / 2; y = (rect.height - 16) / 2; Transform swtTransform = new Transform(e.gc.getDevice()); e.gc.getTransform(swtTransform); swtTransform.translate(x, y); e.gc.setTransform(swtTransform); swtTransform.dispose(); e.gc.setBackground(getDisplay().getSystemColor( SWT.COLOR_BLACK)); e.gc.setLineWidth((int) stroke.getLineWidth()); e.gc.drawLine(10, 8, 90, 8); } } }); }
Example #11
Source File: SWTStrokeCanvas.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a new instance. * * @param parent the parent. * @param style the style. */ public SWTStrokeCanvas(Composite parent, int style) { super(parent, style); addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { BasicStroke stroke = (BasicStroke) getStroke(); if (stroke != null) { int x, y; Rectangle rect = getClientArea(); x = (rect.width - 100) / 2; y = (rect.height - 16) / 2; Transform swtTransform = new Transform(e.gc.getDevice()); e.gc.getTransform(swtTransform); swtTransform.translate(x, y); e.gc.setTransform(swtTransform); swtTransform.dispose(); e.gc.setBackground(getDisplay().getSystemColor( SWT.COLOR_BLACK)); e.gc.setLineWidth((int) stroke.getLineWidth()); e.gc.drawLine(10, 8, 90, 8); } } }); }
Example #12
Source File: SWTStrokeCanvas.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a new instance. * * @param parent the parent. * @param style the style. */ public SWTStrokeCanvas(Composite parent, int style) { super(parent, style); addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { BasicStroke stroke = (BasicStroke) getStroke(); if (stroke != null) { int x, y; Rectangle rect = getClientArea(); x = (rect.width - 100) / 2; y = (rect.height - 16) / 2; Transform swtTransform = new Transform(e.gc.getDevice()); e.gc.getTransform(swtTransform); swtTransform.translate(x, y); e.gc.setTransform(swtTransform); swtTransform.dispose(); e.gc.setBackground(getDisplay().getSystemColor( SWT.COLOR_BLACK)); e.gc.setLineWidth((int) stroke.getLineWidth()); e.gc.drawLine(10, 8, 90, 8); } } }); }
Example #13
Source File: MinimapOverviewRuler.java From Pydev with Eclipse Public License 1.0 | 5 votes |
public Parameters(GC gc, Color styledTextForeground, Point size, int lineCount, int marginCols, Color marginColor, int spacing, int imageHeight, Transform transform, Image tmpImage) { this.gc = gc; this.styledTextForeground = styledTextForeground; this.size = size; this.lineCount = lineCount; this.marginCols = marginCols; this.marginColor = marginColor; this.spacing = spacing; this.imageHeight = imageHeight; this.transform = transform; this.tmpImage = tmpImage; }
Example #14
Source File: SWTGraphics2D.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Applies a scale transform. * * @param scaleX the scale factor along the x-axis. * @param scaleY the scale factor along the y-axis. */ 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(); }
Example #15
Source File: R31Enhance.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Equivalent to <code><b>GC.setTransform()</b></code> in r3.1. * * @param gc * @param value */ static void setTransform( GC gc, Object value ) { if ( R31_AVAILABLE ) { gc.setTransform( (Transform) value ); } }
Example #16
Source File: R31Enhance.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Equivalent to <code><b>Transform.rotate()</b></code> in r3.1. * * @param gc * @param transform * @param value */ static void rotate( GC gc, Object transform, float value ) { if ( R31_AVAILABLE ) { ( (Transform) transform ).rotate( value ); } }
Example #17
Source File: R31Enhance.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Equivalent to <code><b>Transform.dispose()</b></code> in r3.1. * * @param transform */ static void disposeTransform( Object transform ) { if ( R31_AVAILABLE ) { ( (Transform) transform ).dispose( ); } }
Example #18
Source File: SWTGraphics2D.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Concatenates the specified transform to the existing transform. * * @param t the transform. */ 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(); }
Example #19
Source File: SWTGraphics2D.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Applies a translation. * * @param x the translation along the x-axis. * @param y the translation along the y-axis. */ 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(); }
Example #20
Source File: R31Enhance.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Equivalent to <code><b>new Transform()</b></code> in r3.1. * * @param param * @return */ static Object newTransform( Device param ) { if ( R31_AVAILABLE ) { return new Transform( param ); } return null; }
Example #21
Source File: SWTGraphics2D.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Returns the current transform. * * @return The current transform. */ public AffineTransform getTransform() { Transform swtTransform = new Transform(this.gc.getDevice()); this.gc.getTransform(swtTransform); AffineTransform awtTransform = toAwtTransform(swtTransform); swtTransform.dispose(); return awtTransform; }
Example #22
Source File: SWTGraphics2D.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Concatenates the specified transform to the existing transform. * * @param t the transform. */ 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(); }
Example #23
Source File: SWTGraphics2D.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Returns the current transform. * * @return The current transform. */ public AffineTransform getTransform() { Transform swtTransform = new Transform(this.gc.getDevice()); this.gc.getTransform(swtTransform); AffineTransform awtTransform = toAwtTransform(swtTransform); swtTransform.dispose(); return awtTransform; }
Example #24
Source File: SWTGraphics2D.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Applies a scale transform. * * @param scaleX the scale factor along the x-axis. * @param scaleY the scale factor along the y-axis. */ 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(); }
Example #25
Source File: SWTGraphics2D.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Applies a translation. * * @param x the translation along the x-axis. * @param y the translation along the y-axis. */ 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(); }
Example #26
Source File: SWTGraphics2D.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Concatenates the specified transform to the existing transform. * * @param t the transform. */ 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(); }
Example #27
Source File: SWTGraphics2D.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Returns the current transform. * * @return The current transform. */ public AffineTransform getTransform() { Transform swtTransform = new Transform(this.gc.getDevice()); this.gc.getTransform(swtTransform); AffineTransform awtTransform = toAwtTransform(swtTransform); swtTransform.dispose(); return awtTransform; }
Example #28
Source File: DefaultTableHeaderRenderer.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * Set the rotation of the header text. Please note that you have to call <code>redraw()</code> on the table * yourself if you change the rotation while the table is showing. * * @param rotation rotation in degrees anti clockwise between 0 and 90 degrees. */ public void setRotation(int rotation) { if (rotation < 0 || rotation > 90) { throw new IllegalArgumentException("Rotation range 0..90"); } if (_rotation != rotation) { disposeTransformations(); _rotation = rotation; _transform = new Transform(Display.getCurrent()); _transformInv = new Transform(Display.getCurrent()); _transform.rotate(-rotation); _transformInv.rotate(-rotation); _transformInv.invert(); } }
Example #29
Source File: StatechartDefinitionSection.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override public void paintControl(PaintEvent e) { int w = e.width; int h = e.height; Transform tr = new Transform(e.display); tr.translate(w / 2, h / 2); tr.rotate(rotationAngle); e.gc.setTransform(tr); tr.dispose(); int drawHeight = -w + 2; e.gc.drawString(sectionExpanded ? "" : text, 0, drawHeight % 2 != 0 ? drawHeight + 1 : drawHeight - 1); }
Example #30
Source File: StatechartDefinitionSection.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected void drawIconBorder(Label icon, GC gc) { Rectangle rect = new Rectangle(0, 0, icon.getBounds().width - 1, icon.getBounds().height - 1); Transform t = new Transform(getDisplay()); gc.setTransform(t); t.dispose(); gc.setForeground(ColorConstants.lightGray); gc.drawRectangle(0, 0, rect.width, rect.height); }