Is there a way to specify a layout for children of a PolylineConnection
?
有没有办法为PolylineConnection的子项指定布局?
I want to add several Label
s to a PolylineConnection
at ConnectionLocator.MIDDLE
without the use of a container figure for the labels.
我想在ConnectionLocator.MIDDLE的PolylineConnection中添加几个标签,而不使用标签的容器图。
Both PolylineConnection
and Label
have EditParts
, and the label's model objects are children of the polyline connection's model objects.
PolylineConnection和Label都有EditParts,标签的模型对象是折线连接的模型对象的子对象。
Ideally I want to add all label children of a polyline to ConnectionLocator.MIDDLE
in a ToolbarLayout
...
理想情况下,我想将折线的所有标签子项添加到ToolbarLayout中的ConnectionLocator.MIDDLE ...
2 个解决方案
#1
1
What you are trying to do is mix two layouts: on the first hand you want to use a ConnectionLocator.MIDDLE
to locate the figures, but on the other hand you want to have the figures at this location to have their own layout.
你要做的是混合两个布局:第一方面你想使用ConnectionLocator.MIDDLE来定位数字,但另一方面你想让这个位置的数字有自己的布局。
The only solution you have is to create a figure that uses a ToolbarLayout
and locate it in the Polyline
using the ConnectionLocator
您唯一的解决方案是创建一个使用ToolbarLayout的图形,并使用ConnectionLocator在Polyline中找到它
#2
0
I've found a way to achieve what I wanted:
我找到了实现我想要的方法:
Very generally, the first child must be added at ConnectionLocator.MIDDLE
, and the rest of the children relative to the child before them with the help of RelativeLocator
like this (line would be in a loop over all figure children in connection's edit part):
通常情况下,必须在ConnectionLocator.MIDDLE中添加第一个子节点,并在RelativeLocator的帮助下将其余子节点相对于子节点添加到此处(行将在连接的编辑部分中的所有数字子节点上循环):
figure.add(childFigure,
new RelativeLocator((IFigure) figureChildren.get(currentIndex - 1),
0.5,
1.7);
I've written a blog post with more details.
我写了一篇博文,内容更详细。
#1
1
What you are trying to do is mix two layouts: on the first hand you want to use a ConnectionLocator.MIDDLE
to locate the figures, but on the other hand you want to have the figures at this location to have their own layout.
你要做的是混合两个布局:第一方面你想使用ConnectionLocator.MIDDLE来定位数字,但另一方面你想让这个位置的数字有自己的布局。
The only solution you have is to create a figure that uses a ToolbarLayout
and locate it in the Polyline
using the ConnectionLocator
您唯一的解决方案是创建一个使用ToolbarLayout的图形,并使用ConnectionLocator在Polyline中找到它
#2
0
I've found a way to achieve what I wanted:
我找到了实现我想要的方法:
Very generally, the first child must be added at ConnectionLocator.MIDDLE
, and the rest of the children relative to the child before them with the help of RelativeLocator
like this (line would be in a loop over all figure children in connection's edit part):
通常情况下,必须在ConnectionLocator.MIDDLE中添加第一个子节点,并在RelativeLocator的帮助下将其余子节点相对于子节点添加到此处(行将在连接的编辑部分中的所有数字子节点上循环):
figure.add(childFigure,
new RelativeLocator((IFigure) figureChildren.get(currentIndex - 1),
0.5,
1.7);
I've written a blog post with more details.
我写了一篇博文,内容更详细。