Esempio n. 1
0
      public void mouseWheelMoved(MouseWheelEvent e) {
        String st[] = {"PER UNITA'", "PER BLOCCO"};

        int unit = e.getUnitsToScroll();

        // calcolo per la scrollbar verticale l'attuale posizione
        // e l'unità di incremento per scroll
        JScrollBar sb = sp.getVerticalScrollBar();
        int y = sb.getValue();
        int y1 =
            e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL
                ? sb.getUnitIncrement(1)
                : sb.getBlockIncrement(1);

        sb.setValue(y + y1 * unit); // aggiorna la view della textarea

        int a = e.getScrollAmount();
        int b = e.getScrollType();
        int c = e.getUnitsToScroll();
        int d = e.getWheelRotation();
        double f = e.getPreciseWheelRotation();
        String g =
            "Unità da scorrere per giro di tacca: "
                + a
                + "\nTipo di scroll: "
                + st[e.getScrollType()]
                + "\nUnità che scorreranno verso l'alto: "
                + c
                + "\nNumero di tacche ruotate: "
                + d
                + "\nNumero di tacche precisamente ruotate: "
                + f;

        wheel_area.setText(g);
      }
  @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);
      }
    }
  }
 /** @param e */
 @Override
 public void mouseWheelMoved(MouseWheelEvent e) {
   if (simulationBox.onBackground()) {
     simulationBox.zoom(e.getPreciseWheelRotation());
   }
 }