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


Java PPath类代码示例

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


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

示例1: initialize

import org.piccolo2d.nodes.PPath; //导入依赖的package包/类
public void initialize() {
    final PLayer l = new PLayer();
    final PPath n = PPath.createEllipse(0, 0, 100, 80);
    n.setPaint(Color.red);
    n.setStroke(null);
    PBoundsHandle.addBoundsHandlesTo(n);
    l.addChild(n);
    n.translate(200, 200);

    final PCamera c = new PCamera();
    c.setBounds(0, 0, 100, 80);
    c.scaleView(0.1);
    c.addLayer(l);
    PBoundsHandle.addBoundsHandlesTo(c);
    c.setPaint(Color.yellow);

    getCanvas().getLayer().addChild(l);
    getCanvas().getLayer().addChild(c);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:20,代码来源:CameraExample.java

示例2: initialize

import org.piccolo2d.nodes.PPath; //导入依赖的package包/类
public void initialize() {
    final PRoot root = getCanvas().getRoot();
    final PLayer layer = getCanvas().getLayer();

    final PNode n = PPath.createRectangle(0, 0, 100, 80);
    final PNode sticky = PPath.createRectangle(0, 0, 50, 50);
    PBoundsHandle.addBoundsHandlesTo(n);
    sticky.setPaint(Color.YELLOW);
    PBoundsHandle.addBoundsHandlesTo(sticky);

    layer.addChild(n);
    getCanvas().getCamera().addChild(sticky);

    final PCamera otherCamera = new PCamera();
    otherCamera.addLayer(layer);
    root.addChild(otherCamera);

    final PCanvas other = new PCanvas();
    other.setCamera(otherCamera);
    final PFrame result = new PFrame("TwoCanvasExample", false, other);
    result.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    result.setLocation(500, 100);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:24,代码来源:TwoCanvasExample.java

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

示例4: initialize

import org.piccolo2d.nodes.PPath; //导入依赖的package包/类
/** {@inheritDoc} */
public void initialize() {
    final PLayer layer = getCanvas().getLayer();
    // Create the node that we expect to get garbage collected.
    PNode node = PPath.createEllipse(20, 20, 20, 20);
    layer.addChild(node);
    // Create a WeakReference to the node so we can detect if it is gc'd.
    final WeakReference ref = new WeakReference(layer.getChild(0));
    // Create and execute an activity.
    ((PNode) ref.get()).animateToPositionScaleRotation(0, 0, 5.0, 0, 1000);
    // Create a Timer that will start after the activity and repeat.
    new Timer(2000, new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            // Remove our reference to the node.
            layer.removeAllChildren();
            // Force garbage collection.
            System.gc();
            // This should print null if the node was successfully gc'd. (IT never does.)
            System.out.println(ref.get());
            // This prints 0 as expected.
            System.out.println(layer.getRoot().getActivityScheduler().getActivitiesReference().size());
        }
    }).start();
    // This will cause any previous activity references to clear.
    forceCleanupOfPriorActivities(layer);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:27,代码来源:ActivityMemoryLeakBugExample.java

示例5: initialize

import org.piccolo2d.nodes.PPath; //导入依赖的package包/类
public void initialize() {
    final PNode n1 = PPath.createRectangle(0, 0, 100, 80);
    final PNode n2 = PPath.createRectangle(0, 0, 100, 80);

    getCanvas().getLayer().addChild(n1);
    getCanvas().getLayer().addChild(n2);

    n2.scale(2.0);
    n2.rotate(Math.toRadians(90));
    // n2.setScale(2.0);
    // n2.setScale(1.0);
    n2.scale(0.5);
    n2.setPaint(Color.red);

    n1.offset(100, 0);
    n2.offset(100, 0);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:18,代码来源:PositionExample.java

示例6: initialize

import org.piccolo2d.nodes.PPath; //导入依赖的package包/类
public void initialize() {
    final PLayer layer = getCanvas().getLayer();

    final Random random = new Random();
    for (int i = 0; i < 1000; i++) {
        final PPath each = PPath.createRectangle(0, 0, 100, 80);
        each.scale(random.nextFloat() * 2);
        each.offset(random.nextFloat() * 10000, random.nextFloat() * 10000);
        each.setPaint(new Color(random.nextFloat(), random.nextFloat(), random.nextFloat()));
        each.setStroke(new BasicStroke(1 + 10 * random.nextFloat()));
        each.setStrokePaint(new Color(random.nextFloat(), random.nextFloat(), random.nextFloat()));
        layer.addChild(each);
    }
    getCanvas().removeInputEventListener(getCanvas().getPanEventHandler());
    getCanvas().addInputEventListener(new PNavigationEventHandler());
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:17,代码来源:NavigationExample.java

示例7: initialize

import org.piccolo2d.nodes.PPath; //导入依赖的package包/类
public void initialize() {
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {
            final PNode rect = PPath.createRectangle(i * 60, j * 60, 50, 50);
            rect.setPaint(Color.blue);
            getCanvas().getLayer().addChild(rect);
        }
    }

    // Turn off default navigation event handlers
    getCanvas().removeInputEventListener(getCanvas().getPanEventHandler());
    getCanvas().removeInputEventListener(getCanvas().getZoomEventHandler());

    // Create a selection event handler
    final PSelectionEventHandler selectionEventHandler = new PSelectionEventHandler(getCanvas().getLayer(),
            getCanvas().getLayer());
    getCanvas().addInputEventListener(selectionEventHandler);
    getCanvas().getRoot().getDefaultInputManager().setKeyboardFocus(selectionEventHandler);

    PNotificationCenter.defaultCenter().addListener(this, "selectionChanged",
            PSelectionEventHandler.SELECTION_CHANGED_NOTIFICATION, selectionEventHandler);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:23,代码来源:SelectionExample.java

示例8: initialize

import org.piccolo2d.nodes.PPath; //导入依赖的package包/类
public void initialize() {
    final PCanvas canvas = getCanvas();

    final PPath circle = PPath.createEllipse(0, 0, 100, 100);
    circle.setStroke(new BasicStroke(10));
    circle.setPaint(Color.YELLOW);

    final PPath rectangle = PPath.createRectangle(-100, -50, 100, 100);
    rectangle.setStroke(new BasicStroke(15));
    rectangle.setPaint(Color.ORANGE);

    final PNodeCache cache = new PNodeCache();
    cache.addChild(circle);
    cache.addChild(rectangle);

    cache.invalidateCache();

    canvas.getLayer().addChild(cache);
    canvas.removeInputEventListener(canvas.getPanEventHandler());
    canvas.addInputEventListener(new PDragEventHandler());
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:22,代码来源:NodeCacheExample.java

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

示例10: initialize

import org.piccolo2d.nodes.PPath; //导入依赖的package包/类
public void initialize() {
    final PComposite composite = new PComposite();

    final PNode circle = PPath.createEllipse(0, 0, 100, 100);
    final PNode rectangle = PPath.createRectangle(50, 50, 100, 100);
    final PNode text = new PText("Hello world!");

    composite.addChild(circle);
    composite.addChild(rectangle);
    composite.addChild(text);

    rectangle.rotate(Math.toRadians(45));
    rectangle.setPaint(Color.RED);

    text.scale(2.0);
    text.setPaint(Color.GREEN);

    getCanvas().getLayer().addChild(composite);
    getCanvas().removeInputEventListener(getCanvas().getPanEventHandler());
    getCanvas().addInputEventListener(new PDragEventHandler());
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:22,代码来源:CompositeExample.java

示例11: testRenderFull

import org.piccolo2d.nodes.PPath; //导入依赖的package包/类
public void testRenderFull() {
    final POffscreenCanvas canvas = new POffscreenCanvas(100, 200);
    final PPath rect = PPath.createRectangle(0.0f, 0.0f, 200.0f, 300.0f);
    rect.setPaint(new Color(255, 0, 0));
    rect.setStroke(null);
    rect.offset(-100.0d, -100.0d);
    canvas.getCamera().getLayer(0).addChild(rect);
    final BufferedImage image = new BufferedImage(100, 200, BufferedImage.TYPE_INT_ARGB);
    final Graphics2D graphics = image.createGraphics();
    canvas.render(graphics);
    for (int x = 0; x < 100; x++) {
        for (int y = 0; y < 200; y++) {
            // red pixel, RGBA is 255, 0, 0, 255
            assertEquals(-65536, image.getRGB(x, y));
        }
    }
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:18,代码来源:POffscreenCanvasTest.java

示例12: testPick

import org.piccolo2d.nodes.PPath; //导入依赖的package包/类
public void testPick() {
    final PCanvas canvas = new PCanvas();
    final PCamera camera = canvas.getCamera();
    final PLayer layer = canvas.getLayer();

    camera.setBounds(0, 0, 100, 100);

    final PNode a = PPath.createRectangle(0, 0, 100, 100);
    final PNode b = PPath.createRectangle(0, 0, 100, 100);
    final PNode c = PPath.createRectangle(0, 0, 100, 100);

    layer.addChild(a);
    layer.addChild(b);
    layer.addChild(c);

    final PPickPath pickPath = camera.pick(50, 50, 2);

    assertTrue(pickPath.getPickedNode() == c);
    assertTrue(pickPath.nextPickedNode() == b);
    assertTrue(pickPath.nextPickedNode() == a);
    assertTrue(pickPath.nextPickedNode() == camera);
    assertTrue(pickPath.nextPickedNode() == null);
    assertTrue(pickPath.nextPickedNode() == null);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:25,代码来源:PPickPathTest.java

示例13: createNode

import org.piccolo2d.nodes.PPath; //导入依赖的package包/类
/**
 * Creates a {@link PPath} object as a rectangle that has rounded corners.
 *
 * @param text
 *            the {@link PText} object
 * @return a {@link PPath} object
 */
public static PPath createNode(PText text) {
	return PPath.createRoundRectangle(-5
			- 0.5F
					* (float) text.getWidth(), // x
			-5
					- 0.5F
							* (float) text.getHeight(), // y
			(float) text.getWidth()
					+ mOffsetWidth, // width + offset
			(float) text.getHeight()
					+ mOffsetHeight, // height + offset
			mArcWidth, // arcWidth
			mArcHeight // arcHeight
	);
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:23,代码来源:RectanglesWithRoundedCornersPiccolo2dNodeRenderer.java

示例14: createNode

import org.piccolo2d.nodes.PPath; //导入依赖的package包/类
@Override
public PPath createNode(Identifier identifier, PText text) {
	IdentifierWrapper wrapper = IdentifierHelper.identifier(identifier);
	String typeName = wrapper.getTypeName();
	switch (typeName) {
		case IfmapStrings.IDENTITY_EL_NAME:
			if (ExtendedIdentifierHelper.isExtendedIdentifier(identifier)) {
				String extendedIdentifierTypeName =
						ExtendedIdentifierHelper.getExtendedIdentifierInnerTypeName(identifier);
				if (extendedIdentifierTypeName.equals("service")) {
					return EllipsePiccolo2dNodeRenderer.createNode(text);
				}
			}
		case IfmapStrings.ACCESS_REQUEST_EL_NAME:
		case IfmapStrings.DEVICE_EL_NAME:
		case IfmapStrings.IP_ADDRESS_EL_NAME:
		case IfmapStrings.MAC_ADDRESS_EL_NAME:
		default:
			return RectanglesWithRoundedCornersPiccolo2dNodeRenderer.createNode(text);
	}
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:22,代码来源:ExamplePiccolo2dNodeRenderer.java

示例15: createNode

import org.piccolo2d.nodes.PPath; //导入依赖的package包/类
/**
 * Creates a new {@link PPath} object as a ellipse.
 *
 * @param text
 *            the {@link PText} object
 * @return a {@link PPath} object
 */
public static PPath createNode(PText text) {
	PBounds bounds = text.getFullBoundsReference();
	float width = (float) (bounds.getWidth()
			+ mGlowWidth);
	float height = (float) (bounds.getHeight()
			+ mGlowHeight);

	PPath result = PPath.createEllipse(-0.5F
			* width, // x
			-0.5F
					* height, // y
			width, // width
			height // height
	);

	return result;
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:25,代码来源:EllipsePiccolo2dNodeRenderer.java


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