Eclipse Gef | Tutorial

public void addPropertyChangeListener(PropertyChangeListener listener) listeners.addPropertyChangeListener(listener);

public void removePropertyChangeListener(PropertyChangeListener listener) listeners.removePropertyChangeListener(listener);

// Getters & Setters with property change firing public int getX() return x; public void setX(int x) int old = this.x; this.x = x; listeners.firePropertyChange(LOCATION_PROP, old, x);

public class RectangleFigure extends RectangleFigure public RectangleFigure() setBackgroundColor(ColorConstants.lightBlue); setForegroundColor(ColorConstants.blue); setBorder(new LineBorder(1)); eclipse gef tutorial

@Override protected PaletteRoot getPaletteRoot() // return palette with creation tools (optional) return null; // for minimal

(root) – manages children:

editor/ShapeEditor.java :

– similar. 4. Create the Figure (Draw2D) Visual representation.

@Override protected void createEditPolicies() // For now, no edit policies – just static content

private Diagram createDiagram() diagram = new Diagram(); RectangleShape rect = new RectangleShape(); rect.setX(100); rect.setY(100); rect.setWidth(80); rect.setHeight(60); diagram.addShape(rect); EllipseShape ellipse = new EllipseShape(); ellipse.setX(250); ellipse.setY(150); ellipse.setWidth(70); ellipse.setHeight(70); diagram.addShape(ellipse); return diagram; @Override protected void createEditPolicies() // For now, no

@Override protected void initializeGraphicalViewer() super.initializeGraphicalViewer(); GraphicalViewer viewer = getGraphicalViewer(); viewer.setContents(createDiagram()); viewer.getControl().setBackground(ColorConstants.white);

:

public abstract class Shape public static final String LOCATION_PROP = "location"; public static final String SIZE_PROP = "size"; RectangleShape rect = new RectangleShape()

0:00
0:00