Results 1 to 3 of 3
- 02-05-2012, 12:32 PM #1
Member
- Join Date
- Jan 2012
- Posts
- 15
- Rep Power
- 0
converting double to pixel coordinates
hi all,
in my program i have a circle in a panel, that i want it to move0 on a parabola of equation y = ax2. in the circle class i have created a move method that moves that this circle using the repaint() method but the problem that i am having is that the filloval(int x, int y, int w, int h) does not accept double variables for x and y. for this reason my parabola trajectory is not so precise and the circle seems to jump instead of moving.
i want to ask how can i make my circle move in smaller intervals to make it move instead of jumping.
i was thinking of converting the double variables to pixel variables? does there exist any method that can do this
thanks for any help.
- 02-05-2012, 01:51 PM #2
Re: converting double to pixel coordinates
Can you give some examples of this?converting the double variables to pixel variables?
pixels are referenced by int values: 0 to width and 0 to height of the panel. There isn't a pixel at 4.345 There is a pixel at 4 and there is a pixel at 5.
Look at the classes in the java.awt.geom package. Many of them take doubles are arguments.
- 02-05-2012, 06:43 PM #3
Re: converting double to pixel coordinates
All Graphics objects are instances of Graphics2D. You can cast the reference, apply suitable RenderingHints and draw or fill a Shape -- which may have subpixel coordinates.
Have you gone through the 2D Graphics tutorial? For now you could start with Drawing Geometric Primitives (The Java™ Tutorials > 2D Graphics > Working with Geometry) but you should go through the whole tutorial trail as soon as you get the time.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
how to plot a curve which has double datatype coordinates
By murdplacid in forum Java 2DReplies: 6Last Post: 11-02-2010, 04:14 PM -
Converting double to char array?
By Blasz in forum New To JavaReplies: 9Last Post: 08-29-2010, 07:32 PM -
NullPointerException converting String to double
By infaddict in forum New To JavaReplies: 3Last Post: 07-19-2008, 06:01 PM -
Converting String to Double
By srini in forum New To JavaReplies: 1Last Post: 12-24-2007, 08:03 PM -
Arc2D.Double coordinates
By alley in forum Java 2DReplies: 2Last Post: 11-07-2007, 10:27 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks