Search in sources :

Example 26 with MapStyleModel

use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.

the class MLogicalStyleController method copyStyleExtensions.

public void copyStyleExtensions(final IStyle style, final NodeModel target) {
    final MTextController textController = MTextController.getController();
    final MapStyleModel extension = MapStyleModel.getExtension(target.getMap());
    final NodeModel styleNode = extension.getStyleNode(style);
    if (styleNode != null) {
        final MAttributeController attributeController = MAttributeController.getController();
        attributeController.copyAttributesToNode(styleNode, target);
        final String detailTextText = DetailTextModel.getDetailTextText(styleNode);
        if (detailTextText != null)
            textController.setDetails(target, detailTextText);
        final String noteText = NoteModel.getNoteText(styleNode);
        if (noteText != null) {
            MNoteController noteController = (MNoteController) NoteController.getController();
            noteController.setNoteText(target, noteText);
        }
    }
}
Also used : MNoteController(org.freeplane.features.note.mindmapmode.MNoteController) NodeModel(org.freeplane.features.map.NodeModel) MAttributeController(org.freeplane.features.attribute.mindmapmode.MAttributeController) MapStyleModel(org.freeplane.features.styles.MapStyleModel) MTextController(org.freeplane.features.text.mindmapmode.MTextController)

Example 27 with MapStyleModel

use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.

the class MapBackgroundColorAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final Controller controller = Controller.getCurrentController();
    MapStyle mapStyle = (MapStyle) controller.getModeController().getExtension(MapStyle.class);
    final MapStyleModel model = (MapStyleModel) mapStyle.getMapHook(controller.getMap());
    final Color oldBackgroundColor;
    final String colorPropertyString = ResourceController.getResourceController().getProperty(MapStyle.RESOURCES_BACKGROUND_COLOR);
    final Color defaultBgColor = ColorUtils.stringToColor(colorPropertyString);
    if (model != null) {
        oldBackgroundColor = model.getBackgroundColor();
    } else {
        oldBackgroundColor = defaultBgColor;
    }
    final Color actionColor = ColorTracker.showCommonJColorChooserDialog(controller.getSelection().getSelected(), TextUtils.getText("choose_map_background_color"), oldBackgroundColor, defaultBgColor);
    mapStyle.setBackgroundColor(model, actionColor);
}
Also used : MapStyleModel(org.freeplane.features.styles.MapStyleModel) Color(java.awt.Color) MapStyle(org.freeplane.features.styles.MapStyle) ResourceController(org.freeplane.core.resources.ResourceController) Controller(org.freeplane.features.mode.Controller)

Example 28 with MapStyleModel

use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.

the class NewUserStyleAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final String styleName = JOptionPane.showInputDialog(TextUtils.getText("enter_new_style_name"));
    if (styleName == null) {
        return;
    }
    final Controller controller = Controller.getCurrentController();
    final NodeModel selectedNode = controller.getSelection().getSelected();
    final MapModel map = controller.getMap();
    final MapStyleModel styleModel = MapStyleModel.getExtension(map);
    final MapModel styleMap = styleModel.getStyleMap();
    final IStyle newStyle = StyleFactory.create(styleName);
    if (null != styleModel.getStyleNode(newStyle)) {
        UITools.errorMessage(TextUtils.getText("style_already_exists"));
        return;
    }
    final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
    final NodeModel newNode = new NodeModel(styleMap);
    newNode.setUserObject(newStyle);
    final LogicalStyleController styleController = LogicalStyleController.getController();
    final ArrayList<IStyle> styles = new ArrayList<IStyle>(styleController.getStyles(selectedNode));
    for (int i = styles.size() - 1; i >= 0; i--) {
        IStyle style = styles.get(i);
        if (MapStyleModel.DEFAULT_STYLE.equals(style)) {
            continue;
        }
        final NodeModel styleNode = styleModel.getStyleNode(style);
        if (styleNode == null) {
            continue;
        }
        Controller.getCurrentModeController().copyExtensions(LogicalStyleKeys.NODE_STYLE, styleNode, newNode);
    }
    Controller.getCurrentModeController().copyExtensions(LogicalStyleKeys.NODE_STYLE, selectedNode, newNode);
    Controller.getCurrentModeController().copyExtensions(Keys.ICONS, selectedNode, newNode);
    NodeModel userStyleParentNode = styleModel.getStyleNodeGroup(styleMap, MapStyleModel.STYLES_USER_DEFINED);
    if (userStyleParentNode == null) {
        userStyleParentNode = new NodeModel(styleMap);
        userStyleParentNode.setUserObject(new StyleTranslatedObject(MapStyleModel.STYLES_USER_DEFINED));
        mapController.insertNode(userStyleParentNode, styleMap.getRootNode(), false, false, true);
    }
    mapController.insertNode(newNode, userStyleParentNode, false, false, true);
    mapController.select(newNode);
    final IActor actor = new IActor() {

        public void undo() {
            styleModel.removeStyleNode(newNode);
            styleController.refreshMap(map);
        }

        public String getDescription() {
            return "NewStyle";
        }

        public void act() {
            styleModel.addStyleNode(newNode);
            styleController.refreshMap(map);
        }
    };
    Controller.getCurrentModeController().execute(actor, styleMap);
}
Also used : MapStyleModel(org.freeplane.features.styles.MapStyleModel) MMapController(org.freeplane.features.map.mindmapmode.MMapController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) ArrayList(java.util.ArrayList) MapModel(org.freeplane.features.map.MapModel) Controller(org.freeplane.features.mode.Controller) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) MMapController(org.freeplane.features.map.mindmapmode.MMapController) IStyle(org.freeplane.features.styles.IStyle) StyleTranslatedObject(org.freeplane.features.styles.StyleTranslatedObject) NodeModel(org.freeplane.features.map.NodeModel) IActor(org.freeplane.core.undo.IActor)

Example 29 with MapStyleModel

use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.

the class EditStylesAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final Controller currentController = Controller.getCurrentController();
    final MapModel map = currentController.getMap();
    final MapStyleModel mapStyleModel = MapStyleModel.getExtension(map);
    final MapModel styleMap = mapStyleModel.getStyleMap();
    if (styleMap == null) {
        UITools.errorMessage(TextUtils.getText("no_styles_found_in_map"));
        return;
    }
    final IMapViewManager mapViewManager = currentController.getMapViewManager();
    currentMapView = mapViewManager.getMapViewComponent();
    mapViewManager.changeToMapView((Component) null);
    final IUndoHandler undoHandler = (IUndoHandler) map.getExtension(IUndoHandler.class);
    undoHandler.startTransaction();
    init();
    SModeController modeController = getModeController();
    modeController.getMapController().newMapView(styleMap);
    Controller controller = modeController.getController();
    Component mapViewComponent = controller.getMapViewManager().getMapViewComponent();
    ((DialogController) controller.getViewController()).setMapView(mapViewComponent);
    dialog.setLocationRelativeTo(currentController.getViewController().getCurrentRootComponent());
    dialog.setVisible(true);
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) MapStyleModel(org.freeplane.features.styles.MapStyleModel) IUndoHandler(org.freeplane.core.undo.IUndoHandler) MapModel(org.freeplane.features.map.MapModel) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) ViewController(org.freeplane.features.ui.ViewController) Component(java.awt.Component)

Example 30 with MapStyleModel

use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.

the class NewLevelStyleAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final MapModel map = Controller.getCurrentController().getMap();
    final MapStyleModel styleModel = MapStyleModel.getExtension(map);
    NodeModel levelStyleParentNode = styleModel.getStyleNodeGroup(map, MapStyleModel.STYLES_AUTOMATIC_LAYOUT);
    final String styleName = "AutomaticLayout.level," + levelStyleParentNode.getChildCount();
    final IStyle styleObject = StyleFactory.create(TranslatedObject.format(styleName));
    final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
    final NodeModel node = new NodeModel(map);
    node.setUserObject(styleObject);
    mapController.insertNode(node, levelStyleParentNode, false, false, true);
    mapController.select(node);
    final IActor actor = new IActor() {

        public void undo() {
            styleModel.removeStyleNode(node);
        }

        public String getDescription() {
            return "NewLevelStyle";
        }

        public void act() {
            styleModel.addStyleNode(node);
        }
    };
    Controller.getCurrentModeController().execute(actor, map);
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel) MMapController(org.freeplane.features.map.mindmapmode.MMapController) IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel)

Aggregations

MapStyleModel (org.freeplane.features.styles.MapStyleModel)48 NodeModel (org.freeplane.features.map.NodeModel)39 IStyle (org.freeplane.features.styles.IStyle)30 Color (java.awt.Color)10 MapModel (org.freeplane.features.map.MapModel)10 Controller (org.freeplane.features.mode.Controller)6 LengthUnits (org.freeplane.core.ui.LengthUnits)5 IActor (org.freeplane.core.undo.IActor)5 MMapController (org.freeplane.features.map.mindmapmode.MMapController)5 StyleTranslatedObject (org.freeplane.features.styles.StyleTranslatedObject)4 ModeController (org.freeplane.features.mode.ModeController)3 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)3 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)3 MapStyle (org.freeplane.features.styles.MapStyle)3 Font (java.awt.Font)2 ArrayList (java.util.ArrayList)2 DashVariant (org.freeplane.features.DashVariant)2 ConditionalStyleModel (org.freeplane.features.styles.ConditionalStyleModel)2 MapView (org.freeplane.view.swing.map.MapView)2 NodeView (org.freeplane.view.swing.map.NodeView)2