当前位置: 首页>>代码示例>>Java>>正文


Java Path.cubicTo方法代码示例

本文整理汇总了Java中org.eclipse.swt.graphics.Path.cubicTo方法的典型用法代码示例。如果您正苦于以下问题:Java Path.cubicTo方法的具体用法?Java Path.cubicTo怎么用?Java Path.cubicTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.swt.graphics.Path的用法示例。


在下文中一共展示了Path.cubicTo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: arcSelf

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:21,代码来源:GraphUtils.java

示例2: arcReversed

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:16,代码来源:GraphUtils.java

示例3: toSwtPath

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
/**
 * Converts an AWT <code>Shape</code> into a SWT <code>Path</code>.
 * 
 * @param shape  the shape.
 * 
 * @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;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:39,代码来源:SWTGraphics2D.java

示例4: toSwtPath

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:39,代码来源:SWTGraphics2D.java

示例5: pathIterator2Path

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
/**
 * Converts a java 2d path iterator to a SWT path.
 * 
 * @param iter specifies the iterator to be converted.
 * @return the corresponding path object. Must be disposed() when no longer
 *         used.
 */
private Path pathIterator2Path(final PathIterator iter) {
    final float[] coords = new float[6];

    final Path path = new Path(device);

    while (!iter.isDone()) {
        final int type = iter.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_CLOSE:
                path.close();
                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;
            default:
                // log this?
        }

        iter.next();
    }
    return path;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:44,代码来源:SWTGraphics2D.java

示例6: paintRecursive

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
private void paintRecursive(GC gc, DrawableViewNode node, Path connectionPath) {
    if (mSelectedNode == node && node.viewNode.filtered) {
        gc.drawImage(sFilteredSelectedImage, node.left, (int) Math.round(node.top));
    } else if (mSelectedNode == node) {
        gc.drawImage(sSelectedImage, node.left, (int) Math.round(node.top));
    } else if (node.viewNode.filtered) {
        gc.drawImage(sFilteredImage, node.left, (int) Math.round(node.top));
    } else {
        gc.drawImage(sNotSelectedImage, node.left, (int) Math.round(node.top));
    }
    int N = node.children.size();
    if (N == 0) {
        return;
    }
    float childSpacing =
            (1.0f * (DrawableViewNode.NODE_HEIGHT - 2 * TreeView.LINE_PADDING)) / N;
    for (int i = 0; i < N; i++) {
        DrawableViewNode child = node.children.get(i);
        paintRecursive(gc, child, connectionPath);
        float x1 = node.left + DrawableViewNode.NODE_WIDTH;
        float y1 =
                (float) node.top + TreeView.LINE_PADDING + childSpacing * i + childSpacing / 2;
        float x2 = child.left;
        float y2 = (float) child.top + DrawableViewNode.NODE_HEIGHT / 2.0f;
        float cx1 = x1 + TreeView.BEZIER_FRACTION * DrawableViewNode.PARENT_CHILD_SPACING;
        float cy1 = y1;
        float cx2 = x2 - TreeView.BEZIER_FRACTION * DrawableViewNode.PARENT_CHILD_SPACING;
        float cy2 = y2;
        connectionPath.moveTo(x1, y1);
        connectionPath.cubicTo(cx1, cy1, cx2, cy2, x2, y2);
    }
}
 
开发者ID:utds3lab,项目名称:SMVHunter,代码行数:33,代码来源:TreeViewOverview.java

示例7: createScaledPath

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
/**
 * Scales given path by zoom factor
 * 
 * @param path
 *            Path to be scaled
 * @return Scaled path
 */
private Path createScaledPath(Path path) {
	PathData p = path.getPathData();
	for (int i = 0; i < p.points.length; i += 2) {
		p.points[i] = (float) (p.points[i] * zoom + fractionalX);
		p.points[i + 1] = (float) (p.points[i + 1] * zoom + fractionalY);
	}
	Path scaledPath = new Path(path.getDevice());
	int index = 0;
	for (int i = 0; i < p.types.length; i++) {
		byte type = p.types[i];
		switch (type) {
		case SWT.PATH_MOVE_TO:
			scaledPath.moveTo(p.points[index], p.points[index + 1]);
			index += 2;
			break;
		case SWT.PATH_LINE_TO:
			scaledPath.lineTo(p.points[index], p.points[index + 1]);
			index += 2;
			break;
		case SWT.PATH_CUBIC_TO:
			scaledPath.cubicTo(p.points[index], p.points[index + 1],
					p.points[index + 2], p.points[index + 3],
					p.points[index + 4], p.points[index + 5]);
			index += 6;
			break;
		case SWT.PATH_QUAD_TO:
			scaledPath.quadTo(p.points[index], p.points[index + 1],
					p.points[index + 2], p.points[index + 3]);
			index += 4;
			break;
		case SWT.PATH_CLOSE:
			scaledPath.close();
			break;
		}
	}
	return scaledPath;
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:45,代码来源:ScaledGraphics.java


注:本文中的org.eclipse.swt.graphics.Path.cubicTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。