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);
}
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);
}
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);
}
}
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);
}
}
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);
}
}
Aggregations