There is a subtle terminology problem here I guess.  The term "bounds"
tends to be shorthand for "bounding box" which is an approximation of
the true boundary of an object using a rectangle which is no smaller
than (and hopefully not much larger than, if at all larger) the true
boundary.  It is useful for fast calculations to tell if you are
anywhere near the shape, but it can't tell you if you are actually
inside the shape.

In the docs for the contains() method it uses the term "boundary" which
means the true boundary of the path - i.e. the pixels that would be
captured by a fill operation.  It does not refer to the "bounding box"
which is returned from the getBounds() method.  Perhaps a different term
should be used there for clarity.

So, contains is "really contains", though it may test against the
"bounds - i.e. bounding box" as a quick rejection test before it traces
the path comparing the point to every edge to determine true "insideness"...

                               ...jim

[EMAIL PROTECTED] wrote:
I've a query with regards the java.awt.geom.Path2D.contains() method.  I thought a point 
is considered to lie inside a Shape if and only if: "it lies completely [b]inside 
the Shape's boundary[/b]"
I have a path2D that tells me that a point it does NOT contain point2D p, but 
when I determine the path's bounds, the bounds DOES contain the point p.  How 
is this possible?


                Path2D.Double path = new Path2D.Double();
                path.moveTo( 314000.0, 236500.0 );
                path.lineTo( 316500.0, 236500.0 );
                path.lineTo( 316500.0, 232000.0 );

                Rectangle2D r = path.getBounds2D();
                PathIterator pit = r.getPathIterator( null );
                double[] coords = new double[6];
                while( !pit.isDone() )
                {
                        pit.currentSegment( coords );
                        System.out.println( coords[0] + ", "
                                        + coords[1] );
                        pit.next();
                }

                Point2D.Double p= new Point2D.Double(
                                314400.0, 234454.0 );
                boolean a = r.contains( p);
                System.out.println( a );
                boolean b = path.contains( p);
                System.out.println( b );
[Message sent by forum member 'deirdre' (deirdre)]

http://forums.java.net/jive/thread.jspa?messageID=237130

===========================================================================
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".

===========================================================================
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