Search in sources :

Example 46 with MapView

use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.

the class ConnectorView method getModeController.

private ModeController getModeController() {
    NodeView nodeView = source;
    if (source == null) {
        nodeView = target;
    }
    final MapView mapView = nodeView.getMap();
    return mapView.getModeController();
}
Also used : MapView(org.freeplane.view.swing.map.MapView) NodeView(org.freeplane.view.swing.map.NodeView)

Example 47 with MapView

use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.

the class ExternalResource method setZoom.

public void setZoom(final float r) {
    zoom = r;
    for (final NodeView nodeView : viewers) {
        final JComponent viewer = nodeView.getContent(ViewerController.VIEWER_POSITION);
        final MapView mapView = (MapView) SwingUtilities.getAncestorOfClass(MapView.class, viewer);
        final Dimension preferredSize = ((ScalableComponent) viewer).getOriginalSize();
        preferredSize.width = (int) (preferredSize.width * r);
        preferredSize.height = (int) (preferredSize.height * r);
        preferredSize.width = mapView.getZoomed(preferredSize.width);
        preferredSize.height = mapView.getZoomed(preferredSize.height);
        ((ScalableComponent) viewer).setFinalViewerSize(preferredSize);
        viewer.revalidate();
    }
}
Also used : JComponent(javax.swing.JComponent) MapView(org.freeplane.view.swing.map.MapView) Dimension(java.awt.Dimension) NodeView(org.freeplane.view.swing.map.NodeView)

Example 48 with MapView

use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.

the class NodeHistory method go.

private void go(final boolean back) {
    final NodeHolder lastNodeHolder = currentNodeHolder;
    if (back) {
        if (canGoBack()) {
            nodeIterator.previous();
            nodeIterator.previous();
            currentNodeHolder = nodeIterator.next();
        } else {
            backAction.setEnabled(false);
            return;
        }
    } else {
        if (canGoForward()) {
            currentNodeHolder = nodeIterator.next();
        } else {
            forwardAction.setEnabled(false);
            return;
        }
    }
    if (lastNodeHolder.equals(currentNodeHolder)) {
        go(back);
        return;
    }
    final NodeModel toBeSelected = currentNodeHolder.getNode();
    if (removed(toBeSelected)) {
        currentNodeHolder = lastNodeHolder;
        go(back);
        return;
    }
    boolean changeModule = false;
    MapView newModule = null;
    if (lastNodeHolder.getHoldMapView() != currentNodeHolder.getHoldMapView()) {
        changeModule = true;
        newModule = currentNodeHolder.getMapView();
        if (newModule == null) {
            nodeIterator.remove();
            go(back);
            return;
        }
    }
    final boolean fChangeModule = changeModule;
    final MapView newView;
    if (fChangeModule) {
        newView = newModule;
        final Controller controller = newView.getModeController().getController();
        final IMapViewManager mapViewManager = controller.getMapViewManager();
        final boolean res = mapViewManager.changeToMapView(newView);
        if (!res) {
            LogUtils.warn("Can't change to map mapView " + newView);
            return;
        }
    } else {
        newView = currentNodeHolder.getHoldMapView();
    }
    if (!toBeSelected.isRoot()) {
        newView.getModeController().getMapController().setFolded(toBeSelected.getParentNode(), false);
    }
    newView.getModeController().getMapController().select(toBeSelected);
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) NodeModel(org.freeplane.features.map.NodeModel) MapView(org.freeplane.view.swing.map.MapView) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) LinkController(org.freeplane.features.link.LinkController)

Example 49 with MapView

use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.

the class ViewerLayoutManager method layoutContainer.

public void layoutContainer(final Container parent) {
    if (!parent.isPreferredSizeSet()) {
        throw new IllegalStateException("preferred size not set for " + parent);
    }
    final Dimension preferredSize = parent.getPreferredSize();
    final MapView mapView = (MapView) SwingUtilities.getAncestorOfClass(MapView.class, parent);
    if (mapView == null) {
        return;
    }
    final float newZoom = mapView.getZoom();
    if (zoom != newZoom) {
        final float ratio = newZoom / zoom;
        preferredSize.width = (int) (Math.rint(preferredSize.width * ratio));
        preferredSize.height = (int) (Math.rint(preferredSize.height * ratio));
        parent.setPreferredSize(preferredSize);
        zoom = newZoom;
    }
}
Also used : MapView(org.freeplane.view.swing.map.MapView) Dimension(java.awt.Dimension)

Example 50 with MapView

use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.

the class NodeHolder method getMapView.

MapView getMapView() {
    final MapView mapView = mMapView.get();
    final Controller controller = mapView.getModeController().getController();
    final MapViewController mapViewManager = (MapViewController) controller.getMapViewManager();
    for (final MapView m : mapViewManager.getMapViewVector()) {
        if (m == mapView) {
            return mapView;
        }
    }
    return null;
}
Also used : MapView(org.freeplane.view.swing.map.MapView) MapViewController(org.freeplane.view.swing.map.MapViewController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) MapViewController(org.freeplane.view.swing.map.MapViewController)

Aggregations

MapView (org.freeplane.view.swing.map.MapView)55 NodeView (org.freeplane.view.swing.map.NodeView)20 ModeController (org.freeplane.features.mode.ModeController)19 Point (java.awt.Point)15 NodeModel (org.freeplane.features.map.NodeModel)13 Controller (org.freeplane.features.mode.Controller)11 Component (java.awt.Component)9 MainView (org.freeplane.view.swing.map.MainView)9 Dimension (java.awt.Dimension)8 JComponent (javax.swing.JComponent)8 MMapController (org.freeplane.features.map.mindmapmode.MMapController)7 ResourceController (org.freeplane.core.resources.ResourceController)6 MapController (org.freeplane.features.map.MapController)6 MTextController (org.freeplane.features.text.mindmapmode.MTextController)5 IMapViewManager (org.freeplane.features.ui.IMapViewManager)5 Color (java.awt.Color)4 Rectangle (java.awt.Rectangle)4 LocationController (org.freeplane.features.nodelocation.LocationController)4 MLocationController (org.freeplane.features.nodelocation.mindmapmode.MLocationController)4 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)4