Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » [Zest] Drawing grahics on a graph
[Zest] Drawing grahics on a graph [message #902796] Mon, 20 August 2012 13:32 Go to next message
Magnus Sjöstrand is currently offline Magnus SjöstrandFriend
Messages: 16
Registered: June 2012
Junior Member
I think I have seen this question being mentioned somewhere else but there was no good solution to it.

The issue is that when drawing something (rectangle, drawline) on a graph and thereafter adding nodes the old drawings will disappear from being overpainted. The drawing for these shapes is done in a paintEvent. It possibly have something to do with the redrawing of figureCanvas (?)

I saw a 'dirty' solution to this in where one would make the drawings in a composite parent and place a transparent graph over that so that the drawings would be placed under the nodes.


Also, as suggested as a solution, making the graph's background transparant only gives me a empty background (this is not black)

Color c1 = new Color(Display.getDefault(), 50, 50, 200);
graph = new Graph(parent, SWT.NONE);
parent.setBackground(c1);
graph.getLightweightSystem().getRootFigure().setOpaque(false);

[Updated on: Mon, 20 August 2012 13:38]

Report message to a moderator

Re: [Zest] Drawing grahics on a graph [message #903254 is a reply to message #902796] Wed, 22 August 2012 17:28 Go to previous messageGo to next message
Magnus Sjöstrand is currently offline Magnus SjöstrandFriend
Messages: 16
Registered: June 2012
Junior Member
In a update to this, and I have no idea why, but this seems to solve the problem.

By adding a paintListener at the end of the method and using setClipping((Region)null)

Example:
graph.addPaintListener(new PaintListener() {
	public void paintControl(PaintEvent e) {
		e.gc.setClipping((Region)null);
		e.gc.drawLine(10, 10, 100, 100);
	}
});


However this will only draw a line relative to the view. If you know how to draw relative to the graph feel free to add some input.

[Updated on: Wed, 22 August 2012 17:33]

Report message to a moderator

Re: [Zest] Drawing grahics on a graph [message #903548 is a reply to message #903254] Fri, 24 August 2012 08:56 Go to previous message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Hi,

I don't use the Zest, but in draw2D you can convert the relative coordinates to absolute coordinates using figure.translateToAbsolute().
So if you know the graph's main figure bounds, call graph.translateToAbsolute(graph.getBounds().getLocation()) in the paintControl().
Previous Topic:How to create two figures on a single Drag and drop in GEF?
Next Topic:GEF shapes example minimap
Goto Forum:
  


Current Time: Tue Mar 19 02:35:16 GMT 2024

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

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

Back to the top