Search in sources :

Example 1 with MapBackgroundImageAction

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

the class MLogicalStyleController method initM.

public void initM() {
    final ModeController modeController = Controller.getCurrentModeController();
    modeController.getMapController().addNodeChangeListener(new StyleRemover());
    modeController.registerExtensionCopier(new ExtensionCopier());
    modeController.addAction(new RedefineStyleAction());
    modeController.addAction(new NewUserStyleAction());
    modeController.addAction(new ManageMapConditionalStylesAction());
    modeController.addAction(new ManageNodeConditionalStylesAction());
    modeController.addAction(new CopyStyleExtensionsAction());
    if (modeController.getModeName().equals("MindMap")) {
        modeController.addAction(new MapBackgroundColorAction());
        modeController.addAction(new MapBackgroundImageAction());
        modeController.addAction(new MapBackgroundClearAction());
        modeController.addAction(new SetBooleanMapPropertyAction(MapStyle.FIT_TO_VIEWPORT));
        modeController.addAction(new CopyMapStylesAction());
    }
    if (!modeController.getController().getViewController().isHeadless()) {
        final IUserInputListenerFactory userInputListenerFactory = modeController.getUserInputListenerFactory();
        final MenuBuilder menuBuilder = userInputListenerFactory.getMenuBuilder(MenuBuilder.class);
        // TODO RIBBONS - apply to ribbons as well
        Controller.getCurrentController().getMapViewManager().addMapSelectionListener(new IMapSelectionListener() {

            public void beforeMapChange(final MapModel oldMap, final MapModel newMap) {
                removeStyleMenu(menuBuilder, "main_menu_styles");
                removeStyleMenu(menuBuilder, "node_popup_styles");
            }

            public void afterMapChange(final MapModel oldMap, final MapModel newMap) {
                addStyleMenu(menuBuilder, "main_menu_styles", newMap);
                addStyleMenu(menuBuilder, "node_popup_styles", newMap);
            }
        });
        final MapController mapController = modeController.getMapController();
        mapController.addMapChangeListener(new IMapChangeListener() {

            public void onPreNodeMoved(final NodeModel oldParent, final int oldIndex, final NodeModel newParent, final NodeModel child, final int newIndex) {
            }

            public void onPreNodeDelete(final NodeModel oldParent, final NodeModel selectedNode, final int index) {
            }

            public void onNodeMoved(final NodeModel oldParent, final int oldIndex, final NodeModel newParent, final NodeModel child, final int newIndex) {
            }

            public void onNodeInserted(final NodeModel parent, final NodeModel child, final int newIndex) {
            }

            public void onNodeDeleted(final NodeModel parent, final NodeModel child, final int index) {
            }

            public void mapChanged(final MapChangeEvent event) {
                if (event.getProperty().equals(MapStyle.MAP_STYLES)) {
                    removeStyleMenu(menuBuilder, "main_menu_styles");
                    addStyleMenu(menuBuilder, "main_menu_styles", event.getMap());
                    removeStyleMenu(menuBuilder, "node_popup_styles");
                    addStyleMenu(menuBuilder, "node_popup_styles", event.getMap());
                }
            }
        });
        mapController.addNodeSelectionListener(new INodeSelectionListener() {

            public void onSelect(final NodeModel node) {
                selectActions();
            }

            public void onDeselect(final NodeModel node) {
            }
        });
    }
}
Also used : IMapSelectionListener(org.freeplane.features.map.IMapSelectionListener) IMapChangeListener(org.freeplane.features.map.IMapChangeListener) IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) MapBackgroundImageAction(org.freeplane.view.swing.features.filepreview.MapBackgroundImageAction) IExtensionCopier(org.freeplane.features.map.IExtensionCopier) ModeController(org.freeplane.features.mode.ModeController) MapModel(org.freeplane.features.map.MapModel) MenuBuilder(org.freeplane.core.ui.MenuBuilder) MapController(org.freeplane.features.map.MapController) INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener) NodeModel(org.freeplane.features.map.NodeModel) MapBackgroundClearAction(org.freeplane.view.swing.features.filepreview.MapBackgroundClearAction) MapChangeEvent(org.freeplane.features.map.MapChangeEvent)

Aggregations

IUserInputListenerFactory (org.freeplane.core.ui.IUserInputListenerFactory)1 MenuBuilder (org.freeplane.core.ui.MenuBuilder)1 IExtensionCopier (org.freeplane.features.map.IExtensionCopier)1 IMapChangeListener (org.freeplane.features.map.IMapChangeListener)1 IMapSelectionListener (org.freeplane.features.map.IMapSelectionListener)1 INodeSelectionListener (org.freeplane.features.map.INodeSelectionListener)1 MapChangeEvent (org.freeplane.features.map.MapChangeEvent)1 MapController (org.freeplane.features.map.MapController)1 MapModel (org.freeplane.features.map.MapModel)1 NodeModel (org.freeplane.features.map.NodeModel)1 ModeController (org.freeplane.features.mode.ModeController)1 MapBackgroundClearAction (org.freeplane.view.swing.features.filepreview.MapBackgroundClearAction)1 MapBackgroundImageAction (org.freeplane.view.swing.features.filepreview.MapBackgroundImageAction)1