| Draw on GMF Canvas without updating the notation model [message #1806078] |
Thu, 02 May 2019 07:13  |
Eclipse User |
|
|
|
Hi,
I want to temporarily draw stuff onto a GMF Editor Canvas, but I don't want to do that by updating the notational model. The usecase is that I have a tool that proposes potentially interesting changes to the model, e.g, the tool proposes to create a Generalization between two classes. The propositions are then shown like a preview in the diagram, e.g. it draws the proposed generalization with the arrow connection.
Does anyone know how I can directly use the Draw2D (I guess) API to draw on the GMF canvas?
Thanks,
Felix
|
|
|
| Re: Draw on GMF Canvas without updating the notation model [message #1806270 is a reply to message #1806078] |
Tue, 07 May 2019 05:17  |
Eclipse User |
|
|
|
Answering my own question, yes, I did something like this:
IGraphicalEditPart p1 = getGraphicalPart(d1);
IGraphicalEditPart p2 = getGraphicalPart(d2);
if (p1 != null && p2 != null) {
IFigure f1 = p1.getFigure();
IFigure f2 = p2.getFigure();
PolylineConnectionEx conn = new PolylineConnectionEx() {
public void paint(Graphics graphics) {
setLineWidth(3);
setForegroundColor(ColorConstants.red);
super.paint(graphics);
}
};
conn.setSourceAnchor(new ChopboxAnchor(f1));
conn.setTargetAnchor(new ChopboxAnchor(f2));
LayerManager manager = (LayerManager) viewer.getEditPartRegistry()
.get(LayerManager.ID);
ConnectionLayer layer = (ConnectionLayer) manager.getLayer(LayerConstants.CONNECTION_LAYER);
layer.add(conn);
|
|
|
Powered by
FUDForum. Page generated in 0.03217 seconds