Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Draw on GMF Canvas without updating the notation model
Draw on GMF Canvas without updating the notation model [message #1806078] Thu, 02 May 2019 11:13 Go to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 364
Registered: December 2015
Senior Member
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 09:17 Go to previous message
Felix Dorner is currently offline Felix DornerFriend
Messages: 364
Registered: December 2015
Senior Member
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);
Previous Topic:Multiline Link
Next Topic:GraphicalViewer
Goto Forum:
  


Current Time: Tue Nov 24 18:57:42 GMT 2020

Powered by FUDForum. Page generated in 0.02156 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top