moving a generalPath

The GeneralPath class represents a geometric path constructed from straight lines, and quadratic and cubic (Bezier) curves. It can contain multiple subpaths.

i got that, and i created a shape using :

GeneralPath piece = new GeneralPath ();

piece.moveTo(0,0);
piece.curveTo(12,34,45,56,67,78);
.
.
.
piece.closePath();

now each time i draw it using my paint method it’ll start drawing at coordinates 0,0

Without redrawing the piece, how can i move the whole GeneralPath ??

my issue is that if i change the 1st moveTo coordinate, i’ll have to change every following GeneralPath’s instruction coordinate(moveTo (x+ changeInx, y +changeInY))

Is there a way around this ??

Graphics.translate(x,y) or Graphics2D.translate(tx,ty)

The latter being equivalent to Graphics2D.setTransform(AffineTransform.getTranslateInstance(tx,ty))

i use the Graphics2D.translate to paint it in the desired location, though i wanted to be able to translate it so that i can compare whether the mouse click lies within the shape. i’ll be trying the AffineTransform.getTranslateInstance, if you have better technique plz feel free to share and thanks for the response :slight_smile: