本文整理汇总了Java中org.piccolo2d.extras.nodes.PComposite.addChild方法的典型用法代码示例。如果您正苦于以下问题:Java PComposite.addChild方法的具体用法?Java PComposite.addChild怎么用?Java PComposite.addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.piccolo2d.extras.nodes.PComposite
的用法示例。
在下文中一共展示了PComposite.addChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.piccolo2d.extras.nodes.PComposite; //导入方法依赖的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());
}
示例2: addIdentifier
import org.piccolo2d.extras.nodes.PComposite; //导入方法依赖的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.
}
});
}
}
示例3: addMetadata
import org.piccolo2d.extras.nodes.PComposite; //导入方法依赖的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.
}
});
}
}