Search in sources :

Example 81 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class Slide method getCurrentPlacedNode.

public NodeModel getCurrentPlacedNode() {
    if (placedNodeId != null) {
        MapModel map = getMap();
        NodeModel currentPlacedNode = map.getNodeForID(placedNodeId);
        final IMapSelection selection = Controller.getCurrentController().getSelection();
        if (currentPlacedNode != null && currentPlacedNode.hasVisibleContent()) {
            return currentPlacedNode;
        } else {
            return selection.getSelected();
        }
    } else
        return null;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection) MapModel(org.freeplane.features.map.MapModel)

Example 82 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class Slide method applyFilter.

private void applyFilter() {
    MapModel map = getMap();
    final ICondition condition = getEffectiveFilterCondition();
    new Filter(condition, showsAncestors, showsDescendants, false).applyFilter(this, map, false);
}
Also used : Filter(org.freeplane.features.filter.Filter) MapModel(org.freeplane.features.map.MapModel) ICondition(org.freeplane.features.filter.condition.ICondition)

Example 83 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class NoteController method getNoteCSSStyle.

protected String getNoteCSSStyle(ModeController modeController, NodeModel node, float zoom, boolean asHtmlFragment) {
    final StringBuilder rule = new StringBuilder();
    // set default font for notes:
    final NodeStyleController style = (NodeStyleController) Controller.getCurrentModeController().getExtension(NodeStyleController.class);
    MapModel map = modeController.getController().getMap();
    if (map != null) {
        final MapStyleModel model = MapStyleModel.getExtension(map);
        final NodeModel noteStyleNode = model.getStyleNodeSafe(MapStyleModel.NOTE_STYLE);
        final Font noteFont = style.getFont(noteStyleNode);
        Color noteBackground = style.getBackgroundColor(noteStyleNode);
        Color noteForeground = style.getColor(noteStyleNode);
        final int alignment = style.getHorizontalTextAlignment(noteStyleNode).swingConstant;
        final CssRuleBuilder cssRuleBuilder = new CssRuleBuilder();
        if (asHtmlFragment)
            cssRuleBuilder.withHTMLFont(noteFont);
        else
            cssRuleBuilder.withCSSFont(noteFont);
        cssRuleBuilder.withColor(noteForeground).withBackground(noteBackground).withAlignment(alignment);
        if (asHtmlFragment)
            cssRuleBuilder.withMaxWidthAsPt(zoom, NodeSizeModel.getMaxNodeWidth(noteStyleNode), style.getMaxWidth(node));
        rule.append(cssRuleBuilder);
    }
    return rule.toString();
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) CssRuleBuilder(org.freeplane.core.ui.components.html.CssRuleBuilder) MapStyleModel(org.freeplane.features.styles.MapStyleModel) Color(java.awt.Color) MapModel(org.freeplane.features.map.MapModel) Font(java.awt.Font)

Example 84 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class CopyMapStylesAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final Controller controller = Controller.getCurrentController();
    final ModeController modeController = controller.getModeController();
    final MFileManager fileManager = MFileManager.getController(modeController);
    final JFileChooser fileChooser = fileManager.getFileChooser(true);
    fileChooser.setMultiSelectionEnabled(false);
    final int returnVal = fileChooser.showOpenDialog(controller.getMapViewManager().getMapViewComponent());
    if (returnVal != JFileChooser.APPROVE_OPTION) {
        return;
    }
    File file = fileChooser.getSelectedFile();
    if (!file.exists()) {
        return;
    }
    try {
        final URL url = Compat.fileToUrl(file);
        final MapModel map = controller.getMap();
        MapStyle mapStyleController = MapStyle.getController(modeController);
        mapStyleController.copyStyle(url, map, true);
    } catch (MalformedURLException e1) {
        e1.printStackTrace();
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) JFileChooser(javax.swing.JFileChooser) MapStyle(org.freeplane.features.styles.MapStyle) MFileManager(org.freeplane.features.url.mindmapmode.MFileManager) ModeController(org.freeplane.features.mode.ModeController) MapModel(org.freeplane.features.map.MapModel) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) File(java.io.File) URL(java.net.URL)

Example 85 with MapModel

use of org.freeplane.features.map.MapModel 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()) {
        modeController.addUiBuilder(Phase.ACTIONS, "style_actions", new StyleMenuBuilder(modeController), new ChildActionEntryRemover(modeController));
        final IUserInputListenerFactory userInputListenerFactory = modeController.getUserInputListenerFactory();
        Controller.getCurrentController().getMapViewManager().addMapSelectionListener(new IMapSelectionListener() {

            public void beforeMapChange(final MapModel oldMap, final MapModel newMap) {
            }

            public void afterMapChange(final MapModel oldMap, final MapModel newMap) {
                userInputListenerFactory.rebuildMenus(STYLE_ACTIONS);
            }
        });
        final MapController mapController = modeController.getMapController();
        mapController.addMapChangeListener(new IMapChangeListener() {

            public void onPreNodeMoved(NodeMoveEvent nodeMoveEvent) {
            }

            public void onPreNodeDelete(NodeDeletionEvent nodeDeletionEvent) {
            }

            public void onNodeMoved(NodeMoveEvent nodeMoveEvent) {
            }

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

            public void onNodeDeleted(NodeDeletionEvent nodeDeletionEvent) {
            }

            public void mapChanged(final MapChangeEvent event) {
                if (event.getProperty().equals(MapStyle.MAP_STYLES)) {
                    userInputListenerFactory.rebuildMenus(STYLE_ACTIONS);
                }
            }
        });
        mapController.addNodeSelectionListener(new INodeSelectionListener() {

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

            public void onDeselect(final NodeModel node) {
            }
        });
    }
}
Also used : IMapChangeListener(org.freeplane.features.map.IMapChangeListener) ChildActionEntryRemover(org.freeplane.core.ui.menubuilders.generic.ChildActionEntryRemover) 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) NodeModel(org.freeplane.features.map.NodeModel) NodeDeletionEvent(org.freeplane.features.map.NodeDeletionEvent) MapBackgroundClearAction(org.freeplane.view.swing.features.filepreview.MapBackgroundClearAction) MapChangeEvent(org.freeplane.features.map.MapChangeEvent) IMapSelectionListener(org.freeplane.features.map.IMapSelectionListener) IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) SetBooleanMapPropertyAction(org.freeplane.features.styles.SetBooleanMapPropertyAction) MapController(org.freeplane.features.map.MapController) NodeMoveEvent(org.freeplane.features.map.NodeMoveEvent) INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener)

Aggregations

MapModel (org.freeplane.features.map.MapModel)143 NodeModel (org.freeplane.features.map.NodeModel)47 ModeController (org.freeplane.features.mode.ModeController)35 Controller (org.freeplane.features.mode.Controller)31 IActor (org.freeplane.core.undo.IActor)27 MMapModel (org.freeplane.features.map.mindmapmode.MMapModel)16 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)16 IUndoHandler (org.freeplane.core.undo.IUndoHandler)15 AttributeRegistry (org.freeplane.features.attribute.AttributeRegistry)14 IStyle (org.freeplane.features.styles.IStyle)14 File (java.io.File)13 MMapController (org.freeplane.features.map.mindmapmode.MMapController)13 URL (java.net.URL)12 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)11 MapStyleModel (org.freeplane.features.styles.MapStyleModel)10 IMapViewManager (org.freeplane.features.ui.IMapViewManager)10 MapController (org.freeplane.features.map.MapController)9 URI (java.net.URI)8 ResourceController (org.freeplane.core.resources.ResourceController)8 IOException (java.io.IOException)7