I've had to solve the problem of mapping between screen and user coordinates several times in Java, so I wrote ZoomRect.java, a convenience class that converts between an arbitrary rectangle and the screen canvas. I have no idea how useful it really is, but I think it does a good job of abstracting out this problem.
Internally, it automatically takes care of aspect ratios with this line of code:
int size=Math.min(canvas.width, canvas.height);
which adds extra space on the shorter dimension. You could change it to Math.max
to instead crop the longer dimension.
Using it is straightforward:
this.trans = new ZoomRect(this.getSize(), myCoords).getTransform());
graphics.transform(this.trans);
Once you have your canvas using it, you can, say, iterate through the points on your canvas, convert them to complex numbers, and run them through your algorithm.