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


Java PNode.setBounds方法代码示例

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


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

示例1: main

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public static void main( String[] args ) {
    HTMLNode testNode = new HTMLNode( " " );
    testNode.setOffset( 100, 100 );
    System.out.println( "Bounds for space are: " + testNode.getFullBoundsReference() );
    System.out.println( "Offset for space string: " + testNode.getOffset() );
    HTMLNode testNode2 = new HTMLNode( "<html>Hi</html>" );
    System.out.println( "Bounds for real string are: " + testNode2.getFullBoundsReference() );

    PNode testNode3 = new PNode();
    testNode3.setBounds( 10, 10, 10, 0 );
    System.out.println( "Bounds for plain PNode = " + testNode3.getFullBoundsReference() );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:MultiNucleusDecayLinearTimeChart.java

示例2: composeOtherNodes

import edu.umd.cs.piccolo.PNode; //导入方法依赖的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:mleoking,项目名称:PhET,代码行数:32,代码来源:NodeExample.java

示例3: createCustomNode

import edu.umd.cs.piccolo.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:mleoking,项目名称:PhET,代码行数:36,代码来源:NodeExample.java

示例4: setUp

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public void setUp() throws Exception {
    node = new PNode();
    locator = PBoundsLocator.createEastLocator(node);
    handle = new PSWTHandle(locator);
    node.setBounds(0, 0, 100, 100);
    node.addChild(handle);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:PSWTHandleTest.java

示例5: testChangingParentDoesNotChangeLocatorNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public void testChangingParentDoesNotChangeLocatorNode() {
    handle.relocateHandle();
    PNode newParent = new PNode();
    newParent.setBounds(50, 50, 100, 100);

    final double originalX = handle.getX();
    handle.setParent(newParent);

    final double newX = handle.getX();

    assertEquals(newX, originalX, Double.MIN_VALUE);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:PSWTHandleTest.java

示例6: testResizingParentCausesRelocateHandle

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public void testResizingParentCausesRelocateHandle() {
    final int[] relocateCounts = new int[1];
    PHandle handle = new PHandle(new OriginLocator()) {
        public void relocateHandle() {
            super.relocateHandle();
            relocateCounts[0]++;
        }
    };        
    PNode parent = new PNode();
    parent.addChild(handle);
    relocateCounts[0] = 0;
    parent.setBounds(0, 0, 100, 100);
    assertEquals(1, relocateCounts[0]);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:15,代码来源:PHandleTest.java

示例7: nodeDemo

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public void nodeDemo() {
    final PLayer layer = getCanvas().getLayer();
    final PNode aNode = PPath.createRectangle(0, 0, 100, 80);

    // A node needs to be a descendent of the root to be displayed on the
    // screen.
    layer.addChild(aNode);

    // The default color for a node is blue, but you can change that with
    // the setPaint method.
    aNode.setPaint(Color.red);

    // A node can have children nodes added to it.
    aNode.addChild(PPath.createRectangle(0, 0, 100, 80));

    // The base bounds of a node is easy to change. Note that changing the
    // base
    // bounds of a node will not change it's children.
    aNode.setBounds(-10, -10, 200, 110);

    // Each node has a transform that can be used to transform the node, and
    // all its children on the screen.
    aNode.translate(100, 100);
    aNode.scale(1.5);
    aNode.rotate(45);

    // The transparency of any node can be set, this transparency will be
    // applied to any of the nodes children as well.
    aNode.setTransparency(0.75f);

    // Its easy to copy nodes.
    final PNode aCopy = (PNode) aNode.clone();

    // Make is so that the copies children are not pickable. For this
    // example
    // that means you will not be able to grab the child and remove it from
    // its parent.
    aNode.setChildrenPickable(false);

    // Change the look of the copy
    aNode.setPaint(Color.GREEN);
    aNode.setTransparency(1.0f);

    // Let's add the copy to the root, and translate it so that it does not
    // cover the original node.
    layer.addChild(aCopy);
    aCopy.setOffset(0, 0);
    aCopy.rotate(-45);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:50,代码来源:NodeExample.java

示例8: nodeDemo

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public void nodeDemo() {
    final PLayer layer = getCanvas().getLayer();
    final PNode aNode = PPath.createRectangle(0, 0, 100, 80);

    // A node needs to be a descendent of the root to be displayed on the
    // screen.
    layer.addChild(aNode);

    // The default color for a node is blue, but you can change that with
    // the setPaint method.
    aNode.setPaint(Color.red);

    // A node can have children nodes added to it.
    aNode.addChild(PPath.createRectangle(0, 0, 100, 80));

    // The base bounds of a node is easy to change. Note that changing the
    // base bounds of a node will not change it's children.
    aNode.setBounds(-10, -10, 200, 110);

    // Each node has a transform that can be used to transform the node, and
    // all its children on the screen.
    aNode.translate(100, 100);
    aNode.scale(1.5);
    aNode.rotate(45);

    // The transparency of any node can be set, this transparency will be
    // applied to any of the nodes children as well.
    aNode.setTransparency(0.75f);

    // Its easy to copy nodes.
    final PNode aCopy = (PNode) aNode.clone();

    // Make is so that the copies children are not pickable. For this
    // example that means you will not be able to grab the child and remove
    // it from its parent.
    aNode.setChildrenPickable(false);

    // Change the look of the copy
    aNode.setPaint(Color.GREEN);
    aNode.setTransparency(1.0f);

    // Let's add the copy to the root, and translate it so that it does not
    // cover the original node.
    layer.addChild(aCopy);
    aCopy.setOffset(0, 0);
    aCopy.rotate(-45);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:48,代码来源:BirdsEyeViewExample.java

示例9: setUp

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public void setUp() {
    node = new PNode();
    node.setBounds(0, 0, 100, 100);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:5,代码来源:PSWTBoundsHandleTest.java

示例10: dragHandle

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Is invoked when the handle is being dragged.
 * 
 * @param aLocalDimension dimension representing the magnitude of the handle
 *            drag
 * @param aEvent event responsible for the call
 */
public void dragHandle(final PDimension aLocalDimension, final PInputEvent aEvent) {
    final PBoundsLocator l = (PBoundsLocator) getLocator();

    final PNode n = l.getNode();
    final PBounds b = n.getBounds();

    final PNode parent = getParent();
    if (parent != n && parent instanceof PCamera) {
        ((PCamera) parent).localToView(aLocalDimension);
    }

    localToGlobal(aLocalDimension);
    n.globalToLocal(aLocalDimension);

    final double dx = aLocalDimension.getWidth();
    final double dy = aLocalDimension.getHeight();

    switch (l.getSide()) {
        case SwingConstants.NORTH:
            b.setRect(b.x, b.y + dy, b.width, b.height - dy);
            break;

        case SwingConstants.SOUTH:
            b.setRect(b.x, b.y, b.width, b.height + dy);
            break;

        case SwingConstants.EAST:
            b.setRect(b.x, b.y, b.width + dx, b.height);
            break;

        case SwingConstants.WEST:
            b.setRect(b.x + dx, b.y, b.width - dx, b.height);
            break;

        case SwingConstants.NORTH_WEST:
            b.setRect(b.x + dx, b.y + dy, b.width - dx, b.height - dy);
            break;

        case SwingConstants.SOUTH_WEST:
            b.setRect(b.x + dx, b.y, b.width - dx, b.height + dy);
            break;

        case SwingConstants.NORTH_EAST:
            b.setRect(b.x, b.y + dy, b.width + dx, b.height - dy);
            break;

        case SwingConstants.SOUTH_EAST:
            b.setRect(b.x, b.y, b.width + dx, b.height + dy);
            break;
        default:
            throw new RuntimeException("Invalid side returned from PBoundsLocator");
    }

    boolean flipX = false;
    boolean flipY = false;

    if (b.width < 0) {
        flipX = true;
        b.width = -b.width;
        b.x -= b.width;
    }

    if (b.height < 0) {
        flipY = true;
        b.height = -b.height;
        b.y -= b.height;
    }

    if (flipX || flipY) {
        flipSiblingBoundsHandles(flipX, flipY);
    }

    n.setBounds(b);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:82,代码来源:PBoundsHandle.java


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