Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Length of PolylineConnection ?
Length of PolylineConnection ? [message #161740] Thu, 16 December 2004 13:48 Go to next message
Eclipse UserFriend
Originally posted by: ssc.acentic.net

Hi

How do I get the length of the connection line ?

PolylineConnection c = new PolylineConnection();
ChopboxAnchor sourceAnchor = new ChopboxAnchor(f1);
ChopboxAnchor targetAnchor = new ChopboxAnchor(f2);
c.setSourceAnchor(sourceAnchor);
c.setTargetAnchor(targetAnchor);

System.out.println("lenght ? : " + c.getSize() ); // <-- problem,
getSize is not correct


-Sebastian
Re: Length of PolylineConnection ? [message #161844 is a reply to message #161740] Fri, 17 December 2004 05:27 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
getSize() returns the size of the rectangle that would completely enclose
the PolylineConnection. What you need to do is calculate the length for
each line segment in the PolylineConnection (i.e., at various bendpoints)
using the Pythagorean theorem, and add them up.

"Sebastian Scholz" <ssc@acentic.net> wrote in message
news:cps3m5$6f7$1@www.eclipse.org...
> Hi
>
> How do I get the length of the connection line ?
>
> PolylineConnection c = new PolylineConnection();
> ChopboxAnchor sourceAnchor = new ChopboxAnchor(f1);
> ChopboxAnchor targetAnchor = new ChopboxAnchor(f2);
> c.setSourceAnchor(sourceAnchor);
> c.setTargetAnchor(targetAnchor);
>
> System.out.println("lenght ? : " + c.getSize() ); // <-- problem,
> getSize is not correct
>
>
> -Sebastian
>
Re: Length of PolylineConnection ? [message #161883 is a reply to message #161844] Fri, 17 December 2004 08:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ssc.acentic.net

Well, I have no problem calculating anything to get the length, but my
problem here is that I do not have any start or end point.

How would I get the sourceAnchor coordinates ?
Re: Length of PolylineConnection ? [message #161923 is a reply to message #161883] Fri, 17 December 2004 15:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

The endpoints get set when a layout occurs. The connection does not move
immediately when you call setSourceAnchor, etc. What are you trying to do?


"Sebastian Scholz" <ssc@acentic.net> wrote in message
news:cpu5vo$nah$1@www.eclipse.org...
> Well, I have no problem calculating anything to get the length, but my
> problem here is that I do not have any start or end point.
>
> How would I get the sourceAnchor coordinates ?
>
>
>
Re: Length of PolylineConnection ? [message #162147 is a reply to message #161923] Mon, 20 December 2004 07:24 Go to previous message
Eclipse UserFriend
Originally posted by: ssc.acentic.net

Well, basically I want to do 2 things :

1. I want to create a more dynamic method to add a line between 2 Figures
to add a Label in the exact middle and

2. I want to make the Figures dragable (which I was not able to achieve
yet) and update the line between it.

From my understanding I need 2 things, the coordinates of a start and a
end point of the line to know whats between it. Right now I have a very
dirty solution, take the starting point of Figure 1, get the size, get the
middle point of the closest line to the next Figure,... do the same with
the Figure 2 and then calculate the distance between the 2 poings, BUT I
kinda thought since the line is drawn by this "PolylineConnection" it
should knows these 2 points.
Previous Topic:class not found
Next Topic:How do you run the GEF examples
Goto Forum:
  


Current Time: Fri Apr 26 08:53:08 GMT 2024

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

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

Back to the top