Getting anchors from Pictogram Element [message #1289530] |
Wed, 09 April 2014 11:57 |
|
Hello,
I'm having some trouble trying to create a new connections programmatically.
I have two graphical objects and a connection between them. I then want to programmatically delete one of them (and the connection), create another one on it's place, and create the connection again.
I delete the graphical object with a delete feature, create another one with the add feature, but in order to create the connection, I need the anchors of the newly created object, and I can't see how to get them from the Pictogram Element returned from the add feature...
Am I doing this the right way? If so, how can I get the anchor?
Thanks.
|
|
|
|
Re: Getting anchors from Pictogram Element [message #1290911 is a reply to message #1290628] |
Thu, 10 April 2014 14:51 |
|
Yes, I have the PE, and it contains 3 anchors, but how can I get them? It must be obvious, but I can´t figure it out... That´s what I do:
AddContext addContext = new AddContext();
addContext.setNewObject(...);
addContext.setTargetContainer(getDiagram());
addContext.setX(...);
addContext.setY(...);
IAddFeature addFeature = getFeatureProvider().getAddFeature(addContext);
if (addFeature.canAdd(addContext))
PictogramElement addedElement = addFeature.add(addContext);
Anchor anchor1 = ...
Anchor anchor2 = ### PROBLEM ###
AddConnectionContext connectionContext = new AddConnectionContext(anchor1, anchor2);
connectionContext.setNewObject(...);
IAddFeature connectionAddFeature = getFeatureProvider().getAddFeature(connectionContext);
if (connectionAddFeature.canAdd(connectionContext))
connectionAddFeature.add(connectionContext);
The problem is that anchor2 is a anchor from addedElement, but I don't know how to get it...
[Updated on: Thu, 10 April 2014 14:52] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03261 seconds