Search in sources :

Example 31 with MapStyleModel

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

the class NewUserStyleAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final String styleName = JOptionPane.showInputDialog(TextUtils.getText("enter_new_style_name"));
    if (styleName == null) {
        return;
    }
    final Controller controller = Controller.getCurrentController();
    final NodeModel selectedNode = controller.getSelection().getSelected();
    final MapModel map = controller.getMap();
    final MapStyleModel styleModel = MapStyleModel.getExtension(map);
    final IStyle style = StyleFactory.create(styleName);
    if (null != styleModel.getStyleNode(style)) {
        UITools.errorMessage(TextUtils.getText("style_already_exists"));
        return;
    }
    final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
    final NodeModel newNode = new NodeModel(map);
    newNode.setUserObject(style);
    Controller.getCurrentModeController().copyExtensions(LogicalStyleKeys.NODE_STYLE, selectedNode, newNode);
    Controller.getCurrentModeController().copyExtensions(Keys.ICONS, selectedNode, newNode);
    NodeModel userStyleParentNode = styleModel.getStyleNodeGroup(map, MapStyleModel.STYLES_USER_DEFINED);
    if (userStyleParentNode == null) {
        userStyleParentNode = new NodeModel(map);
        userStyleParentNode.setUserObject(new StyleTranslatedObject(MapStyleModel.STYLES_USER_DEFINED));
        mapController.insertNode(userStyleParentNode, map.getRootNode(), false, false, true);
    }
    mapController.insertNode(newNode, userStyleParentNode, false, false, true);
    mapController.select(newNode);
    final IActor actor = new IActor() {

        public void undo() {
            styleModel.removeStyleNode(newNode);
        }

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

        public void act() {
            styleModel.addStyleNode(newNode);
        }
    };
    Controller.getCurrentModeController().execute(actor, map);
}
Also used : IStyle(org.freeplane.features.styles.IStyle) StyleTranslatedObject(org.freeplane.features.styles.StyleTranslatedObject) 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) Controller(org.freeplane.features.mode.Controller) MMapController(org.freeplane.features.map.mindmapmode.MMapController)

Example 32 with MapStyleModel

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

the class MindMapHTMLWriter method writeHTML.

void writeHTML(final NodeModel rootNodeOfBranch) throws IOException {
    setDefaultsFrom(rootNodeOfBranch.getMap());
    final String htmlExportFoldingOption = getProperty("html_export_folding");
    writeFoldingCode = (htmlExportFoldingOption.equals("html_export_fold_currently_folded") && mapController.hasFoldedStrictDescendant(rootNodeOfBranch)) || htmlExportFoldingOption.equals("html_export_fold_all");
    ResourceController.getResourceController().getBooleanProperty("export_icons_in_html");
    fileout.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" + lf + "<html>" + lf + "<head>" + lf);
    fileout.write("<title>" + MindMapHTMLWriter.writeHTML_escapeUnicodeAndSpecialCharacters(TextController.getController().getPlainTransformedTextWithoutNodeNumber(rootNodeOfBranch).replace('\n', ' ')) + "</title>" + lf);
    writeStyle();
    fileout.write(lf + "</head>" + lf + "<body");
    final MapStyleModel style = MapStyleModel.getExtension(rootNodeOfBranch.getMap());
    final Color background = style != null ? style.getBackgroundColor() : null;
    if (background != null) {
        fileout.write(" bgcolor=" + ColorUtils.colorToString(background));
    }
    fileout.write(">" + lf);
    if (writeFoldingCode) {
        writeBodyWithFolding(rootNodeOfBranch);
    } else {
        writeHTML(rootNodeOfBranch, "1", 0, /* isRoot */
        true, true, /* depth */
        1);
    }
    fileout.write("</body>" + lf);
    fileout.write("</html>" + lf);
    fileout.close();
    resetDefaults();
}
Also used : MapStyleModel(org.freeplane.features.styles.MapStyleModel) Color(java.awt.Color)

Example 33 with MapStyleModel

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

the class MindMapHTMLWriter method setDefaultsFrom.

private void setDefaultsFrom(MapModel map) {
    final MapStyleModel model = MapStyleModel.getExtension(map);
    final NodeModel styleNode = model.getStyleNodeSafe(MapStyleModel.DEFAULT_STYLE);
    defaultFont = nodeStyleController.getFont(styleNode);
    defaultColor = nodeStyleController.getColor(styleNode);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel)

Example 34 with MapStyleModel

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

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

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