| [Draw2D] Adding Decorations to Figures [message #79827] |
Sat, 17 May 2003 13:24  |
Eclipse User |
|
|
|
Originally posted by: a_shishkov.yahoo.com
Hello,
I've looked at Draw2D Example 4 - Connections and Anchors. I tried it out
and it works fine. Now I want to add a label decoration to a shape. The
decoration works fine when I add it to a PolylineConnection, but not when I
try to use it for a Shape. Here is my code:
Ellipse circle = new Ellipse();
circle.setBounds(x, y, w, h);
circle.setOpaque(true);
Label label = new Label("somelabel");
label.setOpaque(true);
label.setBackgroundColor(ColorConstants.buttonLightest);
label.setBorder(new LineBorder());
RelativeLocator rl = new RelativeLocator(circle,
PositionConstants.SOUTH_EAST);
// also tried RelativeLocator rl = new RelativeLocator(circle, 1.0, 1.0);
circle.add(label, rl);
panel.add(circle);
With this code I see no label next to the circle and when I print the label
coordinates they are always 0,0. I also tried implementing the Locator
interface and found that if I substitute my Locator implementation for
RelativeLocator, the relocate(IFigure target) method never gets called.
Am I doing something wrong? I am using Win XP with Eclipse 2.1.
Thank you for your help.
Angel
|
|
|
| Re: [Draw2D] Adding Decorations to Figures [message #79857 is a reply to message #79827] |
Sat, 17 May 2003 14:47  |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
PolylineConnection uses a special layoutmanager that recognizes locators.
You could set this as the layoutmanager for a shape, but polylineconnection
also is able to update its bounds to include any of its children decoration.
Normal figures like shapes cannot do this.
The best way to add a label is via composition. Create a Figure that
contains both a shape and a label figure as children. The parent figure can
use a ToolbarLayout in vertical orientation.
"Angel Shishkov" <a_shishkov@yahoo.com> wrote in message
news:ba5r5o$b4j$1@rogue.oti.com...
> Hello,
>
> I've looked at Draw2D Example 4 - Connections and Anchors. I tried it out
> and it works fine. Now I want to add a label decoration to a shape. The
> decoration works fine when I add it to a PolylineConnection, but not when
I
> try to use it for a Shape. Here is my code:
>
> Ellipse circle = new Ellipse();
> circle.setBounds(x, y, w, h);
> circle.setOpaque(true);
>
> Label label = new Label("somelabel");
> label.setOpaque(true);
> label.setBackgroundColor(ColorConstants.buttonLightest);
> label.setBorder(new LineBorder());
> RelativeLocator rl = new RelativeLocator(circle,
> PositionConstants.SOUTH_EAST);
> // also tried RelativeLocator rl = new RelativeLocator(circle, 1.0, 1.0);
> circle.add(label, rl);
>
> panel.add(circle);
>
> With this code I see no label next to the circle and when I print the
label
> coordinates they are always 0,0. I also tried implementing the Locator
> interface and found that if I substitute my Locator implementation for
> RelativeLocator, the relocate(IFigure target) method never gets called.
>
> Am I doing something wrong? I am using Win XP with Eclipse 2.1.
>
> Thank you for your help.
>
> Angel
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.33600 seconds