• Post Reply Bookmark Topic Watch Topic
  • New Topic

Extending the Shape class  RSS feed

 
Kieran Murray
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

Is there anyway of extending the Shape class.
I want to draw a circle with a sqiggle in it - to represent a generator.

I need to implement this as a Shape as I want to be able to affine transform it with code similar to the one below.

Shape transformedCircle = new Path2D.Double(circle0, atf);
In this case I want my own Shape instead of the circle circle0.

Kind regards,

Apprentice
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By Shape, do you mean java.awt.Shape? That's not a class but an interface. Path2D.Double already implements Shape, and it isn't "final" so you can extend it in the usual fashion.
[ July 20, 2008: Message edited by: Campbell Ritchie ]
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could extend Ellipse2D similar to Ellipse2D.double, but you have to ask yourself how you should override some of the methods. Especially getPathIterator could be a problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!