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


Java PPath.createEllipse方法代码示例

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


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

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

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

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

示例6: composeOtherNodes

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

    // create parts for the face.
    final PNode eye1 = PPath.createEllipse(0, 0, 20, 20);
    eye1.setPaint(Color.YELLOW);
    final PNode eye2 = (PNode) eye1.clone();
    final PNode mouth = PPath.createRectangle(0, 0, 40, 20);
    mouth.setPaint(Color.BLACK);

    // add the face parts
    myCompositeFace.addChild(eye1);
    myCompositeFace.addChild(eye2);
    myCompositeFace.addChild(mouth);

    // don't want anyone grabbing out our eye's.
    myCompositeFace.setChildrenPickable(false);

    // position the face parts.
    eye2.translate(25, 0);
    mouth.translate(0, 30);

    // set the face bounds so that it neatly contains the face parts.
    final PBounds b = myCompositeFace.getUnionOfChildrenBounds(null);
    myCompositeFace.setBounds(b.inset(-5, -5));

    // opps it to small, so scale it up.
    myCompositeFace.scale(1.5);

    getCanvas().getLayer().addChild(myCompositeFace);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:32,代码来源:NodeExample.java

示例7: addGlow

import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
private void addGlow(PComposite pNode, Color pHighlight) {
	Point2D vPosition = pNode.getOffset();
	PBounds vBound = pNode.getFullBoundsReference();
	float vShadowWidth = (float) (1.1
			* vBound.getWidth()
			+ mGlowWidth);
	float vShadowHeight = (float) (vBound.getHeight()
			+ mGlowHeight);
	PPath vShadow = PPath.createEllipse(-0.5F
			* vShadowWidth, // x
			-0.5F
					* vShadowHeight, // y
			vShadowWidth, // width
			vShadowHeight // height
	);
	vShadow.setOffset((float) (vPosition.getX()), // x
			(float) (vPosition.getY()) // y
	);
	vShadow.setStroke(null);
	Color opaqueHighlight = new Color(pHighlight.getRed(),
			pHighlight.getGreen(), pHighlight.getBlue(), 255);
	Color transparentHighlight = new Color(pHighlight.getRed(),
			pHighlight.getGreen(), pHighlight.getBlue(), 0);
	vShadow.setPaint(ColorHelper.createGradientColor(new Piccolo2DGraphicWrapper(vShadow, null), opaqueHighlight,
			transparentHighlight));
	vShadow.setTransparency(0.0f);
	synchronized (pNode) {
		mLayerGlow.addChild(vShadow);
		pNode.addAttribute("glow", vShadow);
	}
	vShadow.animateToTransparency(1.0f, 500); // TODO Use SettingManager
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:33,代码来源:Piccolo2DPanel.java

示例8: initialize

import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void initialize() {
    super.initialize();

    getCanvas().removeInputEventListener(getCanvas().getPanEventHandler());

    // Create a decorator group that is NOT volatile
    final DecoratorGroup dg = new DecoratorGroup();
    dg.setPaint(Color.magenta);

    // Put some nodes under the group for it to decorate
    final PPath p1 = PPath.createEllipse(25, 25, 75, 75);
    p1.setPaint(Color.red);
    final PPath p2 = PPath.createRectangle(125, 75, 50, 50);
    p2.setPaint(Color.blue);

    // Add everything to the Piccolo hierarchy
    dg.addChild(p1);
    dg.addChild(p2);
    getCanvas().getLayer().addChild(dg);

    // Create a decorator group that IS volatile
    final VolatileDecoratorGroup vdg = new VolatileDecoratorGroup(getCanvas().getCamera());
    vdg.setPaint(Color.cyan);

    // Put some nodes under the group for it to decorate
    final PPath p3 = PPath.createEllipse(275, 175, 50, 50);
    p3.setPaint(Color.blue);
    final PPath p4 = PPath.createRectangle(175, 175, 75, 75);
    p4.setPaint(Color.green);

    // Add everything to the Piccolo hierarchy
    vdg.addChild(p3);
    vdg.addChild(p4);
    getCanvas().getLayer().addChild(vdg);

    // Create a selection handler so we can see that the decorator actually
    // works
    final ArrayList selectableParents = new ArrayList();
    selectableParents.add(dg);
    selectableParents.add(vdg);

    final PSelectionEventHandler ps = new PSelectionEventHandler(getCanvas().getLayer(), selectableParents);
    getCanvas().addInputEventListener(ps);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:45,代码来源:GroupExample.java

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


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