[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.tools.gef] How to translate absolute mouse coordinates to relative coordinates in an editor
|
Hi all,
I'm creating a little plug-in to drop requirements in a Sysml editor.
I want to make automatic to add a Satisfy link between the droped requirement and the class behind the mouse during the drop.
For that I have make a class implementing DropActionAdapter and in the handleDrop(Modeler modeler, Transfer transfer, EditPart editPart) method I want to get the editPart behind the mouse.
public void handleDrop(Modeler modeler, Transfer transfer, EditPart editPart) {
//I get the inputEvent in an other method
mouseLocation = new Point(inputEvent.x, inputEvent.y);
//The edit part is the root editPart on the editor
IFigure fig = ((GraphicalEditPart)editPart).getFigure();
fig.translateToRelative(mouseLocation);
EditPart part = editPart.getViewer().findObjectAt(mouseLocation);
//[...]
}
My problem is that the mouse location is not translated to relative and so the new EditPart (part) is the root EditPart
Is there something wrong in my code ?
Any help is welcome !!
Arnaud