title: Java Graphics.drawLine() inexact: drawn lines are too long
body: <p>I have a polygon with the vertices (0,0), (100,0), (100,100), and (0,100).
  I debugged the program and those are the exact lines that java is drawing.
  Instead of drawing an exact square, some of the lines are a pixel too long:<br/>
  <a href="http://gyazo.com/7418546c51c9a10fc690b18afcc96360.png" rel="nofollow">http://gyazo.com/7418546c51c9a10fc690b18afcc96360.png</a><br/>
  (The green circle is just me testing the centroid).
  When I move the square out of the corner, you can see that the top left corner is the only corner that is exactly correct.
  Why is this happening?
  Right before drawLine, I wrote the lines to the console after they were converted to integer coordinates, and they were correct. So I can't see what could possibly be wrong except for the drawLine functions.
  drawLine:</p>
  
  <pre><code>        g.drawLine((int) line.getStart().getX(), (int) line.getStart().getY(), 
              (int) line.getEnd().getX(), (int) line.getEnd().getY());
  </code></pre>
  
  <p>The line has a start vector and an end vector. The vectors contain an x and y.</p>
  
  <p>Even when doing this:</p>
  
  <pre><code>    g.drawLine(0, 0, 100, 0);
      g.drawLine(100, 0, 100, 100);
      g.drawLine(100, 100, 0, 100);
      g.drawLine(0, 100, 0, 0);
  </code></pre>
  
  <p>It still produces the same result.
  This works though:</p>
  
  <pre><code>    g.drawLine(0, 0, 100, 0);
      g.drawLine(101, 0, 101, 100);
      g.drawLine(100, 101, 0, 101);
      g.drawLine(0, 100, 0, 0);
  </code></pre>