diff --git a/core/src/build/conf/checkstyle.xml b/core/src/build/conf/checkstyle.xml index be1ded8..1c1489b 100644 --- a/core/src/build/conf/checkstyle.xml +++ b/core/src/build/conf/checkstyle.xml @@ -137,7 +137,10 @@ - + + + + diff --git a/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java b/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java index 50d169c..6fff975 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java +++ b/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java @@ -388,11 +388,11 @@ * when it is not interacting or animating. The default value is * PPaintContext. HIGH_QUALITY_RENDERING. * - * @param requestedQuality supports PPaintContext.HIGH_QUALITY_RENDERING or + * @param normalRenderQuality supports PPaintContext.HIGH_QUALITY_RENDERING or * PPaintContext.LOW_QUALITY_RENDERING */ - public void setDefaultRenderQuality(final int requestedQuality) { - normalRenderQuality = requestedQuality; + public void setDefaultRenderQuality(final int normalRenderQuality) { + this.normalRenderQuality = normalRenderQuality; repaint(); } @@ -401,11 +401,11 @@ * when it is animating. The default value is * PPaintContext.LOW_QUALITY_RENDERING. * - * @param requestedQuality supports PPaintContext.HIGH_QUALITY_RENDERING or + * @param animatingRenderQuality supports PPaintContext.HIGH_QUALITY_RENDERING or * PPaintContext.LOW_QUALITY_RENDERING */ - public void setAnimatingRenderQuality(final int requestedQuality) { - animatingRenderQuality = requestedQuality; + public void setAnimatingRenderQuality(final int animatingRenderQuality) { + this.animatingRenderQuality = animatingRenderQuality; if (getAnimating()) { repaint(); } @@ -416,11 +416,11 @@ * when it is interacting. The default value is * PPaintContext.LOW_QUALITY_RENDERING. * - * @param requestedQuality supports PPaintContext.HIGH_QUALITY_RENDERING or + * @param interactingRenderQuality supports PPaintContext.HIGH_QUALITY_RENDERING or * PPaintContext.LOW_QUALITY_RENDERING */ - public void setInteractingRenderQuality(final int requestedQuality) { - interactingRenderQuality = requestedQuality; + public void setInteractingRenderQuality(final int interactingRenderQuality) { + this.interactingRenderQuality = interactingRenderQuality; if (getInteracting()) { repaint(); } diff --git a/core/src/main/java/edu/umd/cs/piccolo/PNode.java b/core/src/main/java/edu/umd/cs/piccolo/PNode.java index dd9ab9f..287d6c5 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/PNode.java +++ b/core/src/main/java/edu/umd/cs/piccolo/PNode.java @@ -279,10 +279,10 @@ /** Tracks the parent of this node, may be null. */ private transient PNode parent; - + /** Tracks all immediate child nodes. */ private List children; - + /** Bounds of the PNode. */ private final PBounds bounds; @@ -842,11 +842,11 @@ // **************************************************************** // Copying - Methods for copying this node and its descendants. - // Copying is implemened in terms of serialization. + // Copying is implemented in terms of serialization. // **************************************************************** /** - * The copy method copies this node and all of its descendents. Note that + * The copy method copies this node and all of its descendants. Note that * copying is implemented in terms of java serialization. See the * serialization notes for more information. * @@ -1269,10 +1269,10 @@ * events are forwared to this nodes parent so that its property change * listeners will also be notified. * - * @param newPropertyChangeParentMask new mask for property change bubble up + * @param propertyChangeParentMask new mask for property change bubble up */ - public void setPropertyChangeParentMask(final int newPropertyChangeParentMask) { - this.propertyChangeParentMask = newPropertyChangeParentMask; + public void setPropertyChangeParentMask(final int propertyChangeParentMask) { + this.propertyChangeParentMask = propertyChangeParentMask; } /** @@ -1597,7 +1597,7 @@ // // The full bounds of a node store the nodes bounds // together with the union of the bounds of all the - // node's descendents. The full bounds are stored in the parent + // node's descendants. The full bounds are stored in the parent // coordinate system of this node, the full bounds DOES change // when you translate, scale, or rotate this node. // @@ -1610,7 +1610,7 @@ /** * Return a copy of this node's full bounds. These bounds are stored in the * parent coordinate system of this node and they include the union of this - * node's bounds and all the bounds of it's descendents. + * node's bounds and all the bounds of it's descendants. * * @return a copy of this node's full bounds. */ @@ -1621,7 +1621,7 @@ /** * Return a reference to this node's full bounds cache. These bounds are * stored in the parent coordinate system of this node and they include the - * union of this node's bounds and all the bounds of it's descendents. The + * union of this node's bounds and all the bounds of it's descendants. The * bounds returned by this method should not be modified. * * @return a reference to this node's full bounds cache. @@ -1654,21 +1654,23 @@ * @param dstBounds if not null the new bounds will be stored here * @return union of children bounds */ - public PBounds getUnionOfChildrenBounds(PBounds dstBounds) { + public PBounds getUnionOfChildrenBounds(final PBounds dstBounds) { + PBounds resultBounds; if (dstBounds == null) { - dstBounds = new PBounds(); + resultBounds = new PBounds(); } else { - dstBounds.resetToZero(); + resultBounds = dstBounds; + resultBounds.resetToZero(); } final int count = getChildrenCount(); for (int i = 0; i < count; i++) { final PNode each = (PNode) children.get(i); - dstBounds.add(each.getFullBoundsReference()); + resultBounds.add(each.getFullBoundsReference()); } - return dstBounds; + return resultBounds; } /** @@ -1730,7 +1732,7 @@ * Set if this node has a child with volatile bounds. This should normally * be managed automatically by the bounds validation process. * - * @param childBoundsVolatile true if this node has a descendent with + * @param childBoundsVolatile true if this node has a descendant with * volatile bounds */ protected void setChildBoundsVolatile(final boolean childBoundsVolatile) { @@ -1771,21 +1773,27 @@ * Set the full bounds invalid flag. This flag is set when the full bounds * of this node need to be recomputed as is the case when this node is * transformed or when one of this node's children changes geometry. + * + * @param fullBoundsInvalid true=invalid, false=valid */ protected void setFullBoundsInvalid(final boolean fullBoundsInvalid) { this.fullBoundsInvalid = fullBoundsInvalid; } /** - * Return true if one of this node's descendents has invalid bounds. + * Return true if one of this node's descendants has invalid bounds. + * + * @return whether child bounds are invalid */ protected boolean getChildBoundsInvalid() { return childBoundsInvalid; } /** - * Set the flag indicating that one of this node's descendents has invalid + * Set the flag indicating that one of this node's descendants has invalid * bounds. + * + * @param childBoundsInvalid true=invalid, false=valid */ protected void setChildBoundsInvalid(final boolean childBoundsInvalid) { this.childBoundsInvalid = childBoundsInvalid; @@ -1843,10 +1851,10 @@ /** * This method is called to validate the bounds of this node and all of its - * descendents. It returns true if this nodes bounds or the bounds of any of - * its descendents are marked as volatile. + * descendants. It returns true if this nodes bounds or the bounds of any of + * its descendants are marked as volatile. * - * @return true if this node or any of its descendents have volatile bounds + * @return true if this node or any of its descendants have volatile bounds */ protected boolean validateFullBounds() { final boolean boundsVolatile = getBoundsVolatile(); @@ -1961,12 +1969,12 @@ // // Since this transform defines the local coordinate system of this // node the following methods with affect the global position both - // this node and all of its descendents. + // this node and all of its descendants. // **************************************************************** /** * Returns the rotation applied by this node's transform in radians. This - * rotation affects this node and all its descendents. The value returned + * rotation affects this node and all its descendants. The value returned * will be between 0 and 2pi radians. * * @return rotation in radians. @@ -1990,7 +1998,7 @@ /** * Rotates this node by theta (in radians) about the 0,0 point. This will - * affect this node and all its descendents. + * affect this node and all its descendants. * * @param theta the amount to rotate by in radians */ @@ -2015,9 +2023,10 @@ /** * Rotates this node by theta (in radians) about the given point. This will - * affect this node and all its descendents. + * affect this node and all its descendants. * * @param theta the amount to rotate by in radians + * @param point the point about which to rotate */ public void rotateAboutPoint(final double theta, final Point2D point) { rotateAboutPoint(theta, point.getX(), point.getY()); @@ -2025,9 +2034,11 @@ /** * Rotates this node by theta (in radians) about the given point. This will - * affect this node and all its descendents. + * 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); @@ -2053,7 +2064,7 @@ * global rotation is as requested. * * @param theta the amount to rotate by in radians relative to the global - * coord system. + * coordinate system. */ public void setGlobalRotation(final double theta) { if (parent != null) { @@ -2066,7 +2077,7 @@ /** * Return the scale applied by this node's transform. The scale is effecting - * this node and all its descendents. + * this node and all its descendants. * * @return scale applied by this nodes transform. */ @@ -2079,7 +2090,7 @@ /** * Set the scale of this node's transform. The scale will affect this node - * and all its descendents. + * and all its descendants. * * @param scale the scale to set the transform to */ @@ -2092,7 +2103,7 @@ /** * Scale this nodes transform by the given amount. This will affect this - * node and all of its descendents. + * node and all of its descendants. * * @param scale the amount to scale by */ @@ -2102,7 +2113,7 @@ /** * Scale this nodes transform by the given amount about the specified point. - * This will affect this node and all of its descendents. + * This will affect this node and all of its descendants. * * @param scale the amount to scale by * @param point the point to scale about @@ -2113,9 +2124,11 @@ /** * Scale this nodes transform by the given amount about the specified point. - * This will affect this node and all of its descendents. + * 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); @@ -2127,6 +2140,8 @@ /** * Return the global scale that is being applied to this node by its * transform together with the transforms of all its ancestors. + * + * @return global scale of this node */ public double getGlobalScale() { return getLocalToGlobalTransform(null).getScale(); @@ -2148,6 +2163,11 @@ } } + /** + * Returns the x offset of this node as applied by its transform. + * + * @return x offset of this node as applied by its transform + */ public double getXOffset() { if (transform == null) { return 0; @@ -2155,6 +2175,11 @@ return transform.getTranslateX(); } + /** + * Returns the y offset of this node as applied by its transform. + * + * @return y offset of this node as applied by its transform + */ public double getYOffset() { if (transform == null) { return 0; @@ -2164,7 +2189,7 @@ /** * Return the offset that is being applied to this node by its transform. - * This offset effects this node and all of its descendents and is specified + * This offset effects this node and all of its descendants and is specified * in the parent coordinate system. This returns the values that are in the * m02 and m12 positions in the affine transform. * @@ -2179,12 +2204,12 @@ /** * Set the offset that is being applied to this node by its transform. This - * offset effects this node and all of its descendents and is specified in + * 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 point a point representing the x and y offset + * @param point value of new offset */ public void setOffset(final Point2D point) { setOffset(point.getX(), point.getY()); @@ -2192,7 +2217,7 @@ /** * Set the offset that is being applied to this node by its transform. This - * offset effects this node and all of its descendents and is specified in + * 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. @@ -2212,6 +2237,9 @@ * effected by this nodes current scale or rotation. This is implemented by * directly adding dx to the m02 position and dy to the m12 position in the * affine transform. + * + * @param dx amount to add to this nodes current x Offset + * @param dy amount to add to this nodes current y Offset */ public void offset(final double dx, final double dy) { getTransformReference(true); @@ -2221,7 +2249,10 @@ /** * 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 descendents. + * 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); @@ -2233,6 +2264,8 @@ /** * Return the global translation that is being applied to this node by its * transform together with the transforms of all its ancestors. + * + * @return the global translation applied to this node */ public Point2D getGlobalTranslation() { final Point2D p = getOffset(); @@ -2273,11 +2306,14 @@ * computes lerp(a, b, t) = a + t*(b - a). This produces a result that * changes from a (when t = 0) to b (when t = 1). * + * @param t variable 'time' parameter * @param a from point * @param b to Point - * @param t variable 'time' parameter + * + * @return linear interpolation between and b at time interval t (given as # + * between 0f and 1f) */ - static public double lerp(final double t, final double a, final double b) { + public static double lerp(final double t, final double a, final double b) { return a + t * (b - a); } @@ -2312,6 +2348,9 @@ * @param destBounds The bounds (in global coordinates) used to calculate * this transform's node * @param millis Number of milliseconds over which to perform the animation + * + * @return newly scheduled activity or node if activity could not be + * scheduled */ public PActivity animateToRelativePosition(final Point2D srcPt, final Point2D destPt, final Rectangle2D destBounds, final int millis) { @@ -2409,6 +2448,9 @@ * should create a new transform (and assign that transform to the nodes * local transform variable) instead of returning null. * + * @param createNewTransformIfNull if the transform has not been + * initialised, should it be? + * * @return reference to this node's transform */ public PAffineTransform getTransformReference(final boolean createNewTransformIfNull) { @@ -2439,19 +2481,19 @@ /** * Set the transform applied to this node. * - * @param newTransform the new transform value + * @param transform the new transform value */ - public void setTransform(final AffineTransform newTransform) { - if (newTransform == null) { - transform = null; + public void setTransform(final AffineTransform transform) { + if (transform == null) { + this.transform = null; } else { - getTransformReference(true).setTransform(newTransform); + getTransformReference(true).setTransform(transform); } invalidatePaint(); invalidateFullBounds(); - firePropertyChange(PROPERTY_CODE_TRANSFORM, PROPERTY_TRANSFORM, null, transform); + firePropertyChange(PROPERTY_CODE_TRANSFORM, PROPERTY_TRANSFORM, null, this.transform); } // **************************************************************** @@ -2460,7 +2502,7 @@ // painted. // // Generally you will not need to call these invalidate methods - // when starting out with Piccolo because methods such as setPaint + // when starting out with Piccolo2d because methods such as setPaint // already automatically call them for you. You will need to call // them when you start creating your own nodes. // @@ -2537,7 +2579,7 @@ } /** - * Repaint this node and any of its descendents if they have invalid paint. + * Repaint this node and any of its descendants if they have invalid paint. */ public void validateFullPaint() { if (getPaintInvalid()) { @@ -2585,20 +2627,37 @@ } // **************************************************************** - // Occluding - Methods to support occluding optimization. Not yet + // Occluding - Methods to support occluding optimisation. Not yet // complete. // **************************************************************** + /** + * Returns whether this node is Opaque. + * + * @param boundary boundary to check and see if this node covers completely. + * + * @return true if opaque + */ public boolean isOpaque(final Rectangle2D boundary) { return false; } + /** + * Returns whether this node has been flagged as occluded. + * + * @return true if occluded + */ public boolean getOccluded() { return occluded; } - public void setOccluded(final boolean isOccluded) { - occluded = isOccluded; + /** + * Flags this node as occluded. + * + * @param occluded new value for occluded + */ + public void setOccluded(final boolean occluded) { + this.occluded = occluded; } // **************************************************************** @@ -2609,7 +2668,7 @@ // // The default painting behavior is to first paint the node, and // then paint the node's children on top of the node. If a node - // needs wants specialized painting behavior it can override: + // needs wants specialised painting behavior it can override: // // paint() - Painting here will happen before the children // are painted, so the children will be painted on top of painting done @@ -2625,18 +2684,18 @@ /** * Return true if this node is visible, that is if it will paint itself and - * descendents. + * descendants. * - * @return true if this node and its descendents are visible. + * @return true if this node and its descendants are visible. */ public boolean getVisible() { return visible; } /** - * Set the visibility of this node and its descendents. + * Set the visibility of this node and its descendants. * - * @param isVisible true if this node and its descendents are visible + * @param isVisible true if this node and its descendants are visible */ public void setVisible(final boolean isVisible) { if (getVisible() != isVisible) { @@ -2650,29 +2709,36 @@ } /** - * Return the paint used to paint this node. This value may be null. + * Return the paint used while painting this node. This value may be null. + * + * @return the paint used while painting this node. */ public Paint getPaint() { return paint; } /** - * Set the paint used to paint this node. This value may be set to 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 old = paint; + final Paint oldPaint = paint; paint = newPaint; invalidatePaint(); - firePropertyChange(PROPERTY_CODE_PAINT, PROPERTY_PAINT, old, paint); + firePropertyChange(PROPERTY_CODE_PAINT, PROPERTY_PAINT, oldPaint, paint); } /** * Return the transparency used when painting this node. Note that this - * transparency is also applied to all of the node's descendents. + * transparency is also applied to all of the node's descendants. + * + * @return how transparent this node is 0f = completely transparent, 1f = + * completely opaque */ public float getTransparency() { return transparency; @@ -2680,16 +2746,17 @@ /** * Set the transparency used to paint this node. Note that this transparency - * applies to this node and all of its descendents. + * applies to this node and all of its descendants. + * + * @param zeroToOne transparency value for this node. 0f = fully + * transparent, 1f = fully opaque */ public void setTransparency(final float zeroToOne) { - if (transparency == zeroToOne) { - return; + if (transparency != zeroToOne) { + transparency = zeroToOne; + invalidatePaint(); + firePropertyChange(PROPERTY_CODE_TRANSPARENCY, PROPERTY_TRANSPARENCY, null, null); } - - transparency = zeroToOne; - invalidatePaint(); - firePropertyChange(PROPERTY_CODE_TRANSPARENCY, PROPERTY_TRANSPARENCY, null, null); } /** @@ -2708,7 +2775,7 @@ } /** - * Paint this node and all of its descendents. Most subclasses do not need + * Paint this node and all of its descendants. Most subclasses do not need * to override this method, they should override paint or * paintAfterChildren instead. * @@ -2751,7 +2818,7 @@ * Return a new Image representing this node and all of its children. The * image size will be equal to the size of this nodes full bounds. * - * @return a new image representing this node and its descendents + * @return a new image representing this node and its descendants */ public Image toImage() { final PBounds b = getFullBoundsReference(); @@ -2766,9 +2833,12 @@ * * @param width pixel width of the resulting image * @param height pixel height of the resulting image + * @param backgroundPaint paint to fill the image with before drawing this + * node, may be null + * * @return a new image representing this node and its descendents */ - public Image toImage(final int width, final int height, final Paint backGroundPaint) { + public Image toImage(final int width, final int height, final Paint backgroundPaint) { BufferedImage result; if (GraphicsEnvironment.isHeadless()) { @@ -2780,7 +2850,7 @@ result = graphicsConfiguration.createCompatibleImage(width, height, Transparency.TRANSLUCENT); } - return toImage(result, backGroundPaint); + return toImage(result, backgroundPaint); } /** @@ -2788,7 +2858,10 @@ * background, paint is null, then the image will not be filled with a color * prior to rendering * - * @return a rendering of this image and its descendents into the specified + * @param image Image onto which this node will be painted + * @param backGroundPaint will fill background of image with this. May be + * null. + * @return a rendering of this image and its descendants onto the specified * image */ public Image toImage(final BufferedImage image, final Paint backGroundPaint) { @@ -2843,6 +2916,8 @@ * @param graphics the context into which the node is drawn * @param pageFormat the size and orientation of the page * @param pageIndex the zero based index of the page to be drawn + * + * @return Either NO_SUCH_PAGE or PAGE_EXISTS */ public int print(final Graphics graphics, final PageFormat pageFormat, final int pageIndex) { if (pageIndex != 0) { @@ -2962,12 +3037,12 @@ } /** - * Try to pick this node and all of its descendents. Most subclasses should + * Try to pick this node and all of its descendants. Most subclasses should * not need to override this method. Instead they should override * pick or pickAfterChildren. * * @param pickPath the pick path to add the node to if its picked - * @return true if this node or one of its descendents was picked. + * @return true if this node or one of its descendants was picked. */ public boolean fullPick(final PPickPath pickPath) { if (getVisible() && (getPickable() || getChildrenPickable()) && fullIntersects(pickPath.getPickBounds())) { @@ -3001,6 +3076,13 @@ return false; } + /** + * 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()); @@ -3060,6 +3142,7 @@ * 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) { @@ -3094,7 +3177,7 @@ /** * Return true if this node is an ancestor of the parameter node. * - * @param node a possible descendent node + * @param node a possible descendant node * @return true if this node is an ancestor of the given node */ public boolean isAncestorOf(final PNode node) { @@ -3109,7 +3192,7 @@ } /** - * Return true if this node is a descendent of the parameter node. + * Return true if this node is a descendant of the parameter node. * * @param node a possible ancestor node * @return true if this nodes descends from the given node @@ -3127,6 +3210,8 @@ /** * Return true if this node descends from the root. + * + * @return whether this node descends from root node */ public boolean isDescendentOfRoot() { return getRoot() != null; @@ -3147,6 +3232,8 @@ /** * Change the order of this node in its parent's children list so that it * will draw in front of all of its other sibling nodes. + * + * @param sibling sibling in back of which this nodes should be moved. */ public void moveInBackOf(final PNode sibling) { final PNode p = parent; @@ -3172,6 +3259,8 @@ /** * Change the order of this node in its parent's children list so that it * will draw before the given sibling node. + * + * @param sibling sibling in front of which this nodes should be moved. */ public void moveInFrontOf(final PNode sibling) { final PNode p = parent; @@ -3195,6 +3284,8 @@ /** * 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; @@ -3204,6 +3295,9 @@ /** * Return the index where the given child is stored. + * + * @param child child so search for + * @return index of child or -1 if not found */ public int indexOfChild(final PNode child) { if (children == null) { @@ -3389,7 +3483,7 @@ } /** - * Return an iterator over this node's direct descendent children. + * Return an iterator over this node's direct descendant children. * * @return iterator over this nodes children */ @@ -3403,6 +3497,9 @@ /** * Return the root node (instance of PRoot). If this node does not descend * from a PRoot then null will be returned. + * + * @return root element of this node, or null if this node does not descend + * from a PRoot */ public PRoot getRoot() { if (parent != null) { @@ -3412,9 +3509,9 @@ } /** - * Return a collection containing this node and all of its descendent nodes. + * Return a collection containing this node and all of its descendant nodes. * - * @return a new collection containing this node and all descendents + * @return a new collection containing this node and all descendants */ public Collection getAllNodes() { return getAllNodes(null, null); @@ -3422,18 +3519,24 @@ /** * Return a collection containing the subset of this node and all of its - * descendent nodes that are accepted by the given node filter. If the + * descendant nodes that are accepted by the given node filter. If the * filter is null then all nodes will be accepted. If the results parameter * is not null then it will be used to collect this subset instead of * creating a new collection. * * @param filter the filter used to determine the subset - * @return a collection containing this node and all descendents + * @param resultantNodes where matching nodes should be added + * @return a collection containing this node and all descendants */ - public Collection getAllNodes(final PNodeFilter filter, Collection results) { - if (results == null) { + public Collection getAllNodes(final PNodeFilter filter, final Collection resultantNodes) { + Collection results; + if (resultantNodes == null) { results = new ArrayList(); } + else { + results = resultantNodes; + } + if (filter == null || filter.accept(this)) { results.add(this); } @@ -3457,23 +3560,33 @@ // **************************************************************** /** - * Write this node and all of its descendent nodes to the given outputsteam. + * Write this node and all of its descendant nodes to the given outputsteam. * This stream must be an instance of PObjectOutputStream or serialization * will fail. This nodes parent is written out conditionally, that is it * will only be written out if someone else writes it out unconditionally. * * @param out the output stream to write to, must be an instance of * PObjectOutputStream + * @throws IOException when an error occurs speaking to underlying + * ObjectOutputStream */ private void writeObject(final ObjectOutputStream out) throws IOException { + if (!(out instanceof PObjectOutputStream)) { + throw new IllegalArgumentException("PNode.writeObject may only be used with PObjectOutputStreams"); + } out.defaultWriteObject(); ((PObjectOutputStream) out).writeConditionalObject(parent); } /** - * Read this node and all of its descendents in from the given input stream. + * Read this node and all of its descendants in from the given input stream. * * @param in the stream to read from + * + * @throws IOException when an error occurs speaking to underlying + * ObjectOutputStream + * @throws ClassNotFoundException when a class is desiarialized that no + * longer exists. This can happen if it's renamed or deleted. */ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); @@ -3482,11 +3595,18 @@ /** * @deprecated see http://code.google.com/p/piccolo2d/issues/detail?id=99 + * + * @return a string representation of this node's state */ protected String paramString() { return ""; } + /** + * Returns an array of input event listeners that are attached to this node. + * + * @return event listeners attached to this node + */ public PInputEventListener[] getInputEventListeners() { if (listenerList == null || listenerList.getListenerCount() == 0) { return new PInputEventListener[] {}; @@ -3502,25 +3622,25 @@ } /** - * PSceneGraphDelegate is an interface to recive low level node - * events. It together with PNode.SCENE_GRAPH_DELEGATE gives Piccolo users + * PSceneGraphDelegate is an interface to receive low level node + * events. It together with PNode.SCENE_GRAPH_DELEGATE gives Piccolo2d users * an efficient way to learn about low level changes in Piccolo's scene * graph. Most users will not need to use this. */ public interface PSceneGraphDelegate { /** - * Called to notify delegate that the node needs repainting + * Called to notify delegate that the node needs repainting. * * @param node node needing repaint */ - public void nodePaintInvalidated(PNode node); + void nodePaintInvalidated(PNode node); /** * Called to notify delegate that the node and all it's children need - * repainting + * repainting. * * @param node node needing repaint */ - public void nodeFullBoundsInvalidated(PNode node); + void nodeFullBoundsInvalidated(PNode node); } } diff --git a/core/src/main/java/edu/umd/cs/piccolo/PRoot.java b/core/src/main/java/edu/umd/cs/piccolo/PRoot.java index 5f227f4..40ce8cb 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/PRoot.java +++ b/core/src/main/java/edu/umd/cs/piccolo/PRoot.java @@ -42,9 +42,9 @@ import edu.umd.cs.piccolo.util.PNodeFilter; /** - * PRoot serves as the top node in Piccolo's runtime structure. The PRoot - * responsible for running the main UI loop that processes input from activities - * and external events. + * PRoot serves as the top node in Piccolo2D's runtime structure. The + * PRoot responsible for running the main UI loop that processes input from + * activities and external events. *

* * @version 1.1 @@ -65,30 +65,59 @@ * input sources, but old value will always be null. */ public static final String PROPERTY_INPUT_SOURCES = "inputSources"; - public static final int PROPERTY_CODE_INPUT_SOURCES = 1 << 14; - public static final String PROPERTY_INTERACTING_CHANGED = "INTERACTING_CHANGED_NOTIFICATION"; - public static final int PROPERTY_CODE_INTERACTING_CHANGED = 1 << 13; - - protected transient boolean processingInputs; - protected transient boolean processInputsScheduled; - - private transient int interacting; - private PInputManager defaultInputManager; - private transient final List inputSources; - private transient long globalTime; - private final PActivityScheduler activityScheduler; /** - * This interfaces is for advanced use only. If you want to implement a - * different kind of input framework then Piccolo provides you can hook it - * in here. + * The property code that identifies a change in the set of this root's + * input sources (see {@link InputSource InputSource}). In any property + * change event the new value will be a reference to the list of this root's + * input sources, but old value will always be null. */ - public static interface InputSource { - /** - * Causes the system to process any pending Input Events - */ - public void processInput(); - } + public static final int PROPERTY_CODE_INPUT_SOURCES = 1 << 14; + + /** + * The property name that identifies a change in this node's interacting + * state. + */ + public static final String PROPERTY_INTERACTING_CHANGED = "INTERACTING_CHANGED_NOTIFICATION"; + + /** + * The property code that identifies a change in this node's interacting + * state. + */ + public static final int PROPERTY_CODE_INTERACTING_CHANGED = 1 << 13; + + /** Whether this not is currently processing inputs. */ + protected transient boolean processingInputs; + + /** Whether this node needs to have its inputs processed. */ + protected transient boolean processInputsScheduled; + + /** The number of interactions this node is currently participating in. */ + private transient int interacting; + + /** + * The singleton instance of the default input manager. + */ + private PInputManager defaultInputManager; + + /** The Input Sources that are registered to this node. */ + private final transient List inputSources; + + /** + * Used to provide a consistent clock time to activities as they are being + * processed. + * + * Should it happen that an activity step take longer than a millisecond, + * the next step will be unaffected by the change in clock had it used + * System.currentMillis(). + */ + private transient long globalTime; + + /** + * Object responsible for scheduling activities, regardless of where in the + * scene they take place. + */ + private final PActivityScheduler activityScheduler; /** * Construct a new PRoot(). Note the PCanvas already creates a basic scene @@ -110,6 +139,9 @@ * Activities are given a chance to run during each call to the roots * processInputs method. When the activity has finished running * it will automatically get removed. + * + * @param activity Activity that should be scheduled + * @return whether it has been scheduled (always true) */ public boolean addActivity(final PActivity activity) { getActivityScheduler().addActivity(activity); @@ -118,6 +150,8 @@ /** * Get the activity scheduler associated with this root. + * + * @return associated scheduler */ public PActivityScheduler getActivityScheduler() { return activityScheduler; @@ -150,12 +184,11 @@ } } - // **************************************************************** - // Basics - // **************************************************************** - /** - * Return this. + * Since getRoot is handled recursively, and root is the lowest point in the + * hierarchy, simply returns itself. + * + * @return itself */ public PRoot getRoot() { return this; @@ -165,6 +198,8 @@ * Get the default input manager to be used when processing input events. * PCanvas's use this method when they forward new swing input events to the * PInputManager. + * + * @return a singleton instance of PInputManager */ public PInputManager getDefaultInputManager() { if (defaultInputManager == null) { @@ -196,7 +231,7 @@ * @param isInteracting True if this root has user interaction taking place * @see PCanvas#setInteracting(boolean) */ - public void setInteracting(boolean isInteracting) { + public void setInteracting(final boolean isInteracting) { final boolean wasInteracting = getInteracting(); if (isInteracting) { @@ -206,8 +241,7 @@ interacting--; } - isInteracting = getInteracting(); - if (!isInteracting) { + if (!isInteracting && !getInteracting()) { // force all the child cameras to repaint for (int i = 0; i < getChildrenCount(); i++) { final PNode child = getChild(i); @@ -226,7 +260,9 @@ /** * Advanced. If you want to add additional input sources to the roots UI * process you can do that here. You will seldom do this unless you are - * making additions to the piccolo framework. + * making additions to the Piccolo2D framework. + * + * @param inputSource An input source that should be added */ public void addInputSource(final InputSource inputSource) { inputSources.add(inputSource); @@ -236,50 +272,63 @@ /** * Advanced. If you want to remove the default input source from the roots * UI process you can do that here. You will seldom do this unless you are - * making additions to the piccolo framework. + * making additions to the Piccolo2D framework. + * + * @param inputSource input source that should no longer be asked about + * input events */ public void removeInputSource(final InputSource inputSource) { - inputSources.remove(inputSource); - firePropertyChange(PROPERTY_CODE_INPUT_SOURCES, PROPERTY_INPUT_SOURCES, null, inputSources); + if (inputSources.remove(inputSource)) { + firePropertyChange(PROPERTY_CODE_INPUT_SOURCES, PROPERTY_INPUT_SOURCES, null, inputSources); + } } /** * Returns a new timer. This method allows subclasses, such as PSWTRoot to - * create custom timers that will be used transparently by the Piccolo + * create custom timers that will be used transparently by the Piccolo2D * framework. + * + * @param delay # of milliseconds before action listener is invoked + * @param listener listener to be invoked after delay + * + * @return A new Timer */ public Timer createTimer(final int delay, final ActionListener listener) { return new Timer(delay, listener); } // **************************************************************** - // UI Loop - Methods for running the main UI loop of Piccolo. + // UI Loop - Methods for running the main UI loop of Piccolo2D. // **************************************************************** /** - * Get the global Piccolo time. This is set to System.currentTimeMillis() at - * the beginning of the roots processInputs method. Activities - * should usually use this global time instead of System. + * Get the global Piccolo2D time. This is set to System.currentTimeMillis() + * at the beginning of the roots processInputs method. + * Activities should usually use this global time instead of System. * currentTimeMillis() so that multiple activities will be synchronized. + * + * @return time as recorded at the beginning of activity scheduling */ public long getGlobalTime() { return globalTime; } /** - * This is the heartbeat of the Piccolo framework. Pending input events are - * processed. Activities are given a chance to run, and the bounds caches - * and any paint damage is validated. + * This is the heartbeat of the Piccolo2D framework. Pending input events + * are processed. Activities are given a chance to run, and the bounds + * caches and any paint damage is validated. */ public void processInputs() { PDebug.startProcessingInput(); processingInputs = true; globalTime = System.currentTimeMillis(); - final int count = inputSources == null ? 0 : inputSources.size(); - for (int i = 0; i < count; i++) { - final InputSource each = (InputSource) inputSources.get(i); - each.processInput(); + if (inputSources.size() > 0) { + final Iterator inputSourceIterator = inputSources.iterator(); + while (inputSourceIterator.hasNext()) { + final InputSource each = (InputSource) inputSourceIterator.next(); + each.processInput(); + } } activityScheduler.processActivities(globalTime); @@ -290,26 +339,31 @@ PDebug.endProcessingInput(); } + /** {@inheritDoc} */ public void setFullBoundsInvalid(final boolean fullLayoutInvalid) { super.setFullBoundsInvalid(fullLayoutInvalid); scheduleProcessInputsIfNeeded(); } + /** {@inheritDoc} */ public void setChildBoundsInvalid(final boolean childLayoutInvalid) { super.setChildBoundsInvalid(childLayoutInvalid); scheduleProcessInputsIfNeeded(); } + /** {@inheritDoc} */ public void setPaintInvalid(final boolean paintInvalid) { super.setPaintInvalid(paintInvalid); scheduleProcessInputsIfNeeded(); } + /** {@inheritDoc} */ public void setChildPaintInvalid(final boolean childPaintInvalid) { super.setChildPaintInvalid(childPaintInvalid); scheduleProcessInputsIfNeeded(); } + /** {@inheritDoc} */ public void scheduleProcessInputsIfNeeded() { /* * The reason for the special case here (when not in the event dispatch @@ -319,9 +373,9 @@ */ if (!SwingUtilities.isEventDispatchThread()) { /* - * Piccolo is not thread safe and should amost always be called from - * the Swing event dispatch thread. It should only reach this point - * when a new canvas is being created. + * Piccolo2D is not thread safe and should almost always be called + * from the Swing event dispatch thread. It should only reach this + * point when a new canvas is being created. */ return; } @@ -340,4 +394,14 @@ }); } } + + /** + * This interfaces is for advanced use only. If you want to implement a + * different kind of input framework then Piccolo2D provides you can hook it + * in here. + */ + public static interface InputSource { + /** Causes the system to process any pending Input Events. */ + void processInput(); + } } diff --git a/core/src/main/java/edu/umd/cs/piccolo/event/PInputEvent.java b/core/src/main/java/edu/umd/cs/piccolo/event/PInputEvent.java index 6882285..66421bf 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/event/PInputEvent.java +++ b/core/src/main/java/edu/umd/cs/piccolo/event/PInputEvent.java @@ -60,23 +60,46 @@ * @author Jesse Grosjean */ public class PInputEvent { - + /** The underlying Swing Event. */ private final InputEvent inputEvent; + + /** Path relating to the current mouse event. */ private PPickPath pickPath; + + /** Input manager responsible for the creation of this event. */ private final PInputManager inputManager; + + /** Flag used to identify this event as handled. */ private boolean handled; + /** + * Create an event with the given inputManager and based on the given swing + * event. + * + * @param inputManager source of PInputEvent + * @param event underlying swing event + */ public PInputEvent(final PInputManager inputManager, final InputEvent event) { super(); inputEvent = event; this.inputManager = inputManager; } + /** + * Changes the cursor to the one provided and stores it on the cursor stack + * for later retrieval. + * + * @param cursor + */ public void pushCursor(final Cursor cursor) { final PComponent component = getTopCamera().getComponent(); component.pushCursor(cursor); } + /** + * Removes the top most cursor from the cursor stack and sets it as the + * current cursor. + */ public void popCursor() { final PComponent component = getTopCamera().getComponent(); component.popCursor(); @@ -98,6 +121,8 @@ * Return the bottom most camera that is currently painting. If you are * using internal cameras this may be different then what is returned by * getTopCamera. + * + * @return the current PickPath's bottom camera. */ public PCamera getCamera() { return getPath().getBottomCamera(); diff --git a/core/src/main/java/edu/umd/cs/piccolo/event/PInputEventFilter.java b/core/src/main/java/edu/umd/cs/piccolo/event/PInputEventFilter.java index 462e84f..210d127 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/event/PInputEventFilter.java +++ b/core/src/main/java/edu/umd/cs/piccolo/event/PInputEventFilter.java @@ -57,51 +57,106 @@ | InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK | InputEvent.ALT_MASK | InputEvent.ALT_GRAPH_MASK | InputEvent.META_MASK; + /** If event modifiers don't match this exactly, event it filtered. */ private int andMask; + + /** If event modifiers have no bits from orMask enabled, event is filtered. */ private int orMask; + + /** If event modifier has any of the notMask bits on, it is not accepted. */ private int notMask; + + /** Number of clicks that an incoming event must have to be accepted. */ private short clickCount = -1; + /** Whether accepted events should be marked as handled. */ private boolean marksAcceptedEventsAsHandled = false; + /** Whether handled events should be immediately filtered. */ private boolean acceptsAlreadyHandledEvents = false; + + /** Whether key pressed events are accepted. */ private boolean acceptsKeyPressed = true; + + /** Whether key released events are accepted. */ private boolean acceptsKeyReleased = true; + + /** Whether key typed events are accepted. */ private boolean acceptsKeyTyped = true; + /** Whether mouse clicked events are accepted. */ private boolean acceptsMouseClicked = true; + + /** Whether mouse dragged events are accepted. */ private boolean acceptsMouseDragged = true; + + /** Whether mouse entered events are accepted. */ private boolean acceptsMouseEntered = true; + + /** Whether mouse exited events are accepted. */ private boolean acceptsMouseExited = true; + + /** Whether mouse moved events are accepted. */ private boolean acceptsMouseMoved = true; + + /** Whether mouse pressed events are accepted. */ private boolean acceptsMousePressed = true; + + /** Whether mouse released events are accepted. */ private boolean acceptsMouseReleased = true; + + /** Whether mouse wheel rotated events are accepted. */ private boolean acceptsMouseWheelRotated = true; + + /** Whether focus events are accepted. */ private boolean acceptsFocusEvents = true; + /** + * Creates a PInputEventFilter that accepts everything. + */ public PInputEventFilter() { acceptEverything(); } - public PInputEventFilter(final int aAndMask) { + /** + * Creates a PInputEventFilter that will accept events if they have the + * given andMask. + * + * @param andMask exact pattern event modifiers must be to get accepted + */ + public PInputEventFilter(final int andMask) { this(); - andMask = aAndMask; + this.andMask = andMask; } - public PInputEventFilter(final int aAndMask, final int aNotMask) { - this(aAndMask); - notMask = aNotMask; + /** + * Creates a PInputEventFilter that will accept events if they have the + * given andMask and do not contain any of the bits in the notMask. + * + * @param andMask exact pattern event modifiers must be to get accepted + * @param notMask if any or these bits are on event is not accepted + */ + public PInputEventFilter(final int andMask, final int notMask) { + this(andMask); + this.notMask = notMask; } - public boolean acceptsEvent(final PInputEvent aEvent, final int type) { + /** + * Returns true if the passed event is one that is accepted. + * + * @param event Event under consideration + * @param type The type of event encoded as the PInputEvent + * @return true if event is accepted + */ + public boolean acceptsEvent(final PInputEvent event, final int type) { boolean aResult = false; int modifiers = 0; - if (!aEvent.isFocusEvent()) { - modifiers = aEvent.getModifiers(); + if (!event.isFocusEvent()) { + modifiers = event.getModifiers(); } - if (aEvent.isHandled() && !acceptsAlreadyHandledEvents) { + if (event.isHandled() && !acceptsAlreadyHandledEvents) { return false; } @@ -115,7 +170,7 @@ } } - if (aEvent.isMouseEvent() && clickCount != -1 && clickCount != aEvent.getClickCount()) { + if (event.isMouseEvent() && clickCount != -1 && clickCount != event.getClickCount()) { return false; } @@ -175,16 +230,22 @@ } if (aResult && getMarksAcceptedEventsAsHandled()) { - aEvent.setHandled(true); + event.setHandled(true); } return aResult; } + /** + * Makes this filter accept all mouse click combinations. + */ public void acceptAllClickCounts() { clickCount = -1; } + /** + * Makes the filter accept all event types. + */ public void acceptAllEventTypes() { acceptsKeyPressed = true; acceptsKeyReleased = true; @@ -200,6 +261,9 @@ acceptsFocusEvents = true; } + /** + * Makes this filter accept absolutely everything. + */ public void acceptEverything() { acceptAllEventTypes(); setAndMask(0); @@ -208,66 +272,147 @@ acceptAllClickCounts(); } + /** + * Returns whether this filter accepts key pressed events. + * + * @return true if filter accepts key pressed events + */ public boolean getAcceptsKeyPressed() { return acceptsKeyPressed; } + /** + * Returns whether this filter accepts key released events. + * + * @return true if filter accepts key released events + */ public boolean getAcceptsKeyReleased() { return acceptsKeyReleased; } + /** + * Returns whether this filter accepts key typed events. + * + * @return true if filter accepts key typed events + */ public boolean getAcceptsKeyTyped() { return acceptsKeyTyped; } + /** + * Returns whether this filter accepts mouse clicked events. + * + * @return true if filter accepts mouse clicked events + */ public boolean getAcceptsMouseClicked() { return acceptsMouseClicked; } + /** + * Returns whether this filter accepts mouse dragged events. + * + * @return true if filter accepts mouse dragged events + */ public boolean getAcceptsMouseDragged() { return acceptsMouseDragged; } + /** + * Returns whether this filter accepts mouse entered events. + * + * @return true if filter accepts mouse entered events + */ public boolean getAcceptsMouseEntered() { return acceptsMouseEntered; } + /** + * Returns whether this filter accepts mouse exited events. + * + * @return true if filter accepts mouse exited events + */ public boolean getAcceptsMouseExited() { return acceptsMouseExited; } + /** + * Returns whether this filter accepts mouse moved events. + * + * @return true if filter accepts mouse moved events + */ public boolean getAcceptsMouseMoved() { return acceptsMouseMoved; } + /** + * Returns whether this filter accepts mouse pressed events. + * + * @return true if filter accepts mouse pressed events + */ public boolean getAcceptsMousePressed() { return acceptsMousePressed; } + /** + * Returns whether this filter accepts mouse released events. + * + * @return true if filter accepts mouse released events + */ public boolean getAcceptsMouseReleased() { return acceptsMouseReleased; } + /** + * Returns whether this filter accepts mouse wheel rotated events. + * + * @return true if filter accepts mouse wheel rotated events + */ public boolean getAcceptsMouseWheelRotated() { return acceptsMouseWheelRotated; } + /** + * Returns whether this filter accepts focus events. + * + * @return true if filter accepts focus events + */ public boolean getAcceptsFocusEvents() { return acceptsFocusEvents; } + /** + * Returns whether this filter accepts events that have already been flagged + * as handled. + * + * @return true if filter accepts events that have already been flagged as + * handled + */ public boolean getAcceptsAlreadyHandledEvents() { return acceptsAlreadyHandledEvents; } + /** + * Returns whether this filter marks events as handled if they are accepted. + * + * @return true if filter will mark events as filtered if they are accepted + */ public boolean getMarksAcceptedEventsAsHandled() { return marksAcceptedEventsAsHandled; } + /** + * Flags all mouse click events as disallowed, regardless of button + * configuration. + */ public void rejectAllClickCounts() { clickCount = Short.MAX_VALUE; } + /** + * Configures filter so that no events will ever get accepted. By itself not + * terribly useful, but it's a more restrictive starting point than + * acceptAllEvents(); + */ public void rejectAllEventTypes() { acceptsKeyPressed = false; acceptsKeyReleased = false; @@ -283,74 +428,168 @@ acceptsFocusEvents = false; } + /** + * Sets the number of clicks that an incoming event must have to be accepted. + * + * @param aClickCount number clicks that an incoming event must have to be accepted + */ public void setAcceptClickCount(final short aClickCount) { clickCount = aClickCount; } + /** + * Sets whether this filter accepts key pressed events. + * + * @param aBoolean whether filter should accept key pressed events + */ public void setAcceptsKeyPressed(final boolean aBoolean) { acceptsKeyPressed = aBoolean; } + /** + * Sets whether this filter accepts key released events. + * + * @param aBoolean whether filter should accept key released events + */ public void setAcceptsKeyReleased(final boolean aBoolean) { acceptsKeyReleased = aBoolean; } + /** + * Sets whether this filter accepts key typed events. + * + * @param aBoolean whether filter should accept key typed events + */ + public void setAcceptsKeyTyped(final boolean aBoolean) { acceptsKeyTyped = aBoolean; } + /** + * Sets whether this filter accepts mouse clicked events. + * + * @param aBoolean whether filter should accept mouse clicked events + */ public void setAcceptsMouseClicked(final boolean aBoolean) { acceptsMouseClicked = aBoolean; } + /** + * Sets whether this filter accepts mouse dragged events. + * + * @param aBoolean whether filter should accept mouse dragged events + */ public void setAcceptsMouseDragged(final boolean aBoolean) { acceptsMouseDragged = aBoolean; } + /** + * Sets whether this filter accepts mouse entered events. + * + * @param aBoolean whether filter should accept mouse entered events + */ public void setAcceptsMouseEntered(final boolean aBoolean) { acceptsMouseEntered = aBoolean; } + /** + * Sets whether this filter accepts mouse exited events. + * + * @param aBoolean whether filter should accept mouse exited events + */ public void setAcceptsMouseExited(final boolean aBoolean) { acceptsMouseExited = aBoolean; } + /** + * Sets whether this filter accepts mouse moved events. + * + * @param aBoolean whether filter should accept mouse moved events + */ public void setAcceptsMouseMoved(final boolean aBoolean) { acceptsMouseMoved = aBoolean; } + /** + * Sets whether this filter accepts mouse pressed events. + * + * @param aBoolean whether filter should accept mouse pressed events + */ public void setAcceptsMousePressed(final boolean aBoolean) { acceptsMousePressed = aBoolean; } + /** + * Sets whether this filter accepts mouse released events. + * + * @param aBoolean whether filter should accept mouse released events + */ public void setAcceptsMouseReleased(final boolean aBoolean) { acceptsMouseReleased = aBoolean; } + /** + * Sets whether this filter accepts mouse wheel rotation events. + * + * @param aBoolean whether filter should accept mouse wheel rotated events + */ public void setAcceptsMouseWheelRotated(final boolean aBoolean) { acceptsMouseWheelRotated = aBoolean; } + /** + * Sets whether this filter accepts focus events. + * + * @param aBoolean whether filter should accept focus events + */ public void setAcceptsFocusEvents(final boolean aBoolean) { acceptsFocusEvents = aBoolean; } + /** + * Sets and mask used to filter events. All bits of the andMask must be 1s + * for the event to be accepted. + * + * @param aAndMask the and mask to use for filtering events + */ public void setAndMask(final int aAndMask) { andMask = aAndMask; } + /** + * Sets whether already handled events should be accepted. + * + * @param aBoolean whether already handled events should be accepted + */ public void setAcceptsAlreadyHandledEvents(final boolean aBoolean) { acceptsAlreadyHandledEvents = aBoolean; } + /** + * Sets whether events will be marked as dirty once accepted. + * + * @param aBoolean whether events will be marked as dirty once accepted + */ public void setMarksAcceptedEventsAsHandled(final boolean aBoolean) { marksAcceptedEventsAsHandled = aBoolean; } + /** + * Sets not mask used to filter events. If any of the not bits are enabled, + * then the event is not accepted. + * + * @param aNotMask the not mask to use for filtering events + */ public void setNotMask(final int aNotMask) { notMask = aNotMask; } + /** + * Sets or mask used to filter events. If any of the or bits are enabled, + * then the event is accepted. + * + * @param aOrMask the or mask to use for filtering events + */ public void setOrMask(final int aOrMask) { orMask = aOrMask; }