Hi, I try to create a custom figure (combination of multiple rectangles) to show on swt canvas without any success.
Here is my code for creating this custom figure:
public class CycleTimeBar extends Figure{
public CycleTimeBar(List<Color> blockColors)
{
ToolbarLayout layout = new ToolbarLayout();
layout.setHorizontal(true);
this.setLayoutManager(layout);
for(Color blockColor : blockColors)
{
RectangleFigure fig = new RectangleFigure();
fig.setBackgroundColor(blockColor);
fig.setSize(new Dimension(20, 20));
this.add(fig);
}
}
}
And here is where I call and show the figure:
Canvas draw2dCanvas = new Canvas(parent, SWT.NONE);
draw2dCanvas.setLayoutData(new RowData(834, 345));
LightweightSystem lws = new LightweightSystem(draw2dCanvas);
IFigure figure = new Figure();
lws.setContents(figure);
List<Color> barColors = new ArrayList<Color>();
barColors.add(ColorConstants.red);
barColors.add(ColorConstants.yellow);
barColors.add(ColorConstants.green);
figure.add(new CycleTimeBar(barColors));
I tried to add just a rectangleFigure to draw2dCanvas and it shows with no problem. But it can't show my custom figure.
Can anybody please help me identify the problem?
Thanks a lot.