I have an ArrayList
in my Method. It contains a special class of Circles. Within ColoredCircle
there is a variable of type Point2D.Double p1
. I have to transform these coordinates on a different coordinate system. When I do that the method is altering my ArrayList, filling it with the transformed coordinates. Why? I didn't even touch my ArrayList
in my transformation method.
public ArrayList<ColoredCircle> algorithm(final ArrayList<ColoredCircle> circleList) {
ColoredCircle a = circleList.get(0);
ColoredCircle b = circleList.get(1);
ColoredCircle c = circleList.get(2);
for (ColoredCircle cr : circleList) {
System.out.println("algo"+ cr.getPoint().getX()+" "+cr.getPoint().getY());
}
Point2D.Double circleCoordinateC1 = this.transorm_coordinates_circle(b.center, a.getPoint());
for (ColoredCircle cr : circleList) {
System.out.println("algo2"+ cr.getPoint().getX()+" "+cr.getPoint().getY());
}
Transormation Method:
public Point2D.Double transorm_coordinates_circle(Point2D.Double circle_center, Point2D.Double point) {
double x = point.getX() - circle_center.getX();
double y = (point.getY() - circle_center.getY()) * -1;
point.setLocation(x, y);
System.out.println("Point "+point.getX()+" "+point.getY());
return point;
}