title: Creating a composite Shape in Java 2D
body: <p>Using Java 2D I've patched several Bezier curves (<code>CubicCurve2D</code>) together to create a "blob".  The problem I now face is how to:</p>
  
  <ol>
  <li>Efficiently fill the blob with a given colour.</li>
  <li>Efficiently determine whether a given point lies inside the blob.</li>
  </ol>
  
  <p>I noticed thst <code>CubicCurve2D</code> implements <code>Shape</code> which provides numerous <code>contains</code> methods for determining "insideness" and that <code>Graphics2D</code> is able to fill a <code>Shape</code> via the <code>fill(Shape)</code> (which I believe uses <code>Shape</code>'s <code>getPathIterator</code> methods to do this).  </p>
  
  <p>Given this I was hoping I could create a composite <code>Shape</code>, whereby my <code>getPathIterator(AffineTransform)</code> method would simply link the underlying <code>PathIterator</code>s together.  However, this is producing a <code>NoSuchElementException</code> once my shape contains more than one <code>CubicCurve2D</code>.  Even if I do manage to achieve this I'm not convinced it will work as expected because a <code>CubicCurve2D</code> is always filled on the convex side, and my "blob" is composed of concave and convex curves.  The "contains" problem is even harder as a point can legitimately lie within the blob but not within any of the individual curves.</p>
  
  <ul>
  <li>Am I approaching this problem in the correct way (trying to implement <code>Shape</code>?) or is there an idiomatic way to do this that I'm unaware of?  I would have thought that the problem of compositing geometric shapes would be fairly common.</li>
  <li>Does anyone have any suggestions regarding how to solve this problem?</li>
  </ul>
  
  <p>Thanks in advance.</p>