Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Use Draw2D on top of a StyledText
Use Draw2D on top of a StyledText [message #249454] Tue, 30 June 2009 10:46 Go to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member

I want to use Draw2D on top of a StyledText. It should be possible as StyledText implements Canvas.
But I have two problems.

1) When adding a Figure the text is not visible anymore as the background gets white.

2) When using the scrollbars the drawn figures get corrupted.

Any suggestions how to solve the above issues?

Here is the simple test code I use to draw on the StyledText:

LightweightSystem system = new LightweightSystem(textViewer.getTextWidget());
Figure figure = new Figure();
XYLayout layout = new XYLayout();
PolylineConnection conn = new PolylineConnection();
conn.setStart(new Point(10, 10));
conn.setEnd(new Point(40, 40));

Re: Use Draw2D on top of a StyledText [message #512892 is a reply to message #249454] Mon, 08 February 2010 10:07 Go to previous message
David Forbes is currently offline David ForbesFriend
Messages: 1
Registered: February 2010
Junior Member
Hi Kai,

this is what I found out: When defining a LightweightSystem, the constructor builds internally a Rootfigure with opaque = true!

Here is a way, that worked for me:

public void createControl(final Composite parent) {
cc = (StyledText) sourceviewer.getControl();
Canvas canvas = new Canvas(parent, SWT.TRANSPARENT);

// you'll have to add a way to set the bounds of your canvas
//e.g. PaintListener or so

LightweightSystem myLWS = new LightweightSystem();
IFigure root = myLWS.getRootFigure();
root.setLayoutManager(new BorderLayout());

//now add your shapes here

Of course, there is still a lot to do (synchro Canvas and StyledText, etc.) this makes it possible to use Draw2d on StyledText!

Best regards,

Previous Topic:Router with only one angle
Next Topic:FlowLayout not wrapping
Goto Forum:

Current Time: Fri Apr 20 12:55:33 GMT 2018

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

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