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


Java Path.moveTo方法代码示例

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


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

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
/** Paints an arc from src to tgt using the given control point ctr. */
public static float[] arc(GC gc, Point ctr, Point src, Point tgt) {
	Path path = new Path(gc.getDevice());
	path.moveTo((int) src.x, (int) src.y);
	path.quadTo((int) ctr.x, (int) ctr.y, (int) tgt.x, (int) tgt.y);
	gc.drawPath(path);

	float[] pp = path.getPathData().points;
	return pp;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:11,代码来源:GraphUtils.java

示例3: 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

示例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.
 * 
 * @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

示例5: 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

示例6: 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

示例7: paintLeftArrow

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
protected void paintLeftArrow(Graphics graphics){
	int width = pagingControlHeight / 4;
	Rectangle r = getBounds().getCopy();
	Point start = new Point(r.getRight().x - 10, r.getCenter().y);
	Path triangle = new Path(null);
	triangle.moveTo(start.x, start.y);
	triangle.lineTo(start.x - width, start.y - pagingControlHeight/2);
	triangle.lineTo(start.x - width, start.y + pagingControlHeight/2);
	graphics.fillPath(triangle);
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:11,代码来源:ScrollableViewFigureAndroid.java

示例8: paintRightArrow

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
protected void paintRightArrow(Graphics graphics){
	int width = pagingControlHeight / 4;
	Rectangle r = getBounds().getCopy();
	Point start = new Point(r.x + 10, r.getCenter().y);
	Path triangle = new Path(null);
	triangle.moveTo(start.x, start.y);
	triangle.lineTo(start.x + width, start.y - pagingControlHeight/2);
	triangle.lineTo(start.x + width, start.y + pagingControlHeight/2);
	graphics.fillPath(triangle);
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:11,代码来源:ScrollableViewFigureAndroid.java

示例9: getTopRoundedRectangle

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
public static Path getTopRoundedRectangle(PrecisionRectangle tempRect, float radius,boolean drawLeftSide,boolean drawRightSide){
	if (radius <= 0) return getRoundedRectangle(tempRect, radius,drawLeftSide,drawRightSide);
	float width = radius * 2;
	float dy = radius - tempRect.height;
	float dx = radius - (float) Math.sqrt(radius*radius - dy*dy);
	float alpha =  dy > 0 ? (float)(Math.acos(dy/radius)*180/Math.PI) : 90;
	Path p = new Path(null);
	float x = (float) tempRect.preciseX;
	float y = (float) tempRect.preciseY;
	float right = (float) tempRect.preciseRight();
	float bottom = (float) tempRect.preciseBottom();
	
	if (dy < 0){
		p.moveTo(x, y + radius);
	} else {
		p.moveTo(x + dx, y - dy);
	}
	p.addArc(x, y, width, width, 90 + alpha, -alpha);
	p.addArc(right-width, y, width, width, 90, -alpha);
	
	if (dy < 0){
		p.lineTo(right, bottom);//rightBottom
		p.lineTo(x, bottom);//leftBottom
	}
			
	return p;
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:28,代码来源:Drawer.java

示例10: getBottomRoundedRectangle

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
public static Path getBottomRoundedRectangle(PrecisionRectangle tempRect, float radius,boolean drawLeftSide,boolean drawRightSide){
	if (radius <= 0) return getRoundedRectangle(tempRect, radius,drawLeftSide,drawRightSide);
	float width = radius * 2;
	float dy = radius - tempRect.height;
	float dx = radius - (float) Math.sqrt(radius*radius - dy*dy);
	float alpha =  dy > 0 ? (float)(Math.acos(dy/radius)*180/Math.PI) : 90;
	Path p = new Path(null);
	float x = (float) tempRect.preciseX;
	float y = (float) tempRect.preciseY;
	float right = (float) tempRect.preciseRight();
	float bottom = (float) tempRect.preciseBottom();
	
	if (dy < 0){
		p.moveTo(x, bottom - radius);
	} else {
		p.moveTo(x + dx, y);
	}
	p.addArc(x, bottom - 2*radius, width, width, 270 - alpha, alpha);
	p.addArc(right-width, bottom - 2*radius, width, width, 270, alpha);
	
	if (dy < 0){
		p.lineTo(right, y);//rightTop
		p.lineTo(x, y);//leftTop
	}
			
	return p;
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:28,代码来源:Drawer.java

示例11: paintButton

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
protected void paintButton(Graphics graphics) {
	graphics.setBackgroundColor(ColorConstants.black);
	Rectangle bounds = getBounds().getCopy();
	Path path = new Path(null);
	path.moveTo(bounds.right() - BUTTON_SIZE.width / 2,
			bounds.getCenter().y - BUTTON_SIZE.height / 2);
	path.lineTo(bounds.right()- 3*BUTTON_SIZE.width / 2,
			bounds.getCenter().y - BUTTON_SIZE.height / 2);
	path.lineTo(bounds.right() - BUTTON_SIZE.width,
			bounds.getCenter().y + BUTTON_SIZE.height / 2);
	graphics.fillPath(path);
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:13,代码来源:PickerFigure.java

示例12: 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

示例13: paintScale

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
void paintScale(final GC gc) {
	gc.setBackground(IGamaColors.BLACK.color());
	final int BAR_WIDTH = 1;
	final int BAR_HEIGHT = 8;
	final int x = 0;
	final int y = 0;
	final int margin = 20;
	final int width = scalebar.getBounds().width - 2 * margin;
	final int height = scalebar.getBounds().height;
	final int barStartX = x + 1 + BAR_WIDTH / 2 + margin;
	final int barStartY = y + height - BAR_HEIGHT / 2;

	final Path path = new Path(WorkbenchHelper.getDisplay());
	path.moveTo(barStartX, barStartY - BAR_HEIGHT + 2);
	path.lineTo(barStartX, barStartY + 2);
	path.moveTo(barStartX, barStartY - BAR_HEIGHT / 2 + 2);
	path.lineTo(barStartX + width, barStartY - BAR_HEIGHT / 2 + 2);
	path.moveTo(barStartX + width, barStartY - BAR_HEIGHT + 2);
	path.lineTo(barStartX + width, barStartY + 2);

	gc.setForeground(IGamaColors.WHITE.color());
	gc.setLineStyle(SWT.LINE_SOLID);
	gc.setLineWidth(BAR_WIDTH);
	gc.drawPath(path);
	gc.setFont(coord.getFont());
	drawStringCentered(gc, "0", barStartX, barStartY - 6, false);
	drawStringCentered(gc, getScaleRight(), barStartX + width, barStartY - 6, false);
	path.dispose();
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:30,代码来源:DisplayOverlay.java

示例14: paintTurtle

import org.eclipse.swt.graphics.Path; //导入方法依赖的package包/类
private void paintTurtle(GC gc, Point p)
{
	Path path = new Path(getDisplay());
	int x;
	int y;
	x = p.x - (int)Math.round(Math.cos(Math.toRadians(_turtle.getAngle() + 90)) * 5);
	y = p.y - (int)Math.round(Math.sin(Math.toRadians(_turtle.getAngle() + 90)) * 5);
	Point p1 = new Point(x, y);
	x = p.x + (int)Math.round(Math.cos(Math.toRadians(_turtle.getAngle() + 90)) * 5);
	y = p.y + (int)Math.round(Math.sin(Math.toRadians(_turtle.getAngle() + 90)) * 5);
	Point p2 = new Point(x, y);
	x = p.x + (int)Math.round(Math.cos(Math.toRadians(_turtle.getAngle())) * 10);
	y = p.y + (int)Math.round(Math.sin(Math.toRadians(_turtle.getAngle())) * 10);
	Point p3 = new Point(x, y);
	path.moveTo(p1.x, p1.y);
	path.lineTo(p2.x, p2.y);
	path.lineTo(p3.x, p3.y);
	path.lineTo(p1.x, p1.y);
	if (_turtle.isPenDown())
	{
		gc.setBackground(_turtleColor);
	}
	else
	{
		gc.setBackground(getBackground());
	}
	gc.fillPath(path);
	gc.setForeground(new Color(getDisplay(), 0, 0, 0));
	gc.drawPath(path);
}
 
开发者ID:yinonavraham,项目名称:myLOGO,代码行数:31,代码来源:TurtleCanvas.java

示例15: 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.moveTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。