• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PPath类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: drag

import org.piccolo2d.nodes.PPath; //导入依赖的package包/类
@Override
@SuppressWarnings({"unchecked"})
protected void drag(PInputEvent e) {
	LOGGER.trace("Method drag("
			+ e + ") called.");
	PNode pickedNode = e.getPickedNode();
	if (pickedNode instanceof PComposite) {
		super.drag(e);
		PComposite vNode = (PComposite) pickedNode;

		/* Redraw edges */
		ArrayList<PPath> vEdges = (ArrayList<PPath>) vNode.getAttribute("edges");
		for (PPath vEdge : vEdges) {
			mPanel.updateEdge(vEdge, (Position) vNode.getAttribute("position"));
		}
		/* TODO Redraw the shadow */
		PPath vShadow = (PPath) vNode.getAttribute("glow");
		if (vShadow != null) {
			vShadow.setOffset(vNode.getOffset());
		}
	}
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:23,代码来源:NodeEventHandler.java


示例17: mouseEntered

import org.piccolo2d.nodes.PPath; //导入依赖的package包/类
@Override
public void mouseEntered(PInputEvent e) {
	LOGGER.trace("Method mouseEntered("
			+ e + ") called.");
	super.mouseEntered(e);

	if (!mConnection.isPropablePicked()) {
		PNode pickedNode = e.getPickedNode();
		if (pickedNode instanceof PComposite) {
			PPath vNode = (PPath) pickedNode.getChild(0);
			PText vText = (PText) pickedNode.getChild(1);
			GraphicWrapper wrapper = Piccolo2DGraphicWrapperFactory.create(vNode, vText);
			mConnection.showProperty(wrapper.getData());
			mPanel.mouseEntered(wrapper);
		}
	}
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:18,代码来源:NodeEventHandler.java


示例18: mouseClicked

import org.piccolo2d.nodes.PPath; //导入依赖的package包/类
@Override
public void mouseClicked(PInputEvent e) {
	LOGGER.trace("Method mouseClicked ("
			+ e + ") called.");
	super.mouseClicked(e);

	PNode pickedNode = e.getPickedNode();
	if (e.isLeftMouseButton()) {
		if (pickedNode instanceof PComposite) {
			PPath vNode = (PPath) pickedNode.getChild(0);
			PText vText = (PText) pickedNode.getChild(1);
			GraphicWrapper wrapper = Piccolo2DGraphicWrapperFactory.create(vNode, vText);
			mConnection.pickAndShowProperties(wrapper);
		} else {
			mConnection.clearProperties();
		}
	}
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:19,代码来源:NodeEventHandler.java


示例19: drawEdge

import org.piccolo2d.nodes.PPath; //导入依赖的package包/类
@Override
public void drawEdge(PPath pEdge, Point2D vStart, Point2D vEnd, Metadata metadata, Identifier identifier) {
	super.drawEdge(pEdge, vStart, vEnd, metadata, identifier);

	// only for edges between two metadata
	if (identifier != null) {
		return;
	}

	// only for policy-feature and policy-action metadata
	if ("policy-feature".equals(metadata.getTypeName())) {
		drawPolicyFeatureMetadataReferenceDashedLine(pEdge, vStart, vEnd);
		
	} else if ("policy-action".equals(metadata.getTypeName())) {
		drawPolicyActionMetadataReferenceDashedLine(pEdge, vStart, vEnd);
		
	} else {
		return;
	}
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:21,代码来源:PolicyMetadataReferenceEdgeRenderer.java


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EntryType类代码示例发布时间:2022-05-22
下一篇:
Java PublicSuffixMatcher类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap