use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.
the class AddLocalLinkAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final IMapSelection selection = Controller.getCurrentController().getSelection();
final List<NodeModel> selecteds = selection.getOrderedSelection();
final int size = selecteds.size();
if (size < 2) {
Controller.getCurrentController();
UITools.errorMessage(TextUtils.getText("less_than_two_selected_nodes"));
return;
}
final NodeModel target = selecteds.get(size - 1);
final String targetId = (target).createID();
for (NodeModel source : selecteds) {
if (source != target)
((MLinkController) LinkController.getController()).setLink(source, ("#" + targetId), LinkController.LINK_ABSOLUTE);
}
}
use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.
the class Filter method applyFilter.
/*
* (non-Javadoc)
* @see
* freeplane.controller.filter.Filter#applyFilter(freeplane.modes.MindMap)
*/
public void applyFilter(Object source, final MapModel map, final boolean force) {
if (map == null) {
return;
}
try {
displayFilterStatus();
Controller.getCurrentController().getViewController().setWaitingCursor(true);
final Filter oldFilter = map.getFilter();
map.setFilter(this);
if (force || !isConditionStronger(oldFilter)) {
final NodeModel root = map.getRootNode();
resetFilter(root);
if (filterChildren(root, checkNode(root), false)) {
addFilterResult(root, FilterInfo.FILTER_SHOW_ANCESTOR);
}
}
final IMapSelection selection = Controller.getCurrentController().getSelection();
final NodeModel selected = selection.getSelected();
final NodeModel selectedVisible = selected.getVisibleAncestorOrSelf();
selection.keepNodePosition(selectedVisible, 0.5f, 0.5f);
refreshMap(source, map);
selectVisibleNode();
} finally {
Controller.getCurrentController().getViewController().setWaitingCursor(false);
}
}
use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.
the class MMapController method moveNodesInGivenDirection.
public void moveNodesInGivenDirection(NodeModel selected, Collection<NodeModel> movedNodes, final int direction) {
final List<NodeModel> mySelecteds = new ArrayList<NodeModel>(movedNodes);
final Comparator<Object> comparator = (direction == -1) ? null : new Comparator<Object>() {
public int compare(final Object o1, final Object o2) {
final int i1 = ((Integer) o1).intValue();
final int i2 = ((Integer) o2).intValue();
return i2 - i1;
}
};
if (mySelecteds.size() == 0)
return;
Collection<NodeModel> selectedNodes = new ArrayList<NodeModel>(getSelectedNodes());
final NodeModel parent = mySelecteds.get(0).getParentNode();
if (parent != null) {
final Vector<NodeModel> sortedChildren = getSortedSiblings(parent);
final TreeSet<Integer> range = new TreeSet<Integer>(comparator);
for (final NodeModel node : mySelecteds) {
if (node.getParentNode() != parent) {
LogUtils.warn("Not all selected nodes have the same parent.");
return;
}
range.add(new Integer(sortedChildren.indexOf(node)));
}
Integer last = range.iterator().next();
for (final Integer newInt : range) {
if (Math.abs(newInt.intValue() - last.intValue()) > 1) {
LogUtils.warn("Not adjacent nodes. Skipped. ");
return;
}
last = newInt;
}
for (final Integer position : range) {
final NodeModel node = sortedChildren.get(position.intValue());
moveSingleNodeInGivenDirection(node, direction);
}
final IMapSelection selection = Controller.getCurrentController().getSelection();
selection.selectAsTheOnlyOneSelected(selected);
for (NodeModel selectedNode : selectedNodes) {
selection.makeTheSelected(selectedNode);
}
}
}
use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.
the class CenterSelectedNodeAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final IMapSelection selection = Controller.getCurrentController().getSelection();
final Component mapView = Controller.getCurrentController().getMapViewManager().getMapViewComponent();
final JRootPane rootPane = SwingUtilities.getRootPane(mapView);
if (!rootPane.isValid()) {
rootPane.revalidate();
}
selection.centerNode(selection.getSelected());
}
use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.
the class DefaultMapMouseListener method mouseClicked.
public void mouseClicked(final MouseEvent e) {
final Object source = e.getSource();
if (!(source instanceof MapView))
return;
final MapView map = (MapView) source;
final Controller controller = map.getModeController().getController();
final IMapSelection selection = controller.getSelection();
if (selection != null) {
final NodeModel selected = selection.getSelected();
if (selected != null)
controller.getMapViewManager().getComponent(selected).requestFocusInWindow();
}
}
Aggregations