Search in sources :

Example 1 with ScalableComponent

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

the class MapView method adjustBackgroundComponentScale.

private void adjustBackgroundComponentScale() {
    if (backgroundComponent != null) {
        if (fitToViewport) {
            final JViewport vp = (JViewport) getParent();
            final Dimension viewPortSize = vp.getVisibleRect().getSize();
            ((ScalableComponent) backgroundComponent).setFinalViewerSize(viewPortSize);
        } else {
            ((ScalableComponent) backgroundComponent).setMaximumComponentSize(getPreferredSize());
            ((ScalableComponent) backgroundComponent).setFinalViewerSize(zoom);
        }
    }
}
Also used : ScalableComponent(org.freeplane.view.swing.features.filepreview.ScalableComponent) JViewport(javax.swing.JViewport) Dimension(java.awt.Dimension)

Example 2 with ScalableComponent

use of org.freeplane.view.swing.features.filepreview.ScalableComponent 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)2 JViewport (javax.swing.JViewport)2 ScalableComponent (org.freeplane.view.swing.features.filepreview.ScalableComponent)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 JComponent (javax.swing.JComponent)1 ImageLoadingListener (org.freeplane.view.swing.features.filepreview.ImageLoadingListener)1