[Zest] setBackgroundImage() for Graph doesn't work [message #512362] |
Thu, 04 February 2010 18:55 |
philipp.hauer Messages: 13 Registered: February 2010 |
Junior Member |
|
|
Hello,
I like to insert an image into the background of my graph.
public class GraphSnippet1 {
public static void main(String[] args) {
Display d = new Display();
Shell shell = new Shell(d);
shell.setLayout(new FillLayout());
shell.setSize(400, 400);
Graph graph = new Graph(shell, SWT.NONE);
graph.setBackgroundImage(new Image(null, "res/image.png")); //doesn't work!
//g.setBackground(new Color(null,255,0,0)); //works fine!
GraphNode n = new GraphNode(graph, SWT.NONE, "Paper");
GraphNode n2 = new GraphNode(graph, SWT.NONE, "Rock");
new GraphConnection(graph, SWT.NONE, n, n2);
graph.setLayoutAlgorithm(new SpringLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING), true);
shell.open();
while (!shell.isDisposed()) {
while (!d.readAndDispatch()) {
d.sleep();
}
}
}
}
The setBackgroundImage()-method seems to do nothing, while setBackground() does work.
What's my mistake? Or is there any workaround?
Greetings
Philipp H.
[Updated on: Thu, 04 February 2010 18:58] Report message to a moderator
|
|
|
|
|
Re: [Zest] setBackgroundImage() for Graph doesn't work [message #681750 is a reply to message #676362] |
Thu, 09 June 2011 18:55 |
Mark Mising name Messages: 73 Registered: July 2009 Location: Ohio, USA |
Member |
|
|
I tried your setOpaque() idea and that works as a workaround! Thank you! I submitted a bug report.
Mark
P.S. Following up... the work-around has problems, too. It seems that certain dialog boxes (such as JFace File Choosers and Color Choosers, but not simple message boxes), cause the background image in the Graph to disappear again, as if the dialog box triggered some code that set the Graph's setOpaque() method back to true. I guess, the bottom line is that it needs to be fixed in the source code, not by work-arounds. Hopefully, the bug will be fixed in the next patch release...
[Updated on: Fri, 10 June 2011 15:27] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04704 seconds