Search in sources :

Example 16 with LengthUnits

use of org.freeplane.core.ui.LengthUnits in project freeplane by freeplane.

the class MultipleImage method addLinkIcon.

public void addLinkIcon(Icon icon, NodeModel node) {
    final Quantity<LengthUnits> iconHeight = IconController.getController().getIconSize(node);
    final IconFactory iconFactory = IconFactory.getInstance();
    final Icon scaledIcon = iconFactory.canScaleIcon(icon) ? iconFactory.getScaledIcon(icon, iconHeight) : icon;
    mIcons.add(scaledIcon);
    mUIIcons.add(null);
}
Also used : LengthUnits(org.freeplane.core.ui.LengthUnits) Icon(javax.swing.Icon) UIIcon(org.freeplane.features.icon.UIIcon) IconFactory(org.freeplane.features.icon.factory.IconFactory)

Example 17 with LengthUnits

use of org.freeplane.core.ui.LengthUnits in project freeplane by freeplane.

the class LocationController method getStyleChildGap.

private Quantity<LengthUnits> getStyleChildGap(final MapModel map, final Collection<IStyle> styleKeys) {
    final MapStyleModel model = MapStyleModel.getExtension(map);
    for (IStyle styleKey : styleKeys) {
        final NodeModel styleNode = model.getStyleNode(styleKey);
        if (styleNode == null) {
            continue;
        }
        final LocationModel styleModel = styleNode.getExtension(LocationModel.class);
        if (styleModel == null) {
            continue;
        }
        Quantity<LengthUnits> vGap = styleModel.getVGap();
        if (vGap == LocationModel.DEFAULT_VGAP) {
            continue;
        }
        return vGap;
    }
    return null;
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) LengthUnits(org.freeplane.core.ui.LengthUnits) MapStyleModel(org.freeplane.features.styles.MapStyleModel)

Example 18 with LengthUnits

use of org.freeplane.core.ui.LengthUnits in project freeplane by freeplane.

the class NodeStyleBuilder method writeAttributes.

private void writeAttributes(final ITreeWriter writer, final NodeModel node, final NodeBorderModel border, final boolean forceFormatting) {
    final Boolean borderWidthMatchesEdgeWidth = forceFormatting ? nsc.getBorderWidthMatchesEdgeWidth(node) : border.getBorderWidthMatchesEdgeWidth();
    if (borderWidthMatchesEdgeWidth != null) {
        writer.addAttribute("BORDER_WIDTH_LIKE_EDGE", borderWidthMatchesEdgeWidth.toString());
    }
    final Quantity<LengthUnits> borderWidth = forceFormatting ? nsc.getBorderWidth(node) : border.getBorderWidth();
    if (borderWidth != null) {
        writer.addAttribute("BORDER_WIDTH", borderWidth.toString());
    }
    final Boolean borderColorMatchesEdgeColor = forceFormatting ? nsc.getBorderColorMatchesEdgeColor(node) : border.getBorderColorMatchesEdgeColor();
    if (borderColorMatchesEdgeColor != null) {
        writer.addAttribute("BORDER_COLOR_LIKE_EDGE", borderColorMatchesEdgeColor.toString());
    }
    final Color borderColor = forceFormatting ? nsc.getBorderColor(node) : border.getBorderColor();
    if (borderColor != null) {
        ColorUtils.addColorAttributes(writer, "BORDER_COLOR", "BORDER_COLOR_ALPHA", borderColor);
    }
    final Boolean borderDashMatchesEdgeDash = forceFormatting ? nsc.getBorderDashMatchesEdgeDash(node) : border.getBorderDashMatchesEdgeDash();
    if (borderDashMatchesEdgeDash != null) {
        writer.addAttribute("BORDER_DASH_LIKE_EDGE", borderDashMatchesEdgeDash.toString());
    }
    DashVariant borderDash = forceFormatting ? nsc.getBorderDash(node) : border.getBorderDash();
    if (borderDash != null) {
        writer.addAttribute("BORDER_DASH", borderDash.name());
    }
}
Also used : LengthUnits(org.freeplane.core.ui.LengthUnits) DashVariant(org.freeplane.features.DashVariant) Color(java.awt.Color)

Example 19 with LengthUnits

use of org.freeplane.core.ui.LengthUnits in project freeplane by freeplane.

the class NodeStyleController method getBorderWidth.

private Quantity<LengthUnits> getBorderWidth(final MapModel map, final Collection<IStyle> styleKeys) {
    final MapStyleModel model = MapStyleModel.getExtension(map);
    for (IStyle styleKey : styleKeys) {
        final NodeModel styleNode = model.getStyleNode(styleKey);
        if (styleNode == null) {
            continue;
        }
        final NodeBorderModel borderModel = NodeBorderModel.getModel(styleNode);
        if (borderModel == null) {
            continue;
        }
        final Quantity<LengthUnits> borderWidth = borderModel.getBorderWidth();
        if (borderWidth == null) {
            continue;
        }
        return borderWidth;
    }
    return DEFAULT_BORDER_WIDTH;
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) LengthUnits(org.freeplane.core.ui.LengthUnits) MapStyleModel(org.freeplane.features.styles.MapStyleModel)

Example 20 with LengthUnits

use of org.freeplane.core.ui.LengthUnits in project freeplane by freeplane.

the class NodeStyleController method getMaxNodeWidth.

private Quantity<LengthUnits> getMaxNodeWidth(final MapModel map, final Collection<IStyle> styleKeys) {
    final MapStyleModel model = MapStyleModel.getExtension(map);
    for (IStyle styleKey : styleKeys) {
        final NodeModel styleNode = model.getStyleNode(styleKey);
        if (styleNode == null) {
            continue;
        }
        final NodeSizeModel sizeModel = NodeSizeModel.getModel(styleNode);
        if (sizeModel == null) {
            continue;
        }
        final Quantity<LengthUnits> maxTextWidth = sizeModel.getMaxNodeWidth();
        if (maxTextWidth == null) {
            continue;
        }
        return maxTextWidth;
    }
    return DEFAULT_MAXIMUM_WIDTH;
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) LengthUnits(org.freeplane.core.ui.LengthUnits) MapStyleModel(org.freeplane.features.styles.MapStyleModel)

Aggregations

LengthUnits (org.freeplane.core.ui.LengthUnits)21 BooleanProperty (org.freeplane.core.resources.components.BooleanProperty)6 IStyle (org.freeplane.features.styles.IStyle)6 NodeModel (org.freeplane.features.map.NodeModel)5 IActor (org.freeplane.core.undo.IActor)4 MapStyleModel (org.freeplane.features.styles.MapStyleModel)4 MapController (org.freeplane.features.map.MapController)3 Icon (javax.swing.Icon)2 IconFactory (org.freeplane.features.icon.factory.IconFactory)2 MapModel (org.freeplane.features.map.MapModel)2 ModeController (org.freeplane.features.mode.ModeController)2 NodeSizeModel (org.freeplane.features.nodestyle.NodeSizeModel)2 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)2 Color (java.awt.Color)1 Font (java.awt.Font)1 NextColumnProperty (org.freeplane.core.resources.components.NextColumnProperty)1 FreeplaneIconFactory (org.freeplane.core.ui.svgicons.FreeplaneIconFactory)1 Quantity (org.freeplane.core.util.Quantity)1 DashVariant (org.freeplane.features.DashVariant)1 IconController (org.freeplane.features.icon.IconController)1