GEF Shapes Example: How can I change the TargetDecoration for Connections?
-
24-05-2021 - |
Вопрос
In the GEF shapes example, there are two types of connections, they differ by line style only (int Graphics.LINE_DASH
or int Graphics.LINE_SOLID
).
Now I wanna change the TargetDecoration (or rather set it to null
) for one of them. How do I do this?
I've tried an if
in the below method (below is the original), but it didn't have any effect. I tried if (getCastedModel().getLineStyle() != Graphics.LINE_DASH) connections.setTargetDecoration(null)
and left he rest as it was.
protected IFigure createFigure() {
PolylineConnection connection = (PolylineConnection) super
.createFigure();
connection.setTargetDecoration(new PolygonDecoration()); // arrow at
// target
// endpoint
connection.setLineStyle(getCastedModel().getLineStyle()); // line
// style
return connection;
}
Thanks!
Решение
The following code worked (changed the last two lines before the return):
protected IFigure createFigure() {
PolylineConnection connection = (PolylineConnection) super.createFigure();
connection.setTargetDecoration(new PolygonDecoration());
connection.setLineStyle(getCastedModel().getLineStyle());
if(getCastedModel().getLineStyle() == Graphics.LINE_DASH) {
connection.setTargetDecoration(null);
}
return connection;
}
This is the result:
Strange that this didn't work for you...
Не связан с StackOverflow