本文整理汇总了Java中org.piccolo2d.nodes.PPath.setStroke方法的典型用法代码示例。如果您正苦于以下问题:Java PPath.setStroke方法的具体用法?Java PPath.setStroke怎么用?Java PPath.setStroke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.piccolo2d.nodes.PPath
的用法示例。
在下文中一共展示了PPath.setStroke方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.piccolo2d.nodes.PPath; //导入方法依赖的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.nodes.PPath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void initialize() {
PPath line1 = PPath.createLine(5f, 10f, 5f, 100f);
line1.setStroke(new BasicStroke(0));
getCanvas().getLayer().addChild(line1);
PPath line2 = new PPath.Float();
line2.setStroke(new BasicStroke(0));
line2.moveTo(15f, 10f);
line2.lineTo(15f, 100f);
getCanvas().getLayer().addChild(line2);
PPath line3 = PPath.createLine(25f, 10f, 26f, 100f);
line3.setStroke(new BasicStroke(0));
getCanvas().getLayer().addChild(line3);
}
示例3: 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());
}
示例4: 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());
}
示例5: 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));
}
}
}
示例6: initialize
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void initialize() {
PPath eacha = PPath.createRectangle(50, 50, 300, 300);
eacha.setPaint(Color.red);
getCanvas().getLayer().addChild(eacha);
eacha = PPath.createRectangle(-50, -50, 100, 100);
eacha.setPaint(Color.green);
getCanvas().getLayer().addChild(eacha);
eacha = PPath.createRectangle(350, 350, 100, 100);
eacha.setPaint(Color.green);
getCanvas().getLayer().addChild(eacha);
getCanvas().getCamera().addInputEventListener(new PBasicInputEventHandler() {
public void mousePressed(final PInputEvent event) {
if (!(event.getPickedNode() instanceof PCamera)) {
event.setHandled(true);
getCanvas().getCamera().animateViewToPanToBounds(event.getPickedNode().getGlobalFullBounds(), 500);
}
}
});
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().getZoomEventHandler());
}
示例7: 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);
}
示例8: OffscreenCanvasExample
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
/**
* Create a new offscreen canvas example with the specified graphics device.
*
* @param device graphics device
*/
public OffscreenCanvasExample(final GraphicsDevice device) {
final GraphicsConfiguration configuration = device.getDefaultConfiguration();
frame = new Frame(configuration);
frame.setUndecorated(true);
frame.setIgnoreRepaint(true);
frame.setBounds(100, 100, 400, 400);
frame.setVisible(true);
frame.createBufferStrategy(2);
canvas = new POffscreenCanvas(400, 400);
final PText text = new PText("Offscreen Canvas Example");
text.setFont(text.getFont().deriveFont(32.0f));
text.setTextPaint(new Color(200, 200, 200));
text.offset(200.0f - text.getWidth() / 2.0f, 200.0f - text.getHeight() / 2.0f);
final PPath rect = PPath.createRectangle(0.0f, 0.0f, 360.0f, 360.0f);
rect.setPaint(new Color(20, 20, 20, 80));
rect.setStroke(new BasicStroke(2.0f));
rect.setStrokePaint(new Color(20, 20, 20));
rect.offset(20.0f, 20.0f);
canvas.getCamera().getLayer(0).addChild(text);
canvas.getCamera().getLayer(0).addChild(rect);
final Rectangle2D right = new Rectangle2D.Double(200.0f, 200.0f, 800.0f, 800.0f);
final Rectangle2D left = new Rectangle2D.Double(-200.0f, 200.0f, 225.0f, 225.0f);
final Rectangle2D start = new Rectangle2D.Double(0.0f, 0.0f, 400.0f, 400.0f);
final PActivity toRight = canvas.getCamera().animateViewToCenterBounds(right, true, 5000);
final PActivity toLeft = canvas.getCamera().animateViewToCenterBounds(left, true, 5000);
final PActivity toStart = canvas.getCamera().animateViewToCenterBounds(start, true, 5000);
toLeft.startAfter(toRight);
toStart.startAfter(toLeft);
}
示例9: 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);
}
示例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包/类
/** {@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);
}
示例12: addGlow
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
private void addGlow(PComposite pNode, Color pHighlight) {
Point2D vPosition = pNode.getOffset();
PBounds vBound = pNode.getFullBoundsReference();
float vShadowWidth = (float) (1.1
* vBound.getWidth()
+ mGlowWidth);
float vShadowHeight = (float) (vBound.getHeight()
+ mGlowHeight);
PPath vShadow = PPath.createEllipse(-0.5F
* vShadowWidth, // x
-0.5F
* vShadowHeight, // y
vShadowWidth, // width
vShadowHeight // height
);
vShadow.setOffset((float) (vPosition.getX()), // x
(float) (vPosition.getY()) // y
);
vShadow.setStroke(null);
Color opaqueHighlight = new Color(pHighlight.getRed(),
pHighlight.getGreen(), pHighlight.getBlue(), 255);
Color transparentHighlight = new Color(pHighlight.getRed(),
pHighlight.getGreen(), pHighlight.getBlue(), 0);
vShadow.setPaint(ColorHelper.createGradientColor(new Piccolo2DGraphicWrapper(vShadow, null), opaqueHighlight,
transparentHighlight));
vShadow.setTransparency(0.0f);
synchronized (pNode) {
mLayerGlow.addChild(vShadow);
pNode.addAttribute("glow", vShadow);
}
vShadow.animateToTransparency(1.0f, 500); // TODO Use SettingManager
}
示例13: drawStraightDashedLine
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
/**
* Draws a straight dashed line.
*
* @param pEdge
* the {@link PPath} object representing the edge
* @param vStart
* the starting point of the edge
* @param vEnd
* the end point of the edge
*/
public static void drawStraightDashedLine(PPath pEdge, Point2D vStart, Point2D vEnd) {
float[] dash = {10.0f};
pEdge.setStroke(new BasicStroke(3.0f, BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f));
pEdge.moveTo((float) vStart.getX(), (float) vStart.getY());
pEdge.lineTo((float) vEnd.getX(), (float) vEnd.getY());
}