Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Graphics 2D  RSS feed

 
Ra Carter
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i hope i can say this properly...

i am trying to make a shape move on screen with the Graphics2D api. previously i was using a Rectangle and going through the process of translating the rectangle and repainting the screen. but then i generalized my class to accept a Shape. i thought using Graphics2D.translate would have the same affect but my object does not appear to move... how can i translate a Shape and have the translation affect on the x, y coordinates stay with the object?
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For animating shapes you can:
1 — keep the shape as a member variable and use a transform to draw it in the new position. To get the x,y position/location of the transformed shape you can transform the location of the original.
2 — redefine the shape each time you move it. The bounds will show the current x,y position/location.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!