The JFreeChart forum has no answeres yet.
I am not doing that with listeners. I am sure there is a way you can get the
items from the chart.
Here is some more explenation:
...
ChartRenderingInfo chartrenderinginfo = chartpanel.getChartRenderingInfo();
EntityCollection entities = chartrenderinginfo.getEntityCollection();
//also does not work: item is always null?
item = (XYItemEntity)entities.getEntity(x,y);
//this also does not work...
//item = (XYItemEntity)chartpanel.getEntityForPoint(x, y);
//this also does not work
//Point p = chartpanel.translateJava2DToScreen(new Point(x,y));
//item = (XYItemEntity)entities.getEntity(p.getX(), p.getY());
if (item != null){
//this shall be entered if an item is found
//but never entered although I have data on the chart
}else{
System.out.println("item is null");
}
Any idea?
Message was edited by:
JavaPars
Ok, but this is not exactly what i wanted. here is some detailed explanation:
The user can choose some of the items displayed on the chart by making a right click and than dragging the mouse to some other point. When dooing this a rect is drawn, so the user sees what will be selected. So what I want is to find out which items are within the selection area. My idea to find this out is:
1. get all the possible xy coordinates that are in this area
2. for all of these coordinates try to find out if an item is on the achart or not (see sourcecode above)
does this help to understand what I am trying to do? As you see I do not need the listener you mentioned...
yes, sure. but only if I click on ONE item. How about if you do not click on an item? Again: The user selects ALL items he wants by clicking+dragging the mouse. Any idea? I have a workaround for my problem. But I I hope there is a way how one can get items from a chart by specifying the xy coordinates. If this is not possible, than JFreeChart might shall make this possible. I believe this is a reasonable requirement...