use of org.freeplane.features.map.NodeModel 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.features.map.NodeModel in project freeplane by freeplane.
the class VerticalNodeViewLayoutStrategy method calculateLayoutData.
public void calculateLayoutData() {
final NodeModel node = view.getModel();
viewLevels = view.isFolded() ? SummaryLevels.ignoringChildNodes(node) : SummaryLevels.of(node);
for (boolean isLeft : viewLevels.sides) calculateLayoutData(isLeft);
applyLayoutToChildComponents();
}
use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.
the class NodeProxy method appendAsCloneImpl.
private Node appendAsCloneImpl(NodeModel toBeCloned, boolean withSubtree) {
final NodeModel target = getDelegate();
final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
if (toBeCloned.getParentNode() == null || toBeCloned.isRoot())
throw new IllegalArgumentException("can't clone root node or node without parent");
if (!toBeCloned.getMap().equals(getDelegate().getMap()))
throw new IllegalArgumentException("can't clone a node from another map");
if (toBeCloned.subtreeContainsCloneOf(target))
throw new IllegalArgumentException("can't clone a node which has this node as child");
final NodeModel clone = withSubtree ? toBeCloned.cloneTree() : toBeCloned.cloneContent();
mapController.addNewNode(clone, target, target.getChildCount(), target.isNewChildLeft());
return new NodeProxy(clone, getScriptContext());
}
use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.
the class ControllerProxy method select.
public void select(final Collection<Node> toSelect) {
final Iterator<Node> it = toSelect.iterator();
if (!it.hasNext()) {
return;
}
final Node firstNode = it.next();
select(firstNode);
while (it.hasNext()) {
final Node nextNode = it.next();
final NodeModel nodeModel = ((NodeProxy) nextNode).getDelegate();
Controller.getCurrentModeController().getMapController().displayNode(nodeModel);
Controller.getCurrentController().getSelection().toggleSelected(nodeModel);
}
}
use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.
the class RemoveAllAttributesAction method setEnabled.
@Override
public void setEnabled() {
boolean enable = false;
final AttributeUtilities atrUtil = new AttributeUtilities();
final Collection<NodeModel> nodes = Controller.getCurrentModeController().getMapController().getSelectedNodes();
for (final NodeModel node : nodes) {
if (node != null && atrUtil.hasAttributes(node)) {
enable = true;
break;
}
}
setEnabled(enable);
}
Aggregations