Search in sources :

Example 1 with DashVariant

use of org.freeplane.features.DashVariant in project freeplane by freeplane.

the class EdgeController method getStyleDash.

private DashVariant getStyleDash(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 EdgeModel styleModel = EdgeModel.getModel(styleNode);
        if (styleModel == null) {
            continue;
        }
        final DashVariant dash = styleModel.getDash();
        if (dash == null) {
            continue;
        }
        return dash;
    }
    return null;
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) DashVariant(org.freeplane.features.DashVariant) MapStyleModel(org.freeplane.features.styles.MapStyleModel)

Example 2 with DashVariant

use of org.freeplane.features.DashVariant in project freeplane by freeplane.

the class LinkController method getStandardDashVariant.

public DashVariant getStandardDashVariant() {
    final String standard = ResourceController.getResourceController().getProperty(RESOURCES_DASH_VARIANT);
    final DashVariant variant = DashVariant.valueOf(standard);
    return variant;
}
Also used : DashVariant(org.freeplane.features.DashVariant)

Example 3 with DashVariant

use of org.freeplane.features.DashVariant in project freeplane by freeplane.

the class MNodeStyleController method setBorderDash.

public void setBorderDash(final NodeModel node, final DashVariant borderDash) {
    final DashVariant oldBorderDash = NodeBorderModel.getBorderDash(node);
    final IActor actor = new IActor() {

        public void act() {
            NodeBorderModel.setBorderDash(node, borderDash);
            final MapController mapController = getModeController().getMapController();
            mapController.nodeChanged(node);
        }

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

        public void undo() {
            NodeBorderModel.setBorderDash(node, oldBorderDash);
            final MapController mapController = getModeController().getMapController();
            mapController.nodeChanged(node);
        }
    };
    getModeController().execute(actor, node.getMap());
}
Also used : DashVariant(org.freeplane.features.DashVariant) IActor(org.freeplane.core.undo.IActor) MapController(org.freeplane.features.map.MapController)

Example 4 with DashVariant

use of org.freeplane.features.DashVariant in project freeplane by freeplane.

the class MEdgeController method setDash.

public void setDash(final NodeModel node, final DashVariant dash) {
    final ModeController modeController = Controller.getCurrentModeController();
    final DashVariant oldDash = EdgeModel.createEdgeModel(node).getDash();
    if (dash == oldDash) {
        return;
    }
    final IActor actor = new IActor() {

        public void act() {
            EdgeModel.createEdgeModel(node).setDash(dash);
            modeController.getMapController().nodeChanged(node);
            edgeWidthRefresh(node);
        }

        private void edgeWidthRefresh(final NodeModel node) {
            for (final NodeModel child : modeController.getMapController().childrenUnfolded(node)) {
                if (child.getViewers().isEmpty())
                    continue;
                final EdgeModel edge = EdgeModel.getModel(child);
                if (edge == null || edge.getWidth() == EdgeModel.WIDTH_PARENT) {
                    modeController.getMapController().nodeRefresh(child);
                    edgeWidthRefresh(child);
                }
            }
        }

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

        public void undo() {
            EdgeModel.createEdgeModel(node).setDash(oldDash);
            modeController.getMapController().nodeChanged(node);
            edgeWidthRefresh(node);
        }
    };
    modeController.execute(actor, node.getMap());
}
Also used : DashVariant(org.freeplane.features.DashVariant) NodeModel(org.freeplane.features.map.NodeModel) IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController) EdgeModel(org.freeplane.features.edge.EdgeModel)

Example 5 with DashVariant

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

Aggregations

DashVariant (org.freeplane.features.DashVariant)7 NodeModel (org.freeplane.features.map.NodeModel)3 IStyle (org.freeplane.features.styles.IStyle)3 IActor (org.freeplane.core.undo.IActor)2 MapStyleModel (org.freeplane.features.styles.MapStyleModel)2 Color (java.awt.Color)1 LengthUnits (org.freeplane.core.ui.LengthUnits)1 EdgeModel (org.freeplane.features.edge.EdgeModel)1 MapController (org.freeplane.features.map.MapController)1 MapModel (org.freeplane.features.map.MapModel)1 ModeController (org.freeplane.features.mode.ModeController)1 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)1