本文整理汇总了Java中org.piccolo2d.nodes.PText.setOffset方法的典型用法代码示例。如果您正苦于以下问题:Java PText.setOffset方法的具体用法?Java PText.setOffset怎么用?Java PText.setOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.piccolo2d.nodes.PText
的用法示例。
在下文中一共展示了PText.setOffset方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.piccolo2d.nodes.PText; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void initialize() {
PText label = new PText("Note white at border S and E\nIt goes away when frame is resized");
label.setOffset(200, 340);
getCanvas().getLayer().addChild(label);
getCanvas().setBackground(Color.PINK);
getCanvas().setOpaque(true);
setSize(410, 410);
//getCanvas().setSize(410, 410); does not help
}
示例2: 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);
}
示例3: 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);
}
示例4: addHeaderAt
import org.piccolo2d.nodes.PText; //导入方法依赖的package包/类
private PText addHeaderAt(String labelText, double x, double y) {
PText labelNode = new PText(labelText);
labelNode.setOffset(x, y);
getCanvas().getLayer().addChild(labelNode);
return labelNode;
}
示例5: addIdentifier
import org.piccolo2d.nodes.PText; //导入方法依赖的package包/类
@Override
public synchronized void addIdentifier(NodeIdentifier pNode) {
LOGGER.trace("Method addIdentifier("
+ pNode + ") called.");
if (!mMapNode.containsKey(pNode)) {
PText vText = new PText(
mIdentifierInformationStrategy.getText(pNode
.getIdentifier()));
vText.setHorizontalAlignment(Component.CENTER_ALIGNMENT);
vText.setFont(new Font(null, Font.PLAIN, mFontSize));
vText.setOffset(-0.5F
* (float) vText.getWidth(), -0.5F
* (float) vText.getHeight());
final PPath vNode = mPiccolo2dIdentifierRenderer.createNode(pNode.getIdentifier(), vText);
/* Composite */
final PComposite vCom = new PComposite();
vCom.addChild(vNode);
vCom.addChild(vText);
vCom.setOffset( // Set position
mAreaOffsetX
+ pNode.getX()
* mAreaWidth, // x
mAreaOffsetY
+ pNode.getY()
* mAreaHeight // y
);
// Add edges to node
vCom.addAttribute("type", NodeType.IDENTIFIER);
vCom.addAttribute("position", pNode);
vCom.addAttribute("data", pNode.getIdentifier());
vCom.addAttribute("edges", new ArrayList<PPath>());
paintIdentifierNode(pNode.getIdentifier(), vNode, vText);
mMapNode.put(pNode, vCom); // Add node to HashMap.
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
mLayerNode.addChild(vCom); // Add node to layer.
}
});
}
}
示例6: addMetadata
import org.piccolo2d.nodes.PText; //导入方法依赖的package包/类
private synchronized void addMetadata(NodeMetadata pNode) {
LOGGER.trace("Method addMetadata("
+ pNode + ") called.");
if (!mMapNode.containsKey(pNode)) {
final String vPublisher = MetadataHelper.extractPublisherId(pNode.getMetadata());
if (!mPublisher.contains(vPublisher)) {
mPublisher.add(vPublisher);
}
/* Text */
PText vText = new PText(mMetadataInformationStrategy.getText(pNode
.getMetadata()));
vText.setHorizontalAlignment(Component.CENTER_ALIGNMENT);
vText.setFont(new Font(null, Font.PLAIN, mFontSize));
vText.setOffset(-0.5F
* (float) vText.getWidth(), -0.5F
* (float) vText.getHeight());
/* Rectangle */
final PPath vNode = mPiccolo2dMetadataRenderer.createNode(pNode.getMetadata(), vText);
/* Composite */
final PComposite vCom = new PComposite();
vCom.addChild(vNode);
vCom.addChild(vText);
vCom.setOffset(mAreaOffsetX
+ pNode.getX()
* mAreaWidth,
mAreaOffsetY
+ pNode.getY()
* mAreaHeight);
vCom.addAttribute("type", NodeType.METADATA);
vCom.addAttribute("publisher", vPublisher);
vCom.addAttribute("position", pNode);
vCom.addAttribute("data", pNode.getMetadata());
vCom.addAttribute("edges", new ArrayList<PPath>()); // Add
// edges
// to
// node
paintMetadataNode(pNode.getMetadata(), vNode, vText);
mMapNode.put(pNode, vCom); // Add node to HashMap.
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
mLayerNode.addChild(vCom); // Add node to layer.
}
});
}
}