[Zest] setBackgroundImage() for Graph doesn't work [message #512362] |
Thu, 04 February 2010 13:55  |
Eclipse User |
|
|
|
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] by Moderator
|
|
|
|
|
|
|
Re: [Zest] setBackgroundImage() for Graph doesn't work [message #726379 is a reply to message #726371] |
Sat, 17 September 2011 14:32  |
Eclipse User |
|
|
|
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.06735 seconds