[Zest] Drawing grahics on a graph [message #902796] |
Mon, 20 August 2012 13:32 |
Magnus Sjöstrand 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 |
Magnus Sjöstrand 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03601 seconds