• Post Reply Bookmark Topic Watch Topic
  • New Topic

2D drawing question

 
Georgios Fofikos
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi forum!

Lets say that I have drawn a complex 2D shape using CubicCurve2D, drawLines, etc.
Is there a way to define a square around the shape so I can move all of its "components" using only one relative x,y position instead of calculating the different x and y's of the curves, lines and arcs ?
Thank you!
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could draw all the items on a JPanel and move the JPanel around on parent container.
 
Stanislav Lapitsky
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try to use your Graphics' translate(x, y) method.

Or for better code cast the Graphics to Graphics2D. Get the Graphics2D old AffineTransform and store it somehow. Then render your shapes and restore the old AffineTransform.

Regards,
Stas
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!