本文整理汇总了Java中org.piccolo2d.extras.nodes.PComposite类的典型用法代码示例。如果您正苦于以下问题:Java PComposite类的具体用法?Java PComposite怎么用?Java PComposite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PComposite类属于org.piccolo2d.extras.nodes包,在下文中一共展示了PComposite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: startDrag
import org.piccolo2d.extras.nodes.PComposite; //导入依赖的package包/类
@Override
protected void startDrag(PInputEvent e) {
LOGGER.trace("Method startDrag("
+ e + ") called.");
PNode pickedNode = e.getPickedNode();
if (pickedNode instanceof PComposite) {
super.startDrag(e);
e.setHandled(true);
pickedNode.raiseToTop();
Position position = (Position) pickedNode.getAttribute("position");
if (position != null) {
position.setInUse(true);
}
PActivity activity = (PActivity) pickedNode.getAttribute("activity");
if (activity != null) {
activity.terminate();
}
}
}
示例3: drag
import org.piccolo2d.extras.nodes.PComposite; //导入依赖的package包/类
@Override
@SuppressWarnings({"unchecked"})
protected void drag(PInputEvent e) {
LOGGER.trace("Method drag("
+ e + ") called.");
PNode pickedNode = e.getPickedNode();
if (pickedNode instanceof PComposite) {
super.drag(e);
PComposite vNode = (PComposite) pickedNode;
/* Redraw edges */
ArrayList<PPath> vEdges = (ArrayList<PPath>) vNode.getAttribute("edges");
for (PPath vEdge : vEdges) {
mPanel.updateEdge(vEdge, (Position) vNode.getAttribute("position"));
}
/* TODO Redraw the shadow */
PPath vShadow = (PPath) vNode.getAttribute("glow");
if (vShadow != null) {
vShadow.setOffset(vNode.getOffset());
}
}
}
示例4: endDrag
import org.piccolo2d.extras.nodes.PComposite; //导入依赖的package包/类
@Override
protected void endDrag(PInputEvent e) {
LOGGER.trace("Method endDrag("
+ e + ") called.");
PNode pickedNode = e.getPickedNode();
if (pickedNode instanceof PComposite) {
super.endDrag(e);
/* Set new position */
Point2D vPoint = e.getPickedNode().getOffset();
boolean pinNode = e.isControlDown() ? true : false;
Position vNode = (Position) e.getPickedNode().getAttribute("position");
mConnection.updateNode(vNode, // Position-Object
(vPoint.getX()
/ mPanel.getAreaWidth())
+ mPanel.getAreaOffsetX(), // x
(vPoint.getY()
/ mPanel.getAreaHeight())
+ mPanel.getAreaOffsetY(), // y
0.0, // z
pinNode);
vNode.setInUse(false);
}
}
示例5: mouseEntered
import org.piccolo2d.extras.nodes.PComposite; //导入依赖的package包/类
@Override
public void mouseEntered(PInputEvent e) {
LOGGER.trace("Method mouseEntered("
+ e + ") called.");
super.mouseEntered(e);
if (!mConnection.isPropablePicked()) {
PNode pickedNode = e.getPickedNode();
if (pickedNode instanceof PComposite) {
PPath vNode = (PPath) pickedNode.getChild(0);
PText vText = (PText) pickedNode.getChild(1);
GraphicWrapper wrapper = Piccolo2DGraphicWrapperFactory.create(vNode, vText);
mConnection.showProperty(wrapper.getData());
mPanel.mouseEntered(wrapper);
}
}
}
示例6: mouseClicked
import org.piccolo2d.extras.nodes.PComposite; //导入依赖的package包/类
@Override
public void mouseClicked(PInputEvent e) {
LOGGER.trace("Method mouseClicked ("
+ e + ") called.");
super.mouseClicked(e);
PNode pickedNode = e.getPickedNode();
if (e.isLeftMouseButton()) {
if (pickedNode instanceof PComposite) {
PPath vNode = (PPath) pickedNode.getChild(0);
PText vText = (PText) pickedNode.getChild(1);
GraphicWrapper wrapper = Piccolo2DGraphicWrapperFactory.create(vNode, vText);
mConnection.pickAndShowProperties(wrapper);
} else {
mConnection.clearProperties();
}
}
}
示例7: deleteNode
import org.piccolo2d.extras.nodes.PComposite; //导入依赖的package包/类
@Override
public synchronized void deleteNode(Position pPosition) {
LOGGER.trace("Method deleteNode("
+ pPosition + ") called.");
PComposite vNode = mMapNode.get(pPosition);
if (vNode != null) {
/* Delete node from layer */
mLayerNode.removeChild(vNode);
/* Remove Shadow */
PPath vShadow = (PPath) vNode.getAttribute("glow");
if (vShadow != null) {
mLayerGlow.removeChild(vShadow);
}
/* Metadata */
if (pPosition instanceof NodeMetadata) {
/* Delete edges from layer */
for (PPath vEdge : mMapEdge.get(pPosition)) {
deleteEdge(pPosition, vEdge);
}
/* Delete edge from HashMap */
mMapEdge.remove(pPosition);
}
/* Delete node from HashMap */
mMapNode.remove(pPosition);
}
}
示例8: markAsNew
import org.piccolo2d.extras.nodes.PComposite; //导入依赖的package包/类
@Override
public synchronized void markAsNew(final Position pPosition) {
LOGGER.trace("Method markAsNew("
+ pPosition + ") called.");
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
PComposite vNode = mMapNode.get(pPosition);
if (vNode != null) {
addGlow(vNode, mColorNewNode);
} else {
LOGGER.debug("Coundn't find "
+ pPosition
+ " to mark as new.");
}
}
});
}
示例9: markAsDelete
import org.piccolo2d.extras.nodes.PComposite; //导入依赖的package包/类
@Override
public synchronized void markAsDelete(final Position pPosition) {
LOGGER.trace("Method markAsDelete("
+ pPosition + ") called.");
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
PComposite vNode = mMapNode.get(pPosition);
if (vNode != null) {
addGlow(vNode, mColorDeleteNode);
} else {
LOGGER.debug("Coundn't find "
+ pPosition
+ " to mark as delete.");
}
}
});
}
示例10: adjustPanelSize
import org.piccolo2d.extras.nodes.PComposite; //导入依赖的package包/类
/**
* Adjust the size of the panel depending on the number and size of labels.
*/
@Override
public synchronized void adjustPanelSize() {
LOGGER.trace("Method adjustPanelSize() called.");
int vNumberOfNodes = mMapNode.size();
int vNumberOfChars = 0;
if (vNumberOfNodes > 0) {
for (PComposite vNode : mMapNode.values()) {
vNumberOfChars += ((PText) vNode.getChild(1)).getText()
.length();
}
double vAverage = vNumberOfChars
/ vNumberOfNodes;
double vSize = (Math.sqrt(vNumberOfNodes)
+ vAverage)
* 50;
mAreaHeight = vSize;
mAreaWidth = vSize;
}
}
示例11: repaintNodes
import org.piccolo2d.extras.nodes.PComposite; //导入依赖的package包/类
@Override
public synchronized void repaintNodes(NodeType pType) {
LOGGER.trace("Method repaintNodes("
+ pType + ") called.");
for (Object key : mMapNode.keySet()) {
PComposite vCom = mMapNode.get(key);
PPath vNode = (PPath) vCom.getChild(0);
PText vText = (PText) vCom.getChild(1);
if (pType == NodeType.IDENTIFIER) {
if (vCom.getAttribute("type").equals(pType)) {
NodeIdentifier i = (NodeIdentifier) key;
Identifier identifier = i.getIdentifier();
paintIdentifierNode(identifier, vNode, vText);
}
} else if (pType == NodeType.METADATA) {
if (vCom.getAttribute("type").equals(pType)) {
NodeMetadata m = (NodeMetadata) key;
Metadata metadata = m.getMetadata();
paintMetadataNode(metadata, vNode, vText);
}
}
}
}
示例12: getNodes
import org.piccolo2d.extras.nodes.PComposite; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<GraphicWrapper> getNodes() {
ArrayList<PComposite> nodes = (ArrayList<PComposite>) mNode.getAttribute("nodes");
List<GraphicWrapper> edgesNodes = new ArrayList<GraphicWrapper>();
if (nodes != null) {
for (PComposite vCom : nodes) {
PPath vNode = (PPath) vCom.getChild(0);
PText vText = (PText) vCom.getChild(1);
GraphicWrapper g = Piccolo2DGraphicWrapperFactory.create(vNode, vText);
edgesNodes.add(g);
}
}
return edgesNodes;
}
示例13: mouseExited
import org.piccolo2d.extras.nodes.PComposite; //导入依赖的package包/类
@Override
public void mouseExited(PInputEvent e) {
LOGGER.trace("Method mouseExited("
+ e + ") called.");
super.mouseExited(e);
if (!mConnection.isPropablePicked()) {
PNode pickedNode = e.getPickedNode();
if (pickedNode instanceof PComposite) {
mPanel.mouseExited();
}
}
}
示例14: addEdge
import org.piccolo2d.extras.nodes.PComposite; //导入依赖的package包/类
/**
* Add an edge to the graph.
*
* @param pKey
* a key to group the edge.
* @param pNodeFirst
* the node where the edge starts.
* @param pNodeSecond
* the node where the edge ends.
*/
@Override
@SuppressWarnings("unchecked")
public synchronized void addEdge(NodeMetadata pKey, Position pNodeFirst,
Position pNodeSecond) {
LOGGER.trace("Method addEdge("
+ pKey + ", " + pNodeFirst + ", "
+ pNodeSecond + ") called.");
PPath vEdge = new PPath.Float();
PComposite vNodeFirst = mMapNode.get(pNodeFirst);
PComposite vNodeSecond = mMapNode.get(pNodeSecond);
/* Add Edge to Node. */
((ArrayList<PPath>) vNodeFirst.getAttribute("edges")).add(vEdge);
((ArrayList<PPath>) vNodeSecond.getAttribute("edges")).add(vEdge);
/* Add Node to Edge. */
vEdge.addAttribute("nodes", new ArrayList<PComposite>());
((ArrayList<PComposite>) vEdge.getAttribute("nodes")).add(vNodeFirst);
((ArrayList<PComposite>) vEdge.getAttribute("nodes")).add(vNodeSecond);
/* Add edge to layer. */
mLayerEdge.addChild(vEdge);
/* Add edge to HashMap. */
ArrayList<PPath> vEdges = mMapEdge.get(pKey);
if (vEdges == null) { // Is first entry?
vEdges = new ArrayList<>();
mMapEdge.put(pKey, vEdges);
}
vEdges.add(vEdge);
updateEdge(vEdge, pKey);
}
示例15: deleteEdge
import org.piccolo2d.extras.nodes.PComposite; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void deleteEdge(Object pKey, PPath pEdge) {
LOGGER.trace("Method deleteEdge("
+ pKey + ", " + pEdge + ") called.");
/* Remove edge from layer */
mLayerEdge.removeChild(pEdge);
/* Remove edge from node */
for (PComposite vNode : ((ArrayList<PComposite>) pEdge
.getAttribute("nodes"))) {
((ArrayList<PPath>) vNode.getAttribute("edges")).remove(pEdge);
}
}