public void setDocument(Document newDocument) {
        // clean up any previous documents
        if (document != null) {
            // parent should dispose, we just want to break reference
            document = null;
        }
        document = newDocument;

        // clean up old document model and create a new one
        if (documentViewModel != null) {
            documentViewModel.dispose();
            documentViewModel = null;
        }
        documentViewModel = new DocumentViewModelImpl(document, documentViewScrollPane);

        // setup view type
        setViewType();

        // remove re-size listener.
        documentViewScrollPane.addComponentListener(this);
        documentViewScrollPane.validate();
    }