I want to insert a cell at a position on the page (similar as when dragging from the palette). The position should be the position of my mouse event, so the position where i do my right or left click. How can I convert the position of the mouse event in the graph control component to the graph page coordinates (the view or the canvas?)? Within the implementation of getCellAt(x,x) there is some computation with the scale and translation of the canvas. 1. Is there a funtion for conversion or what should i do? 2. How is that implemented in the editor example with drag and drop?

asked 08 Feb '13, 11:21

greg's gravatar image

greg
13
accept rate: 0%

edited 26 Feb '13, 07:00

David's gravatar image

David
4.9k21831


Found it myself:

final Object object = mComponent.getCellAt(evt.getX(), evt.getY());
final Point pnt = SwingUtilities.convertPoint(mComponent.getGraphControl(), evt.getPoint(), this);
final mxPoint pos = mComponent.getPointForEvent(evt, false);

where mComponent is the graph component and evt is the MouseEvent in coordinates of the graph component and this is a parent component of the graph component.

link

answered 03 Apr '13, 12:40

greg's gravatar image

greg
13
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×194
×45
×22
×9
×2

Asked: 08 Feb '13, 11:21

Seen: 2,341 times

Last updated: 03 Apr '13, 12:40