/** * Add a collection of nodes to be children of this node. If these nodes * already have parents they will first be removed from those parents. * * @param nodes a collection of nodes to be added to this node */ public void addChildren(final Collection nodes) { final Iterator i = nodes.iterator(); while (i.hasNext()) { final PNode each = (PNode) i.next(); addChild(each); } }
/** * Lower this node within the Z-order of its parent to the bottom. * * @since 3.0 */ public void lowerToBottom() { final PNode p = parent; if (p != null) { p.removeChild(this); p.addChild(0, this); } }
/** * Raise this node within the Z-order of its parent to the top. * * @since 3.0 */ public void raiseToTop() { final PNode p = parent; if (p != null) { p.removeChild(this); p.addChild(this); } }
/** * Add a node to be a new child of this node. The new node is added to the * end of the list of this node's children. If child was previously a child * of another node, it is removed from that first. * * @param child the new child to add to this node */ public void addChild(final PNode child) { int insertIndex = getChildrenCount(); if (child.parent == this) { insertIndex--; } addChild(insertIndex, child); }
/** * Adds bounds handles to all corners and edges of the provided node. * * @param node to decorate with bounds handles. */ public static void addBoundsHandlesTo(final PNode node) { node.addChild(new PSWTBoundsHandle(PBoundsLocator.createEastLocator(node))); node.addChild(new PSWTBoundsHandle(PBoundsLocator.createWestLocator(node))); node.addChild(new PSWTBoundsHandle(PBoundsLocator.createNorthLocator(node))); node.addChild(new PSWTBoundsHandle(PBoundsLocator.createSouthLocator(node))); node.addChild(new PSWTBoundsHandle(PBoundsLocator.createNorthEastLocator(node))); node.addChild(new PSWTBoundsHandle(PBoundsLocator.createNorthWestLocator(node))); node.addChild(new PSWTBoundsHandle(PBoundsLocator.createSouthEastLocator(node))); node.addChild(new PSWTBoundsHandle(PBoundsLocator.createSouthWestLocator(node))); }
/** {@inheritDoc} */ protected void initializeMarquee(final PInputEvent e) { super.initializeMarquee(e); marquee = new PSWTPath(new Rectangle2D.Float((float) pressPt.getX(), (float) pressPt.getY(), 0, 0)) { /** * */ private static final long serialVersionUID = 1L; protected void paint(final PPaintContext paintContext) { final SWTGraphics2D s2g = (SWTGraphics2D) paintContext.getGraphics(); s2g.gc.setLineStyle(SWT.LINE_DASH); super.paint(paintContext); s2g.gc.setLineStyle(SWT.LINE_SOLID); } }; marquee.setStrokeColor(Color.black); marquee.setPaint(null); marqueeParent.addChild(marquee); }
/** * Swaps this node out of the scene graph tree, and replaces it with the * specified replacement node. This node is left dangling, and it is up to * the caller to manage it. The replacement node will be added to this * node's parent in the same position as this was. That is, if this was the * 3rd child of its parent, then after calling replaceWith(), the * replacement node will also be the 3rd child of its parent. If this node * has no parent when replace is called, then nothing will be done at all. * * @param replacementNode the new node that replaces the current node in the * scene graph tree. */ public void replaceWith(final PNode replacementNode) { if (parent != null) { final PNode p = parent; final int index = p.getChildrenReference().indexOf(this); p.removeChild(this); p.addChild(index, replacementNode); } }
/** * Raise this node within the Z-order of its parent above the specified sibling node. * * @since 3.0 * @param sibling sibling node to raise this node above */ public void raiseAbove(final PNode sibling) { final PNode p = parent; if (p != null && p == sibling.getParent()) { p.removeChild(this); final int index = p.indexOfChild(sibling); p.addChild(index + 1, this); } }
/** * Lower this node within the Z-order of its parent below the specified sibling node. * * @since 3.0 * @param sibling sibling node to lower this node below */ public void lowerBelow(final PNode sibling) { final PNode p = parent; if (p != null && p == sibling.getParent()) { p.removeChild(this); final int index = p.indexOfChild(sibling); p.addChild(index, this); } }
/** * Set the parent of this node, and transform the node in such a way that it * doesn't move in global coordinates. * * @param newParent The new parent of this node. */ public void reparent(final PNode newParent) { final AffineTransform originalTransform = getLocalToGlobalTransform(null); final AffineTransform newTransform = newParent.getGlobalToLocalTransform(null); newTransform.concatenate(originalTransform); removeFromParent(); setTransform(newTransform); newParent.addChild(this); computeFullBounds(fullBoundsCache); }