use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class MNodeMotionListener method mousePressed.
@Override
public void mousePressed(MouseEvent e) {
final MapView mapView = MapView.getMapView(e.getComponent());
mapView.select();
doubleClickTimer.cancel();
setClickDelay();
if (isInDragRegion(e)) {
if ((e.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) == (InputEvent.BUTTON1_DOWN_MASK)) {
nodeSelector.stopTimerForDelayedSelection();
final NodeView nodeV = getNodeView(e);
final Point point = e.getPoint();
findGridPoint(point);
UITools.convertPointToAncestor(nodeV, point, JScrollPane.class);
setDragStartingPoint(point, nodeV.getModel());
}
} else
super.mousePressed(e);
}
use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class MNodeMotionListener method mouseClicked.
@Override
public void mouseClicked(final MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2 && doubleClickTimer.getDelay() > 0) {
final MainView mainView = (MainView) e.getComponent();
if (mainView.getMouseArea().equals(MouseArea.MOTION)) {
final Controller controller = Controller.getCurrentController();
MLocationController locationController = (MLocationController) LocationController.getController(controller.getModeController());
if (e.getModifiersEx() == 0) {
final NodeView nodeV = getNodeView(e);
final NodeModel node = nodeV.getModel();
locationController.moveNodePosition(node, LocationModel.getModel(node).getVGap(), LocationModel.HGAP, 0);
return;
}
if (Compat.isCtrlEvent(e)) {
final NodeView nodeV = getNodeView(e);
final NodeModel node = nodeV.getModel();
locationController.moveNodePosition(node, LocationModel.VGAP, LocationModel.getModel(node).getHGap(), LocationModel.getModel(node).getShiftY());
return;
}
} else {
if (Compat.isPlainEvent(e) && !isInFoldingRegion(e)) {
final MTextController textController = MTextController.getController();
textController.getEventQueue().activate(e);
textController.edit(FirstAction.EDIT_CURRENT, false);
}
}
}
super.mouseClicked(e);
}
use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class MNodeMotionListener method calculateNewNodeIndex.
private int calculateNewNodeIndex(final NodeView nodeV, final boolean left, final int start, final int end) {
final NodeModel node = nodeV.getModel();
if (SummaryNode.isSummaryNode(node))
return -1;
final int nodeY = getRefY(nodeV);
final NodeView parent = nodeV.getParentView();
int newIndex = 0;
int oldIndex = -1;
int wrondSideCount = 0;
for (int i = start; i < end; i++) {
final Component component = parent.getComponent(i);
if (!(component instanceof NodeView))
continue;
NodeView sibling = (NodeView) component;
if (sibling.isLeft() == left && !SummaryNode.isSummaryNode(sibling.getModel()) && getRefY(sibling) > nodeY)
break;
else {
if (sibling != nodeV) {
newIndex++;
if (sibling.isLeft() != left)
wrondSideCount++;
else
wrondSideCount = 0;
} else {
oldIndex = i;
}
}
}
final int result = newIndex - wrondSideCount;
if (result == oldIndex)
return -1;
return result;
}
use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class MMapViewController method createEditor.
public EditNodeBase createEditor(final NodeModel node, final EditNodeBase.IEditControl editControl, String text, final boolean editLong) {
final String htmlEditingOption = ResourceController.getResourceController().getProperty("html_editing_option");
final boolean editInternalWysiwyg = editLong && StringUtils.equals(htmlEditingOption, "internal-wysiwyg");
final boolean editExternal = editLong && StringUtils.equals(htmlEditingOption, "external");
if (!HtmlUtils.isHtmlNode(text)) {
text = HtmlUtils.plainToHTML(text);
}
if (editInternalWysiwyg) {
final EditNodeWYSIWYG editNodeWYSIWYG = new EditNodeWYSIWYG(node, text, editControl, true);
final ViewController viewController = Controller.getCurrentModeController().getController().getViewController();
if (EditedComponent.TEXT.equals(editControl.getEditType())) {
int preferredHeight = (int) (getComponent(node).getHeight() * 1.2);
preferredHeight = Math.max(preferredHeight, Integer.parseInt(ResourceController.getResourceController().getProperty("el__min_default_window_height")));
preferredHeight = Math.min(preferredHeight, Integer.parseInt(ResourceController.getResourceController().getProperty("el__max_default_window_height")));
int preferredWidth = (int) (getComponent(node).getWidth() * 1.2);
preferredWidth = Math.max(preferredWidth, Integer.parseInt(ResourceController.getResourceController().getProperty("el__min_default_window_width")));
preferredWidth = Math.min(preferredWidth, Integer.parseInt(ResourceController.getResourceController().getProperty("el__max_default_window_width")));
final Dimension preferredSize = new Dimension(preferredWidth, preferredHeight);
editNodeWYSIWYG.setPreferredSize(preferredSize);
}
final MainView mainView = (MainView) getComponent(node);
final NodeView nodeView = mainView.getNodeView();
if (EditedComponent.TEXT.equals(editControl.getEditType())) {
final Font font = getFont(node);
editNodeWYSIWYG.setTitle("edit_long_node");
editNodeWYSIWYG.setFont(font);
final Color nodeTextColor = getTextColor(node);
editNodeWYSIWYG.setTextColor(nodeTextColor);
editNodeWYSIWYG.setBackground(nodeView.getTextBackground());
} else if (EditedComponent.DETAIL.equals(editControl.getEditType())) {
final MapView map = nodeView.getMap();
editNodeWYSIWYG.setTitle("edit_details");
editNodeWYSIWYG.setFont(map.getDetailFont());
editNodeWYSIWYG.setTextColor(map.getDetailForeground());
editNodeWYSIWYG.setBackground(nodeView.getDetailBackground());
} else if (EditedComponent.NOTE.equals(editControl.getEditType())) {
final MapView map = nodeView.getMap();
editNodeWYSIWYG.setTitle("edit_note");
editNodeWYSIWYG.setFont(map.getDefaultNoteFont());
editNodeWYSIWYG.setBackground(Color.WHITE);
}
return editNodeWYSIWYG;
} else if (editExternal) {
return new EditNodeExternalApplication(node, text, editControl);
} else {
final EditNodeBase textfield = createEditor(node, editControl.getEditType(), text, editControl);
if (textfield != null)
return textfield;
}
return createEditor(node, editControl, text, true);
}
use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class DefaultNodeMouseMotionListener method showFoldingPopup.
private void showFoldingPopup(MouseEvent e) {
ModeController mc = Controller.getCurrentController().getModeController();
final FoldingController foldingController = mc.getExtension(FoldingController.class);
if (foldingController == null)
return;
final NodeView nodeView = nodeSelector.getRelatedNodeView(e);
final JPopupMenu popupmenu = foldingController.createFoldingPopupMenu(nodeView.getModel());
AutoHide.start(popupmenu);
new NodePopupMenuDisplayer().showMenuAndConsumeEvent(popupmenu, e);
}
Aggregations