/** * Finds the cursor under the given point. * * @param aPoint the coordinate of the potential cursor, cannot be <code>null</code>. * @return the cursor index, or -1 if not found. */ protected final Cursor findCursor(final Point aPoint) { final SignalDiagramModel model = getModel(); final long refIdx = model.locationToTimestamp(aPoint); final double snapArea = CURSOR_SENSITIVITY_AREA / model.getZoomFactor(); for (Cursor cursor : model.getDefinedCursors()) { if (cursor.inArea(refIdx, snapArea)) { return cursor; } } return null; }
/** {@inheritDoc} */ @Override public void mouseMoved(final MouseEvent aEvent) { final MouseEvent event = convertEvent(aEvent); final Point point = event.getPoint(); final SignalDiagramModel model = getModel(); if (model.isCursorMode()) { final Cursor hoveredCursor = findCursor(point); if (hoveredCursor != null) { setMouseCursor(aEvent, CURSOR_MOVE_CURSOR); aEvent.consume(); } else { setMouseCursor(aEvent, null); aEvent.consume(); } } setToolTipText(ViewUtils.getToolTipText(getModel(), point)); }