Example: Implement a flowchart GMF editor using EuGENia

@namespace(uri="flowchart", prefix="flowchart")
package flowchart;

class Flowchart {
   val Node[*] nodes;
   val Transition[*] transitions;

@gmf.node(label="name", label.icon="false")
abstract class Node {
   attr String name;
   ref Transition[*]#source outgoing;
   ref Transition[*]#target incoming;

@gmf.link(label="name", source="source", target="target", target.decoration="arrow")
class Transition {
   attr String name;
   ref Node#outgoing source;
   ref Node#incoming target;

class Subflow extends Flowchart, Node{

class Action extends Node {

class Decision extends Node {
// Set text of transitionLabel to empty string
var transitionLabel = GmfGraph!Label.all.
transitionLabel.text = "";

// Add bold font to actionLabel
var actionLabel = GmfGraph!Label.all.
actionLabel.font = new GmfGraph!BasicFont;
actionLabel.font.style = GmfGraph!FontStyle#BOLD;

// Add italic font to actionLabel
var decisionLabel = GmfGraph!Label.all.
decisionLabel.font = new GmfGraph!BasicFont;
decisionLabel.font.style = GmfGraph!FontStyle#ITALIC;
var genPlugin = GmfGen!GenPlugin.all.first();

* Copyright (c) 2008 The University of York.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
* SPDX-License-Identifier: EPL-2.0
package org.eclipse.epsilon.eugenia.examples.flowchart.diagram.figures;

import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;

public class DiamondFigure extends Figure {
  public void paint(Graphics graphics) {
    Rectangle r = getBounds();
    // Define the points of a diamond
    Point p1 = new Point(r.x, r.y + r.height/2);
    Point p2 = new Point(r.x + r.width/2, r.y);
    Point p3 = new Point(r.x + r.width, r.y + r.height/2);
    Point p4 = new Point(r.x + r.width/2, r.y + r.height - 1);
    PointList pointList = new PointList();
    // Fill the shape
    // Draw the outline
    graphics.drawLine(p1, p2);
    graphics.drawLine(p2, p3);
    graphics.drawLine(p3, p4);
    graphics.drawLine(p4, p1);
    // Move the label to the centre of the diamond
    WrappingLabel label = (WrappingLabel) getChildren().get(0);
    LayoutUtil.moveToCenter(label, this, graphics);

What's this?

In this example we use EuGENia to implement a flowchart GMF editor, and EOL to polish its appearance.

What are .emf files?

.emf files are Ecore metamodels expressed using the Emfatic textual syntax.

More examples...

Epsilon Object Language
Epsilon Transformation Language
Epsilon Generation Language
Epsilon Validation Language
Epsilon Merging Language
Epsilon Flock
Epsilon Model Generation Language
Epsilon Pattern Language
Combining the Epsilon Languages

Even more examples...

More examples are available in the examples folder of the Git repository.