I am using JFreeChart for a medical analysis toolkit and need to select a region to do some manipulations. Once i select it, I need to set the background color of the region to do something else ( this is plainly an interface issue, but really important).
Here is the code snippet which does this.
Code: Select all
else if(e.isAltDown()){
this.currentMouseMode = MOUSEMODE.PICKREGION;
double x = this.renderer.getPlot().getDomainCrosshairValue();
double y = this.renderer.getPlot().getRangeAxis().getUpperBound();
double width = e.getX()-x;
double height = y - this.renderer.getPlot().getRangeAxis().getLowerBound();
this.mouseDragPreviousPoint = new Point();
this.mouseDragPreviousPoint.setLocation(x, y);
Dimension d = new Dimension();
d.setSize(width, height);
/*
I am stuck at obtaining the graphics2d context!!!
*/
Rectangle r = new Rectangle(this.mouseDragPreviousPoint,d);
this.renderer.getPlot().drawBackground(g2, r);
}
Basically, I am using the Crosshair and the clicked point to form a rectangle. So now, I have the rectangle area to color, but am stuck at setting the background color of the particular area. Any suggestions would be greatly appreciated.
Avanidhar