Search in sources :

Example 1 with NodeSizeModel

use of org.freeplane.features.nodestyle.NodeSizeModel in project freeplane by freeplane.

the class MNodeStyleController method createOwnSizeModel.

private NodeSizeModel createOwnSizeModel(final NodeModel node) {
    {
        final NodeSizeModel sizeModel = NodeSizeModel.getModel(node);
        if (sizeModel != null) {
            return sizeModel;
        }
    }
    final ModeController modeController = Controller.getCurrentModeController();
    final IActor actor = new IActor() {

        public void act() {
            node.addExtension(new NodeSizeModel());
        }

        public String getDescription() {
            return null;
        }

        public void undo() {
            node.removeExtension(NodeSizeModel.class);
        }
    };
    modeController.execute(actor, node.getMap());
    return NodeSizeModel.getModel(node);
}
Also used : NodeSizeModel(org.freeplane.features.nodestyle.NodeSizeModel) IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController)

Example 2 with NodeSizeModel

use of org.freeplane.features.nodestyle.NodeSizeModel in project freeplane by freeplane.

the class MNodeStyleController method copySizeModel.

private void copySizeModel(final NodeModel source, final NodeModel target) {
    final NodeSizeModel sourceSizeModel = NodeSizeModel.getModel(source);
    if (sourceSizeModel != null) {
        setMaxNodeWidth(target, sourceSizeModel.getMaxNodeWidth());
        setMinNodeWidth(target, sourceSizeModel.getMinNodeWidth());
    }
}
Also used : NodeSizeModel(org.freeplane.features.nodestyle.NodeSizeModel)

Example 3 with NodeSizeModel

use of org.freeplane.features.nodestyle.NodeSizeModel in project freeplane by freeplane.

the class MNodeStyleController method setMaxNodeWidth.

public void setMaxNodeWidth(final NodeModel node, final Quantity<LengthUnits> maxNodeWidth) {
    Quantity.assertNonNegativeOrNull(maxNodeWidth);
    final NodeSizeModel sizeModel = createOwnSizeModel(node);
    final Quantity<LengthUnits> oldValue = NodeSizeModel.getMaxNodeWidth(node);
    final IActor actor = new IActor() {

        public void act() {
            sizeModel.setMaxNodeWidth(maxNodeWidth);
            final MapController mapController = getModeController().getMapController();
            mapController.nodeChanged(node);
        }

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

        public void undo() {
            sizeModel.setMaxNodeWidth(oldValue);
            final MapController mapController = getModeController().getMapController();
            mapController.nodeChanged(node);
        }
    };
    getModeController().execute(actor, node.getMap());
    final Quantity<LengthUnits> minNodeWidth = getMinWidth(node);
    if (maxNodeWidth != null && minNodeWidth != null && maxNodeWidth.toBaseUnitsRounded() < minNodeWidth.toBaseUnitsRounded()) {
        setMinNodeWidth(node, maxNodeWidth);
    }
}
Also used : LengthUnits(org.freeplane.core.ui.LengthUnits) NodeSizeModel(org.freeplane.features.nodestyle.NodeSizeModel) IActor(org.freeplane.core.undo.IActor) MapController(org.freeplane.features.map.MapController)

Example 4 with NodeSizeModel

use of org.freeplane.features.nodestyle.NodeSizeModel in project freeplane by freeplane.

the class MNodeStyleController method setMinNodeWidth.

public void setMinNodeWidth(final NodeModel node, final Quantity<LengthUnits> minNodeWidth) {
    Quantity.assertNonNegativeOrNull(minNodeWidth);
    final NodeSizeModel sizeModel = createOwnSizeModel(node);
    final Quantity<LengthUnits> oldValue = NodeSizeModel.getMinNodeWidth(node);
    final IActor actor = new IActor() {

        public void act() {
            sizeModel.setMinNodeWidth(minNodeWidth);
            final MapController mapController = getModeController().getMapController();
            mapController.nodeChanged(node);
        }

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

        public void undo() {
            sizeModel.setMinNodeWidth(oldValue);
            final MapController mapController = getModeController().getMapController();
            mapController.nodeChanged(node);
        }
    };
    getModeController().execute(actor, node.getMap());
    final Quantity<LengthUnits> maxNodeWidth = getMaxWidth(node);
    if (maxNodeWidth != null && minNodeWidth != null && maxNodeWidth.toBaseUnits() < minNodeWidth.toBaseUnits()) {
        setMaxNodeWidth(node, minNodeWidth);
    }
}
Also used : LengthUnits(org.freeplane.core.ui.LengthUnits) NodeSizeModel(org.freeplane.features.nodestyle.NodeSizeModel) IActor(org.freeplane.core.undo.IActor) MapController(org.freeplane.features.map.MapController)

Aggregations

NodeSizeModel (org.freeplane.features.nodestyle.NodeSizeModel)4 IActor (org.freeplane.core.undo.IActor)3 LengthUnits (org.freeplane.core.ui.LengthUnits)2 MapController (org.freeplane.features.map.MapController)2 ModeController (org.freeplane.features.mode.ModeController)1