Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » MidpointLocator problem
MidpointLocator problem [message #177568] Thu, 14 April 2005 15:47 Go to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 161
Registered: July 2009
Senior Member
Hi all,
These codes shows a label in the middle of a connection:
Label label=new Label();
label.setText("test");
conn.add(label,new MidpointLocator(conn, 0));

But replace them with following code, nothing is in the middle(expecting an
triangle):
conn.add(new PolygonDecoration(),new MidpointLocator(conn, 0));

why?

Regards
Hao
Re: MidpointLocator problem [message #177592 is a reply to message #177568] Thu, 14 April 2005 17:05 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
What do you mean nothing? What were you expecting? That triangle is the
polygon decoration you added. Usually, the polygon decorations are used
with endpoint locators to create arrowheads on either end of the connection.

"Hao Zhang" <bjzhanghao@21cn.com> wrote in message
news:d3m3n1$slo$1@news.eclipse.org...
> Hi all,
> These codes shows a label in the middle of a connection:
> Label label=new Label();
> label.setText("test");
> conn.add(label,new MidpointLocator(conn, 0));
>
> But replace them with following code, nothing is in the middle(expecting
an
> triangle):
> conn.add(new PolygonDecoration(),new MidpointLocator(conn, 0));
>
> why?
>
> Regards
> Hao
>
>
Re: MidpointLocator problem [message #177663 is a reply to message #177568] Thu, 14 April 2005 19:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

A PolygonDecoration is a RotatableDecoration and requires a special locator:
ArrowLocator.
PolygonDecoration is a Polygon. You cannot call setBounds on polygon
either.

"Hao Zhang" <bjzhanghao@21cn.com> wrote in message
news:d3m3n1$slo$1@news.eclipse.org...
> Hi all,
> These codes shows a label in the middle of a connection:
> Label label=new Label();
> label.setText("test");
> conn.add(label,new MidpointLocator(conn, 0));
>
> But replace them with following code, nothing is in the middle(expecting
> an
> triangle):
> conn.add(new PolygonDecoration(),new MidpointLocator(conn, 0));
>
> why?
>
> Regards
> Hao
>
>
Re: MidpointLocator problem [message #177766 is a reply to message #177663] Fri, 15 April 2005 01:10 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 161
Registered: July 2009
Senior Member
I see, however, what should I do to place a rotatable trianble in the middle
of a polyline connection?

"Randy Hudson" <none@us.ibm.com> д
Re: MidpointLocator problem [message #177774 is a reply to message #177766] Fri, 15 April 2005 01:26 Go to previous message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 161
Registered: July 2009
Senior Member
Problem solved using following subclass of MidpointLocator, thanks.

class MyMidpointLocator extends MidpointLocator {
public MyMidpointLocator(Connection c, int i) {
super(c, i);
}
public void relocate(IFigure target) {
PointList points = getConnection().getPoints();
RotatableDecoration arrow = (RotatableDecoration) target;
arrow.setLocation(getLocation(points));
arrow.setReferencePoint(points.getPoint(getIndex()));
}
}

"Hao Zhang" <bjzhanghao@21cn.com> д
Previous Topic:Custom Selection Drawing
Next Topic:Outline view selection doesn't do Properties
Goto Forum:
  


Current Time: Thu Feb 02 14:37:55 GMT 2023

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

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

Back to the top