Search in sources :

Example 26 with IStyle

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

the class AddStyleAttributes method getAttributes.

private NodeModel getAttributes(final NodeModel node) {
    final IStyle style = LogicalStyleController.getController().getFirstStyle(node);
    final MapStyleModel extension = MapStyleModel.getExtension(node.getMap());
    final NodeModel styleNode = extension.getStyleNode(style);
    return styleNode;
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel)

Example 27 with IStyle

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

the class CloudController method getStyleCloud.

protected CloudModel getStyleCloud(final MapModel map, final Collection<IStyle> collection) {
    final MapStyleModel model = MapStyleModel.getExtension(map);
    for (IStyle styleKey : collection) {
        final NodeModel styleNode = model.getStyleNode(styleKey);
        if (styleNode == null) {
            continue;
        }
        final CloudModel styleModel = CloudModel.getModel(styleNode);
        if (styleModel != null) {
            return styleModel;
        }
    }
    return null;
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel)

Example 28 with IStyle

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

the class EdgeController method getStyleStyle.

private EdgeStyle getStyleStyle(final MapModel map, final Collection<IStyle> collection) {
    final MapStyleModel model = MapStyleModel.getExtension(map);
    for (IStyle styleKey : collection) {
        final NodeModel styleNode = model.getStyleNode(styleKey);
        if (styleNode == null) {
            continue;
        }
        final EdgeModel styleModel = EdgeModel.getModel(styleNode);
        if (styleModel == null) {
            continue;
        }
        final EdgeStyle style = styleModel.getStyle();
        if (style == null) {
            continue;
        }
        return style;
    }
    return null;
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel)

Example 29 with IStyle

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

the class NodeStyleProxy method setName.

public void setName(String styleName) {
    if (styleName == null) {
        setStyle(null);
    } else {
        final MapStyleModel mapStyleModel = MapStyleModel.getExtension(getDelegate().getMap());
        // actually styles is a HashSet so lookup is fast
        final Set<IStyle> styles = mapStyleModel.getStyles();
        // search for user defined styles
        final IStyle styleString = StyleFactory.create(styleName);
        if (styles.contains(styleString)) {
            setStyle(styleString);
            return;
        }
        // search for predefined styles by key
        final IStyle styleNamedObject = StyleFactory.create(new TranslatedObject(styleName));
        if (styles.contains(styleNamedObject)) {
            setStyle(styleNamedObject);
            return;
        }
        // search for predefined styles by their translated name (style.toString())
        for (IStyle style : styles) {
            if (style.toString().equals(styleName)) {
                setStyle(style);
                return;
            }
        }
        throw new IllegalArgumentException("style '" + styleName + "' not found");
    }
}
Also used : IStyle(org.freeplane.features.styles.IStyle) MapStyleModel(org.freeplane.features.styles.MapStyleModel) StyleTranslatedObject(org.freeplane.features.styles.StyleTranslatedObject) TranslatedObject(org.freeplane.core.resources.TranslatedObject)

Example 30 with IStyle

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

the class DeleteLevelStyleAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final SModeController modeController = (SModeController) Controller.getCurrentModeController();
    final MapModel map = Controller.getCurrentController().getMap();
    final MapStyleModel styleModel = MapStyleModel.getExtension(map);
    NodeModel levelStyleParentNode = styleModel.getStyleNodeGroup(map, MapStyleModel.STYLES_AUTOMATIC_LAYOUT);
    final int childNumber = levelStyleParentNode.getChildCount() - 1;
    if (childNumber < 1) {
        UITools.errorMessage(TextUtils.getText("can_not_delete_root_style"));
        return;
    }
    final String styleName = "AutomaticLayout.level," + childNumber;
    final IStyle styleObject = StyleFactory.create(TranslatedObject.format(styleName));
    final MMapController mapController = (MMapController) modeController.getMapController();
    final NodeModel node = styleModel.getStyleNode(styleObject);
    mapController.deleteNode(node);
    final IActor actor = new IActor() {

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

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

        public void act() {
            styleModel.removeStyleNode(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

IStyle (org.freeplane.features.styles.IStyle)43 NodeModel (org.freeplane.features.map.NodeModel)31 MapStyleModel (org.freeplane.features.styles.MapStyleModel)30 MapModel (org.freeplane.features.map.MapModel)14 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)10 LengthUnits (org.freeplane.core.ui.LengthUnits)9 Color (java.awt.Color)5 IActor (org.freeplane.core.undo.IActor)5 MMapController (org.freeplane.features.map.mindmapmode.MMapController)4 DashVariant (org.freeplane.features.DashVariant)3 StyleTranslatedObject (org.freeplane.features.styles.StyleTranslatedObject)3 Controller (org.freeplane.features.mode.Controller)2 ModeController (org.freeplane.features.mode.ModeController)2 ArrayList (java.util.ArrayList)1 TranslatedObject (org.freeplane.core.resources.TranslatedObject)1 IMapSelection (org.freeplane.features.map.IMapSelection)1 HorizontalTextAlignment (org.freeplane.features.nodestyle.NodeStyleModel.HorizontalTextAlignment)1 AutomaticLayoutController (org.freeplane.features.styles.AutomaticLayoutController)1 LogicalStyleModel (org.freeplane.features.styles.LogicalStyleModel)1