On Thu, 13 Jun 2002, Matias Rodriguez wrote:

> Hello. I have a doubt about the following code.
>
> GeneralPath p=new GeneralPath();
>
> p.moveTo(0,0);
> p.lineTo(1,0);
> p.lineTo(1,1);
> p.lineTo(0,1);
> p.closePath();
>
> System.out.println(p.contains(0,0)); //prints true
> System.out.println(p.contains(1,1)); //prints false
>
>  Why does the "p.contains(1,1)" returns false and "p.contains(0,0)" returns
> true if both points are part of the Shape? I was expecting to return true
> even if the point is at the boundary.


>From http://java.sun.com/j2se/1.4/docs/api/java/awt/Shape.html

  Definition of insideness: A point is considered to lie inside a Shape if
  and only if:

     + it lies completely inside theShape boundary or
     + it lies exactly on the Shape boundary and the space immediately
       adjacent to the point in the increasing X direction is entirely
       inside the boundary or
     + it lies exactly on a horizontal boundary segment and the space
       immediately adjacent to the point in the increasing Y direction
       is inside the boundary.

All three cases fail for (1,1).

-David


------------------------+--------------------------+
David Eisner            | E-mail: [EMAIL PROTECTED]   |
CALCE EPSC              | Phone:  301-405-5341     |
University of Maryland  | Fax:    301-314-9269     |
------------------------+--------------------------+

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to