Java Code Examples for org.eclipse.swt.graphics.Path#cubicTo()
The following examples show how to use
org.eclipse.swt.graphics.Path#cubicTo() .
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: GraphUtils.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Paints an looping arc from scr to tgt. * <p/> * <b>Assumption:</b> The tgt is located right/below of the src. */ public static float[] arcSelf(GC gc, Point src, Point tgt) { Path path = new Path(gc.getDevice()); int diffH = 10; int diff = diffH * 3; path.moveTo((int) src.x, (int) src.y); path.cubicTo( (int) src.x + diff, (int) src.y - diffH, (int) tgt.x, (int) tgt.y - diff, (int) tgt.x, (int) tgt.y); gc.drawPath(path); float[] pp = path.getPathData().points; return pp; }
Example 2
Source File: SWTGraphics2D.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Converts an AWT <code>Shape</code> into a SWT <code>Path</code>. * * @param shape the shape (<code>null</code> not permitted). * * @return The path. */ private Path toSwtPath(Shape shape) { int type; float[] coords = new float[6]; Path path = new Path(this.gc.getDevice()); PathIterator pit = shape.getPathIterator(null); while (!pit.isDone()) { type = pit.currentSegment(coords); switch (type) { case (PathIterator.SEG_MOVETO): path.moveTo(coords[0], coords[1]); break; case (PathIterator.SEG_LINETO): path.lineTo(coords[0], coords[1]); break; case (PathIterator.SEG_QUADTO): path.quadTo(coords[0], coords[1], coords[2], coords[3]); break; case (PathIterator.SEG_CUBICTO): path.cubicTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]); break; case (PathIterator.SEG_CLOSE): path.close(); break; default: break; } pit.next(); } return path; }
Example 3
Source File: GraphUtils.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Paints an arc from src to tgt. * <p/> * <b>Assumption:</b> The tgt is located below of the src. */ public static float[] arcReversed(GC gc, Point src, Point tgt) { Path path = new Path(gc.getDevice()); int ydiff = (int) ((tgt.y - src.y) / 3); path.moveTo((int) src.x, (int) src.y); path.cubicTo((int) src.x, (int) src.y + ydiff, (int) tgt.x, (int) tgt.y - ydiff * 2, (int) tgt.x, (int) tgt.y); gc.drawPath(path); float[] pp = path.getPathData().points; return pp; }
Example 4
Source File: SWTGraphics2D.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Converts an AWT <code>Shape</code> into a SWT <code>Path</code>. * * @param shape the shape (<code>null</code> not permitted). * * @return The path. */ private Path toSwtPath(Shape shape) { int type; float[] coords = new float[6]; Path path = new Path(this.gc.getDevice()); PathIterator pit = shape.getPathIterator(null); while (!pit.isDone()) { type = pit.currentSegment(coords); switch (type) { case (PathIterator.SEG_MOVETO): path.moveTo(coords[0], coords[1]); break; case (PathIterator.SEG_LINETO): path.lineTo(coords[0], coords[1]); break; case (PathIterator.SEG_QUADTO): path.quadTo(coords[0], coords[1], coords[2], coords[3]); break; case (PathIterator.SEG_CUBICTO): path.cubicTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]); break; case (PathIterator.SEG_CLOSE): path.close(); break; default: break; } pit.next(); } return path; }
Example 5
Source File: SWTGraphics2D.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Converts an AWT <code>Shape</code> into a SWT <code>Path</code>. * * @param shape the shape (<code>null</code> not permitted). * * @return The path. */ private Path toSwtPath(Shape shape) { int type; float[] coords = new float[6]; Path path = new Path(this.gc.getDevice()); PathIterator pit = shape.getPathIterator(null); while (!pit.isDone()) { type = pit.currentSegment(coords); switch (type) { case (PathIterator.SEG_MOVETO): path.moveTo(coords[0], coords[1]); break; case (PathIterator.SEG_LINETO): path.lineTo(coords[0], coords[1]); break; case (PathIterator.SEG_QUADTO): path.quadTo(coords[0], coords[1], coords[2], coords[3]); break; case (PathIterator.SEG_CUBICTO): path.cubicTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]); break; case (PathIterator.SEG_CLOSE): path.close(); break; default: break; } pit.next(); } return path; }
Example 6
Source File: SWTGraphics2D.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Converts an AWT <code>Shape</code> into a SWT <code>Path</code>. * * @param shape the shape (<code>null</code> not permitted). * * @return The path. */ private Path toSwtPath(Shape shape) { int type; float[] coords = new float[6]; Path path = new Path(this.gc.getDevice()); PathIterator pit = shape.getPathIterator(null); while (!pit.isDone()) { type = pit.currentSegment(coords); switch (type) { case (PathIterator.SEG_MOVETO): path.moveTo(coords[0], coords[1]); break; case (PathIterator.SEG_LINETO): path.lineTo(coords[0], coords[1]); break; case (PathIterator.SEG_QUADTO): path.quadTo(coords[0], coords[1], coords[2], coords[3]); break; case (PathIterator.SEG_CUBICTO): path.cubicTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]); break; case (PathIterator.SEG_CLOSE): path.close(); break; default: break; } pit.next(); } return path; }
Example 7
Source File: SWTGraphics2D.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Converts an AWT <code>Shape</code> into a SWT <code>Path</code>. * * @param shape the shape (<code>null</code> not permitted). * * @return The path. */ private Path toSwtPath(Shape shape) { int type; float[] coords = new float[6]; Path path = new Path(this.gc.getDevice()); PathIterator pit = shape.getPathIterator(null); while (!pit.isDone()) { type = pit.currentSegment(coords); switch (type) { case (PathIterator.SEG_MOVETO): path.moveTo(coords[0], coords[1]); break; case (PathIterator.SEG_LINETO): path.lineTo(coords[0], coords[1]); break; case (PathIterator.SEG_QUADTO): path.quadTo(coords[0], coords[1], coords[2], coords[3]); break; case (PathIterator.SEG_CUBICTO): path.cubicTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]); break; case (PathIterator.SEG_CLOSE): path.close(); break; default: break; } pit.next(); } return path; }
Example 8
Source File: SWTGraphics2D.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Converts an AWT <code>Shape</code> into a SWT <code>Path</code>. * * @param shape the shape (<code>null</code> not permitted). * * @return The path. */ private Path toSwtPath(Shape shape) { int type; float[] coords = new float[6]; Path path = new Path(this.gc.getDevice()); PathIterator pit = shape.getPathIterator(null); while (!pit.isDone()) { type = pit.currentSegment(coords); switch (type) { case (PathIterator.SEG_MOVETO): path.moveTo(coords[0], coords[1]); break; case (PathIterator.SEG_LINETO): path.lineTo(coords[0], coords[1]); break; case (PathIterator.SEG_QUADTO): path.quadTo(coords[0], coords[1], coords[2], coords[3]); break; case (PathIterator.SEG_CUBICTO): path.cubicTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]); break; case (PathIterator.SEG_CLOSE): path.close(); break; default: break; } pit.next(); } return path; }
Example 9
Source File: SWTGraphics2D.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Converts an AWT <code>Shape</code> into a SWT <code>Path</code>. * * @param shape the shape (<code>null</code> not permitted). * * @return The path. */ private Path toSwtPath(Shape shape) { int type; float[] coords = new float[6]; Path path = new Path(this.gc.getDevice()); PathIterator pit = shape.getPathIterator(null); while (!pit.isDone()) { type = pit.currentSegment(coords); switch (type) { case (PathIterator.SEG_MOVETO): path.moveTo(coords[0], coords[1]); break; case (PathIterator.SEG_LINETO): path.lineTo(coords[0], coords[1]); break; case (PathIterator.SEG_QUADTO): path.quadTo(coords[0], coords[1], coords[2], coords[3]); break; case (PathIterator.SEG_CUBICTO): path.cubicTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]); break; case (PathIterator.SEG_CLOSE): path.close(); break; default: break; } pit.next(); } return path; }
Example 10
Source File: LoginDialog.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** * Create a default image. It is a port of the image used by the Login Box * in the project SwingX * * @param w width * @param h height * @return a default image (blue wave) */ private Image createDefaultImage(final int w, final int h) { final Display display = Display.getCurrent(); final Color backgroundColor = new Color(display, 49, 121, 242); final Color gradientColor1 = new Color(display, 155, 185, 245); final Color gradientColor2 = new Color(display, 53, 123, 242); final Image img = new Image(display, w, h); final GC gc = new GC(img); gc.setAdvanced(true); gc.setAntialias(SWT.ON); gc.setBackground(backgroundColor); gc.fillRectangle(0, 0, w, h); final Path curveShape = new Path(display); curveShape.moveTo(0, h * .6f); curveShape.cubicTo(w * .167f, h * 1.2f, w * .667f, h * -.5f, w, h * .75f); curveShape.lineTo(w, h); curveShape.lineTo(0, h); curveShape.lineTo(0, h * .8f); curveShape.close(); final Pattern pattern = new Pattern(display, 0, 0, 1, h * 1.2f, gradientColor1, gradientColor2); gc.setBackgroundPattern(pattern); gc.fillPath(curveShape); final Font font = new Font(display, "Arial Bold", 30, SWT.NONE); gc.setFont(font); gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); final Point textSize = gc.stringExtent(ResourceManager.getLabel(ResourceManager.LOGIN)); gc.drawString(ResourceManager.getLabel(ResourceManager.LOGIN), (int) (w * .05f), (h - textSize.y) / 2, true); font.dispose(); curveShape.dispose(); pattern.dispose(); backgroundColor.dispose(); gradientColor1.dispose(); gradientColor2.dispose(); gc.dispose(); return img; }