0

I would like to ask whether it is possible to draw a line using double variables instead of integers. If yes how?

tenorsax
  • 21,123
  • 9
  • 60
  • 107
MBC870
  • 373
  • 3
  • 8
  • 16
  • 1
    Why would you need a double? You wouldn't draw a line that is 22.3px long for example. – Dean Jun 22 '12 at 22:46

2 Answers2

2

You can use Line2D.Double. Use Graphics2D.draw() to draw it.

See Drawing Geometric Primitives for more details and examples.

tenorsax
  • 21,123
  • 9
  • 60
  • 107
1

Like this ?

             Line2D line = new Line2D.Double();
             Graphics2D g2 = aPaintContext.getGraphics();
             for (double x = bx; x < rightBorder; x += 5) {
                line.setLine(x, by, x, bottomBorder);
                g2.draw(line);
Sergii Zagriichuk
  • 5,389
  • 5
  • 28
  • 45