How can I copy a polygon to a new location. I use e.isPopupTrigger()
to select the polygon, but I dont know how to copy it. Is the function of copy similar to the function of translate?
e.g. polygon.translate(x,y)?
Thanks.
EDITED:
//this code doesnt work :-(
if(e.getSource() == Copy){
Polygon copyPolygon = new Polygon();
copyPolygon = selectedTriangle;
copyPolygon.translate(2, 2);
repaint();
}
The problem has been solved with these code :-)
if(e.getSource() == Copy){
Polygon copyPolygon = new Polygon(selectedTriangle.xpoints,selectedTriangle.ypoints,selectedTriangle.npoints);
copyPolygon.translate(10,10);
triangles.add(copyPolygon);
repaint();
}