Beispiel #1
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();
      }
    }
Beispiel #2
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;
    }