Search in sources :

Example 1 with HorizontalTextAlignment

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

the class MNodeStyleController method setHorizontalTextAlignment.

public void setHorizontalTextAlignment(final NodeModel node, final HorizontalTextAlignment textAlignment) {
    final HorizontalTextAlignment oldTextAlignment = NodeStyleModel.getHorizontalTextAlignment(node);
    final IActor actor = new IActor() {

        public void act() {
            NodeStyleModel.setHorizontalTextAlignment(node, textAlignment);
            final MapController mapController = getModeController().getMapController();
            mapController.nodeChanged(node);
        }

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

        public void undo() {
            NodeStyleModel.setHorizontalTextAlignment(node, oldTextAlignment);
            final MapController mapController = getModeController().getMapController();
            mapController.nodeChanged(node);
        }
    };
    getModeController().execute(actor, node.getMap());
}
Also used : IActor(org.freeplane.core.undo.IActor) HorizontalTextAlignment(org.freeplane.features.nodestyle.NodeStyleModel.HorizontalTextAlignment) MapController(org.freeplane.features.map.MapController)

Example 2 with HorizontalTextAlignment

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

the class MainView method updateHorizontalTextAlignment.

void updateHorizontalTextAlignment(NodeView node) {
    final HorizontalTextAlignment textAlignment = NodeStyleController.getController(node.getMap().getModeController()).getHorizontalTextAlignment(node.getModel());
    final boolean isCenteredByDefault = textAlignment == HorizontalTextAlignment.DEFAULT && node.isRoot();
    setHorizontalAlignment(isCenteredByDefault ? HorizontalTextAlignment.CENTER.swingConstant : textAlignment.swingConstant);
}
Also used : HorizontalTextAlignment(org.freeplane.features.nodestyle.NodeStyleModel.HorizontalTextAlignment)

Example 3 with HorizontalTextAlignment

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

the class NodeStyleController method getHorizontalTextAlignment.

private HorizontalTextAlignment getHorizontalTextAlignment(final MapModel map, final Collection<IStyle> style) {
    final MapStyleModel model = MapStyleModel.getExtension(map);
    for (IStyle styleKey : style) {
        final NodeModel styleNode = model.getStyleNode(styleKey);
        if (styleNode == null) {
            continue;
        }
        final NodeStyleModel styleModel = NodeStyleModel.getModel(styleNode);
        if (styleModel == null) {
            continue;
        }
        final HorizontalTextAlignment textAlignment = styleModel.getHorizontalTextAlignment();
        if (textAlignment == null) {
            continue;
        }
        return textAlignment;
    }
    return null;
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel) HorizontalTextAlignment(org.freeplane.features.nodestyle.NodeStyleModel.HorizontalTextAlignment)

Aggregations

HorizontalTextAlignment (org.freeplane.features.nodestyle.NodeStyleModel.HorizontalTextAlignment)3 IActor (org.freeplane.core.undo.IActor)1 MapController (org.freeplane.features.map.MapController)1 NodeModel (org.freeplane.features.map.NodeModel)1 IStyle (org.freeplane.features.styles.IStyle)1 MapStyleModel (org.freeplane.features.styles.MapStyleModel)1