viernes, 8 de febrero de 2013

Eugenia - epsilon - GMF: howto use images instead shapes figures easily

[This post and the blog have been moved to: http://www.carloshelder.es/blog/eugenia-epsilon-gmf-howto-use-images-instead-shapes-figures-easily/]



I did not find any easy way to do it on Internet, so I hope it helps you!

I'll go straight to the point. This is an extract of the code:

ArcadeTongame_editor.emf:

(...)
@gmf.node(figure="figures.In", label.icon="false", label.placement="none", tool.small.bundle="Eugenia_ArcadeTongame", tool.small.path="icons/In32.ico")
class In extends Element {
   attr boolean isStart;
}
(...)


figures/In.java:
package figures;
import java.io.InputStream;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.draw2d.ImageFigure;
public class In extends ImageFigure {
  public In()  {
 
 InputStream in = getClass().getResourceAsStream("images/In48.png");
 Image image = new Image(Display.getDefault(), in);
 this.setImage(image);

  }
}


This is the project structure:

Note: the full project is located at GitHub: http://chelder86.github.com/ArcadeTongame/ (click at View Arcadetongame on GitHub to see the project in GitHub)



This is the RCP Application result:

No hay comentarios:

Publicar un comentario