Search in sources :

Example 6 with LengthUnits

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

the class MaxNodeWidthControlGroup method addControlGroup.

public void addControlGroup(DefaultFormBuilder formBuilder) {
    mSetMaxNodeWidth = new BooleanProperty(ControlGroup.SET_RESOURCE);
    mMaxNodeWidth = new QuantityProperty<LengthUnits>(MAX_NODE_WIDTH, 0, 100000, 0.1, LengthUnits.px);
    propertyChangeListener = new MaxNodeWidthChangeListener(mSetMaxNodeWidth, mMaxNodeWidth);
    mSetMaxNodeWidth.addPropertyChangeListener(propertyChangeListener);
    mMaxNodeWidth.addPropertyChangeListener(propertyChangeListener);
    mSetMaxNodeWidth.layout(formBuilder);
    mMaxNodeWidth.layout(formBuilder);
}
Also used : LengthUnits(org.freeplane.core.ui.LengthUnits) BooleanProperty(org.freeplane.core.resources.components.BooleanProperty)

Example 7 with LengthUnits

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

the class MinNodeWidthControlGroup method addControlGroup.

public void addControlGroup(DefaultFormBuilder formBuilder) {
    mSetMinNodeWidth = new BooleanProperty(ControlGroup.SET_RESOURCE);
    mMinNodeWidth = new QuantityProperty<LengthUnits>(MIN_NODE_WIDTH, 0, 100000, 0.1, LengthUnits.px);
    propertyChangeListener = new MinNodeWidthChangeListener(mSetMinNodeWidth, mMinNodeWidth);
    mSetMinNodeWidth.addPropertyChangeListener(propertyChangeListener);
    mMinNodeWidth.addPropertyChangeListener(propertyChangeListener);
    mSetMinNodeWidth.layout(formBuilder);
    mMinNodeWidth.layout(formBuilder);
}
Also used : LengthUnits(org.freeplane.core.ui.LengthUnits) BooleanProperty(org.freeplane.core.resources.components.BooleanProperty)

Example 8 with LengthUnits

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

the class MNodeMouseWheelListener method mouseWheelMoved.

@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    if (!e.isAltDown()) {
        super.mouseWheelMoved(e);
        return;
    }
    final MainView view = (MainView) e.getComponent();
    final MapView map = (MapView) SwingUtilities.getAncestorOfClass(MapView.class, view);
    if (map.usesLayoutSpecificMaxNodeWidth())
        return;
    final int wheelRotation = e.getWheelRotation();
    final NodeView nodeView = view.getNodeView();
    if (!nodeView.isSelected())
        map.selectAsTheOnlyOneSelected(nodeView);
    final double factor = e.isControlDown() ? 1 : 6 * LengthUnits.pt.factor();
    double newZoomedWidth = Math.max((view.getWidth() - wheelRotation * factor) / map.getZoom(), 0);
    final IMapSelection selection = Controller.getCurrentController().getSelection();
    Quantity<LengthUnits> newZoomedWidthQuantity = LengthUnits.pixelsInPt(newZoomedWidth);
    final ModeController modeController = map.getModeController();
    final MNodeStyleController styleController = (MNodeStyleController) modeController.getExtension(NodeStyleController.class);
    selection.keepNodePosition(nodeView.getModel(), 0f, 0f);
    for (final NodeModel node : selection.getSelection()) {
        styleController.setMinNodeWidth(node, newZoomedWidthQuantity);
        styleController.setMaxNodeWidth(node, newZoomedWidthQuantity);
    }
}
Also used : LengthUnits(org.freeplane.core.ui.LengthUnits) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) NodeModel(org.freeplane.features.map.NodeModel) MainView(org.freeplane.view.swing.map.MainView) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) IMapSelection(org.freeplane.features.map.IMapSelection) MapView(org.freeplane.view.swing.map.MapView) ModeController(org.freeplane.features.mode.ModeController) NodeView(org.freeplane.view.swing.map.NodeView)

Example 9 with LengthUnits

use of org.freeplane.core.ui.LengthUnits 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 10 with LengthUnits

use of org.freeplane.core.ui.LengthUnits 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

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