This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Where is drawImage(...) ?  RSS feed

 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I had a crazy idea to build a NonAffineTransform object,
Obviously Graphics2D can only use AffineTransform's, so I thought about extending Graphics2D and creating a method setNonAffineTransform(...).

I know this is over ambitious a perhaps impossible, but I noticed in Graphics2D, the drawImage(...) method is abstract, so it has no body.

So whenever I do

What implementation of drawImage is being used?
Nothing seems to extend Graphics2D for the method to be implemented.

Can anyone explain? Thanks
 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quote from J2SE API

Constructs a new Graphics2D object. Since Graphics2D is an abstract class, and since it must be customized by subclasses for different output devices, Graphics2D objects cannot be created directly. Instead, Graphics2D objects must be obtained from another Graphics2D object, created by a Component, or obtained from images such as BufferedImage objects.
 
Chet Haase
author
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We extend Graphics2D internally in a private class (called SunGraphics2D, for the curious); that's where all of the real stuff happens.

You might think about delegating to Graphics2D for all of the real functionality - that would allow you to specialize things as necessary and then defer to Sun's implementation to do the heavy lifting.

Chet.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!