* @param becauseOfValidFitMode true will update ui elements with zoom state.
     * @param centeringPoint        point to center on.
     * @return true if the zoom level changed, false otherwise.
     */
    private boolean setZoom(float zoom, Point centeringPoint, boolean becauseOfValidFitMode) {
        if (documentViewModel == null) {
            return false;
        }
        // make sure the zoom falls in between the zoom range
        if (zoomLevels != null) {
            if (zoom < zoomLevels[0])
                zoom = zoomLevels[0];
            else if (zoom > zoomLevels[zoomLevels.length - 1])
                zoom = zoomLevels[zoomLevels.length - 1];
        }

        // set a default centering point if null
        if (centeringPoint == null) {
            centeringPoint = getCenteringPoint();
        }
        // grab previous zoom so that zoom factor can be calculated
        float previousZoom = getZoom();

        // apply zoom
        boolean changed = documentViewModel.setViewZoom(zoom);
        // get the view port validate the viewport and shift the components
        documentViewScrollPane.revalidate();

        // center zoom calculation, find current center and pass
        // it along to zoomCenter function.
        if (changed) {
            float zoomFactor = zoom / previousZoom;
            if (centeringPoint != null) {
                centeringPoint.setLocation(
                        centeringPoint.x * zoomFactor,
                        centeringPoint.y * zoomFactor);
            }
        }
        // still center on click
        zoomCenter(centeringPoint);

        // update the UI controls
        if (viewerController != null) {
            viewerController.doCommonZoomUIUpdates(becauseOfValidFitMode);
        }

        return changed;
    }