use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.
the class UndoHandler method addActor.
/*
* (non-Javadoc)
* @see
* freeplane.base.undo.UndoHandler#addActor(freeplane.base.undo.UndoableActor
* )
*/
public void addActor(final IActor actor) {
resetRedo();
actorList.commitDelay = COMMIT_DELAY;
final long currentTime = System.currentTimeMillis();
if (deactivated) {
if (!actionFrameStarted && currentTime - timeOfLastAdd > UndoHandler.TIME_TO_BEGIN_NEW_ACTION) {
deactivated = false;
} else {
if (actorList.size() > 0) {
actorList.clear();
actorIterator = actorList.listIterator();
}
return;
}
}
if ((actorList.size() > 0) && (actionFrameStarted || currentTime - timeOfLastAdd < UndoHandler.TIME_TO_BEGIN_NEW_ACTION)) {
CompoundActor compoundActor = (CompoundActor) actorIterator.previous();
compoundActor.add(actor);
actorIterator.next();
} else {
CompoundActor compoundActor = new CompoundActor();
final Controller controller = Controller.getCurrentController();
if (map == controller.getMap()) {
final IMapSelection selection = controller.getSelection();
final SelectionActor selectionActor = SelectionActor.create(selection);
compoundActor.add(selectionActor);
}
compoundActor.add(actor);
actorIterator.add(compoundActor);
final int maxEntries = UndoHandler.MAX_ENTRIES;
while (actorList.size() > maxEntries) {
actorList.removeFirst();
actorIterator = actorList.listIterator(actorList.size());
}
}
startActionFrame();
timeOfLastAdd = currentTime;
fireStateChanged();
}
use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.
the class LastOpenedList method selectLastVisitedNode.
private boolean selectLastVisitedNode(RecentFile recentFile) {
if (recentFile != null && recentFile.lastVisitedNodeId != null) {
final MapModel map = Controller.getCurrentController().getMap();
final NodeModel node = map.getNodeForID(recentFile.lastVisitedNodeId);
if (node != null && node.hasVisibleContent()) {
IMapSelection selection = Controller.getCurrentController().getSelection();
// don't override node selection done by UriManager.loadURI()
if (selection.isSelected(map.getRootNode()))
selection.selectAsTheOnlyOneSelected(node);
return true;
}
}
return false;
}
use of org.freeplane.features.map.IMapSelection 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.IMapSelection in project freeplane by freeplane.
the class CopyAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final Controller controller = Controller.getCurrentController();
final ModeController modeController = Controller.getCurrentModeController();
final IMapSelection selection = controller.getSelection();
if (selection != null) {
final ClipboardController clipboardController = (ClipboardController) modeController.getExtension(ClipboardController.class);
final Transferable copy = clipboardController.copy(selection);
if (copy != null) {
clipboardController.setClipboardContents(copy);
}
}
}
use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.
the class LinkController method addLinks.
private void addLinks(final JComponent arrowLinkPopup, final NodeModel source) {
final IMapSelection selection = Controller.getCurrentModeController().getController().getSelection();
if (!selection.isSelected(source)) {
GotoLinkNodeAction gotoLinkNodeAction = new GotoLinkNodeAction(this, source);
gotoLinkNodeAction.configureText("follow_graphical_link", source);
addAction(arrowLinkPopup, gotoLinkNodeAction);
}
}
Aggregations