0

Move object focus

in java if i draw an oval to the screen, say I did this.. fillOval(x,y,4,4); it will draw an oval 4x4 starting at the top left of the oval and spreading right and down.. how can I move that ovals x, y to be the center of the oval instead of the upper left? say I want to grow and shrink it, I want to do that from the center.

13th Mar 2017, 9:32 PM
LordHill
LordHill - avatar
6 Réponses
+ 12
You have to use AffineTransform.createTransformedShape(Shape) then. That returns a new Shape object defined by the geometry of the specified Shape after it has been transformed by this transform. I'd like to mention that you should prefer learning JavaFX instead of awt.
13th Mar 2017, 9:47 PM
Tashi N
Tashi N - avatar
+ 9
Which gui api? Which class of the api do you use to draw the oval?
13th Mar 2017, 9:36 PM
Tashi N
Tashi N - avatar
+ 1
awesome, thanks for pointing me in the right direction, I am off to do some research on affinetransform.. as soon as I finish what I'm working on I will look into JavaFX.. Thanks Tashi!
13th Mar 2017, 9:49 PM
LordHill
LordHill - avatar
+ 1
your right. I have been checking into JavaFX and it looks to be right up my ally. when I finish my game (almost done, maybe another week) I am going to switch over to JavaFX.
14th Mar 2017, 9:50 PM
LordHill
LordHill - avatar
0
I use paintComponent() with Graphics2d generally. I am a noob, but I think it's part of the JComponents
13th Mar 2017, 9:38 PM
LordHill
LordHill - avatar
0
I found a way to hack it to make it work how I want (by moving the x and y inward as I shrink the size), I am just curious if there is a proper way to accomplish this
13th Mar 2017, 9:44 PM
LordHill
LordHill - avatar