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

Java PNode类代码示例

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

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



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

示例1: initialize

import org.piccolo2d.PNode; //导入依赖的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


示例2: getNeighbors

import org.piccolo2d.PNode; //导入依赖的package包/类
/**
 * Returns all pickable nodes that are 1 hop away from the currently focused
 * node. This includes, parent, children, and siblings.
 * 
 * @return list of nodes that are 1 hop away from the current focusNode
 */
public List getNeighbors() {
    final ArrayList result = new ArrayList();
    if (focusNode == null || focusNode.getParent() == null) {
        return result;
    }

    final PNode focusParent = focusNode.getParent();

    final Iterator i = focusParent.getChildrenIterator();

    while (i.hasNext()) {
        final PNode each = (PNode) i.next();
        if (each != focusNode && each.getPickable()) {
            result.add(each);
        }
    }

    result.add(focusParent);
    result.addAll(focusNode.getChildrenReference());
    return result;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:28,代码来源:PNavigationEventHandler.java


示例3: testPickPackWorksInSimpleCases

import org.piccolo2d.PNode; //导入依赖的package包/类
public void testPickPackWorksInSimpleCases() {
    final PLayer layer = new PLayer();
    camera.addChild(layer);

    final PNode node1 = new PNode();
    node1.setBounds(0, 0, 10, 10);
    layer.addChild(node1);

    final PNode node2 = new PNode();
    node2.setBounds(0, 0, 10, 10);
    node2.setOffset(10, 10);
    layer.addChild(node2);

    final PPickPath path1 = camera.pick(5, 5, 1);
    assertEquals(node1, path1.getPickedNode());

    final PPickPath path2 = camera.pick(15, 15, 1);
    assertEquals(node2, path2.getPickedNode());
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:20,代码来源:PCameraTest.java


示例4: initialize

import org.piccolo2d.PNode; //导入依赖的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


示例5: initialize

import org.piccolo2d.PNode; //导入依赖的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


示例6: initialize

import org.piccolo2d.PNode; //导入依赖的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


示例7: dragStandardSelection

import org.piccolo2d.PNode; //导入依赖的package包/类
/**
 * Drag selected nodes.
 * 
 * @param e event responsible for the drag
 */
protected void dragStandardSelection(final PInputEvent e) {
    // There was a press node, so drag selection
    final PDimension d = e.getCanvasDelta();
    e.getTopCamera().localToView(d);

    final PDimension gDist = new PDimension();
    final Iterator selectionEn = getSelection().iterator();
    while (selectionEn.hasNext()) {
        final PNode node = (PNode) selectionEn.next();

        gDist.setSize(d);
        node.getParent().globalToLocal(gDist);
        node.offset(gDist.getWidth(), gDist.getHeight());
    }
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:21,代码来源:PSelectionEventHandler.java


示例8: processEvent

import org.piccolo2d.PNode; //导入依赖的package包/类
/**
 * Process Events - Give each node in the pick path, starting at the bottom
 * most one, a chance to handle the event.
 * 
 * @param event event to be processed
 * @param eventType the type of event being processed
 */
public void processEvent(final PInputEvent event, final int eventType) {
    event.setPath(this);

    for (int i = nodeStack.size() - 1; i >= 0; i--) {
        final PNode each = (PNode) nodeStack.get(i);

        final EventListenerList list = each.getListenerList();

        if (list != null) {
            final Object[] listeners = list.getListeners(PInputEventListener.class);

            for (int j = 0; j < listeners.length; j++) {
                final PInputEventListener listener = (PInputEventListener) listeners[j];
                listener.processEvent(event, eventType);
                if (event.isHandled()) {
                    return;
                }
            }
        }
    }
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:29,代码来源:PPickPath.java


示例9: testToString

import org.piccolo2d.PNode; //导入依赖的package包/类
public void testToString() {
    final PNode a = new PNode();
    final PNode b = new PNode();
    final PNode c = new PNode();
    final PNode d = new PNode();
    final PNode e = new PNode();
    final PNode f = new PNode();

    a.translate(100, 100);
    a.getFullBoundsReference();

    a.addChild(b);
    b.addChild(c);
    c.addChild(d);
    d.addChild(e);
    e.addChild(f);

    assertNotNull(a.toString());
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:20,代码来源:PNodeTest.java


示例10: getComponentForNode

import org.piccolo2d.PNode; //导入依赖的package包/类
/**
 * Finds the component that is serving as the proxy for a specific node.
 * Returns null if not found.
 */
private ProxyComponent getComponentForNode(final PNode node) {
    ProxyComponent nodeComponent = null;
    final Component[] components = container.getComponents();
    if (components != null) {
        for (int i = 0; i < components.length && nodeComponent == null; i++) {
            if (components[i] instanceof ProxyComponent) {
                final ProxyComponent n = (ProxyComponent) components[i];
                if (n.getNode() == node) {
                    nodeComponent = n;
                }
            }
        }
    }
    return nodeComponent;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:20,代码来源:SwingLayoutNode.java


示例11: testAddChildWithIndexMovesChildAround

import org.piccolo2d.PNode; //导入依赖的package包/类
public void testAddChildWithIndexMovesChildAround() {
    final PNode parent = new PNode();

    parent.addChild(new PNode());
    parent.addChild(new PNode());
    parent.addChild(node);

    parent.addChild(0, node);
    assertEquals(node, parent.getChild(0));

    parent.addChild(1, node);
    assertEquals(node, parent.getChild(1));

    parent.addChild(2, node);
    assertEquals(node, parent.getChild(2));
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:17,代码来源:PNodeTest.java


示例12: mousePressed

import org.piccolo2d.PNode; //导入依赖的package包/类
/**
 * A callback that is invoked any time the mouse is pressed on the canvas.
 * If the press occurs directly on the canvas, it create a new PStyledText
 * instance and puts it in editing mode. If the click is on a node, it marks
 * changes it to editing mode.
 * 
 * @param event mouse click event that can be queried
 */
public void mousePressed(final PInputEvent event) {
    final PNode pickedNode = event.getPickedNode();

    stopEditing(event);

    if (event.getButton() != MouseEvent.BUTTON1) {
        return;
    }

    if (pickedNode instanceof PStyledText) {
        startEditing(event, (PStyledText) pickedNode);
    }
    else if (pickedNode instanceof PCamera) {
        final PStyledText newText = createText();
        final Insets pInsets = newText.getInsets();
        newText.translate(event.getPosition().getX() - pInsets.left, event.getPosition().getY() - pInsets.top);
        startEditing(event, newText);
    }
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:28,代码来源:PStyledTextEventHandler.java


示例13: testKeyboardDeleteFiresSelectionChange

import org.piccolo2d.PNode; //导入依赖的package包/类
/**
 * {@link http://code.google.com/p/piccolo2d/issues/detail?id=177}
 */
public void testKeyboardDeleteFiresSelectionChange()
{
    PCanvas canvas = new PCanvas();
    PLayer layer = canvas.getLayer();
    PNode node = new PNode();
    layer.addChild(node);

    PSelectionEventHandler selectionHandler = new PSelectionEventHandler(layer, layer);
    selectionHandler.setDeleteKeyActive(true);
    selectionHandler.select(node);
    assertTrue(selectionHandler.getSelectionReference().contains(node));

    PNotificationCenter notificationCenter = PNotificationCenter.defaultCenter();
    notificationCenter.addListener(this, "selectionChanged", PSelectionEventHandler.SELECTION_CHANGED_NOTIFICATION, null);

    KeyEvent keyEvent = new KeyEvent(canvas, -1, System.currentTimeMillis(), 0, KeyEvent.VK_DELETE);
    PInputEvent event = new PInputEvent(null, keyEvent);
    selectionHandler.keyPressed(event);
    assertTrue(selectionHandler.getSelectionReference().isEmpty());
    assertTrue(selectionChanged);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:25,代码来源:PSelectionEventHandlerTest.java


示例14: testSelectionChange

import org.piccolo2d.PNode; //导入依赖的package包/类
public void testSelectionChange()
{
    PCanvas canvas = new PCanvas();
    PLayer layer = canvas.getLayer();
    PNode node = new PNode();
    layer.addChild(node);

    PSelectionEventHandler selectionHandler = new PSelectionEventHandler(layer, layer);
    assertTrue(selectionHandler.getSelectionReference().isEmpty());

    PNotificationCenter notificationCenter = PNotificationCenter.defaultCenter();
    notificationCenter.addListener(this, "selectionChanged", PSelectionEventHandler.SELECTION_CHANGED_NOTIFICATION, null);

    selectionHandler.select(node);
    assertTrue(selectionHandler.getSelectionReference().contains(node));
    assertTrue(selectionChanged);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:18,代码来源:PSelectionEventHandlerTest.java


示例15: memorySizeOfNodes

import org.piccolo2d.PNode; //导入依赖的package包/类
public void memorySizeOfNodes() {
    final PNode[] nodes = new PNode[NUMBER_NODES];
    Runtime.getRuntime().gc();
    final long startTotalMemory = Runtime.getRuntime().totalMemory();
    final long startFree = Runtime.getRuntime().freeMemory();
    long endFree;
    long endTotal;

    for (int i = 0; i < NUMBER_NODES; i++) {
        nodes[i] = new PNode();
    }

    Runtime.getRuntime().gc();
    endFree = Runtime.getRuntime().freeMemory();
    endTotal = Runtime.getRuntime().totalMemory();

    log.addEntry("Approximate k used by " + NUMBER_NODES + " nodes",
            (endTotal - startTotalMemory + startFree - endFree) / 1024);
    nodes[0].getPaint();
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:21,代码来源:PerformanceTests.java


示例16: testCloneClonesChildrenAswell

import org.piccolo2d.PNode; //导入依赖的package包/类
public void testCloneClonesChildrenAswell() {
    final PNode child = new PNode();
    node.addChild(child);

    final PNode clonedNode = (PNode) node.clone();

    assertEquals(clonedNode.getChildrenCount(), 1);
    assertNotSame(child, clonedNode.getChild(0));
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:10,代码来源:PNodeTest.java


示例17: createCustomNode

import org.piccolo2d.PNode; //导入依赖的package包/类
public void createCustomNode() {
    final PNode n = new PNode() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        public void paint(final PPaintContext aPaintContext) {
            final double bx = getX();
            final double by = getY();
            final double rightBorder = bx + getWidth();
            final double bottomBorder = by + getHeight();

            final Line2D line = new Line2D.Double();
            final Graphics2D g2 = aPaintContext.getGraphics();

            g2.setStroke(new BasicStroke(0));
            g2.setPaint(getPaint());

            // draw vertical lines
            for (double x = bx; x < rightBorder; x += 5) {
                line.setLine(x, by, x, bottomBorder);
                g2.draw(line);
            }

            for (double y = by; y < bottomBorder; y += 5) {
                line.setLine(bx, y, rightBorder, y);
                g2.draw(line);
            }
        }
    };
    n.setBounds(0, 0, 100, 80);
    n.setPaint(Color.black);
    getCanvas().getLayer().addChild(n);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:36,代码来源:NodeExample.java


示例18: layoutChildren

import org.piccolo2d.PNode; //导入依赖的package包/类
public void layoutChildren() {
    double[] colWidths = calculateColumnWidths();

    double currentY = 0;
    for (int i = 0; i < getChildrenCount(); i++) {
        PNode child = getChild(i);
        child.setOffset(colWidths[i % columns] * 1.25, currentY * 1.25);
        if (i % columns == 0 && i > 0) {
            currentY = getFullBounds().getHeight();
        }
    }
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:13,代码来源:PSwingExample3.java


示例19: calculateColumnWidths

import org.piccolo2d.PNode; //导入依赖的package包/类
private double[] calculateColumnWidths() {
    double[] colWidths = new double[columns];
    for (int i = 0; i < getChildrenCount(); i++) {
        PNode child = getChild(i);
        colWidths[i % columns] = Math.max(colWidths[i % columns], child.getFullBounds().getWidth()
                * child.getScale());
    }
    return colWidths;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:10,代码来源:PSwingExample3.java


示例20: testLowerChildToBottom

import org.piccolo2d.PNode; //导入依赖的package包/类
public void testLowerChildToBottom() {
    final PNode child0 = new PNode();
    final PNode child1 = new PNode();
    final PNode child2 = new PNode();
    node.addChild(child0);
    node.addChild(child1);
    node.addChild(child2);
    node.lowerToBottom(child2);
    assertEquals(0, node.indexOfChild(child2));
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:11,代码来源:PNodeTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java IOperationHistoryListener类代码示例发布时间:2022-05-22
下一篇:
Java StreamPlan类代码示例发布时间: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