Skip to main content



      Home
Home » Eclipse Projects » GEF » MidpointLocator problem
MidpointLocator problem [message #177568] Thu, 14 April 2005 11:47 Go to next message
Eclipse UserFriend
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 13:05 Go to previous messageGo to next message
Eclipse UserFriend
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 15: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] Thu, 14 April 2005 21:10 Go to previous messageGo to next message
Eclipse UserFriend
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] Thu, 14 April 2005 21:26 Go to previous message
Eclipse UserFriend
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: Sun Jul 06 11:45:15 EDT 2025

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

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

Back to the top