Anuroop Kuppam
Anuroop Kuppam

Reputation: 167

draw method implementation in graphics2D class

I desperately want to know the implementation of draw method in Graphics2D class. I am actually looking for , how the draw method can draw a Shape.

Upvotes: 2

Views: 2130

Answers (3)

helios
helios

Reputation: 13841

Maybe this can help: http://en.wikipedia.org/wiki/Bresenham's_line_algorithm

It explains some common algorithms for drawing lines. It's applied math to select what pixels must be painted in an optimized way.

Upvotes: 0

jbranchaud
jbranchaud

Reputation: 6087

Edit: Sorry, I have misunderstood the question. I thought OP wanted to know how to use draw in Graphics2D, but it seems that the question is more about how the draw method is implemented under-the-hood.


Oracle has a decent introductory tutorial on this kind of thing.

For instance, to create a rectangle, your code would look something like this:

// draw Rectangle2D.Double
g2.draw(new Rectangle2D.Double(x, y,
                               rectwidth,
                               rectheight));

Upvotes: 0

Amir Afghani
Amir Afghani

Reputation: 38531

grepcode is your friend.

Upvotes: 3

Related Questions