Home » Modeling » GMF (Graphical Modeling Framework) » How to create the FigureDescriptor for this final state figure with GMF Graph
| |
Re: How to create the FigureDescriptor for this final state figure with GMF Graph [message #759852 is a reply to message #759773] |
Wed, 30 November 2011 10:22 |
|
On 30/11/2011 00:01, Hoang wrote:
> Hi everyone,
Hi
> Is the question lack some details or no one is interested in giving the
> answer?
It's probably that AFAIK the best way to get this working is to try and
see, but that's too much time consuming for people reading the forum.
> If you want to test the graph then you can navigate to this GitHub
> project: https://github.com/pnhoang/Selflet
> Import the SelfletBehavior* projects and then you will be able to test
> your change.
Seems like we met that same issues about reducing development loop in
..gmfgraph:
You should have a look at this bug to help you creating your GMFGraph:
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=363449
It shows you a preview of what you're creating. You can get in from the
2.4.x-maintenance branch of GIT GMF-Tooling repository. It will probably
be part of the 3.0 release, and maybe of a 2.4.1.
If you like it, drop a comment or vote for it, it will be easier for me
to convince the project lead to put it in a 2.4.1 ;)
Also I made another tool that is useful for any Draw2d figure:
http://marketplace.eclipse.org/content/draw2d-preview .
Hope you'll find them interesting. And if you're motivated, feel free to
suggest feature requests to GMF Tooling via the tracker.
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=GMF-Tooling
> I am thinking of putting the .svg file as the default image, but I am
> eager to also learn how to draw in draw2d with this specific situation.
> Thanks.
Draw2d follows the same principles as SWT for layouting. Spending a
couple of hours to create some Draw2d figures by hand will for sure make
you save you even more hours in your future usage of gmfgraph.
Regards,
--
http://mickaelistria.wordpress.com
http://twitter.com/#!/mickaelistria
http://www.petalslink.com
|
|
| |
Re: How to create the FigureDescriptor for this final state figure with GMF Graph [message #765214 is a reply to message #759861] |
Tue, 13 December 2011 16:33 |
Hoang Messages: 45 Registered: September 2011 Location: Milan |
Member |
|
|
I have finally come up with the solution to use SVGFigure to save my time.
Basically these are what I do:
- Create the SVG image by using Inskcape to convert from PNG to SVG image.
- In the .gmfgraph:
+ Add a new Figure Gallery with name : Images
+ Under this Figure Gallery, add a Figure Descriptor with name SVGFinalStateFigure
+ Under this Figure Descriptor, add a new Custom Figure name SVGFinalStateFigure, Qualified Class Name: org.eclipse.gmf.runtime.draw2d.ui.render.figures.ScalableImageFigure
+ In the Canvas of this .gmfgraph, add a new Node name SVG Final State, this Node points to the SVGFinalStateFigure created above
- In the .gmfmap:
+ Map the Node Mapping of Diagram Node to this SVG Final State (SVGFinalStateFigure)
- Transform the .gmfmap to .gmfgen
- Regenerate the .diagram project
- Add the Final.svg image created above to the .diagram project
- Add dependencies to the .diagram project org.eclipse.gmf.runtime.draw2d.ui.render
- Update the createNodeShape() function of FinalStateEditPart to the following:
/**
* @generated NOT
*/
protected IFigure createNodeShape() {
URL url = FileLocator.find(SelfletBehaviorDiagramEditorPlugin
.getInstance().getBundle(), new Path("icons/Final.svg"), null); //$NON-NLS-1$
return new ScalableImageFigure(RenderedImageFactory.getInstance(url),
true, true, true);
}
- Add the corresponding imports to this java file
- Ready to go!
The whole commit for this code is located at this GitHub page
Don't be threatened by the generated codes. Just look at the steps above and compare the codes. Some files are generated automatically by GMF Frameworks, so we don't need to care about, e.s. .gmfgen file.
The solution comes from following this tutorial. Thanks everyone.
Hope this helps someone.
[Updated on: Tue, 13 December 2011 16:35] Report message to a moderator
|
|
| | | | |
Goto Forum:
Current Time: Thu Apr 25 10:51:29 GMT 2024
Powered by FUDForum. Page generated in 0.03770 seconds
|