Reputation: 1
g.fillRect( 70, 250, 20, 144 );
g.fillRect( 100, 250, 20, 98 );
If I use that to draw a bar graph
I get the following result:
I want the bars to look like:
I know that I can get that result by doing:
g.fillRect( 70, 200-144, 20, 144 );
g.fillRect( 100, 200-98, 20, 98 );
I'm new to Java and I don't really understand whats happening here and how that fixes the problem can someone explain to me why the downside of the bars after the subtraction are aligned?
I know what the four parameters are for. the first 2 are for x, y position and last two are for the width and length.
Upvotes: 0
Views: 1924
Reputation: 1897
Coordinate systems in almost all (native) GUI programming setups start in the upper left corner pixel. Looks like you're assuming it starts in the lower left.
So the pixel 0,0 is the top left pixel, not the bottom left. (1000,1000) is right 1000 pixels and down 1000 pixels from the top left.
Upvotes: 1