/** {@inheritDoc} */
  @Override
  public void mouseDragged(final MouseEvent aEvent) {
    final MouseEvent event = convertEvent(aEvent);
    final Point point = event.getPoint();

    // Update the selected channel while dragging...
    this.controller.setSelectedChannel(point);

    if (getModel().isCursorMode() && (this.movingCursor >= 0)) {
      this.controller.moveCursor(this.movingCursor, getCursorDropPoint(point));

      aEvent.consume();
    } else {
      if ((this.lastClickPosition == null)
          && ((aEvent.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0)) {
        this.lastClickPosition = new Point(point);
      }

      final JScrollPane scrollPane =
          getAncestorOfClass(JScrollPane.class, (Component) aEvent.getSource());
      if ((scrollPane != null) && (this.lastClickPosition != null)) {
        final JViewport viewPort = scrollPane.getViewport();
        final Component signalView = this.controller.getSignalDiagram().getSignalView();

        boolean horizontalOnly = (aEvent.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0;
        boolean verticalOnly =
            horizontalOnly && ((aEvent.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0);

        int dx = aEvent.getX() - this.lastClickPosition.x;
        int dy = aEvent.getY() - this.lastClickPosition.y;

        Point scrollPosition = viewPort.getViewPosition();
        int newX = scrollPosition.x;
        if (!verticalOnly) {
          newX -= dx;
        }
        int newY = scrollPosition.y;
        if (verticalOnly || !horizontalOnly) {
          newY -= dy;
        }

        int diagramWidth = signalView.getWidth();
        int viewportWidth = viewPort.getWidth();
        int maxX = diagramWidth - viewportWidth - 1;
        scrollPosition.x = Math.max(0, Math.min(maxX, newX));

        int diagramHeight = signalView.getHeight();
        int viewportHeight = viewPort.getHeight();
        int maxY = diagramHeight - viewportHeight;
        scrollPosition.y = Math.max(0, Math.min(maxY, newY));

        viewPort.setViewPosition(scrollPosition);
      }

      // Use UNCONVERTED/ORIGINAL mouse event!
      handleZoomRegion(aEvent, this.lastClickPosition);
    }
  }
Exemple #2
0
    public void mouseDragged(MouseEvent e) {
      int mods = e.getModifiersEx();
      Point dragEnd = e.getPoint();
      boolean shift = (mods & MouseEvent.SHIFT_DOWN_MASK) > 0;
      boolean ctrl = (mods & MouseEvent.CTRL_DOWN_MASK) > 0;
      boolean alt = shift & ctrl;
      ctrl = ctrl & (!alt);
      shift = shift & (!alt);
      boolean nomods = !(shift | ctrl | alt);

      if (dragBegin == null) dragBegin = dragEnd;

      nodrag = false;

      if ((mods & InputEvent.BUTTON3_DOWN_MASK) > 0 || true) {
        double dx = dragEnd.getX() - dragBegin.getX();
        double dy = dragEnd.getY() - dragBegin.getY();

        synchronized (JImage.this) {
          t.preConcatenate(AffineTransform.getTranslateInstance(dx, dy));
        }

        dragBegin = dragEnd;
        repaint();
      }
    }
Exemple #3
0
    public void mouseReleased(MouseEvent e) {
      int mods = e.getModifiersEx();

      if (nodrag && e.getButton() == MouseEvent.BUTTON3) {
        popupMenu.show(JImage.this, (int) e.getPoint().getX(), (int) e.getPoint().getY());
      }

      nodrag = true;
      dragBegin = null;
    }
    @Override
    public void mouseDragged(MouseEvent e) {
      int ctrlMask = InputEvent.CTRL_DOWN_MASK;
      int action =
          ((e.getModifiersEx() & ctrlMask) == ctrlMask)
              ? TransferHandler.COPY
              : TransferHandler.MOVE;

      JTable setTable = (JTable) e.getSource();
      // 非選択状態からいきなりドラッグを開始すると cellEditor が残ってしまう問題の workaround
      if (setTable.isEditing()) {
        setTable.getCellEditor().stopCellEditing();
      }
      TransferHandler handler = setTable.getTransferHandler();
      handler.exportAsDrag(setTable, e, action);
    }
  /** {@inheritDoc} */
  @Override
  public void mouseReleased(final MouseEvent aEvent) {
    final MouseEvent event = convertEvent(aEvent);
    final Point point = event.getPoint();

    if (!isCursorHover(event)) {
      setMouseCursor(event, null);
    }

    if (!handlePopupTrigger(point, aEvent)) {
      this.movingCursor = -1;
    }

    if ((aEvent.getModifiersEx() & InputEvent.BUTTON1_MASK) != 0) {
      // Use UNCONVERTED/ORIGINAL mouse event!
      handleZoomRegion(aEvent, this.lastClickPosition);

      this.lastClickPosition = null;
    }
  }
  /** {@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;
      }
    }
  }
 protected void doSelect(MouseEvent e) {
   setSelectionModes(e.getModifiersEx());
   super.doSelect(e);
 }