How to connect 2 elements created out of same Eobject to different pictogramelements [message #1101242] |
Wed, 04 September 2013 07:35 |
PALANI SANKAR Messages: 35 Registered: April 2013 |
Member |
|
|
Hi All
I am facing a problem.i am creating 2 pictogram elements for an eobject
(ex: Student A) and i want to connect it to pictogram elements (ex: university and college). i can be able to create 2 diagrams using student A Eobject.
But during connection ,
connection between studentA and university.
sourceAnchor=getFeatureProvider().getPictogramElementForBusinessObject(StudentA);---->(1)
targetAnchor=getFeatureProvider().getPictogramElementForBusinessObject(University);
connection between studentA and college.
sourceAnchor=getFeatureProvider().getPictogramElementForBusinessObject(StudentA);--->(2)
targetAnchor=getFeatureProvider().getPictogramElementForBusinessObject(college);
But when i do as above , then the pictogram element is coming as same for (1) && (2)
so both university and college is connecting to same pictogram element(studentA).but i want it to be different.
Is there any way to resolve this issue?if i am doing something wrong means please let me know.
PFA my sample explanation.
i have drawn the expected and current behaviour
Thanks
Palani
Thanks
Palani
|
|
|
|
|
|
Re: How to connect 2 elements created out of same Eobject to different pictogramelements [message #1102912 is a reply to message #1101351] |
Fri, 06 September 2013 07:31 |
Albert Hofkamp Messages: 41 Registered: August 2009 |
Member |
|
|
To give you an example:
In the add method, I do
private final IPeCreateService pec = Graphiti.getPeCreateService();
private final IPeService pes = Graphiti.getPeService();
ContainerShape outer = pec.createContainerShape(parent, true);
pes.setPropertyValue(outer, AUT_ELEMENT, OUTER);
...
Shape hline = pec.createShape(outer, false);
pes.setPropertyValue(hline, AUT_ELEMENT, HLINE);
I label each shape with a unique string during creation and adding of the shapes.
When I need a shape I do something like
ContainerShape outer = (ContainerShape)elm;
Shape hline = null;
Shape vline = null;
Shape kind = null;
Shape name = null;
for (Shape child: outer.getChildren()) {
val = pes.getPropertyValue(child, AUT_ELEMENT);
if (val == null) continue; // Ignore other graphical elements.
if (val.equals(HLINE)) {
hline = child;
} else if (val.equals(VLINE)) {
vline = child;
} else if (val.equals(KIND)) {
kind = child;
} else if (val.equals(NAME)) {
name = child;
}
}
Assert.notNull(hline);
Assert.notNull(vline);
Assert.notNull(kind);
Assert.notNull(name);
This is perhaps a bit too generic for you, but basically, I walk through all shapes, and pick out the ones with the right label. That way I know what I get.
This works much better for me than the 'isinstance' approach of the tutorial.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02984 seconds