I am currently stuck on how to centre a SVG image on the viewport after resizing. The code I have currently pushed works around 90% of the time but at arbitrary viewport sizes, the SVG image suddenly appears to be off centred. While debugging I have confirmed that the widthOffset, heightOffset, viewPosition.x, and viewPosition.y variables are indeed what they should be even when the image suddenly appears to be off centred. I have tried adding revalidate() calls to various points in the paintComponent method but nothing has eliminated the arbitrary off centring.