I am working in my Java project and I am using GraphStream library to visually represent graphs. My question is how to put an image behind a graph? I want an image as a background to my graph.
Asked
Active
Viewed 543 times
2 Answers
2
The method setBackLayerRenderer() is implemented in the class DefaultView, here's what worked for me:
Graph graph = new SingleGraph("graph");`
Viewer viewer = graph.display();
DefaultView view = (DefaultView) viewer.getDefaultView();
view.setBackLayerRenderer(new LayerRenderer() {
@Override
public void render(Graphics2D graphics2D, GraphicGraph graphicGraph, double v, int i, int i1, double v1, double v2, double v3, double v4) {
graphics2D.setColor(Color.green);
graphics2D.drawString("hello", 10, 30);
}
});

acastele
- 21
- 5
0
I think this can be achieved using LayerRenderer
interface with
View.setBackLayerRenderer() / View.setFrontLayerRenderer()
methods. You can find more here.

Raúl
- 1,542
- 4
- 24
- 37
-
But how do I use those methods ? Where do i put the image location ? – user132226 May 22 '15 at 07:31
-
Please check the url, it has quite detailed stuff. – Raúl May 22 '15 at 07:33
-
I still don´t understand how to put an image behind my graph .. How do I use the View.serBackLayerRenderer() method ? – user132226 May 22 '15 at 23:26