Skip to content

Using toJava2D() with group shapes #91

Answered by micycle1
istinnstudio asked this question in Q&A
Discussion options

You must be logged in to vote

The output of the triangulation is a group-type PShape, which consists of multiple child shapes, each representing a triangle in the triangulated geometry.

The toJava2D() method converts group shapes (multipolygons) to a JTS GeometryCollectionShape type, which implements java.awt.shape. However, since the original shape contains multiple paths, it cannot be directly converted to a Path2D.

To work with the triangulation, you have two options:

  1. Cast the output of toJava2D() to a (GeometryCollectionShape) instead, and then use its getPathIterator() method...
  2. Iterate over the child PShapes of the triangulation. For each child, you can call toJava2D() that should return a Path2D representing t…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by istinnstudio
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants