Search in sources :

Example 1 with CssRuleBuilder

use of org.freeplane.core.ui.components.html.CssRuleBuilder in project freeplane by freeplane.

the class NoteController method getNoteCSSStyle.

protected String getNoteCSSStyle(ModeController modeController, NodeModel node, float zoom, boolean asHtmlFragment) {
    final StringBuilder rule = new StringBuilder();
    // set default font for notes:
    final NodeStyleController style = (NodeStyleController) Controller.getCurrentModeController().getExtension(NodeStyleController.class);
    MapModel map = modeController.getController().getMap();
    if (map != null) {
        final MapStyleModel model = MapStyleModel.getExtension(map);
        final NodeModel noteStyleNode = model.getStyleNodeSafe(MapStyleModel.NOTE_STYLE);
        final Font noteFont = style.getFont(noteStyleNode);
        Color noteBackground = style.getBackgroundColor(noteStyleNode);
        Color noteForeground = style.getColor(noteStyleNode);
        final int alignment = style.getHorizontalTextAlignment(noteStyleNode).swingConstant;
        final CssRuleBuilder cssRuleBuilder = new CssRuleBuilder();
        if (asHtmlFragment)
            cssRuleBuilder.withHTMLFont(noteFont);
        else
            cssRuleBuilder.withCSSFont(noteFont);
        cssRuleBuilder.withColor(noteForeground).withBackground(noteBackground).withAlignment(alignment);
        if (asHtmlFragment)
            cssRuleBuilder.withMaxWidthAsPt(zoom, NodeSizeModel.getMaxNodeWidth(noteStyleNode), style.getMaxWidth(node));
        rule.append(cssRuleBuilder);
    }
    return rule.toString();
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) CssRuleBuilder(org.freeplane.core.ui.components.html.CssRuleBuilder) MapStyleModel(org.freeplane.features.styles.MapStyleModel) Color(java.awt.Color) MapModel(org.freeplane.features.map.MapModel) Font(java.awt.Font)

Aggregations

Color (java.awt.Color)1 Font (java.awt.Font)1 CssRuleBuilder (org.freeplane.core.ui.components.html.CssRuleBuilder)1 MapModel (org.freeplane.features.map.MapModel)1 NodeModel (org.freeplane.features.map.NodeModel)1 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)1 MapStyleModel (org.freeplane.features.styles.MapStyleModel)1