[OpenJDK 2D-Dev] Shape.contains - returns true where it should not
Jim Graham
james.graham at oracle.com
Sat Mar 24 00:23:05 UTC 2012
This is not a complete example so I can't run it, but I think I see a
bug in the method you provided.
If I read your example correctly, if contains() returns false for every
location that you test, then you will simply leave firstX and lastX at
the same values they had for the previous line, which might appear that
it "found" a hit, but in reality is simply the fact that you have no
code in there that calls attention to the case where no hit was found
anywhere in the search. Is that perhaps what is happening?
I would initialize firstX to mx+1000 and lastX to -1000 at the top of
the while loop and if lastX <= firstX after both loops had a chance to
look for a fit then I would skip that line as it had no renderable area...
...jim
On 3/19/12 8:32 AM, Geronimo Ma. Hernandez wrote:
> Hello,
>
> I'm working on filling text to arbitrary shapes, where I hit the named problem.
> It's not easy to reproduce, as it depends on fontsize and shape ...
>
> So using the attached code reproduces the attached image.
>
> I use the call Shape.contains(double x, double y, double w, double h) where
> the apidoc says: "Tests if the interior of the Shape entirely contains the
> specified rectangular area."
>
> reaching the last line, there should be no match at all, as most of the given
> rectangle is outside the shape (for all succeeding tests).
> To verify my understanding I draw the tested rectangle when the contains-
> method returns true.
>
> May be, my sample hits the insideness of a point (from Shape-apidocs), where
> the point lies on the shape boundary and the succeeding point is inside the
> shape.
> That might be true for the base point of the rectangle, but it is never true,
> for the entire rectangle.
>
> So this might be considered a bug.
>
>
> kind regards
>
> Gero
More information about the 2d-dev
mailing list