private void calculateBoundaryBox() { double x = 0, y = 0; double xl = 0, xr = 0; double yu = 0, yl = 0; for (TrackSection section : sections) { x = section.getInitialAnchor().getPosX(); y = section.getInitialAnchor().getPosY(); xl = Math.min(x, xl); yu = Math.min(y, yu); xr = Math.max(x, xr); yl = Math.max(y, yl); } initialAnchor = new Anchor(0, -xl, -yu); boundarywidth = xr - xl; boudaryHeight = yl - yu; }