/** * Transform the given point from this node's local coordinate system to the * global coordinate system. Note that this will modify the point parameter. * * @param localPoint point in local coordinate system to be transformed. * @return point in global coordinates */ public Point2D localToGlobal(final Point2D localPoint) { PNode n = this; while (n != null) { n.localToParent(localPoint); n = n.parent; } return localPoint; }
/** * Transform the given dimension from this node's local coordinate system to * the global coordinate system. Note that this will modify the dimension * parameter. * * @param localDimension dimension in local coordinate system to be * transformed. * @return dimension in global coordinates */ public Dimension2D localToGlobal(final Dimension2D localDimension) { PNode n = this; while (n != null) { n.localToParent(localDimension); n = n.parent; } return localDimension; }
/** * Transform the given rectangle from this node's local coordinate system to * the global coordinate system. Note that this will modify the rectangle * parameter. * * @param localRectangle rectangle in local coordinate system to be * transformed. * @return rectangle in global coordinates */ public Rectangle2D localToGlobal(final Rectangle2D localRectangle) { PNode n = this; while (n != null) { n.localToParent(localRectangle); n = n.parent; } return localRectangle; }
/** * Pass the given repaint request up the tree, so that any cameras can * invalidate that region on their associated canvas. * * @param localBounds the bounds to repaint * @param childOrThis if childOrThis does not equal this then this nodes * transform will be applied to the localBounds param */ public void repaintFrom(final PBounds localBounds, final PNode childOrThis) { if (parent != null) { if (childOrThis != this) { localToParent(localBounds); } else if (!getVisible()) { return; } parent.repaintFrom(localBounds, this); } }
/** * 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; }
/** * Moves the dragged node in proportion to the drag distance. * * @param event event representing the drag */ protected void drag(final PInputEvent event) { super.drag(event); final PDimension d = event.getDeltaRelativeTo(draggedNode); draggedNode.localToParent(d); draggedNode.offset(d.getWidth(), d.getHeight()); }