[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: Length of a ConnectionNodeEditPart

Hi,

well you should have the EditPart that is connecting your two editParts. If you refer to the image you posted (http://img16.imageshack.us/img16/8229/lenghtconnection.jpg) it is the blue line with the dot. I suppose you wanted to have the dot in the middle of the line.

Depending on how you modeled your diagram, your connection EditPart should have the methods getSource() and getTarget() what would give you both editParts on both ends of the line. (task and task in your image).

Those editParts have BoundsImpl Objects on them. If you get that object you can call getX() and getY() on both of those objects which would give you the exact location. (Maybe you can even call getAnchor() but I didn't try that. If so, that would be even better for calculating the length of your line). When you have the locations, you can just callculate the length.

For example:

Task1 has the location (5, 30) and Task2 has the location (40,30). The length of your line would be 40 - 5 = 35. It gets a little more complicated when the Y positioning is not the same, but it is still just math.

I don't know if that is the best way of handling this problem. But this would be a way of getting the length of your line which I think was the problem in the first place.

Best,
Artur

josiaspaesjr wrote:

Hi Arthur,

could you give an example of how to do?

Thanks,
Josias Paes