use of org.freeplane.view.swing.map.MainView in project freeplane by freeplane.
the class TextController method registerNodeTextTooltip.
private void registerNodeTextTooltip() {
modeController.addToolTipProvider(NODE_TOOLTIP, new ITooltipProvider() {
@Override
public String getTooltip(final ModeController modeController, NodeModel node, Component view) {
return getTooltip(modeController, node, (MainView) view);
}
private String getTooltip(final ModeController modeController, NodeModel node, MainView view) {
if (!ShortenedTextModel.isShortened(node)) {
return null;
}
final NodeStyleController style = modeController.getExtension(NodeStyleController.class);
final Font font = style.getFont(node);
float zoom = view.getNodeView().getMap().getZoom();
final StringBuilder htmlBodyStyle = new StringBuilder("<body><div style=\"").append(new CssRuleBuilder().withHTMLFont(font).withColor(view.getForeground()).withBackground(view.getNodeView().getTextBackground()).withAlignment(view.getHorizontalAlignment()).withMaxWidthAsPt(zoom, style.getMaxWidth(node)));
final Object data = node.getUserObject();
String text;
try {
text = getTransformedText(data, node, data);
if (text.equals(getShortText(text)))
return null;
} catch (Exception e) {
text = TextUtils.format("MainView.errorUpdateText", data, e.getLocalizedMessage());
htmlBodyStyle.append("color:red;");
}
htmlBodyStyle.append("\">");
if (!HtmlUtils.isHtmlNode(text)) {
text = HtmlUtils.plainToHTML(text);
}
final String tooltipText = text.replaceFirst("<body>", htmlBodyStyle.toString()).replaceFirst("</body>", "</div></body>");
return tooltipText;
}
});
}
use of org.freeplane.view.swing.map.MainView in project freeplane by freeplane.
the class MNodeDragListener method dragGestureRecognized.
public void dragGestureRecognized(final DragGestureEvent e) {
final MainView mainView = (MainView) e.getComponent();
final NodeView nodeView = mainView.getNodeView();
final MapView mapView = nodeView.getMap();
mapView.select();
if (!nodeView.isSelected()) {
nodeView.getMap().getModeController().getController().getSelection().selectAsTheOnlyOneSelected(nodeView.getModel());
}
Rectangle bounds = new Rectangle(0, 0, mainView.getWidth(), mainView.getHeight());
if (!bounds.contains(e.getDragOrigin()))
return;
final int dragActionType = e.getDragAction();
if (dragActionType == DnDConstants.ACTION_MOVE) {
final NodeModel node = nodeView.getModel();
if (node.isRoot()) {
if (!isLinkDragEvent(e))
return;
}
}
final String dragActionName;
Cursor cursor = getCursorByAction(dragActionType);
if (isLinkDragEvent(e)) {
cursor = DragSource.DefaultLinkDrop;
dragActionName = "LINK";
} else if ((e.getTriggerEvent().getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0) {
cursor = DragSource.DefaultCopyDrop;
dragActionName = "COPY";
} else {
dragActionName = "MOVE";
}
final Transferable t = ClipboardController.getController().copy(Controller.getCurrentController().getSelection());
((MindMapNodesSelection) t).setDropAction(dragActionName);
try {
e.startDrag(cursor, t, new DragSourceListener() {
public void dragDropEnd(final DragSourceDropEvent dsde) {
}
public void dragEnter(final DragSourceDragEvent e) {
}
public void dragExit(final DragSourceEvent dse) {
}
public void dragOver(final DragSourceDragEvent dsde) {
}
public void dropActionChanged(final DragSourceDragEvent dsde) {
dsde.getDragSourceContext().setCursor(getCursorByAction(dsde.getUserAction()));
}
});
} catch (final InvalidDnDOperationException ex) {
}
}
use of org.freeplane.view.swing.map.MainView in project freeplane by freeplane.
the class MNodeDropListener method supportFolding.
private void supportFolding(final DropTargetDragEvent dtde) {
final MainView node = getNode(dtde);
if (isInFoldingRegion(dtde)) {
node.setMouseArea(MouseArea.FOLDING);
startUnfoldTimer(node);
} else {
node.setMouseArea(MouseArea.DEFAULT);
stopUnfoldTimer();
}
}
use of org.freeplane.view.swing.map.MainView in project freeplane by freeplane.
the class MNodeDropListener method dragExit.
public void dragExit(final DropTargetEvent e) {
getNode(e).setMouseArea(MouseArea.OUT);
stopUnfoldTimer();
final MainView mainView = getNode(e);
mainView.setDraggedOver(NodeView.DRAGGED_OVER_NO);
mainView.repaint();
}
use of org.freeplane.view.swing.map.MainView in project freeplane by freeplane.
the class MNodeMotionListener method mouseMoved.
@Override
public void mouseMoved(final MouseEvent e) {
if (isDragActive())
return;
final MainView v = (MainView) e.getSource();
if (v.isInDragRegion(e.getPoint())) {
v.setMouseArea(MouseArea.MOTION);
v.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
return;
}
super.mouseMoved(e);
}
Aggregations