* Returns the component that the specified (x,y) chart coordinate is on. If
* the (x,y) point does not fall on a recognized component, then null is
* returned.
*/
protected Object getComponent(int x, int y, XYPlot plot) {
Bounds plotBounds = plot.getBounds();
// First check if (x,y) hit the center plot
if ((null != plotBounds) && (plotBounds.inside(x, y))) {
Overlay o = plot.getOverlayAt(x, y);
if (o != null && (o instanceof Draggable) && ((Draggable)o).isDraggable()) {
return o;
}
return plot;
}
//
// Now check if (x,y) hit the overview axis
//
OverviewAxisPanel oaPanel = plot.getOverviewAxisPanel();
if (oaPanel != null && oaPanel.getLayer() != null) {
Bounds layerBounds = oaPanel.getLayer().getBounds();
Bounds oaPanelBounds = oaPanel.getBounds();
double viewOffsetX = layerBounds.x + oaPanel.getLayerOffsetX();
double viewOffsetY = layerBounds.y + oaPanel.getLayerOffsetY();
Bounds oaPanelAbsBounds = new Bounds(viewOffsetX, viewOffsetY,
oaPanelBounds.width, oaPanelBounds.height);
if (oaPanelAbsBounds.inside(x, y)) {
return oaPanel.getValueAxis();
}
}
return null;