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:

Share Button

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>