Reputation: 755
I am currently working with gmf and I would like to change the colour of connections. I debug the code and I saw thatafter setting createConnectionFigure() method the foreground colour the refresh() method in the AbstractGraphicalEditPart class overrides this colour. Is there any special way that I can change the colour? Also I want to create a circle for source and target decoration of the link. I know that I have to extend the Polyline class but I don;t anything about the rest. Do you know any available example?
Upvotes: 0
Views: 730
Reputation: 606
The preferred way to change the color of your figure is through the notation model(View).
While you create the edge view, you can set the line color for edge in the edge notation.
Connector edge = NotationFactory.eINSTANCE.createConnector();
ViewUtil.setStructuralFeatureValue(edge,NotationPackage.eINSTANCE.getLineStyle_LineColor(),new RGB(0,0,0));
If you have created your GMF editor plugin using GMF tools, there will be a class ViewProvider. There, they would have methods to create edge. You can change it there.
OR
Set the color in the PreferenceStore.
OR
worst case, you can override the refreshForegroundColor() in the ConnectionEditPart & set your own color. However the downside of this approach is, you cannot change the color through the UI.
As for decorations, in your connection figure, decoration can be set through setSourceDecoration & setTargetDecoration
eg: connection.setSourceDecoration(new org.eclipse.draw2d.PolylineDecoration());
Upvotes: 1