| [Zest] setBackgroundImage() for Graph doesn't work [message #512362] |
Thu, 04 February 2010 13: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 13: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 14:55   |
Mark Missing name Messages: 44 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 11:27] Report message to a moderator
|
|
|
|
| Re: [Zest] setBackgroundImage() for Graph doesn't work [message #726379 is a reply to message #726371] |
Sat, 17 September 2011 14:32  |
Mark Missing name Messages: 44 Registered: July 2009 Location: Ohio, USA |
Member |
|
|
Hemanta, I am glad you found an alternative work-around, but for some unknown reason, this approach does not work for me. I get a stack trace when the Graph is open()'d and it points to the ImageFigure I created being an invalid argument to the ...getRootFigure.add() method. I tried several things, but all indications are that my ImageFigure is indeed valid. So, I'm still stuck while I patiently wait for a true fix to be enacted...
Mark
|
|
|
Powered by
FUDForum. Page generated in 0.01621 seconds