本文整理汇总了Java中org.piccolo2d.nodes.PPath.createRectangle方法的典型用法代码示例。如果您正苦于以下问题:Java PPath.createRectangle方法的具体用法?Java PPath.createRectangle怎么用?Java PPath.createRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.piccolo2d.nodes.PPath
的用法示例。
在下文中一共展示了PPath.createRectangle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRenderFull
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void testRenderFull() {
final POffscreenCanvas canvas = new POffscreenCanvas(100, 200);
final PPath rect = PPath.createRectangle(0.0f, 0.0f, 200.0f, 300.0f);
rect.setPaint(new Color(255, 0, 0));
rect.setStroke(null);
rect.offset(-100.0d, -100.0d);
canvas.getCamera().getLayer(0).addChild(rect);
final BufferedImage image = new BufferedImage(100, 200, BufferedImage.TYPE_INT_ARGB);
final Graphics2D graphics = image.createGraphics();
canvas.render(graphics);
for (int x = 0; x < 100; x++) {
for (int y = 0; y < 200; y++) {
// red pixel, RGBA is 255, 0, 0, 255
assertEquals(-65536, image.getRGB(x, y));
}
}
}
示例2: testPick
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void testPick() {
final PCanvas canvas = new PCanvas();
final PCamera camera = canvas.getCamera();
final PLayer layer = canvas.getLayer();
camera.setBounds(0, 0, 100, 100);
final PNode a = PPath.createRectangle(0, 0, 100, 100);
final PNode b = PPath.createRectangle(0, 0, 100, 100);
final PNode c = PPath.createRectangle(0, 0, 100, 100);
layer.addChild(a);
layer.addChild(b);
layer.addChild(c);
final PPickPath pickPath = camera.pick(50, 50, 2);
assertTrue(pickPath.getPickedNode() == c);
assertTrue(pickPath.nextPickedNode() == b);
assertTrue(pickPath.nextPickedNode() == a);
assertTrue(pickPath.nextPickedNode() == camera);
assertTrue(pickPath.nextPickedNode() == null);
assertTrue(pickPath.nextPickedNode() == null);
}
示例3: initialize
import org.piccolo2d.nodes.PPath; //导入方法依赖的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);
}
示例4: initialize
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void initialize() {
final PLayer layer = getCanvas().getLayer();
final Random random = new Random();
for (int i = 0; i < 1000; i++) {
final PPath each = PPath.createRectangle(0, 0, 100, 80);
each.scale(random.nextFloat() * 2);
each.offset(random.nextFloat() * 10000, random.nextFloat() * 10000);
each.setPaint(new Color(random.nextFloat(), random.nextFloat(), random.nextFloat()));
each.setStroke(new BasicStroke(1 + 10 * random.nextFloat()));
each.setStrokePaint(new Color(random.nextFloat(), random.nextFloat(), random.nextFloat()));
layer.addChild(each);
}
getCanvas().removeInputEventListener(getCanvas().getPanEventHandler());
getCanvas().addInputEventListener(new PNavigationEventHandler());
}
示例5: initialize
import org.piccolo2d.nodes.PPath; //导入方法依赖的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());
}
示例6: initialize
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void initialize() {
final PCanvas canvas = getCanvas();
final PPath circle = PPath.createEllipse(0, 0, 100, 100);
circle.setStroke(new BasicStroke(10));
circle.setPaint(Color.YELLOW);
final PPath rectangle = PPath.createRectangle(-100, -50, 100, 100);
rectangle.setStroke(new BasicStroke(15));
rectangle.setPaint(Color.ORANGE);
final PNodeCache cache = new PNodeCache();
cache.addChild(circle);
cache.addChild(rectangle);
cache.invalidateCache();
canvas.getLayer().addChild(cache);
canvas.removeInputEventListener(canvas.getPanEventHandler());
canvas.addInputEventListener(new PDragEventHandler());
}
示例7: createPaths
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void createPaths() {
final PNode[] nodes = new PNode[NUMBER_NODES];
log.startTest();
for (int i = 0; i < NUMBER_NODES; i++) {
nodes[i] = PPath.createRectangle(0, 0, 100, 80);
}
log.endTest("Create " + NUMBER_NODES + " new rect paths");
final Random r = new Random();
for (int i = 0; i < NUMBER_NODES; i++) {
nodes[i].translate(r.nextFloat() * 300, r.nextFloat() * 300);
}
}
示例8: composeOtherNodes
import org.piccolo2d.nodes.PPath; //导入方法依赖的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);
}
示例9: initialize
import org.piccolo2d.nodes.PPath; //导入方法依赖的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);
}
示例10: buildRedRectangleNode
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
private PPath buildRedRectangleNode() {
PPath rectNode = PPath.createRectangle(0.0f, 0.0f, 75.0f, 75.0f);
rectNode.setPaint(Color.RED);
rectNode.setStroke(null);
rectNode.setOffset(25.0d, 325.0d);
return rectNode;
}
示例11: initialize
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void initialize() {
final PLayer layer = getCanvas().getLayer();
final PNode animatedNode = PPath.createRectangle(0, 0, 100, 80);
layer.addChild(animatedNode);
// create animation path
final GeneralPath path = new GeneralPath();
path.moveTo(0, 0);
path.lineTo(300, 300);
path.lineTo(300, 0);
path.append(new Arc2D.Float(0, 0, 300, 300, 90, -90, Arc2D.OPEN), true);
path.closePath();
// create node to display animation path
final PPath ppath = new PPath.Float(path);
layer.addChild(ppath);
// create activity to run animation.
final PPositionPathActivity positionPathActivity = new PPositionPathActivity(5000, 0,
new PPositionPathActivity.Target() {
public void setPosition(final double x, final double y) {
animatedNode.setOffset(x, y);
}
});
// positionPathActivity.setSlowInSlowOut(false);
positionPathActivity.setPositions(path);
positionPathActivity.setLoopCount(Integer.MAX_VALUE);
// add the activity.
animatedNode.addActivity(positionPathActivity);
}
示例12: initialize
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void initialize() {
final PText label = new PText("Stroke Example");
label.setFont(label.getFont().deriveFont(24.0f));
label.offset(20.0d, 20.0d);
final PPath rect = PPath.createRectangle(50.0f, 50.0f, 300.0f, 300.0f);
rect.setStroke(new BasicStroke(4.0f));
rect.setStrokePaint(new Color(80, 80, 80));
final PText fixedWidthLabel = new PText("PFixedWidthStrokes");
fixedWidthLabel.setTextPaint(new Color(80, 0, 0));
fixedWidthLabel.offset(100.0d, 80.0d);
final PPath fixedWidthRect0 = PPath.createRectangle(100.0f, 100.0f, 200.0f, 50.0f);
fixedWidthRect0.setStroke(new PFixedWidthStroke(2.0f));
fixedWidthRect0.setStrokePaint(new Color(60, 60, 60));
final PPath fixedWidthRect1 = PPath.createRectangle(100.0f, 175.0f, 200.0f, 50.0f);
fixedWidthRect1.setStroke(new PFixedWidthStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 10.0f));
// fixedWidthRect1.setStroke(new PFixedWidthStroke(1.5f,
// PFixedWidthStroke.CAP_ROUND, PFixedWidthStroke.JOIN_MITER, 10.0f));
fixedWidthRect1.setStrokePaint(new Color(40, 40, 40));
final PPath fixedWidthRect2 = PPath.createRectangle(100.0f, 250.0f, 200.0f, 50.0f);
fixedWidthRect2.setStroke(new PFixedWidthStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 10.0f,
new float[] { 2.0f, 3.0f, 4.0f }, 1.0f));
// fixedWidthRect2.setStroke(new PFixedWidthStroke(1.0f,
// PFixedWidthStroke.CAP_ROUND, PFixedWidthStroke.JOIN_MITER, 10.0f, new
// float[] { 2.0f, 3.0f, 4.0f }, 1.0f));
fixedWidthRect2.setStrokePaint(new Color(20, 20, 20));
getCanvas().getLayer().addChild(label);
getCanvas().getLayer().addChild(rect);
getCanvas().getLayer().addChild(fixedWidthLabel);
getCanvas().getLayer().addChild(fixedWidthRect0);
getCanvas().getLayer().addChild(fixedWidthRect1);
getCanvas().getLayer().addChild(fixedWidthRect2);
}
示例13: initialize
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void initialize() {
final PPath sticky = PPath.createRectangle(0, 0, 50, 50);
sticky.setPaint(Color.YELLOW);
sticky.setStroke(null);
PBoundsHandle.addBoundsHandlesTo(sticky);
getCanvas().getLayer().addChild(PPath.createRectangle(0, 0, 100, 80));
getCanvas().getCamera().addChild(sticky);
}
示例14: createHierarchy
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public PNode createHierarchy(final int level) {
final PPath result = PPath.createRectangle(0, 0, 100, 100);
if (level > 0) {
final PNode child = createHierarchy(level - 1);
child.scale(0.5);
result.addChild(child);
child.offset(25, 25);
}
return result;
}
示例15: initialize
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void initialize() {
final PLayer layer = getCanvas().getLayer();
final PNode a = PPath.createRectangle(0, 0, 100, 80);
final PNode b = PPath.createRectangle(0, 0, 100, 80);
layer.addChild(a);
layer.addChild(b);
final PActivity a1 = a.animateToPositionScaleRotation(200, 200, 1, 0, 5000);
final PActivity a2 = b.animateToPositionScaleRotation(200, 200, 1, 0, 5000);
a2.startAfter(a1);
}