Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Best practice for own Shapes?
Best practice for own Shapes? [message #757486] Fri, 18 November 2011 15:48 Go to next message
Christian B is currently offline Christian B
Messages: 68
Registered: August 2011
Member
Hi,

Say we have this example, a ContainerShape which has two Anchors and three child shapes.
http://s7.directupload.net/images/111118/jh4cousb.jpg

For now if i want Access to a child or an anchor I use following code:
shapeA1 = containerA.getChildren().get(0);
shapeA2 = containerA.getChildren().get(1);
shapeA3 = containerA.getChildren().get(2);
anchorA1 = containerA.getAnchors()containerShape.get(0);
anchorA2 = containerA.getAnchors()containerShape.get(1);

But what i would like to have is a extra class for the ContainerA with methods
shapeA1 = containerA.getShapeA1();
shapeA2 = containerA.getShapeA2();
shapeA3 = containerA.getShapeA3();
anchorA1 = containerA.getAnchorA1();
anchorA2 = containerA.getAnchorA2()

So the question is, what is the best practice for adding own shapes?
Do I have to extend the peCreateService, so I can implement a method like peCreateService.createContainerA()?

thx for your help!

[Updated on: Fri, 18 November 2011 15:50]

Report message to a moderator

Re: Best practice for own Shapes? [message #757505 is a reply to message #757486] Fri, 18 November 2011 16:55 Go to previous messageGo to next message
Andreas Graf is currently offline Andreas Graf
Messages: 151
Registered: July 2009
Senior Member
Hi,

I don't think that overriding methods will help you, since the shape ecore model is fixed and you will not be able to store your own attributes.
We do it by having our own class hierarchy of "SmartShapes", mapping those to Graphiti Shapes and storing data in properties.

Regards,

Andreas
Re: Best practice for own Shapes? [message #757693 is a reply to message #757505] Mon, 21 November 2011 09:23 Go to previous messageGo to next message
Christian B is currently offline Christian B
Messages: 68
Registered: August 2011
Member
hmkay, i thought of that, too. In a feature, for example, you get the pictogramElement by context.getPictogramElement(). Now you would have to generate the smart shape by mapping the properties to the attributes of the smart shape...

I don't know, if i like this solution, it just generates overhead by mapping smart shape <--> shape. But it might be necessary, if shapes get to complex.
Re: Best practice for own Shapes? [message #758494 is a reply to message #757486] Wed, 23 November 2011 12:58 Go to previous message
Michael Wenz is currently offline Michael Wenz
Messages: 1595
Registered: July 2009
Location: Walldorf, Germany
Senior Member
In the end this turns out to be a matter of identifying shapes somehow. I
see 2 possibilities to do that:
1) Using the linking mechanism
2) Using properties as Andreas pointed out
To ease both ways a proven way to ge is introducing service methods that
retrieve the required object from another one.

HTH,
Michael
Previous Topic:FixPointAnchorEditPart does not override getDragTracker
Next Topic:Using Zest LayoutAlgorithm in Graphiti
Goto Forum:
  


Current Time: Tue Sep 23 08:34:05 GMT 2014

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

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