-
Bug
-
Resolution: Fixed
-
P4
-
1.2.2
-
beta
-
generic
-
generic
Name: krT82822 Date: 08/20/99
Search for "++++" notes:
+++++++++++++++++
the getClipBounds() method states it can return null...
+++++++++++++++++
/**
* Returns the bounding rectangle of the current clipping area.
* This method refers to the user clip, which is independent of the
* clipping associated with device bounds and window visibility.
* If no clip has previously been set, or if the clip has been
* cleared using <code>setClip(null)</code>, this method returns
* <code>null</code>.
* The coordinates in the rectangle are relative to the coordinate
* system origin of this graphics context.
* @return the bounding rectangle of the current clipping area,
* or <code>null</code> if no clip is set.
* @see java.awt.Graphics#getClip
* @see java.awt.Graphics#clipRect
* @see java.awt.Graphics#setClip(int, int, int, int)
* @see java.awt.Graphics#setClip(Shape)
* @since JDK1.1
*/
public abstract Rectangle getClipBounds();
+++++++++++++++++
but the hitClip and getClipBounds(Rectangle) methods don't check for null values!
+++++++++++++++++
/**
* Returns the bounding rectangle of the current clipping area.
* The coordinates in the rectangle are relative to the coordinate
* system origin of this graphics context. This method differs
* from {@link getClipBounds() getClipBounds} in that an existing
* rectangle is used instead of allocating a new one.
* This method refers to the user clip, which is independent of the
* clipping associated with device bounds and window visibility.
* If no clip has previously been set, or if the clip has been
* cleared using <code>setClip(null)</code>, this method returns the
* specified <code>Rectangle</code>.
* @param r the rectangle where the current clipping area is
* copied to. Any current values in this rectangle are
* overwritten.
* @return the bounding rectangle of the current clipping area.
*/
public Rectangle getClipBounds(Rectangle r) {
// FIXME: 1.2 beta3 placeholder, replace for beta4
Rectangle clipRect = getClipBounds();
r.x = clipRect.x;
r.y = clipRect.y;
r.width = clipRect.width;
r.height = clipRect.height;
return r;
}
////////////////////////////
/**
* Returns true if the specified rectangular area intersects
* the bounding rectangle of the current clipping area.
* The coordinates in the rectangle are relative to the coordinate
* system origin of this graphics context.
*
* @param x the x coordinate of the rectangle to test against the clip
* @param y the y coordinate of the rectangle to test against the clip
* @param width the width of the rectangle to test against the clip
* @param height the height of the rectangle to test against the clip
*/
public boolean hitClip(int x, int y, int width, int height) {
// FIXME: 1.2 beta3 placeholder, replace for beta4
return new Rectangle(x,y,width,height).intersects(getClipBounds());
}
++++++++++++++++++
what's more the intersects method of java.awt.Rectangle doesn't check for null passed to it (should return false in such a case)
++++++++++++++++++
/**
* Determines whether or not this <code>Rectangle</code> and the specified
* <code>Rectangle</code> intersect. Two rectangles intersect if
* their intersection is nonempty.
* @param r the specified <code>Rectangle</code>
* @return <code>true</code> if the specified <code>Rectangle</code>
* and this <code>Rectangle</code> insersect;
* <code>false</code> otherwise.
*/
public boolean intersects(Rectangle r) {
return !((r.x + r.width <= x) ||
(r.y + r.height <= y) ||
(r.x >= x + width) ||
(r.y >= y + height));
}
(Review ID: 94169)
======================================================================
- relates to
-
JDK-6513150 Zero scale AffineTransforms gives NPE in SunGraphics2D.getClipBounds()
-
- Open
-