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


Java PPath.lineTo方法代码示例

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


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

示例1: initialize

import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void initialize() {
    PPath line1 = PPath.createLine(5f, 10f, 5f, 100f);
    line1.setStroke(new BasicStroke(0));
    getCanvas().getLayer().addChild(line1);

    PPath line2 = new PPath.Float();
    line2.setStroke(new BasicStroke(0));
    line2.moveTo(15f, 10f);
    line2.lineTo(15f, 100f);
    getCanvas().getLayer().addChild(line2);

    PPath line3 = PPath.createLine(25f, 10f, 26f, 100f);
    line3.setStroke(new BasicStroke(0));
    getCanvas().getLayer().addChild(line3);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:17,代码来源:ZeroWidthStrokeBug.java

示例2: drag

import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void drag(final PInputEvent e) {
    final PNode node = e.getPickedNode();
    node.translate(e.getDelta().width, e.getDelta().height);

    final ArrayList edges = (ArrayList) e.getPickedNode().getAttribute("edges");

    int i;
    for (i = 0; i < edges.size(); i++) {
        final PPath edge = (PPath) edges.get(i);
        final ArrayList nodes = (ArrayList) edge.getAttribute("nodes");
        final PNode node1 = (PNode) nodes.get(0);
        final PNode node2 = (PNode) nodes.get(1);

        edge.reset();
        // Note that the node's "FullBounds" must be used (instead of
        // just the "Bound") because the nodes have non-identity
        // transforms which must be included when determining their
        // position.
        final Point2D.Double bound1 = (Point2D.Double) node1.getFullBounds().getCenter2D();
        final Point2D.Double bound2 = (Point2D.Double) node2.getFullBounds().getCenter2D();

        edge.moveTo((float) bound1.getX(), (float) bound1.getY());
        edge.lineTo((float) bound2.getX(), (float) bound2.getY());
    }
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:26,代码来源:GraphEditorExample.java

示例3: drawEdge

import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
@Override
public void drawEdge(PPath pEdge, Point2D vStart, Point2D vEnd, Metadata metadata,
		Identifier identifier) {
	float xStart = (float) vStart.getX();
	float yStart = (float) vStart.getY();
	float xEnd = (float) vEnd.getX();
	float yEnd = (float) vEnd.getY();
	// float xMid = Math.abs(xEnd
	// - xStart)
	// / 2.0f;
	float yMid = Math.abs(yEnd
			- yStart)
			/ 2.0f;

	pEdge.moveTo(xStart, yStart);
	pEdge.lineTo(xStart, yMid);
	pEdge.lineTo(xEnd, yMid);
	pEdge.lineTo(xEnd, yEnd);
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:20,代码来源:OrthogonalLinePiccolo2dEdgeRenderer.java

示例4: initialize

import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void initialize() {
    final PLayer layer = getCanvas().getLayer();
    final PRoot root = getCanvas().getRoot();
    final Random r = new Random();
    for (int i = 0; i < 1000; i++) {
        final PNode n = PPath.createRectangle(0, 0, 100, 80);
        n.translate(10000 * r.nextFloat(), 10000 * r.nextFloat());
        n.setPaint(new Color(r.nextFloat(), r.nextFloat(), r.nextFloat()));
        layer.addChild(n);
    }
    getCanvas().getCamera().animateViewToCenterBounds(layer.getGlobalFullBounds(), true, 0);
    final PActivity a = new PActivity(-1, 20) {
        public void activityStep(final long currentTime) {
            super.activityStep(currentTime);
            rotateNodes();
        }
    };
    root.addActivity(a);

    final PPath p = new PPath.Float();
    p.moveTo(0, 0);
    p.lineTo(0, 1000);
    final PFixedWidthStroke stroke = new PFixedWidthStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10,
            new float[] { 5, 2 }, 0);
    p.setStroke(stroke);
    layer.addChild(p);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:28,代码来源:DynamicExample.java

示例5: initialize

import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void initialize() {
    final int numNodes = 50;
    final int numEdges = 50;

    // Initialize, and create a layer for the edges (always underneath the
    // nodes)
    final PLayer nodeLayer = getCanvas().getLayer();
    final PLayer edgeLayer = new PLayer();
    getCanvas().getCamera().addLayer(0, edgeLayer);
    final Random rnd = new Random();
    ArrayList tmp;
    for (int i = 0; i < numNodes; i++) {
        final float x = (float) (300. * rnd.nextDouble());
        final float y = (float) (400. * rnd.nextDouble());
        final PPath path = PPath.createEllipse(x, y, 20, 20);
        tmp = new ArrayList();
        path.addAttribute("edges", tmp);
        nodeLayer.addChild(path);
    }

    // Create some random edges
    // Each edge's Tag has an ArrayList used to store associated nodes
    for (int i = 0; i < numEdges; i++) {
        final int n1 = rnd.nextInt(numNodes);
        final int n2 = rnd.nextInt(numNodes);
        final PNode node1 = nodeLayer.getChild(n1);
        final PNode node2 = nodeLayer.getChild(n2);

        final Point2D.Double bound1 = (Point2D.Double) node1.getBounds().getCenter2D();
        final Point2D.Double bound2 = (Point2D.Double) node2.getBounds().getCenter2D();

        final PPath edge = new PPath.Float();
        edge.moveTo((float) bound1.getX(), (float) bound1.getY());
        edge.lineTo((float) bound2.getX(), (float) bound2.getY());

        tmp = (ArrayList) node1.getAttribute("edges");
        tmp.add(edge);
        tmp = (ArrayList) node2.getAttribute("edges");
        tmp.add(edge);

        tmp = new ArrayList();
        tmp.add(node1);
        tmp.add(node2);
        edge.addAttribute("nodes", tmp);

        edgeLayer.addChild(edge);
    }

    // Create event handler to move nodes and update edges
    nodeLayer.addInputEventListener(new NodeDragHandler());
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:52,代码来源:GraphEditorExample.java

示例6: drawStraightDashedLine

import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
/**
 * Draws a straight dashed line.
 *
 * @param pEdge
 *            the {@link PPath} object representing the edge
 * @param vStart
 *            the starting point of the edge
 * @param vEnd
 *            the end point of the edge
 */
public static void drawStraightDashedLine(PPath pEdge, Point2D vStart, Point2D vEnd) {
	float[] dash = {10.0f};
	pEdge.setStroke(new BasicStroke(3.0f, BasicStroke.CAP_BUTT,
			BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f));
	pEdge.moveTo((float) vStart.getX(), (float) vStart.getY());
	pEdge.lineTo((float) vEnd.getX(), (float) vEnd.getY());
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:18,代码来源:StraightDashedLinePiccolo2dEdgeRenderer.java

示例7: drawStraightLine

import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
/**
 * Draws a straight line.
 *
 * @param pEdge
 *            the {@link PPath} object representing the edge
 * @param vStart
 *            the starting point of the edge
 * @param vEnd
 *            the end point of the edge
 */
public static void drawStraightLine(PPath pEdge, Point2D vStart, Point2D vEnd) {
	pEdge.moveTo((float) vStart.getX(), (float) vStart.getY());
	pEdge.lineTo((float) vEnd.getX(), (float) vEnd.getY());
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:15,代码来源:StraightLinePiccolo2dEdgeRenderer.java


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