Search in sources :

Example 16 with IStyle

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

the class MLogicalStyleController method setStyle.

public void setStyle(final NodeModel node, final IStyle style) {
    final ModeController modeController = Controller.getCurrentModeController();
    final IStyle oldStyle = LogicalStyleModel.getStyle(node);
    if (oldStyle != null && oldStyle.equals(style) || oldStyle == style) {
        modeController.getMapController().nodeChanged(node, LogicalStyleModel.class, oldStyle, style);
        return;
    }
    final IActor actor = new IActor() {

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

        public void act() {
            changeStyle(modeController, node, oldStyle, style);
        }

        public void undo() {
            changeStyle(modeController, node, style, oldStyle);
        }

        private void changeStyle(final ModeController modeController, final NodeModel node, final IStyle oldStyle, final IStyle style) {
            if (style != null) {
                final LogicalStyleModel model = LogicalStyleModel.createExtension(node);
                model.setStyle(style);
            } else {
                node.removeExtension(LogicalStyleModel.class);
            }
            modeController.getMapController().nodeChanged(node, LogicalStyleModel.class, oldStyle, style);
            selectActions();
        }
    };
    modeController.execute(actor, node.getMap());
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController) LogicalStyleModel(org.freeplane.features.styles.LogicalStyleModel)

Example 17 with IStyle

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

the class RedefineStyleAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final NodeModel node = Controller.getCurrentController().getSelection().getSelected();
    final IStyle style = LogicalStyleController.getController().getFirstStyle(node);
    final MapStyleModel extension = MapStyleModel.getExtension(node.getMap());
    final NodeModel styleNode = extension.getStyleNode(style);
    if (styleNode == null)
        return;
    Controller.getCurrentModeController().undoableCopyExtensions(LogicalStyleKeys.NODE_STYLE, node, styleNode);
    Controller.getCurrentModeController().undoableRemoveExtensions(LogicalStyleKeys.NODE_STYLE, node, node);
    LogicalStyleController.getController().refreshMap(node.getMap());
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel)

Example 18 with IStyle

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

the class AssignStyleAction method setSelected.

@Override
public void setSelected() {
    IMapSelection selection = Controller.getCurrentController().getSelection();
    if (selection != null) {
        NodeModel node = selection.getSelected();
        final IStyle style = LogicalStyleModel.getStyle(node);
        setSelected(this.style == style || this.style != null && this.style.equals(style));
    } else
        setSelected(false);
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection)

Example 19 with IStyle

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

the class LinkController method formatNodeAsHyperlink.

public boolean formatNodeAsHyperlink(final NodeModel node) {
    String text = node.getText();
    if (text.isEmpty() || HtmlUtils.isHtmlNode(text))
        return false;
    final Boolean ownFlag = ownFormatNodeAsHyperlink(node);
    if (ownFlag != null)
        return ownFlag;
    Collection<IStyle> collection = LogicalStyleController.getController(modeController).getStyles(node);
    final MapStyleModel mapStyles = MapStyleModel.getExtension(node.getMap());
    for (IStyle styleKey : collection) {
        final NodeModel styleNode = mapStyles.getStyleNode(styleKey);
        if (styleNode == null) {
            continue;
        }
        final Boolean styleFlag = ownFormatNodeAsHyperlink(styleNode);
        if (styleFlag != null)
            return styleFlag;
    }
    return false;
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel)

Example 20 with IStyle

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

the class CopyStyleExtensionsAction method actionPerformed.

@Override
protected void actionPerformed(ActionEvent e, NodeModel node) {
    final MLogicalStyleController controller = MLogicalStyleController.getController();
    final IStyle firstStyle = controller.getFirstStyle(node);
    controller.copyStyleExtensions(firstStyle, node);
}
Also used : IStyle(org.freeplane.features.styles.IStyle)

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