Skip to main content



      Home
Home » Modeling » Graphiti » Draw Dashed Line for connections
Draw Dashed Line for connections [message #1235075] Thu, 23 January 2014 09:12 Go to next message
Eclipse UserFriend
Hi, I am beginner in Graphiti. I will be thankful if anyone could help me for my questions.

Question 1: According to the model I try to implement, I need dashed line connection between two Shapes. How can I draw this dashed line ? Is there a built in style for dashed line(or dotted line)?

Question 2: I want to make a connection between a Ereference(connection) and Eobject(shape). is it possible in Graphiti?

Regards,
Cagkan
Re: Draw Dashed Line for connections [message #1235536 is a reply to message #1235075] Fri, 24 January 2014 11:04 Go to previous messageGo to next message
Eclipse UserFriend
cagkan toptas wrote on Thu, 23 January 2014 09:12
Hi, I am beginner in Graphiti. I will be thankful if anyone could help me for my questions.

Question 1: According to the model I try to implement, I need dashed line connection between two Shapes. How can I draw this dashed line ? Is there a built in style for dashed line(or dotted line)?


You have to set the linestyle of ur polyline:
polyline.setLineStyle(LineStyle.DOT);


cagkan toptas wrote on Thu, 23 January 2014 09:12

Question 2: I want to make a connection between a Ereference(connection) and Eobject(shape). is it possible in Graphiti?

Regards,
Cagkan


I am not sure if u can add an anchor to a connection... in other words, Ive tested it, it is possible, but I was not able to connect a Connection with it...

[Updated on: Fri, 24 January 2014 11:07] by Moderator

Re: Draw Dashed Line for connections [message #1236180 is a reply to message #1235536] Sun, 26 January 2014 08:10 Go to previous messageGo to next message
Eclipse UserFriend
Thank you for answers. For question 1 it is okay. For question 2, I try to add chopboxanchor to connection when I add a reference between an object and a reference it connects my shape to point(100,100) in the screen (Can be seen at attached Picture)

// This is from AbstractAddFeature class (the red dotted line)

    public PictogramElement add(IAddContext context) {
        IAddConnectionContext addConContext = (IAddConnectionContext) context;
        DataFlow addedEReference = (DataFlow) context.getNewObject();
        IPeCreateService peCreateService = Graphiti.getPeCreateService();
        
            
        // CONNECTION WITH POLYLINE
        Connection connection = peCreateService
            .createFreeFormConnection(getDiagram());
        connection.setStart(addConContext.getSourceAnchor());
        connection.setEnd(addConContext.getTargetAnchor());

        
        
        IGaService gaService = Graphiti.getGaService();
        
        
        
        Polyline polyline = gaService.createPolyline(connection);
        polyline.setLineWidth(2);
        polyline.setLineStyle(LineStyle.DOT);
        polyline.setForeground(manageColor(E_REFERENCE_FOREGROUND));
 
        // create link and wire it
        link(connection, addedEReference);
        
        ConnectionDecorator cd;
        cd = peCreateService
              .createConnectionDecorator(connection, false, 1.0, true);
        createArrow(cd);
        
        [b]// add a chopbox anchor to the connection [/b]
       [b] peCreateService.createChopboxAnchor(connection);[/b]
        
        return connection;
    }


Did I added it true or I need to do something else?

[Updated on: Mon, 27 January 2014 21:30] by Moderator

Re: Draw Dashed Line for connections [message #1236461 is a reply to message #1236180] Mon, 27 January 2014 04:07 Go to previous messageGo to next message
Eclipse UserFriend
You can ask the connection for the target parent
connection.getEnd().getParent()
.
Now you are able to test, if your connection has the correct target.
Re: Draw Dashed Line for connections [message #1236739 is a reply to message #1236461] Mon, 27 January 2014 19:51 Go to previous messageGo to next message
Eclipse UserFriend

Connection newConnection = null;
Binding newconn = null;

newconn = createBinding(context.getSourceAnchor,context.getTargetAnchor); 	 
AddConnectionContext addContext =
             new AddConnectionContext(context.getSourceAnchor(),context.getTargetAnchor());
         addContext.setNewObject(newconn);
         newConnection = (Connection) getFeatureProvider().addIfPossible(addContext);
return newConnection;


This code piece is from Connection create(ICreateConnectionContext context) function from AbstractCreateConnectionFeature

In function I can detect the source and target object tpye which are True but it doesn't connect them properly. (This is the only case its not working. Between two Eobject instead of between Eobject and Ereference, its working well)

Re: Draw Dashed Line for connections [message #1236879 is a reply to message #1235075] Tue, 28 January 2014 04:35 Go to previous message
Eclipse UserFriend
The source and target object type cant be true.
You have to check if they are an instance of eobject and ereference ( or you build your own emf-model)
So, the canAdd/canCreate method is interesting.
Previous Topic:Force Connection refresh/redraw
Next Topic:No Diagram found for URI
Goto Forum:
  


Current Time: Wed Jul 23 08:34:45 EDT 2025

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

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

Back to the top