private static double hiliteRelativeGrabX;
public void onMouseMove(MouseMoveEvent event) {
ChartState chartInfo = getChartState(event);
Chart chart = chartInfo.chart;
DefaultXYPlot plot = (DefaultXYPlot)chartInfo.chart.getPlot();
if (null == plot.getBounds() || !plot.isOverviewVisible()) {
return;
}
OverviewAxisPanel oaPanel = plot.getOverviewAxisPanel();
ValueAxis overviewAxis = oaPanel.getValueAxis();
Bounds overviewAxisBounds = oaPanel.getBounds();
Bounds hiliteBounds = oaPanel.getHighlightBounds();
CompoundUIAction uiAction = chartInfo.getCompoundUIAction();
// Translate the view (x,y) point into an (x,y) point relative to
// the OverviewAxisPanel.
Bounds plotBounds = plot.getBounds();
int x = getLocalX(event) - (int)plotBounds.x;
int y = getLocalY(event) - (int)plotBounds.bottomY();
final boolean isInAxisBounds = null == hiliteBounds ? false: overviewAxisBounds.inside(x, y);
final boolean isDragging = uiAction.isDragging(overviewAxis);
//log("onMouseMove(" + x + ", " + y + ")" + ": inAxisBounds=" + isInAxisBounds + "; uiAction.startX=" + uiAction.getEndX());
// Determine appropriate cursor type
if (isInAxisBounds) {
if (hiliteBounds != null && hiliteBounds.inside(x, y)) {
chartInfo.chart.setCursor(Cursor.DRAGGABLE);
}
else {
chartInfo.chart.setCursor(Cursor.DEFAULT);
}
}
// else, mouse is outside of overview axis, so don't mess with cursor.
// final double viewOffsetX = plotBounds.x;
final double viewOffsetX = 0;
if (uiAction.isSelecting(overviewAxis)) {
chart.setAnimating(true);
chart.setCursor(Cursor.SELECTING);
chart.setAnimating(true);
// Determine the start and end domain of the highlight selection
double startDomainX = toDomainX(uiAction.getStartX(), plot);
double boundedX = MathUtil.bound(x, overviewAxisBounds.x, overviewAxisBounds.rightX());
double endDomainX = toDomainX(boundedX + viewOffsetX, plot);
if (startDomainX > endDomainX) {
double tmp = startDomainX;
startDomainX = endDomainX;
endDomainX = tmp;
}
// Set the current highlight region in the plot
// TODO - think about setting highlightPanel.bounds instead
plot.setHighlight(startDomainX, endDomainX);
plot.getDomain().setEndpoints(startDomainX, endDomainX);
plot.redraw();
}
else if (hiliteBounds != null && isDragging) {
chart.setAnimating(true);
// hiliteLeftDomainX represents the domain-x value of the left edge
// of the highlight window within the overview axis.
//double hiliteLeftX = x - (hiliteBounds.width / 2.0);x will always be at the center of the hiliteBounds