Robert,
The PathIterator currentSegment method has two outputs:
a. The set of points that describe the current segment. This is stored in
the input float array, as in your example
b. The type of the current segment (not used in your example). This is
returned by the method:
e.g. int segType = pi.currentSegment(coords);
switch(segType){
case pi.SEG_LINETO:
....
>From the PathIterator apidoc:
"SEG_MOVETO and SEG_LINETO types returns one point, SEG_QUADTO returns
two points, SEG_CUBICTO returns 3 points and SEG_CLOSE does not return
any points."
If you want to get a description of your Shape in term of lines only, use
a FlatteningPathIterator. It can be configured so that the lines follow
the original path more or less closely (through the flatness attribute).
I am not sure what you are trying to achieve, but the 2D API supports
sophisticated hit detection that allow you to detect if any Shape was hit
(e.g. on a mouse click). See the Graphics2D.hit method description.
Good luck.
Vincent.
Robert Baldock wrote:
> Greetings all. This is my first post to the list. I'm an Edinburgh-
> based web programmer working for a local web development
> company.
>
> One of my current projects is to build a Java app which generates a
> graphic and an HTML file containing an imagemap to "hotspot" the
> graphic. To do this I need to figure a set of points around the edge
> of the object.
>
> The objects in question are instances of Arc2D and I've seen that
> that this class has a getPathIterator() method which would appear
> to do what I want but I can't find any documentation which explains
> how to use it!
>
> Here's what I've come up with so far:
>
> Arc2D thisArc = new Arc2D.Double(x, y, w, h, startAngle,
> angleSize, Arc2D.PIE);
>
> PathIterator pi = thisArc.getPathIterator(null);
> float[] coords = new float[6];
> while (!pi.isDone()) {
> pi.currentSegment(coords);
> for (int c = 0; c < 6; c++) {
> pi.next();
> }
> }
>
> It's certainly doing something. However, I can't make any sense of
> the values being put into the coords array. And besides, I only
> need one co-ordinate per segment rather than 6!
>
> Other options which occurred to me might be able to achieve
> similar results include:
>
> - mapping the Arc2D to a Polygon and extracting the vertex co-
> ordinates.
> - throwing a GeneralPath around the Arc2D and somehow
> extracting the co-ordinates from that.
>
> However, I have found no way to easily achieve either of these.
>
> Can anyone out there offer some assistance?
>
> Robbie
>
> --------------------------------------------------------
> Robert Baldock
> [EMAIL PROTECTED]
> http://www.rcb.easynet.co.uk/
> --------------------------------------------------------
> =====================================================================
> To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
> Java 2D Home Page: http://java.sun.com/products/java-media/2D/
--
+-----------------------------------------------------------+
| Vincent Hardy [EMAIL PROTECTED] |
| Java Architect Java Solution Center |
| 650-470-2063 Menlo Park |
+-----------------------------------------------------------+
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 2D Home Page: http://java.sun.com/products/java-media/2D/