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


Java PRoot类代码示例

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


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

示例1: initialize

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

import org.piccolo2d.PRoot; //导入依赖的package包/类
public void initialize() {
    final PLayer layer = getCanvas().getLayer();
    final PRoot root = getCanvas().getRoot();
    final Random r = new Random();
    for (int i = 0; i < 1000; i++) {
        final PNode n = PPath.createRectangle(0, 0, 100, 80);
        n.translate(10000 * r.nextFloat(), 10000 * r.nextFloat());
        n.setPaint(new Color(r.nextFloat(), r.nextFloat(), r.nextFloat()));
        layer.addChild(n);
    }
    getCanvas().getCamera().animateViewToCenterBounds(layer.getGlobalFullBounds(), true, 0);
    final PActivity a = new PActivity(-1, 20) {
        public void activityStep(final long currentTime) {
            super.activityStep(currentTime);
            rotateNodes();
        }
    };
    root.addActivity(a);

    final PPath p = new PPath.Float();
    p.moveTo(0, 0);
    p.lineTo(0, 1000);
    final PFixedWidthStroke stroke = new PFixedWidthStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10,
            new float[] { 5, 2 }, 0);
    p.setStroke(stroke);
    layer.addChild(p);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:28,代码来源:DynamicExample.java

示例3: initialize

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

    final PActivity updateHandles = new PActivity(-1, 0) {
        protected void activityStep(final long elapsedTime) {
            super.activityStep(elapsedTime);

            final PRoot root = getActivityScheduler().getRoot();

            if (root.getPaintInvalid() || root.getChildPaintInvalid()) {
                final Iterator i = getCanvas().getCamera().getChildrenIterator();
                while (i.hasNext()) {
                    final PNode each = (PNode) i.next();
                    if (each instanceof PHandle) {
                        final PHandle handle = (PHandle) each;
                        handle.relocateHandle();
                    }
                }
            }
        }
    };

    final PPath rect = PPath.createRectangle(0, 0, 100, 100);
    rect.setPaint(Color.RED);
    c.getLayer().addChild(rect);

    c.getCamera().addChild(new PBoundsHandle(PBoundsLocator.createNorthEastLocator(rect)));
    c.getCamera().addChild(new PBoundsHandle(PBoundsLocator.createNorthWestLocator(rect)));
    c.getCamera().addChild(new PBoundsHandle(PBoundsLocator.createSouthEastLocator(rect)));
    c.getCamera().addChild(new PBoundsHandle(PBoundsLocator.createSouthWestLocator(rect)));

    c.getRoot().getActivityScheduler().addActivity(updateHandles, true);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:34,代码来源:StickyHandleLayerExample.java

示例4: createBasicSceneGraph

import org.piccolo2d.PRoot; //导入依赖的package包/类
/**
 * Builds the basic scene graph associated with this canvas. Developers may
 * override this method to install their own layers, and cameras.
 * 
 * @return PCamera viewing the freshly created scene
 */
public PCamera createBasicSceneGraph() {
    final PRoot r = new PSWTRoot(this);
    final PLayer l = new PLayer();
    final PCamera c = new PCamera();

    r.addChild(c);
    r.addChild(l);
    c.addLayer(l);

    return c;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:18,代码来源:PSWTCanvas.java

示例5: animateStaticViewToTransformFast

import org.piccolo2d.PRoot; //导入依赖的package包/类
/**
 * This copies the behavior of the standard animateViewToTransform but
 * clears the cache when it is done.
 * 
 * @param dest the resulting transform that the view should be
 *            applying when the animation is complete
 * @param duration length in milliseconds that the animation should last
 * @return the scheduled PTransformActivity, null if duration was 0
 */
protected PTransformActivity animateStaticViewToTransformFast(final AffineTransform dest, final long duration) {
    if (duration == 0) {
        setViewTransform(dest);
        return null;
    }

    final PTransformActivity.Target t = new PTransformActivity.Target() {
        public void setTransform(final AffineTransform aTransform) {
            PCacheCamera.this.setViewTransform(aTransform);
        }

        public void getSourceMatrix(final double[] aSource) {
            getViewTransformReference().getMatrix(aSource);
        }
    };

    final PTransformActivity ta = new PTransformActivity(duration, PUtil.DEFAULT_ACTIVITY_STEP_RATE, t, dest) {
        protected void activityFinished() {
            clearViewCache();
            repaint();
            super.activityFinished();
        }
    };

    final PRoot r = getRoot();
    if (r != null) {
        r.getActivityScheduler().addActivity(ta);
    }

    return ta;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:41,代码来源:PCacheCamera.java

示例6: createDefaultCamera

import org.piccolo2d.PRoot; //导入依赖的package包/类
/**
 * Creates a default scene with 1 root, 1 layer, and 1 PCacheCamera.
 * 
 * @return constructed scene with PCacheCamera
 */
protected PCamera createDefaultCamera() {
    final PRoot r = new PRoot();
    final PLayer l = new PLayer();
    final PCamera c = new PCacheCamera();

    r.addChild(c);
    r.addChild(l);
    c.addLayer(l);

    return c;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:17,代码来源:PCacheCanvas.java

示例7: createBasicScenegraph

import org.piccolo2d.PRoot; //导入依赖的package包/类
/**
 * Creates the simplest possible scene graph. 1 Camera, 1 Layer, 1 Root
 * 
 * @return a basic scene with 1 camera, layer and root
 */
public static PCamera createBasicScenegraph() {
    final PRoot root = new PRoot();
    final PLayer layer = new PLayer();
    final PCamera camera = new PCamera();

    root.addChild(camera);
    root.addChild(layer);
    camera.addLayer(layer);

    return camera;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:17,代码来源:PUtil.java

示例8: testAddInputSourceFirePropertyChangeEvent

import org.piccolo2d.PRoot; //导入依赖的package包/类
public void testAddInputSourceFirePropertyChangeEvent() {
    root.addPropertyChangeListener(PRoot.PROPERTY_INPUT_SOURCES, mockListener);

    final PRoot.InputSource newSource = new PRoot.InputSource() {
        public void processInput() {

        }
    };
    root.addInputSource(newSource);

    assertEquals(1, mockListener.getPropertyChangeCount());
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:13,代码来源:PRootTest.java

示例9: testRemoveInputSourceDoesNothingIfStranger

import org.piccolo2d.PRoot; //导入依赖的package包/类
public void testRemoveInputSourceDoesNothingIfStranger() {
    final PRoot.InputSource strangeSource = new PRoot.InputSource() {
        public void processInput() {

        }
    };

    root.removeInputSource(strangeSource);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:10,代码来源:PRootTest.java

示例10: setUp

import org.piccolo2d.PRoot; //导入依赖的package包/类
public void setUp() {
    root = new PRoot();
    mockListener = new MockPropertyChangeListener();
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:5,代码来源:PRootTest.java

示例11: getRoot

import org.piccolo2d.PRoot; //导入依赖的package包/类
/**
 * Return root for this canvas.
 * 
 * @return root of the scene this canvas is viewing through its camera
 */
public PRoot getRoot() {
    return camera.getRoot();
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:9,代码来源:PSWTCanvas.java

示例12: PActivityScheduler

import org.piccolo2d.PRoot; //导入依赖的package包/类
/**
 * Constructs an instance of PActivityScheduler. All activities it will
 * schedule will take place on children of the rootNode provided.
 * 
 * @param rootNode root node of all activities to be performed. All nodes
 *            being animated should have this node as an ancestor.
 */
public PActivityScheduler(final PRoot rootNode) {        
    root = rootNode;
    activities = new ArrayList();
    processingActivities = new ArrayList();
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:13,代码来源:PActivityScheduler.java

示例13: getRoot

import org.piccolo2d.PRoot; //导入依赖的package包/类
/**
 * Returns the node from which all activities will be attached.
 * 
 * @return this scheduler's associated root node
 */
public PRoot getRoot() {
    return root;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:9,代码来源:PActivityScheduler.java


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