/** * 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); }
/** * Raise this node within the Z-order of its parent. * * @since 3.0 */ public void raise() { final PNode p = parent; if (p != null) { final int index = parent.indexOfChild(this); final int siblingIndex = Math.min(parent.getChildrenCount() - 1, index + 1); if (siblingIndex != index) { raiseAbove(parent.getChild(siblingIndex)); } } }
final int count = getChildrenCount(); for (int i = 0; i < count; i++) { final PNode each = (PNode) children.get(i);
/** * This method should be called when the bounds of this node are changed. It * invalidates the full bounds of this node, and also notifies each of this * nodes children that their parent's bounds have changed. As a result of * this method getting called this nodes layoutChildren will be called. */ public void signalBoundsChanged() { invalidateFullBounds(); setBoundsChanged(true); firePropertyChange(PROPERTY_CODE_BOUNDS, PROPERTY_BOUNDS, null, bounds); final int count = getChildrenCount(); for (int i = 0; i < count; i++) { final PNode each = (PNode) children.get(i); each.parentBoundsChanged(); } }
/** * 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); } } }
/** * Compute and return the union of the full bounds of all the children 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 union of children bounds */ public PBounds getUnionOfChildrenBounds(final PBounds dstBounds) { PBounds resultBounds; if (dstBounds == null) { resultBounds = new PBounds(); } else { resultBounds = dstBounds; resultBounds.resetToZero(); } final int count = getChildrenCount(); for (int i = 0; i < count; i++) { final PNode each = (PNode) children.get(i); resultBounds.add(each.getFullBoundsReference()); } return resultBounds; }
/** * Repaint this node and any of its descendants if they have invalid paint. */ public void validateFullPaint() { if (getPaintInvalid()) { repaint(); setPaintInvalid(false); } if (getChildPaintInvalid()) { final int count = getChildrenCount(); for (int i = 0; i < count; i++) { final PNode each = (PNode) children.get(i); each.validateFullPaint(); } setChildPaintInvalid(false); } }
/** * Paint this node and all of its descendants. Most subclasses do not need * to override this method, they should override <code>paint</code> or * <code>paintAfterChildren</code> instead. * * @param paintContext the paint context to use for painting this node and * its children */ public void fullPaint(final PPaintContext paintContext) { if (getVisible() && fullIntersects(paintContext.getLocalClip())) { paintContext.pushTransform(transform); paintContext.pushTransparency(transparency); if (!getOccluded()) { paint(paintContext); } final int count = getChildrenCount(); for (int i = 0; i < count; i++) { final PNode each = (PNode) children.get(i); each.fullPaint(paintContext); } paintAfterChildren(paintContext); paintContext.popTransparency(transparency); paintContext.popTransform(transform); } }
final int count = getChildrenCount(); for (int i = count - 1; i >= 0; i--) { final PNode each = (PNode) children.get(i);
final int count = getChildrenCount(); for (int i = 0; i < count; i++) { final PNode each = (PNode) children.get(i);