Search in sources :

Example 1 with Shape

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

the class MNodeStyleController method setShapeConfiguration.

public void setShapeConfiguration(final NodeModel node, final ShapeConfigurationModel shape) {
    final ModeController modeController = Controller.getCurrentModeController();
    final ShapeConfigurationModel oldShape = NodeStyleModel.getShapeConfiguration(node);
    final IActor actor = new IActor() {

        public void act() {
            NodeStyleModel.setShapeConfiguration(node, shape);
            modeController.getMapController().nodeChanged(node);
            childShapeRefresh(node);
        }

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

        private void childShapeRefresh(final NodeModel node) {
            for (final NodeModel child : modeController.getMapController().childrenUnfolded(node)) {
                if (child.getViewers().isEmpty())
                    continue;
                final Shape childShape = NodeStyleModel.getShape(child);
                if (childShape == null || NodeStyleModel.Shape.as_parent.equals(childShape)) {
                    modeController.getMapController().nodeRefresh(child);
                    childShapeRefresh(child);
                }
            }
        }

        public void undo() {
            NodeStyleModel.setShapeConfiguration(node, oldShape);
            modeController.getMapController().nodeChanged(node);
            childShapeRefresh(node);
        }
    };
    modeController.execute(actor, node.getMap());
}
Also used : ShapeConfigurationModel(org.freeplane.features.nodestyle.ShapeConfigurationModel) NodeModel(org.freeplane.features.map.NodeModel) Shape(org.freeplane.features.nodestyle.NodeStyleModel.Shape) IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController)

Example 2 with Shape

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

the class NodeView method setFolded.

private void setFolded(boolean folded, boolean force) {
    boolean wasFolded = isFolded;
    this.isFolded = folded;
    if (wasFolded != isFolded || force) {
        treeStructureChanged();
        getMap().selectIfSelectionIsEmpty(this);
        Shape shape = NodeStyleController.getController(getMap().getModeController()).getShape(model);
        if (shape.equals(NodeStyleModel.Shape.combined))
            update();
    }
}
Also used : Shape(org.freeplane.features.nodestyle.NodeStyleModel.Shape)

Example 3 with Shape

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

the class NodeStyleBuilder method writeAttributes.

private void writeAttributes(final ITreeWriter writer, final NodeModel node, final NodeStyleModel style, final boolean forceFormatting) {
    final Color color = forceFormatting ? nsc.getColor(node) : style.getColor();
    if (color != null) {
        ColorUtils.addColorAttributes(writer, "COLOR", "ALPHA", color);
    }
    final Color backgroundColor = forceFormatting ? nsc.getBackgroundColor(node) : style.getBackgroundColor();
    if (backgroundColor != null) {
        ColorUtils.addColorAttributes(writer, "BACKGROUND_COLOR", "BACKGROUND_ALPHA", backgroundColor);
    }
    final ShapeConfigurationModel shapeConfiguration = forceFormatting ? nsc.getShapeConfiguration(node) : style.getShapeConfiguration();
    final Shape shape = shapeConfiguration.getShape();
    if (shape != null) {
        writer.addAttribute("STYLE", shape.toString());
    }
    final Quantity<LengthUnits> shapeHorizontalMargin = shapeConfiguration.getHorizontalMargin();
    if (!shapeHorizontalMargin.equals(ShapeConfigurationModel.DEFAULT_MARGIN)) {
        BackwardCompatibleQuantityWriter.forWriter(writer).writeQuantity("SHAPE_HORIZONTAL_MARGIN", shapeHorizontalMargin);
    }
    final Quantity<LengthUnits> shapeVerticalMargin = shapeConfiguration.getVerticalMargin();
    if (!shapeVerticalMargin.equals(ShapeConfigurationModel.DEFAULT_MARGIN)) {
        BackwardCompatibleQuantityWriter.forWriter(writer).writeQuantity("SHAPE_VERTICAL_MARGIN", shapeVerticalMargin);
    }
    final boolean uniformShape = shapeConfiguration.isUniform();
    if (uniformShape) {
        writer.addAttribute("UNIFORM_SHAPE", "true");
    }
    final Boolean numbered = forceFormatting ? Boolean.valueOf(nsc.getNodeNumbering(node)) : style.getNodeNumbering();
    if (numbered != null) {
        writer.addAttribute("NUMBERED", Boolean.toString(numbered));
    }
    final String format = forceFormatting ? nsc.getNodeFormat(node) : style.getNodeFormat();
    if (format != null) {
        writer.addAttribute("FORMAT", format);
    }
    final HorizontalTextAlignment textAlignment = forceFormatting ? nsc.getHorizontalTextAlignment(node) : style.getHorizontalTextAlignment();
    if (textAlignment != null) {
        writer.addAttribute("TEXT_ALIGN", textAlignment.toString());
    }
}
Also used : LengthUnits(org.freeplane.core.ui.LengthUnits) Shape(org.freeplane.features.nodestyle.NodeStyleModel.Shape) Color(java.awt.Color) HorizontalTextAlignment(org.freeplane.features.nodestyle.NodeStyleModel.HorizontalTextAlignment)

Aggregations

Shape (org.freeplane.features.nodestyle.NodeStyleModel.Shape)3 Color (java.awt.Color)1 LengthUnits (org.freeplane.core.ui.LengthUnits)1 IActor (org.freeplane.core.undo.IActor)1 NodeModel (org.freeplane.features.map.NodeModel)1 ModeController (org.freeplane.features.mode.ModeController)1 HorizontalTextAlignment (org.freeplane.features.nodestyle.NodeStyleModel.HorizontalTextAlignment)1 ShapeConfigurationModel (org.freeplane.features.nodestyle.ShapeConfigurationModel)1