4 Replies - 317 Views - Last Post: 02 March 2013 - 12:16 PM Rate Topic: -----

#1 poldz123  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 52
  • Joined: 26-October 12

drawImage in graphics only for INT numbers?

Posted 01 March 2013 - 10:30 PM

Is there any way that I can draw with doubles number in the paintComponent method for JPanel?

I really need it to draw with double numbers
Is This A Good Question/Topic? 0
  • +

Replies To: drawImage in graphics only for INT numbers?

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10376
  • View blog
  • Posts: 38,415
  • Joined: 27-December 08

Re: drawImage in graphics only for INT numbers?

Posted 01 March 2013 - 10:33 PM

Pixels are discrete points. You can only paint at integer coordinates.

Per the documentation: Graphics class
Was This Post Helpful? 1
  • +
  • -

#3 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 822
  • View blog
  • Posts: 2,529
  • Joined: 29-July 11

Re: drawImage in graphics only for INT numbers?

Posted 02 March 2013 - 04:36 AM

Yeah. I don't get that, because you can draw Strings with

drawString(String s, float x, float y);



What's up with that?
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10376
  • View blog
  • Posts: 38,415
  • Joined: 27-December 08

Re: drawImage in graphics only for INT numbers?

Posted 02 March 2013 - 11:13 AM

Maybe I'm just blind, but according to the documentation I linked to, I only saw a drawString() method with int parameters. Why is it so important to be able to use floating point numbers anyways?
Was This Post Helpful? 0
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: drawImage in graphics only for INT numbers?

Posted 02 March 2013 - 12:16 PM

Unless you have noted these methods (both in Graphics and Graphics2D) are abstract because you want an universal way to address a Graphic Card that can work (you don't know) with pixels or double coordinates. So they just delegate to the native code of the Graphic Card.

An affine transform will require double, a drawSring will need it to compute, based on the Font characteristics if the actual drawing will start at pixel: X,Y or X+1,Y or X,Y+1 or X+1,Y+1 based on certain rounding algorithm
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1