Skip to main content



      Home
Home » Eclipse Projects » GEF » Scaling to viewport?
Scaling to viewport? [message #90062] Thu, 07 August 2003 14:55 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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);
> }
> }
>
Previous Topic:Simulate initial connection using ConnectionCreationTool.
Next Topic:draw2D as WYSIWYG editor
Goto Forum:
  


Current Time: Sun Jun 08 18:46:23 EDT 2025

Powered by FUDForum. Page generated in 0.03365 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top