Search in sources :

Example 36 with MapStyleModel

use of org.freeplane.features.styles.MapStyleModel 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 37 with MapStyleModel

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

the class MapProxy method getBackgroundColor.

// MapRO: R
public Color getBackgroundColor() {
    // see MapBackgroundColorAction
    final MapStyle mapStyle = (MapStyle) Controller.getCurrentModeController().getExtension(MapStyle.class);
    final MapStyleModel model = (MapStyleModel) mapStyle.getMapHook(getDelegate());
    if (model != null) {
        return model.getBackgroundColor();
    } else {
        final String colorPropertyString = ResourceController.getResourceController().getProperty(MapStyle.RESOURCES_BACKGROUND_COLOR);
        final Color defaultBgColor = ColorUtils.stringToColor(colorPropertyString);
        return defaultBgColor;
    }
}
Also used : MapStyleModel(org.freeplane.features.styles.MapStyleModel) Color(java.awt.Color) MapStyle(org.freeplane.features.styles.MapStyle)

Example 38 with MapStyleModel

use of org.freeplane.features.styles.MapStyleModel 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 39 with MapStyleModel

use of org.freeplane.features.styles.MapStyleModel 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)

Example 40 with MapStyleModel

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

the class LocationController method getStyleChildGap.

private Quantity<LengthUnits> getStyleChildGap(final MapModel map, final Collection<IStyle> styleKeys) {
    final MapStyleModel model = MapStyleModel.getExtension(map);
    for (IStyle styleKey : styleKeys) {
        final NodeModel styleNode = model.getStyleNode(styleKey);
        if (styleNode == null) {
            continue;
        }
        final LocationModel styleModel = styleNode.getExtension(LocationModel.class);
        if (styleModel == null) {
            continue;
        }
        Quantity<LengthUnits> vGap = styleModel.getVGap();
        if (vGap == LocationModel.DEFAULT_VGAP) {
            continue;
        }
        return vGap;
    }
    return null;
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) LengthUnits(org.freeplane.core.ui.LengthUnits) MapStyleModel(org.freeplane.features.styles.MapStyleModel)

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