I have an app made with Swing and JFreeChart and I'm exporting a ChartPanel object to an Image (BufferedImage to be precise). I expected the added overlay to be a "part" of the panel, and be exported with the panel, but that is not the case. Everything exports properly apart from the overlay. How do I make it include the overlay or export it into Image itself so I could at least try to slap them together somehow?
Simplified code:
CrosshairOverlay crosshairOverlay = new CrosshairOverlay();
//overlay configuration here
chartPanel.addOverlay(crosshairOverlay);
Code for exporting the panel:
int width = 450;
int height = 350;
JFreeChart chart = chartPanel.getChart();
BufferedImage image = chart.createBufferedImage(width, height);
For reference, here's a screenshot of CrosshairOverlayDemo1
: