Refresh bounds of a node [message #78527] |
Fri, 17 November 2006 10:01  |
Eclipse User |
|
|
|
Originally posted by: seliva.gmail.com
Hi!
I am trying to change the location of one node of my gmf diagram
programatically. I think the proper way of doing this is using
ChangeBoundsRequest, but somehow I havent manage to do it.
Here is the code I have use:
ChangeBoundsRequest move_req = new
ChangeBoundsRequest(RequestConstants.REQ_MOVE);
EditPart trainEditPart = getTrainEditPart(diagramEditPart,trainName);
Point destinyLocation = getYardObjectLocation(objectEditPart);
move_req.setMoveDelta(destinyLocation);
Command move_cmd = trainEditPart.getCommand(move_req);
if (move_cmd == null || !(move_cmd.canExecute())) {
throw new IllegalArgumentException("Command is not executable.");
}
else {
diagramEditPart.getDiagramEditDomain().getDiagramCommandStac k().execute(move_cmd);
trainEditPart.refresh();
}
I know that trainEditPart and destinyLocation are the right ones, so the
problem is not there. I also know that the move_cmd is not null and it is
possible to execute it.
I tried to call trainEditPart.refresh() after the command is executed but
it did not make any difference. I dont get any error, so I dont know where
the problem can be, but just the my node is not moving.
Does someone has any idea? Thanks a lot!
|
|
|
|
|
|
Re: Refresh bounds of a node [message #79094 is a reply to message #78921] |
Tue, 21 November 2006 03:11  |
Eclipse User |
|
|
|
Originally posted by: seliva.gmail.com
Hi Mohammed!
thank you very much for your tips. Now I manage to make my object visible
all the time, and moving it within my diagram. (Maybe my problem was that
I was using the plain EditPart without translating it to GraphicalEditPart)
The only problem I have now is that the position is not exact. I calculate
the delta by:
delta = new
Point(destinyLocation.x-currentLocation.x,destinyLocation.y- currentLocation.y);
and check that the delta is the desired one, but anyways, the object
appears a bit moved from that point. Maybe it has something to do with
Relative/Absolute coordinates? Thanks for the help!
|
|
|
Powered by
FUDForum. Page generated in 0.04214 seconds