Scaling to viewport? [message #90062] |
Thu, 07 August 2003 14:55  |
Eclipse User |
|
|
|
I am trying to get the right way to convert from mouse click coordinates to
my ScollingGraphicalViewer coordinates. I am using now this code that
works when I do not zoom, but if I use the zoom, the coordinates that I get
are the un-zoomed ones.
What is the right way to do this?
Thanks.
public class TopDragTracker extends MarqueeDragTracker {
public void mouseDoubleClick(MouseEvent me, EditPartViewer viewer) {
super.mouseDoubleClick(me, viewer);
org.eclipse.swt.graphics.Point p =
new org.eclipse.swt.graphics.Point(me.x, me.y);
Point location = new Point(p.x, p.y);
GraphicalEditPart part = (GraphicalEditPart)viewer.findObjectAt(location);
part.getFigure().translateFromParent(location);
CreateRequest request = new CreateRequest();
request.setLocation(location);
part.performRequest(request);
Point editClick = new Point(p.x, p.y);
Request edit = new DirectEditRequest(RequestConstants.REQ_OPEN);
EditPart child = viewer.findObjectAt(editClick);
child.performRequest(edit);
}
}
|
|
|
Re: Scaling to viewport? [message #90079 is a reply to message #90062] |
Thu, 07 August 2003 17:50  |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
The requests should always have absolute coordinates, so translateFromParent
is unnecessary.
Such translation should be done in the editpart which receives the request,
and the correct way to do it would probably be calling
translateFromAbsolute, not just from the parent.
"Alex Cozzi" <cozzi@almaden.ibm.com> wrote in message
news:bgu7f0$fhg$1@eclipse.org...
> I am trying to get the right way to convert from mouse click coordinates
to
> my ScollingGraphicalViewer coordinates. I am using now this code that
> works when I do not zoom, but if I use the zoom, the coordinates that I
get
> are the un-zoomed ones.
> What is the right way to do this?
> Thanks.
>
>
>
> public class TopDragTracker extends MarqueeDragTracker {
> public void mouseDoubleClick(MouseEvent me, EditPartViewer viewer)
{
> super.mouseDoubleClick(me, viewer);
> org.eclipse.swt.graphics.Point p =
> new org.eclipse.swt.graphics.Point(me.x, me.y);
> Point location = new Point(p.x, p.y);
>
> GraphicalEditPart part =
(GraphicalEditPart)viewer.findObjectAt(location);
> part.getFigure().translateFromParent(location);
> CreateRequest request = new CreateRequest();
> request.setLocation(location);
> part.performRequest(request);
>
> Point editClick = new Point(p.x, p.y);
> Request edit = new
DirectEditRequest(RequestConstants.REQ_OPEN);
> EditPart child = viewer.findObjectAt(editClick);
> child.performRequest(edit);
> }
> }
>
|
|
|
Powered by
FUDForum. Page generated in 0.03365 seconds