|(New to GEF) Tweaking Shapes Example with Labels [message #667399]
||Thu, 28 April 2011 14:17
Registered: April 2011
I am new to GEF/draw2D. I read the Shapes Editor Example Tutorial, and used its source to build the plugin.
I now want to tweak it, to understand some other concepts.
(I've understood the Basic M-V-C model)
I want a simple label, to be shown in the Middle of each figure I draw, to start with, say a label "Rectangle" added in every drawn Rectangle, and a Label "Ellipse" added to every Ellipse drawn.
(I don't really know whether its an easy task or not, but is it possible that I get a choice to Edit those labels on the fly?)
I saw some examples on the net, explaining the Concept of Labels and EditableLabels, but I am not able to understand how it works.
With my knowledge till now, I think I'll need to make changes in the Edit Parts for the Shapes (the RectangularShape and EllipticalShape classes in the Shapes Example) as well as create some "figures" (something which is not a part of Basic tutorial).
Can anyone guide me how should I go about doing it?
(If putting up code is not possible, please try explaining the logic step wise)
Thanks in advance
|Re: (New to GEF) Tweaking Shapes Example with Labels [message #670611 is a reply to message #667399]
||Sun, 15 May 2011 08:02
| Girish Kumar
Registered: May 2011
All those queries you had put here are possible to do..
First of all i think you are familiar with MVC model
In the Editpart, you can see the createFigure() Method, where you are returning the EllipseFigure/Rectangle figure based on the model type rite ...
Ex : Figure ellipse = new EllipseFigure();
ellipse.setLayoutManager(/*your desired layout Manager */);
before returning this, create a figure Label and add that to Ellipse or Rectangle(and set the Layout Manager of the parent fig (Ellipse/rectangle))
Then add the entry name in the model , now Create the custom Figure(refer draw2d official website ), install directEditpolicy on the EditPart for Label...
Powered by FUDForum
. Page generated in 0.02185 seconds