Reputation: 11
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.
Upvotes: 0
Views: 590
Reputation: 21
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);
}
});
Upvotes: 2