/** * Finds all descendants of this node that intersect with the given bounds * and adds them to the results array. * * @param fullBounds bounds to compare against * @param results array into which to add matches */ public void findIntersectingNodes(final Rectangle2D fullBounds, final ArrayList results) { if (fullIntersects(fullBounds)) { final Rectangle2D localBounds = parentToLocal((Rectangle2D) fullBounds.clone()); if (intersects(localBounds)) { results.add(this); } final int count = getChildrenCount(); for (int i = count - 1; i >= 0; i--) { final PNode each = (PNode) children.get(i); each.findIntersectingNodes(localBounds, results); } } }
/** * 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); }
/** {@inheritDoc} */ public void endResizeBounds() { super.endResizeBounds(); target.endResizeBounds(); }
/** * Return a copy of the bounds of this node in the global coordinate system. * * @return the bounds in global coordinate system. */ public PBounds getGlobalBounds() { return (PBounds) localToGlobal(getBounds()); }
/** * 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); } }
nodeBounds.setRect(each.getBoundsReference()); each.localToGlobal(nodeBounds); globalToLocal(nodeBounds); if (each == this || each.isDescendentOf(this)) { localToView(nodeBounds); nodeBounds.setRect(each.getFullBoundsReference()); if (each.getParent() != null) { each.getParent().localToGlobal(nodeBounds); if (each == this || each.isDescendentOf(this)) { localToView(nodeBounds);
/** * 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); } }
final Rectangle2D srcBounds = getGlobalFullBounds(); srcx = lerp(srcPt.getX(), srcBounds.getX(), srcBounds.getX() + srcBounds.getWidth()); srcy = lerp(srcPt.getY(), srcBounds.getY(), srcBounds.getY() + srcBounds.getHeight()); destx = lerp(destPt.getX(), destBounds.getX(), destBounds.getX() + destBounds.getWidth()); desty = lerp(destPt.getY(), destBounds.getY(), destBounds.getY() + destBounds.getHeight()); globalToLocal(pt1); pt2 = new Point2D.Double(destx, desty); globalToLocal(pt2); dx = pt2.getX() - pt1.getX(); dy = pt2.getY() - pt1.getY(); final PAffineTransform at = new PAffineTransform(getTransformReference(true)); at.translate(dx, dy); return animateToTransform(at, millis);
public void setRelativeTargetValue(final float zeroToOne) { PNode.this.setBounds(src.x + zeroToOne * (dst.x - src.x), src.y + zeroToOne * (dst.y - src.y), src.width + zeroToOne * (dst.width - src.width), src.height + zeroToOne * (dst.height - src.height)); }
final PBounds b = n.getBounds(); n.globalToLocal(aLocalDimension); n.setBounds(b);
/** * Try to pick this node after its children have had a chance to be picked. * Most subclasses the define a different geometry will need to override * this method. * * @param pickPath the pick path used for the pick operation * @return true if this node was picked */ protected boolean pickAfterChildren(final PPickPath pickPath) { if (intersects(pickPath.getPickBounds())) { return true; } return false; }
/** * Return a copy of the full bounds of this node in the global coordinate * system. * * @return the full bounds in global coordinate system. */ public PBounds getGlobalFullBounds() { final PBounds b = getFullBounds(); if (parent != null) { parent.localToGlobal(b); } return b; }
/** * Return the y position (in local coords) of this node's bounds. * * @return local y position of bounds */ public double getY() { return getBoundsReference().getY(); }
/** * 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); } }
/** * Compute and return the full bounds of this node. If the dstBounds * parameter is not null then it will be used to return the results instead * of creating a new PBounds. * * @param dstBounds if not null the new bounds will be stored here * @return the full bounds in the parent coordinate system of this node */ public PBounds computeFullBounds(final PBounds dstBounds) { final PBounds result = getUnionOfChildrenBounds(dstBounds); result.add(getBoundsReference()); localToParent(result); return result; }
protected void activityStarted() { src = getBounds(); startResizeBounds(); super.activityStarted(); }