/** * Set the parent of this node. Note this is set automatically when adding * and removing children. * * @param newParent the parent to which this node should be added */ public void setParent(final PNode newParent) { final PNode old = parent; parent = newParent; firePropertyChange(PROPERTY_CODE_PARENT, PROPERTY_PARENT, old, parent); }
/** * Set the pickable flag for this node. Only pickable nodes can receive * input events. Nodes are pickable by default. * * @param isPickable true if this node is pickable */ public void setPickable(final boolean isPickable) { if (getPickable() != isPickable) { pickable = isPickable; firePropertyChange(PROPERTY_CODE_PICKABLE, PROPERTY_PICKABLE, null, null); } }
/** * Set the children pickable flag. If this flag is false then this node will * not try to pick its children. Children are pickable by default. * * @param areChildrenPickable true if this node tries to pick its children */ public void setChildrenPickable(final boolean areChildrenPickable) { if (getChildrenPickable() != areChildrenPickable) { childrenPickable = areChildrenPickable; firePropertyChange(PROPERTY_CODE_CHILDREN_PICKABLE, PROPERTY_CHILDREN_PICKABLE, null, null); } }
/** * Set the paint used to paint this node, which may be null. * * @param newPaint paint that this node should use when painting itself. */ public void setPaint(final Paint newPaint) { if (paint == newPaint) { return; } final Paint oldPaint = paint; paint = newPaint; invalidatePaint(); firePropertyChange(PROPERTY_CODE_PAINT, PROPERTY_PAINT, oldPaint, paint); }
/** * Set the transparency used to paint this node. Note that this transparency * applies to this node and all of its descendants. * * @param newTransparency transparency value for this node. 0f = fully * transparent, 1f = fully opaque */ public void setTransparency(final float newTransparency) { if (Math.abs(transparency - newTransparency) > TRANSPARENCY_RESOLUTION) { final float oldTransparency = transparency; transparency = newTransparency; invalidatePaint(); firePropertyChange(PROPERTY_CODE_TRANSPARENCY, PROPERTY_TRANSPARENCY, new Float(oldTransparency), new Float(newTransparency)); } }
/** * Remove all the children from this node. Node this method is more * efficient then removing each child individually. */ public void removeAllChildren() { if (children != null) { final int count = children.size(); for (int i = 0; i < count; i++) { final PNode each = (PNode) children.get(i); each.setParent(null); } children = null; invalidatePaint(); invalidateFullBounds(); firePropertyChange(PROPERTY_CODE_CHILDREN, PROPERTY_CHILDREN, null, children); } }
/** * Remove the child at the specified position of this group node's children. * Any subsequent children are shifted to the left (one is subtracted from * their indices). The removed child's parent is set to null. * * @param index the index of the child to remove * @return the removed child */ public PNode removeChild(final int index) { if (children == null) { return null; } final PNode child = (PNode) children.remove(index); if (children.size() == 0) { children = null; } child.repaint(); child.setParent(null); invalidateFullBounds(); firePropertyChange(PROPERTY_CODE_CHILDREN, PROPERTY_CHILDREN, null, children); return child; }
/** * Set the visibility of this node and its descendants. * * @param isVisible true if this node and its descendants are visible */ public void setVisible(final boolean isVisible) { if (getVisible() != isVisible) { if (!isVisible) { repaint(); } visible = isVisible; firePropertyChange(PROPERTY_CODE_VISIBLE, PROPERTY_VISIBLE, null, null); invalidatePaint(); } }
/** * 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(); } }
/** * Transform this nodes transform by the given transform. * * @param aTransform the transform to apply. */ public void transformBy(final AffineTransform aTransform) { getTransformReference(true).concatenate(aTransform); invalidatePaint(); invalidateFullBounds(); firePropertyChange(PROPERTY_CODE_TRANSFORM, PROPERTY_TRANSFORM, null, transform); }
/** * Scale this nodes transform by the given amount about the specified point. * This will affect this node and all of its descendants. * * @param scale the amount to scale by * @param x the x coordinate of the point around which to scale * @param y the y coordinate of the point around which to scale */ public void scaleAboutPoint(final double scale, final double x, final double y) { getTransformReference(true).scaleAboutPoint(scale, x, y); invalidatePaint(); invalidateFullBounds(); firePropertyChange(PROPERTY_CODE_TRANSFORM, PROPERTY_TRANSFORM, null, transform); }
/** * Rotates this node by theta (in radians) about the given point. This will * affect this node and all its descendants. * * @param theta the amount to rotate by in radians * @param x the x coordinate of the point around which to rotate * @param y the y coordinate of the point around which to rotate */ public void rotateAboutPoint(final double theta, final double x, final double y) { getTransformReference(true).rotate(theta, x, y); invalidatePaint(); invalidateFullBounds(); firePropertyChange(PROPERTY_CODE_TRANSFORM, PROPERTY_TRANSFORM, null, transform); }
/** * Translate this node's transform by the given amount, using the standard * affine transform translate method. This translation effects this node and * all of its descendants. * * @param dx amount to add to this nodes current x translation * @param dy amount to add to this nodes current y translation */ public void translate(final double dx, final double dy) { getTransformReference(true).translate(dx, dy); invalidatePaint(); invalidateFullBounds(); firePropertyChange(PROPERTY_CODE_TRANSFORM, PROPERTY_TRANSFORM, null, transform); }
firePropertyChange(PROPERTY_CODE_CLIENT_PROPERTIES, PROPERTY_CLIENT_PROPERTIES, null, clientProperties); firePropertyChange(PROPERTY_CODE_CLIENT_PROPERTIES, key.toString(), oldValue, value);
/** * Set the offset that is being applied to this node by its transform. This * offset effects this node and all of its descendants and is specified in * the nodes parent coordinate system. This directly sets the values of the * m02 and m12 positions in the affine transform. Unlike "PNode.translate()" * it is not effected by the transforms scale. * * @param x amount of x offset * @param y amount of y offset */ public void setOffset(final double x, final double y) { getTransformReference(true).setOffset(x, y); invalidatePaint(); invalidateFullBounds(); firePropertyChange(PROPERTY_CODE_TRANSFORM, PROPERTY_TRANSFORM, null, transform); }
/** * Set the transform applied to this node. * * @param transform the new transform value */ public void setTransform(final AffineTransform transform) { if (transform == null) { this.transform = null; } else { getTransformReference(true).setTransform(transform); } invalidatePaint(); invalidateFullBounds(); firePropertyChange(PROPERTY_CODE_TRANSFORM, PROPERTY_TRANSFORM, null, this.transform); }
/** * Add a node to be a new child of this node at the specified index. If * child was previously a child of another node, it is removed from that * node first. * * @param index where in the children list to insert the child * @param child the new child to add to this node */ public void addChild(final int index, final PNode child) { final PNode oldParent = child.getParent(); if (oldParent != null) { oldParent.removeChild(child); } child.setParent(this); getChildrenReference().add(index, child); child.invalidatePaint(); invalidateFullBounds(); firePropertyChange(PROPERTY_CODE_CHILDREN, PROPERTY_CHILDREN, null, children); }
parent.invalidateFullBounds(); firePropertyChange(PROPERTY_CODE_FULL_BOUNDS, PROPERTY_FULL_BOUNDS, null, fullBoundsCache);