Search in sources :

Example 1 with NodeStyleModel

use of org.freeplane.features.nodestyle.NodeStyleModel in project freeplane by freeplane.

the class ClipboardController method writeRTF.

public void writeRTF(final NodeModel mindMapNodeModel, final Writer fileout, final int depth, final HashMap<Color, Integer> colorTable) throws IOException {
    String pre = "{" + "\\li" + depth * 350;
    String level;
    if (depth <= 8) {
        level = "\\outlinelevel" + depth;
    } else {
        level = "";
    }
    String fontsize = "";
    if (NodeStyleModel.getColor(mindMapNodeModel) != null) {
        pre += "\\cf" + colorTable.get(NodeStyleModel.getColor(mindMapNodeModel)).intValue();
    }
    final NodeStyleModel font = NodeStyleModel.getModel(mindMapNodeModel);
    if (font != null) {
        if (Boolean.TRUE.equals(font.isItalic())) {
            pre += "\\i ";
        }
        if (Boolean.TRUE.equals(font.isBold())) {
            pre += "\\b ";
        }
        if (font.getFontSize() != null) {
            fontsize = "\\fs" + Math.round(1.5 * font.getFontSize());
            pre += fontsize;
        }
    }
    pre += "{}";
    fileout.write("\\li" + depth * 350 + level + "{}");
    final String nodeText = TextController.getController().getPlainTransformedText(mindMapNodeModel);
    if (nodeText.matches(" *")) {
        fileout.write("o");
    } else {
        final String text = rtfEscapeUnicodeAndSpecialCharacters(nodeText);
        if (NodeLinks.getValidLink(mindMapNodeModel) != null) {
            final String link = rtfEscapeUnicodeAndSpecialCharacters(NodeLinks.getLinkAsString(mindMapNodeModel));
            if (link.equals(nodeText)) {
                fileout.write(pre + "<{\\ul\\cf1 " + link + "}>" + "}");
            } else {
                fileout.write("{" + fontsize + pre + text + "} ");
                fileout.write("<{\\ul\\cf1 " + link + "}}>");
            }
        } else {
            fileout.write(pre + text + "}");
        }
    }
    fileout.write("\\par");
    fileout.write("\n");
    writeChildrenRTF(mindMapNodeModel, fileout, depth, colorTable);
}
Also used : NodeStyleModel(org.freeplane.features.nodestyle.NodeStyleModel)

Example 2 with NodeStyleModel

use of org.freeplane.features.nodestyle.NodeStyleModel in project freeplane by freeplane.

the class MNodeStyleController method copyStyleModel.

protected void copyStyleModel(final NodeModel source, final NodeModel target) {
    final NodeStyleModel sourceStyleModel = NodeStyleModel.getModel(source);
    if (sourceStyleModel != null) {
        setColor(target, sourceStyleModel.getColor());
        setBackgroundColor(target, sourceStyleModel.getBackgroundColor());
        setShapeConfiguration(target, sourceStyleModel.getShapeConfiguration());
        setFontFamily(target, sourceStyleModel.getFontFamilyName());
        setFontSize(target, sourceStyleModel.getFontSize());
        setBold(target, sourceStyleModel.isBold());
        setStrikedThrough(target, sourceStyleModel.isStrikedThrough());
        setItalic(target, sourceStyleModel.isItalic());
        setNodeFormat(target, sourceStyleModel.getNodeFormat());
        setNodeNumbering(target, sourceStyleModel.getNodeNumbering());
        setHorizontalTextAlignment(target, sourceStyleModel.getHorizontalTextAlignment());
    }
}
Also used : NodeStyleModel(org.freeplane.features.nodestyle.NodeStyleModel)

Example 3 with NodeStyleModel

use of org.freeplane.features.nodestyle.NodeStyleModel in project freeplane by freeplane.

the class MNodeStyleController method setItalic.

/**
 * @param italic
 */
public void setItalic(final NodeModel node, final Boolean italic) {
    final Boolean oldItalic = NodeStyleModel.isItalic(node);
    if (oldItalic == italic || oldItalic != null && oldItalic.equals(italic)) {
        return;
    }
    createOwnStyleModel(node);
    final ModeController modeController = Controller.getCurrentModeController();
    final IActor actor = new IActor() {

        public void act() {
            final NodeStyleModel styleModel = NodeStyleModel.getModel(node);
            styleModel.setItalic(italic);
            Controller.getCurrentModeController().getMapController().nodeChanged(node);
        }

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

        public void undo() {
            final NodeStyleModel styleModel = NodeStyleModel.getModel(node);
            styleModel.setItalic(oldItalic);
            Controller.getCurrentModeController().getMapController().nodeChanged(node);
        }
    };
    modeController.execute(actor, node.getMap());
}
Also used : NodeStyleModel(org.freeplane.features.nodestyle.NodeStyleModel) IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController)

Example 4 with NodeStyleModel

use of org.freeplane.features.nodestyle.NodeStyleModel in project freeplane by freeplane.

the class MNodeStyleController method setFontFamily.

/**
 * @param fontFamily
 */
public void setFontFamily(final NodeModel node, final String fontFamily) {
    final String oldFontFamily = NodeStyleModel.getFontFamilyName(node);
    if (oldFontFamily == fontFamily || oldFontFamily != null && oldFontFamily.equals(fontFamily)) {
        return;
    }
    createOwnStyleModel(node);
    final ModeController modeController = Controller.getCurrentModeController();
    final IActor actor = new IActor() {

        public void act() {
            final NodeStyleModel styleModel = NodeStyleModel.getModel(node);
            styleModel.setFontFamilyName(fontFamily);
            Controller.getCurrentModeController().getMapController().nodeChanged(node);
        }

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

        public void undo() {
            final NodeStyleModel styleModel = NodeStyleModel.getModel(node);
            styleModel.setFontFamilyName(oldFontFamily);
            Controller.getCurrentModeController().getMapController().nodeChanged(node);
        }
    };
    modeController.execute(actor, node.getMap());
}
Also used : NodeStyleModel(org.freeplane.features.nodestyle.NodeStyleModel) IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController)

Example 5 with NodeStyleModel

use of org.freeplane.features.nodestyle.NodeStyleModel in project freeplane by freeplane.

the class MNodeStyleController method createOwnStyleModel.

private NodeStyleModel createOwnStyleModel(final NodeModel node) {
    {
        final NodeStyleModel styleModel = NodeStyleModel.getModel(node);
        if (styleModel != null) {
            return styleModel;
        }
    }
    final ModeController modeController = Controller.getCurrentModeController();
    final IActor actor = new IActor() {

        public void act() {
            node.addExtension(new NodeStyleModel());
        }

        public String getDescription() {
            return null;
        }

        public void undo() {
            node.removeExtension(NodeStyleModel.class);
        }
    };
    modeController.execute(actor, node.getMap());
    return NodeStyleModel.getModel(node);
}
Also used : NodeStyleModel(org.freeplane.features.nodestyle.NodeStyleModel) IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController)

Aggregations

NodeStyleModel (org.freeplane.features.nodestyle.NodeStyleModel)8 IActor (org.freeplane.core.undo.IActor)6 ModeController (org.freeplane.features.mode.ModeController)6