本文整理汇总了Java中org.piccolo2d.PCamera.addLayer方法的典型用法代码示例。如果您正苦于以下问题:Java PCamera.addLayer方法的具体用法?Java PCamera.addLayer怎么用?Java PCamera.addLayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.piccolo2d.PCamera
的用法示例。
在下文中一共展示了PCamera.addLayer方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.piccolo2d.PCamera; //导入方法依赖的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);
}
示例2: initialize
import org.piccolo2d.PCamera; //导入方法依赖的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);
}
示例3: createBasicSceneGraph
import org.piccolo2d.PCamera; //导入方法依赖的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;
}
示例4: createDefaultCamera
import org.piccolo2d.PCamera; //导入方法依赖的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;
}
示例5: createBasicScenegraph
import org.piccolo2d.PCamera; //导入方法依赖的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;
}
示例6: testClone
import org.piccolo2d.PCamera; //导入方法依赖的package包/类
public void testClone() throws CloneNotSupportedException {
final PLayer layer1 = new PLayer();
final PLayer layer2 = new PLayer();
final PCamera camera1 = new PCamera();
camera1.addLayer(layer1);
camera1.addLayer(layer2);
final PCamera cameraCopy = (PCamera) camera1.clone();
//TODO: assertEquals(2, cameraCopy.getLayerCount());
}
示例7: testPaintPaintsAllLayers
import org.piccolo2d.PCamera; //导入方法依赖的package包/类
public void testPaintPaintsAllLayers() {
final PCanvas canvas = new PCanvas();
final PCamera camera = canvas.getCamera();
final BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
final Graphics2D g2 = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(img);
final PLayer layer1 = canvas.getLayer();
final PNode blueSquare = new PNode();
blueSquare.setPaint(Color.BLUE);
blueSquare.setBounds(0, 0, 10, 10);
layer1.addChild(blueSquare);
camera.addLayer(layer1);
final PLayer layer2 = new PLayer();
canvas.getLayer().getRoot().addChild(layer2);
layer2.setOffset(10, 10);
final PNode redSquare = new PNode();
redSquare.setPaint(Color.RED);
redSquare.setBounds(0, 0, 10, 10);
layer2.addChild(redSquare);
camera.addLayer(layer2);
canvas.setBounds(0, 0, 20, 20);
canvas.paint(g2);
assertEquals(Color.BLUE.getRGB(), img.getRGB(5, 5));
assertEquals(Color.RED.getRGB(), img.getRGB(15, 15));
}
示例8: testTooFewLayersCamera
import org.piccolo2d.PCamera; //导入方法依赖的package包/类
public void testTooFewLayersCamera() {
PCamera tooFew = new TooFewLayersCamera();
MockPLayer layer0 = new MockPLayer();
MockPLayer layer1 = new MockPLayer();
tooFew.addLayer(layer0);
tooFew.addLayer(layer1);
assertEquals(layer0, tooFew.getLayer(0));
assertEquals(layer1, tooFew.getLayer(1));
assertEquals(layer0, tooFew.getLayersReference().get(0));
assertEquals(layer1, tooFew.getLayersReference().get(1));
assertEquals(0, tooFew.indexOfLayer(layer0));
assertEquals(0, tooFew.indexOfLayer(layer0));
// pickCameraView
PPickPath pickPath = new PPickPath(tooFew, new PBounds(0, 0, 400, 400));
tooFew.pickCameraView(pickPath);
assertTrue(layer0.fullPickCalled());
assertTrue(layer1.fullPickCalled());
// paintCameraView
BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = image.createGraphics();
PPaintContext paintContext = new PPaintContext(graphics);
tooFew.paintCameraView(paintContext);
assertTrue(layer0.fullPaintCalled());
assertTrue(layer1.fullPaintCalled());
// getUnionOfLayerFullBounds
tooFew.getUnionOfLayerFullBounds();
assertTrue(layer0.fullBoundsReferenceCalled());
assertTrue(layer1.fullBoundsReferenceCalled());
// paintDebugInfo
PDebug.debugBounds = true;
tooFew.paintDebugInfo(paintContext);
assertTrue(layer0.getAllNodesCalled());
assertTrue(layer1.getAllNodesCalled());
PDebug.debugBounds = false;
graphics.dispose();
}
示例9: testTooManyLayersCamera
import org.piccolo2d.PCamera; //导入方法依赖的package包/类
public void testTooManyLayersCamera() {
PCamera tooMany = new TooManyLayersCamera();
MockPLayer layer0 = new MockPLayer();
MockPLayer layer1 = new MockPLayer();
tooMany.addLayer(layer0);
tooMany.addLayer(layer1);
assertEquals(layer0, tooMany.getLayer(0));
assertEquals(layer1, tooMany.getLayer(1));
assertEquals(layer0, tooMany.getLayersReference().get(0));
assertEquals(layer1, tooMany.getLayersReference().get(1));
assertEquals(0, tooMany.indexOfLayer(layer0));
assertEquals(0, tooMany.indexOfLayer(layer0));
// pickCameraView
PPickPath pickPath = new PPickPath(tooMany, new PBounds(0, 0, 400, 400));
tooMany.pickCameraView(pickPath);
assertTrue(layer0.fullPickCalled());
assertTrue(layer1.fullPickCalled());
// paintCameraView
BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = image.createGraphics();
PPaintContext paintContext = new PPaintContext(graphics);
tooMany.paintCameraView(paintContext);
assertTrue(layer0.fullPaintCalled());
assertTrue(layer1.fullPaintCalled());
// getUnionOfLayerFullBounds
tooMany.getUnionOfLayerFullBounds();
assertTrue(layer0.fullBoundsReferenceCalled());
assertTrue(layer1.fullBoundsReferenceCalled());
// paintDebugInfo
PDebug.debugBounds = true;
tooMany.paintDebugInfo(paintContext);
assertTrue(layer0.getAllNodesCalled());
assertTrue(layer1.getAllNodesCalled());
PDebug.debugBounds = false;
graphics.dispose();
}