*/
    private void zoomCenter(Point centeringPoint) {
        // make sure the point is not null
        if (centeringPoint == null) {
            centeringPoint = getCenteringPoint();
        }

        if (centeringPoint == null || documentViewScrollPane == null)
            return;

        // get view port information
        int scrollpaneWidth = documentViewScrollPane.getViewport().getWidth();
        int scrollpaneHeight = documentViewScrollPane.getViewport().getHeight();

        int scrollPaneX = documentViewScrollPane.getViewport().getViewPosition().x;
        int scrollPaneY = documentViewScrollPane.getViewport().getViewPosition().y;

        Dimension pageSize = documentView.getPreferredSize();
        int pageWidth = pageSize.width;
        int pageHeight = pageSize.height;

        // calculate center coordinates of view port x,y
        centeringPoint.setLocation(centeringPoint.x - (scrollpaneWidth / 2),
                centeringPoint.y - (scrollpaneHeight / 2));

        // compensate centering point to make sure that preferred site is
        // respected when moving the view port x,y.

        // Special case when page height or width is smaller then the viewport
        // size.  Respect the zoom but don't try and center on the click
        if (pageWidth < scrollpaneWidth || pageHeight < scrollpaneHeight) {
            if (centeringPoint.x >= pageWidth - scrollpaneWidth ||
                    centeringPoint.x < 0) {
                centeringPoint.x = scrollPaneX;
            }

            if (centeringPoint.y >= pageHeight - scrollpaneHeight ||
                    centeringPoint.y < 0) {
                centeringPoint.y = scrollPaneY;
            }
        }
        // Special case 2: compensate for click where it is not possible to center
        // the page with out shifting the view port paste the pages width
        else {
            // adjust horizontal
            if (centeringPoint.x + scrollpaneWidth > pageWidth) {
                centeringPoint.x = (pageWidth - scrollpaneWidth);
            } else if (centeringPoint.x < 0) {
                centeringPoint.x = 0;
            }

            // adjust vertical
            if (centeringPoint.y + scrollpaneHeight > pageHeight) {
                centeringPoint.y = (pageHeight - scrollpaneHeight);
            } else if (centeringPoint.y < 0) {
                centeringPoint.y = 0;
            }
        }
        // not sure why, but have to set twice for reliable results
        documentViewScrollPane.getViewport().setViewPosition(centeringPoint);
        documentViewScrollPane.getViewport().setViewPosition(centeringPoint);
    }