Search in sources :

Example 1 with ImageLoadingListener

use of org.freeplane.view.swing.features.filepreview.ImageLoadingListener in project freeplane by freeplane.

the class MapView method assignViewerToBackgroundComponent.

private void assignViewerToBackgroundComponent(final IViewerFactory factory, final URI uri) {
    try {
        if (fitToViewport) {
            final JViewport vp = (JViewport) getParent();
            if (vp != null) {
                final Dimension viewPortSize = vp.getVisibleRect().getSize();
                backgroundComponent = (JComponent) factory.createViewer(uri, viewPortSize);
            } else
                backgroundComponent = (JComponent) factory.createViewer(uri, new Dimension(1, 1));
        } else
            backgroundComponent = (JComponent) factory.createViewer(uri, zoom);
        ((ScalableComponent) backgroundComponent).setCenter(true);
        ((ScalableComponent) backgroundComponent).setImageLoadingListener(new ImageLoadingListener() {

            public void imageLoaded() {
                repaint();
            }
        });
    } catch (final MalformedURLException e1) {
        LogUtils.severe(e1);
    } catch (final IOException e1) {
        LogUtils.severe(e1);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ImageLoadingListener(org.freeplane.view.swing.features.filepreview.ImageLoadingListener) ScalableComponent(org.freeplane.view.swing.features.filepreview.ScalableComponent) JViewport(javax.swing.JViewport) JComponent(javax.swing.JComponent) Dimension(java.awt.Dimension) IOException(java.io.IOException)

Aggregations

Dimension (java.awt.Dimension)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 JComponent (javax.swing.JComponent)1 JViewport (javax.swing.JViewport)1 ImageLoadingListener (org.freeplane.view.swing.features.filepreview.ImageLoadingListener)1 ScalableComponent (org.freeplane.view.swing.features.filepreview.ScalableComponent)1