當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。