Ejemplo n.º 1
0
  public void mouseWheelMoved(MouseWheelEvent event) {

    int zoom = event.getWheelRotation();

    mx = event.getX();
    my = event.getY();

    showStatus("Mouse rotated (" + zoom + ")");

    // zoom out
    if (zoom >= 0) {
      dbg.setColor(Color.black);
      //			dbg.drawImage (background, SIZE/2-current_size/2,
      //			        SIZE/2-current_size/2, current_size, current_size, this);
    }
    // zoom in
    else if (zoom < 0) {
      int width = building.getWidth(this);
      int height = building.getHeight(this);
      dbg.drawImage(
          building, width, height, width / 2, height / 2, width, height, width, height, this);
    }

    repaint();
    event.consume();
  }
  @Override
  public void mouseWheelMoved(final MouseWheelEvent e) {
    //		System.out.println( "MouseAndKeyHandler.mouseWheelMoved()" );
    //		System.out.println( e );
    update();

    final int mask = getMask(e);
    final int x = e.getX();
    final int y = e.getY();
    final double wheelRotation = e.getPreciseWheelRotation();

    /*
     * AWT uses the SHIFT_DOWN_MASK to indicate horizontal scrolling. We
     * keep track of whether the SHIFT key was actually pressed for
     * disambiguation. However, we can only detect horizontal scrolling if
     * the SHIFT key is not pressed. With SHIFT pressed, everything is
     * treated as vertical scrolling.
     */
    final boolean exShiftMask = (e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0;
    final boolean isHorizontal = !shiftPressed && exShiftMask;

    for (final BehaviourEntry<ScrollBehaviour> scroll : scrolls) {
      if (scroll.buttons.matches(mask, pressedKeys)) {
        scroll.behaviour.scroll(wheelRotation, isHorizontal, x, y);
      }
    }
  }
Ejemplo n.º 3
0
 public void mouseWheelMoved(MouseWheelEvent e) {
   if (isEnabled()) {
     a += (double) e.getWheelRotation() / (double) 3;
     a = (a >= 1 ? 0.9999 : a <= -1 ? -0.9999 : a);
     face.setEmotion(p, a, d, e.getX(), e.getY());
   }
   paint();
 }
Ejemplo n.º 4
0
 /*
  * (non-Javadoc)
  *
  * @see java.awt.event.MouseWheelListener#mouseWheelMoved(java.awt.event.MouseWheelEvent)
  */
 @Override
 public void mouseWheelMoved(MouseWheelEvent e) {
   ZoneRenderer renderer = (ZoneRenderer) e.getSource();
   if (SwingUtil.isControlDown(e)) {
     if (e.getWheelRotation() > 0) {
       renderer.zoomOut(e.getX(), e.getY());
     } else {
       renderer.zoomIn(e.getX(), e.getY());
     }
   } else {
     if (e.getWheelRotation() > 0) {
       adjustGridSize(renderer, Size.Increase);
     } else {
       adjustGridSize(renderer, Size.Decrease);
     }
   }
 }
Ejemplo n.º 5
0
  @Override
  public void mouseWheelMoved(MouseWheelEvent e) {
    int nbClicks = e.getWheelRotation(); // La vitesse à laquelle on a tourné la roulette

    for (IFormeEditable forme : this.pan.getFormesEditables())
      Action.agrandir(forme, new Point2D(e.getX(), e.getY()), 1 + 0.1 * nbClicks);

    this.pan.repaint();
  }
  public void mouseWheelMoved(MouseWheelEvent e) {

    Event.EventType type = ScrollEvent.ScrollVertical;
    Node node = findTopNode(e.getX(), e.getY());
    int rotation = e.getWheelRotation();
    if (e.isShiftDown()) {
      type = ScrollEvent.ScrollHorizontal;
    }
    EventBus.getSystem().publish(new ScrollEvent(type, node, rotation));
  }
  /*
   * (non-Javadoc)
   *
   * @see java.awt.event.MouseWheelListener#mouseWheelMoved(java.awt.event.
   * MouseWheelEvent)
   */
  @Override
  public void mouseWheelMoved(MouseWheelEvent ev) {

    // checks if the graph exists and if the control key is pressed
    DirectedWeightedGraph canvasGraph = _canvas.get_graph();
    if (canvasGraph != null && ev.isControlDown()) {

      // We search the name of canvas parent
      CanvasPanel panelParent;
      String panel = _canvas.getParent().getClass().getName();
      if (panel.equals("acide.gui.debugPanel.traceSQLPanel.AcideTraceSQLPanel"))
        panelParent = CanvasPanel.TraceSQL;
      else if (panel.equals("acide.gui.debugPanel.debugSQLPanel.AcideDebugSQLPanel"))
        panelParent = CanvasPanel.DebugSQL;
      else if (panel.equals("acide.gui.debugPanel.traceDatalogPanel.AcideTraceDatalogPanel"))
        panelParent = CanvasPanel.TraceData;
      else panelParent = null;

      // gets the coordinates of the event
      int difx = ev.getX() - _canvas.getX0();
      int dify = ev.getY() - _canvas.getY0();
      // checks the wheel rotation direction
      if (ev.getWheelRotation() < 0) {
        // zooms in the canvas and move the graph
        _canvas.zoomIn(panelParent);
        int difx2 = ev.getX() - _canvas.getX0();
        int dify2 = ev.getY() - _canvas.getY0();
        _canvas.moveGraph(difx2 - difx, dify2 - dify);
      } else {
        // zooms out the canvas and move the graph
        _canvas.zoomOut(panelParent);
        int difx2 = ev.getX() - _canvas.getX0();
        int dify2 = ev.getY() - _canvas.getY0();
        _canvas.moveGraph(difx2 - difx, dify2 - dify);
      }
      // repaint the canvas
      _canvas.repaint();
    }
  }
Ejemplo n.º 8
0
  public void mouseWheelMoved(MouseWheelEvent e) {
    if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
      dragX = e.getX();
      dragY = e.getY();

      if (e.isShiftDown()) {
        tmpDragX = dragX - e.getUnitsToScroll();
        tmpDragY = dragY;
      } else {
        tmpDragX = dragX;
        tmpDragY = dragY - e.getUnitsToScroll();
      }
      movingMap(tmpDragX, tmpDragY);
    }
  }
 public void mouseWheelMoved(MouseWheelEvent event) {
   JGVTComponent component = (JGVTComponent) event.getSource();
   double scale = 1 - 0.2 * event.getWheelRotation();
   int x = event.getX();
   int y = event.getY();
   AffineTransform at = AffineTransform.getTranslateInstance(x, y);
   at.scale(scale, scale);
   at.translate(-x, -y);
   AffineTransform rt = (AffineTransform) component.getRenderingTransform().clone();
   rt.preConcatenate(at);
   if (rt.getDeterminant() < MAX_ZOOM_DETERMINANT) {
     return;
   }
   component.setRenderingTransform(rt);
   calculator.reset();
 }
  @Override
  public void mouseWheelMoved(MouseWheelEvent e) {
    double z = zoom;

    zoom *=
        Math.pow(
            1.1, (Client.instance.preferences.game.invertZoom ? 1 : -1) * e.getWheelRotation());
    if (zoom < 0.2) zoom = 0.2;
    if (zoom > 5) zoom = 5;
    double d = zoom - z;
    scrollX += d * e.getX() * 2;
    scrollY += d * e.getY() * 2;
    if (scrollX < 0) scrollX = 0;
    if (scrollY < 0) scrollY = 0;
    int mapWidth = mapCache.length;
    int mapHeight = mapCache[0].length;
    if (scrollX > (int) (mapWidth * tileSize * zoom - width))
      scrollX = (int) (mapWidth * tileSize * zoom - width);
    if (scrollY > (int) (mapHeight * tileSize * zoom - height))
      scrollY = (int) (mapHeight * tileSize * zoom - height);
  }
Ejemplo n.º 11
0
    private MouseEvent transformMouseEvent(MouseEvent event) {
      if (event == null) {
        throw new IllegalArgumentException("MouseEvent is null");
      }
      MouseEvent newEvent;
      if (event instanceof MouseWheelEvent) {
        MouseWheelEvent mouseWheelEvent = (MouseWheelEvent) event;
        newEvent =
            new MouseWheelEvent(
                mouseWheelEvent.getComponent(),
                mouseWheelEvent.getID(),
                mouseWheelEvent.getWhen(),
                mouseWheelEvent.getModifiers(),
                mouseWheelEvent.getX(),
                mouseWheelEvent.getY(),
                mouseWheelEvent.getClickCount(),
                mouseWheelEvent.isPopupTrigger(),
                mouseWheelEvent.getScrollType(),
                mouseWheelEvent.getScrollAmount(),
                mouseWheelEvent.getWheelRotation());
      } else {
        newEvent =
            new MouseEvent(
                event.getComponent(),
                event.getID(),
                event.getWhen(),
                event.getModifiers(),
                event.getX(),
                event.getY(),
                event.getClickCount(),
                event.isPopupTrigger(),
                event.getButton());
      }
      if (view != null && at.getDeterminant() != 0) {
        Rectangle viewBounds = getTransformedSize();
        Insets insets = JXTransformer.this.getInsets();
        int xgap = (getWidth() - (viewBounds.width + insets.left + insets.right)) / 2;
        int ygap = (getHeight() - (viewBounds.height + insets.top + insets.bottom)) / 2;

        double x = newEvent.getX() + viewBounds.getX() - insets.left;
        double y = newEvent.getY() + viewBounds.getY() - insets.top;
        Point2D p = new Point2D.Double(x - xgap, y - ygap);

        Point2D tp;
        try {
          tp = at.inverseTransform(p, null);
        } catch (NoninvertibleTransformException ex) {
          // can't happen, we check it before
          throw new AssertionError("NoninvertibleTransformException");
        }
        // Use transformed coordinates to get the current component
        mouseCurrentComponent =
            SwingUtilities.getDeepestComponentAt(view, (int) tp.getX(), (int) tp.getY());
        if (mouseCurrentComponent == null) {
          mouseCurrentComponent = JXTransformer.this;
        }
        Component tempComponent = mouseCurrentComponent;
        if (mouseDraggedComponent != null) {
          tempComponent = mouseDraggedComponent;
        }

        Point point =
            SwingUtilities.convertPoint(view, (int) tp.getX(), (int) tp.getY(), tempComponent);
        newEvent.setSource(tempComponent);
        newEvent.translatePoint(point.x - event.getX(), point.y - event.getY());
      }
      return newEvent;
    }
  public void mouseWheelMoved(MouseWheelEvent e) {
    if (enabled && !readOnly) {
      if (timer != null && timer.isRunning()) {
        timer.stop();
      }
      if (enableMouseWheel) {
        int count = 1;
        MouseWheelEvent e2;

        long lastEventTime = e.getWhen();
        int steps = 0;
        int r;

        // This cycle is to determine multiple clicks like double wheel, triple wheel event etc.
        // We go through the vector of events and check whether there are events corresponding to
        // multiple events.
        for (int i = 0; i < events.size() && events.get(i) instanceof MouseWheelEvent; i++) {
          e2 = (MouseWheelEvent) events.get(i);

          // The events are considered to be a multiple click when:
          // 1. Coordinates are equal
          // 2. Modifiers are equal
          // 3. Both events are wheel up or down
          // 4. Delay between two subsequent clicks is lower than given number of miliseconds
          r = e2.getWheelRotation();
          if (e2.getX() == e.getX()
              && e2.getY() == e.getY()
              && e2.getModifiers() == e.getModifiers()
              && (lastEventTime - e2.getWhen() < mouseMultiDelay)
              && e2.getID() == e.getID()
              && ((r > 0 && e.getWheelRotation() > 0) || (r < 0 && e.getWheelRotation() < 0))) {
            count++;
            lastEventTime = e2.getWhen();
            steps += Math.abs(r);
          } else {
            break;
          }
        }

        steps += Math.abs(e.getWheelRotation());

        // Generate the command string
        String s =
            "Mouse "
                + (e.getWheelRotation() > 0
                    ? MouseCommand.MOUSE_WHEEL_DOWN
                    : MouseCommand.MOUSE_WHEEL_UP);

        // Insert modifiers if there are any
        String modifiers = parser.modifiersToString(e.getModifiers());
        if (modifiers.length() > 0) {
          s += " " + MouseCommand.PARAM_MODIFIER + "=" + modifiers;
        }

        // Generate the count parameter
        if (count > 1) {
          s += " " + MouseCommand.PARAM_COUNT + "=" + Math.abs(steps);
        }

        // This will determine whether this event is preceded by a mouse move command with the same
        // coordinates.
        // It will be replaced if yes.
        boolean replaceLastMove = false;
        if (enableMouseMoves) {
          if (events.size() > 0 && events.get(events.size() - 1) instanceof MouseEvent) {
            MouseEvent me = (MouseEvent) events.get(events.size() - 1);
            if (me.getID() == MouseEvent.MOUSE_MOVED
                && e.getX() == me.getX()
                && e.getY() == me.getY()) {
              replaceLastMove = true;
            }
          }
        }

        // Generate coordinates
        s += " " + MouseCommand.PARAM_TO + "=" + parser.pointToString(e.getPoint());

        // Insert the command to the current editor
        insertLine(s, count > 1 || replaceLastMove, true, false);
        dragInProgress = false;
      }
      insertEvent(e);
    }
  }
Ejemplo n.º 13
0
    /**
     * Zoom in and out, trying to preserve the point of the image that was under the mouse cursor at
     * the same place
     */
    public void mouseWheelMoved(MouseWheelEvent e) {
      File file;
      Image image;
      Rectangle visibleRect;

      synchronized (ImageDisplay.this) {
        file = ImageDisplay.this.file;
        image = ImageDisplay.this.image;
        visibleRect = ImageDisplay.this.visibleRect;
      }

      mouseIsDragging = false;
      selectedRect = null;

      if (image == null) return;

      // Calculate the mouse cursor position in image coordinates, so that we can center the zoom
      // on that mouse position.
      // To avoid issues when the user tries to zoom in on the image borders, this point is not
      // calculated
      // again if there was less than 1.5seconds since the last event.
      if (e.getWhen() - lastTimeForMousePoint > 1500 || mousePointInImg == null) {
        lastTimeForMousePoint = e.getWhen();
        mousePointInImg = comp2imgCoord(visibleRect, e.getX(), e.getY());
      }

      // Applicate the zoom to the visible rectangle in image coordinates
      if (e.getWheelRotation() > 0) {
        visibleRect.width = visibleRect.width * 3 / 2;
        visibleRect.height = visibleRect.height * 3 / 2;
      } else {
        visibleRect.width = visibleRect.width * 2 / 3;
        visibleRect.height = visibleRect.height * 2 / 3;
      }

      // Check that the zoom doesn't exceed 2:1
      if (visibleRect.width < getSize().width / 2) {
        visibleRect.width = getSize().width / 2;
      }
      if (visibleRect.height < getSize().height / 2) {
        visibleRect.height = getSize().height / 2;
      }

      // Set the same ratio for the visible rectangle and the display area
      int hFact = visibleRect.height * getSize().width;
      int wFact = visibleRect.width * getSize().height;
      if (hFact > wFact) {
        visibleRect.width = hFact / getSize().height;
      } else {
        visibleRect.height = wFact / getSize().width;
      }

      // The size of the visible rectangle is limited by the image size.
      checkVisibleRectSize(image, visibleRect);

      // Set the position of the visible rectangle, so that the mouse cursor doesn't move on the
      // image.
      Rectangle drawRect = calculateDrawImageRectangle(visibleRect);
      visibleRect.x =
          mousePointInImg.x + ((drawRect.x - e.getX()) * visibleRect.width) / drawRect.width;
      visibleRect.y =
          mousePointInImg.y + ((drawRect.y - e.getY()) * visibleRect.height) / drawRect.height;

      // The position is also limited by the image size
      checkVisibleRectPos(image, visibleRect);

      synchronized (ImageDisplay.this) {
        if (ImageDisplay.this.file == file) {
          ImageDisplay.this.visibleRect = visibleRect;
        }
      }
      ImageDisplay.this.repaint();
    }
Ejemplo n.º 14
0
 public static final boolean ExecMouseWheel(GxwCbkHost host, MouseWheelEvent e) {
   IptMouseWheel wheel = e.getWheelRotation() < 0 ? IptMouseWheel_.Up : IptMouseWheel_.Down;
   return host.MouseWheelCbk(IptEvtDataMouse.new_(IptMouseBtn_.None, wheel, e.getX(), e.getY()));
 }
Ejemplo n.º 15
0
  @Override
  public void mouseWheelMoved(MouseWheelEvent e) {
    if ((canting.getCor() != null) && !pressed) {
      // (canting.getCor() != null) -> make sure object exists
      // !pressed -> zooming while dragging can mess up savedCameraPos

      int amount = e.getWheelRotation();

      if (isADown || isWDown || isEDown) { // mod structure

        CorakLSystem cor = getCanting().getCor();

        if (isADown) {
          cor.setAngle(cor.getAngle() - amount);
        }

        if (isWDown) {
          if (amount < 0 || cor.getWidth() > 1) {
            cor.setWidth(cor.getWidth() - amount);
          }
        }

        if (isEDown) {
          if (amount < 0 || cor.getLength() > 1) {
            cor.setLength(cor.getLength() - amount);
          }
        }

        this.prepareCorak(projectPath, cor, getCanting().getCorDataObject(), false);

        justModAppearance = true;

      } else { // zoom
        // get mouse pos in 3d
        this.getPixelLocationInImagePlate(e.getX(), e.getY(), mousePos3D);
        Transform3D mouseTransform = new Transform3D();
        this.getImagePlateToVworld(mouseTransform);
        mouseTransform.transform(mousePos3D);

        // movement vector from camera to mouse, zoom in
        Vector3d moveV = new Vector3d();
        moveV.sub(cameraPos, mousePos3D);
        moveV.normalize();
        double factor = camDist / 10;

        // if scroll down, movement from mouse to camera, zoom out
        moveV.scale(factor * amount);

        Transform3D zoom = new Transform3D();
        zoom.setTranslation(moveV);
        zoom.transform(cameraPos);
        zoom.transform(cameraFocus);

        if (currentProjectionMode == Scene3DObserverCookie.Projection.PARALLEL) {
          // if parallel projection
          // zoom don't make any difference, so, scale the view

          if (e.getWheelRotation() < 0) {
            view.setScreenScale(view.getScreenScale() * 1.109);
          } else {
            view.setScreenScale(view.getScreenScale() / 1.109);
          }
        }

        moveCamera();
      }
    }
  }