Exemplo n.º 1
0
  /**
   * 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;
  }
Exemplo n.º 2
0
  /** {@inheritDoc} */
  @Override
  public void mousePressed(final MouseEvent aEvent) {
    final MouseEvent event = convertEvent(aEvent);
    final Point point = event.getPoint();

    if (!handlePopupTrigger(point, aEvent)) {
      if (getModel().isCursorMode()) {
        Cursor hoveredCursor = findCursor(point);
        if (hoveredCursor != null) {
          this.movingCursor = hoveredCursor.getIndex();
          setMouseCursor(aEvent, SignalView.CURSOR_MOVE_CURSOR);
        } else {
          this.movingCursor = -1;
        }
      }

      if ((aEvent.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0) {
        this.lastClickPosition = point;
      }
    }
  }