Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Custom Figure does not show
icon11.gif  Custom Figure does not show [message #692213] Sun, 03 July 2011 23:31
Li Chen is currently offline Li ChenFriend
Messages: 20
Registered: July 2011
Location: Sydney
Junior Member
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.
Previous Topic:Invoke an action from tool(Entry)
Next Topic:Properties are not shown
Goto Forum:
  


Current Time: Fri Apr 26 10:44:23 GMT 2024

Powered by FUDForum. Page generated in 0.05076 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top