0

I am trying to create a flow chart with Zest eclipse. In order to create graph I am using graphViewer . For the nodes I need custom shapes. In order to achieve that I implemented IFigureProvider in the labelProvider for the graphViewer.

But I am not getting how can I create the diamond shape that is used to represent decision node.

Is graphiti a better way of doing these type of things?

Raja
  • 118
  • 11

1 Answers1

1

Create a custom figure class by extending the Figure class in the overridden paintFigure method draw polygon as follow:

@Override
protected void paintFigure(Graphics g) {
super.paintFigure(g);
Rectangle r = getClientArea();
g.setAntialias(SWT.ON);
g.setLineWidthFloat(2.0f);
g.setBackgroundColor(ColorConstants.black);
PointList diamondPointList=new PointList();
diamondPointList.addPoint(r.x()+r.width()/2, r.y());
diamondPointList.addPoint(r.x()+r.width(), r.y()+r.height()/2);
diamondPointList.addPoint( r.x()+r.width()/2, r.y()+r.height());
diamondPointList.addPoint(r.x(), r.y()+r.height()/2);
g.drawPolygon(diamondPointList);

g.drawLine(r.x()+r.width()/2, (r.y()+r.height()/2)-10, r.x()+r.width()/2, (r.y()+r.height()/2)+10);
g.drawLine((r.x()+r.width()/2)-10, r.y()+r.height()/2, (r.x()+r.width()/2)+10,  r.y()+r.height()/2);
}
Raja
  • 118
  • 11