本文整理汇总了Java中org.piccolo2d.nodes.PText.setTextPaint方法的典型用法代码示例。如果您正苦于以下问题:Java PText.setTextPaint方法的具体用法?Java PText.setTextPaint怎么用?Java PText.setTextPaint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.piccolo2d.nodes.PText
的用法示例。
在下文中一共展示了PText.setTextPaint方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTextNode
import org.piccolo2d.nodes.PText; //导入方法依赖的package包/类
private void createTextNode(final int i) {
PText text = new PText("Label " + i);
text.setTextPaint(TEXT_PAINT);
text.setOffset(random.nextDouble() * 1000.0d - random.nextDouble() * 1000.0,
random.nextDouble() * 1000.0d - random.nextDouble() * 1000.0);
getCanvas().getLayer().addChild(text);
}
示例2: OffscreenCanvasExample
import org.piccolo2d.nodes.PText; //导入方法依赖的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);
}
示例3: initialize
import org.piccolo2d.nodes.PText; //导入方法依赖的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);
}
示例4: initialize
import org.piccolo2d.nodes.PText; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void initialize() {
BufferedImage src = buildRedRectangleImage();
addHeaderAt("Shadow nodes drawn from an image, with increasing blur radius:", 0, 0);
double x = 25.0d;
double y = 25.0d;
for (int blurRadius = 4; blurRadius < 28; blurRadius += 4) {
PImage node = new PImage(src);
PShadow shadowNode = new PShadow(src, SHADOW_PAINT, blurRadius);
node.setOffset(x, y);
// offset the shadow to account for blur radius offset and light direction
shadowNode.setOffset(x - (2 * blurRadius) + 5.0d, y - (2 * blurRadius) + 5.0d);
// add shadow node before node, or set Z explicitly (e.g. sendToBack())
getCanvas().getLayer().addChild(shadowNode);
getCanvas().getLayer().addChild(node);
x += 125.0d;
if (x > 300.0d) {
y += 125.0d;
x = 25.0d;
}
}
addHeaderAt("Shadow nodes drawn from node.toImage():", 0, 300);
PPath rectNode = buildRedRectangleNode();
PShadow rectShadow = new PShadow(rectNode.toImage(), SHADOW_PAINT, 8);
rectShadow.setOffset(25.0d - (2 * 8) + 5.0d, 325.0d - (2 * 8) + 5.0d);
getCanvas().getLayer().addChild(rectShadow);
getCanvas().getLayer().addChild(rectNode);
PText textNode = new PText("Shadow Text");
textNode.setTextPaint(Color.RED);
textNode.setFont(textNode.getFont().deriveFont(36.0f));
textNode.setOffset(125.0d, 325.0d);
PShadow textShadow = new PShadow(textNode.toImage(), SHADOW_PAINT, 8);
textShadow.setOffset(125.0d - (2 * 8) + 2.5d, 325.0d - (2 * 8) + 2.5d);
getCanvas().getLayer().addChild(textShadow);
getCanvas().getLayer().addChild(textNode);
}