Win a copy of Penetration Testing Basics this week in the Security forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java2D: my Shape's getPathIterator is called with a null AffineTransform

Gabe Johnson
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I've written an object that implements Shape. This object has some crazy coordinates that it uses internally that must be mapped to the screen using a transformation. Consider the following code:

Sequence s; // this is my Shape implementation
Graphics2D g; // using this context
g.scale(0.5, 0.5); // scale by 50%

I have been under the impression that any transformations I do to the Graphics context (the scale statement) will be passed on to my shape when it draws by providing a non-null AffineTransform object in the Shape's getPathIterator(..) method. But when Sequence.getPathIterator(AffineTransform) is called, the transform object is null.

My hacky 'solution' to this problem is to externally tell the Sequence object about the transformation it should use, and then use that whenever the getPathIterator() method is called. But that is a bad solution because it requires too much work. I should be able to tell the Graphics context that there's a transformation I want it to use, and be done with it.

Anybody who helps will be visited with a series of fortuitous events and great karma.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic