Graphics g;
Graphics2D g2d = (Graphics2D) g;
As my java is a bit rusty I fully intend to learn this. From what I have garnered so far, it is just a simple casting from the Graphics object to a Graphics2D object. Hmm. Graphics apparently is also abstract. I just looked it up on an API.
This kinda throws everything off for me a bit. I had assumed that since Graphics g was a command it would not be abstract.
However I now realize, it is created but not initialized so it still would work, since we only declared it but not initialzied it.
Graphics g = new Graphics() would obviously fail, now I understand that.
Then how could the line
g2d.translate(tx,ty); be called??
... Okay I feel silly. Apparently I mistook interfaces with Abstract Classes. Interfaces are abstract classes in which all the methods are abstract. With an abstract class, you can make it such that only some of the methods are abstract and some aren't.
No comments:
Post a Comment