public Complex getCartesian(int x, int y) {
        int width = this.getWidth();
        int height = this.getHeight();
        
        if (width == 0 || height == 0) {
            throw new IllegalStateException("Fractal panel does not have valid dimensions. Width:" + width + " Height:" + height);
        } else {
            // Move the graph into the centre of the container
            double calcX = x - width / 2;
            double calcY = y - height / 2;
            
            // Scale the axes
            calcX *= (rmax - rmin) / width;
            calcY *= (imax - imin) / height;
            
            // Calculate zoom offsets
            // Add the average of the x and y space
            calcX += (rmin + rmax) / 2;
            calcY += (imin + imax) / 2;
            
            return new Complex(calcX, calcY);
        }
    }