java/swing: Shape questions: serializing and combining

Posted by Jason S on Stack Overflow See other posts from Stack Overflow or by Jason S
Published on 2010-03-18T14:11:26Z Indexed on 2010/03/18 20:01 UTC
Read the original article Hit count: 317

Filed under:
|
|
|

I have two questions about java.awt.Shape. Suppose I have two Shapes, shape1 and shape2.

  1. How can I serialize them in some way so I can save the information to a file and later recreate it on another computer? (Shape is not Serializable but it does have the getPathIterator() method which seems like you could get the information out but it would be kind of a drag + I'm not sure how to reconstruct a Shape object afterwards.)

  2. How can I combine them into a new Shape so that they form a joint boundary? (e.g. if shape1 is a large square and shape2 is a small circle inside the square, I want the combined shape to be a large square with a small circular hole)

© Stack Overflow or respective owner

Related posts about java

Related posts about swing