Eclipse Gef Tutorial ((top)) -
public class Diagram private List<Shape> children = new ArrayList<>(); public void addChild(Shape s) children.add(s); public List<Shape> getChildren() return children;
@Override protected void initializeGraphicalViewer() diagram = new Diagram(); diagram.addChild(new RectangleNode()); getGraphicalViewer().setContents(diagram);
public class RectangleNodeFigure extends RectangleFigure public RectangleNodeFigure() setBackgroundColor(ColorConstants.lightBlue); setForegroundColor(ColorConstants.blue); setLineWidth(2); eclipse gef tutorial
:
This is the glue that holds everything together. The Controller is a Java class (specifically, an EditPart ) that: return new ShapeSetBoundsCommand(model
@Override protected void configureGraphicalViewer() super.configureGraphicalViewer(); getGraphicalViewer().setEditPartFactory(new ShapesEditPartFactory());
Would you like me to:
At its core, GEF is a framework that allows developers to create rich graphical editors for the Eclipse Workbench. It bridges the gap between your underlying data model (the code) and the visual representation (the UI).
public class ShapeLayoutEditPolicy extends GraphicalEditPolicy @Override protected Command getMoveCommand(ChangeBoundsRequest request) Shape model = (Shape) getHost().getModel(); Rectangle newBounds = request.getTransformedRectangle(model.getBounds()); return new ShapeSetBoundsCommand(model, newBounds); public class Diagram private List<