Search in sources :

Example 11 with MapStyleModel

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

the class EdgeColorsConfigurationFactory method create.

public EdgeColorConfiguration create(MapModel map) {
    MapStyleModel mapStyle = MapStyleModel.getExtension(map);
    final String configurationString = mapStyle.getProperty(EDGE_COLOR_CONFIGURATION_PROPERTY);
    if (configurationString != null)
        return load(configurationString);
    else {
        final EdgeColorConfiguration newConfiguration = createNewConfiguration(map);
        String newConfigurationString = save(newConfiguration);
        mapStyle.setProperty(EDGE_COLOR_CONFIGURATION_PROPERTY, newConfigurationString);
        configurations.put(newConfigurationString, newConfiguration);
        return newConfiguration;
    }
}
Also used : MapStyleModel(org.freeplane.features.styles.MapStyleModel)

Example 12 with MapStyleModel

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

the class EdgeController method getStyleDash.

private DashVariant getStyleDash(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 DashVariant dash = styleModel.getDash();
        if (dash == null) {
            continue;
        }
        return dash;
    }
    return null;
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) DashVariant(org.freeplane.features.DashVariant) MapStyleModel(org.freeplane.features.styles.MapStyleModel)

Example 13 with MapStyleModel

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

the class EdgeController method getStyleEdgeColorRule.

private ObjectRule<Color, Rules> getStyleEdgeColorRule(NodeModel node) {
    MapModel map = node.getMap();
    Collection<IStyle> collection = LogicalStyleController.getController(modeController).getStyles(node);
    final MapStyleModel styles = MapStyleModel.getExtension(map);
    for (IStyle styleKey : collection) {
        final NodeModel styleNode = styles.getStyleNode(styleKey);
        if (styleNode == null) {
            continue;
        }
        if (node != styleNode && map.getRootNode().containsExtension(AutomaticEdgeColor.class)) {
            AutomaticLayoutController automaticLayoutController = modeController.getExtension(AutomaticLayoutController.class);
            if (automaticLayoutController != null && automaticLayoutController.isAutomaticLevelStyle(styleNode)) {
                continue;
            }
        }
        ObjectRule<Color, Rules> nodeColor = getNodeColorRule(styleNode);
        if (nodeColor != null)
            return nodeColor;
    }
    return null;
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) AutomaticLayoutController(org.freeplane.features.styles.AutomaticLayoutController) MapStyleModel(org.freeplane.features.styles.MapStyleModel) Color(java.awt.Color) MapModel(org.freeplane.features.map.MapModel)

Example 14 with MapStyleModel

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

the class EdgeController method getStyleWidth.

private Integer getStyleWidth(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 int width = styleModel.getWidth();
        if (width == EdgeModel.DEFAULT_WIDTH) {
            continue;
        }
        return width;
    }
    return null;
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel)

Example 15 with MapStyleModel

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

the class MMapController method getSiblingsSortedOnSide.

/**
 * Sorts nodes by their left/right status. The left are first.
 */
private List<NodeModel> getSiblingsSortedOnSide(final NodeModel node) {
    final ArrayList<NodeModel> nodes = new ArrayList<NodeModel>(node.getChildCount());
    for (final NodeModel child : Controller.getCurrentModeController().getMapController().childrenUnfolded(node)) {
        nodes.add(child);
    }
    if (!node.isRoot()) {
        return nodes;
    }
    final MapStyleModel mapStyleModel = MapStyleModel.getExtension(node.getMap());
    MapViewLayout layoutType = mapStyleModel.getMapViewLayout();
    if (layoutType.equals(MapViewLayout.OUTLINE)) {
        return nodes;
    }
    Collections.sort(nodes, new Comparator<Object>() {

        public int compare(final Object o1, final Object o2) {
            if (o1 instanceof NodeModel) {
                final NodeModel n1 = (NodeModel) o1;
                if (o2 instanceof NodeModel) {
                    final NodeModel n2 = (NodeModel) o2;
                    final int b1 = n1.isLeft() ? 0 : 1;
                    final int b2 = n2.isLeft() ? 0 : 1;
                    return b1 - b2;
                }
            }
            throw new IllegalArgumentException("Elements in LeftRightComparator are not comparable.");
        }
    });
    return nodes;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel) ArrayList(java.util.ArrayList) MapViewLayout(org.freeplane.features.styles.MapViewLayout)

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