protected void refresh() {
        Logger.getLogger(PreviewComponent.class.getName()).entering(PreviewComponent.class.getName(), "refresh");
        int width = getParent().getWidth();
        int height = getParent().getHeight() - statusToolBarHeigh;
        int maxWidth = (width / 5) + (width / 2);

        if (previewImage == null) {
            return;
        }
        Logger.getLogger(PreviewComponent.class.getName()).log(Level.FINER, "Refreshing the previewComponent");
        if (imageWidth > (maxWidth)) {
            newWidth = maxWidth;
            float scale = (float) newWidth / (float) imageWidth;
            newHeight = (int) ((float) imageHeight * scale);
            if ((imageHeight * ((float) newWidth / (float) imageWidth)) > (height)) {
                newHeight = height;
                scale = (float) newHeight / (float) imageHeight;
                newWidth = (int) ((float) imageWidth * scale);
            }
        } else {
            newHeight = height;
            float scale = (float) newHeight / (float) imageHeight;
            newWidth = (int) ((float) imageWidth * scale);
            if ((imageWidth * ((float) newHeight / (float) imageHeight)) > (maxWidth)) {
                newWidth = maxWidth;
                scale = (float) newWidth / (float) imageWidth;
                newHeight = (int) ((float) imageHeight * scale);
            }
        }
        
        this.setPreferredSize(new Dimension(newWidth, getHeight()));
        repaint();
        Logger.getLogger(PreviewComponent.class.getName()).exiting(PreviewComponent.class.getName(), "refresh");
    }