|
Re: Length of a ConnectionNodeEditPart [message #485745 is a reply to message #485740] |
Mon, 14 September 2009 18:34 |
Artur Kronenberg Messages: 159 Registered: August 2009 |
Senior Member |
|
|
Hi,
your decoration should be referencing its source and its target. You can
get the locations of those two and calculate the difference to get the
length of the connection edit part.
Best,
Artur
josiaspaesjr wrote:
> Hi all,
> I have a class that extends the class ConnectionNodeEditPart. I need to
> retrieve the size of this connection (1) to put the decorator always at
> the center of the connection. There is a way to do or suggest another
> solution?
> For example:
> (1)http://img16.imageshack.us/img16/8229/lenghtconnection.jpg
> Following code decorator:
> private RotatableDecoration createTargetDecoration() {
> PolygonDecoration df = new PolygonDecoration();
> PointList pl = new PointList();
> pl.addPoint(-1,-4);
> pl.addPoint(-3,-3);
> pl.addPoint(-4,-1);
> pl.addPoint(-4,1);
> pl.addPoint(-3,3);
> pl.addPoint(-1,4);
> df.setTemplate(pl);
> df.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));
> df.setBackgroundColor(DF_WHITE);
> df.setForegroundColor(DF_BLACK);
> return df;
> }
> Thanks
> Josias Paes
|
|
|
|
Re: Length of a ConnectionNodeEditPart [message #485772 is a reply to message #485770] |
Mon, 14 September 2009 21:53 |
Artur Kronenberg Messages: 159 Registered: August 2009 |
Senior Member |
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.02782 seconds