Question

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!

Was it helpful?

Solution

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:

enter image description here

Strange that this didn't work for you...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top