Skip to main content



      Home
Home » Modeling » Graphiti » Best practice for own Shapes?
Best practice for own Shapes? [message #757486] Fri, 18 November 2011 10:48 Go to next message
Eclipse UserFriend
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 10:50] by Moderator

Re: Best practice for own Shapes? [message #757505 is a reply to message #757486] Fri, 18 November 2011 11:55 Go to previous messageGo to next message
Eclipse UserFriend
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 04:23 Go to previous messageGo to next message
Eclipse UserFriend
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 07:58 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 18:35:24 EDT 2025

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

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

Back to the top