當前位置: 首頁>>代碼示例>>Java>>正文


Java MouseWheelEvent.getWheelRotation方法代碼示例

本文整理匯總了Java中java.awt.event.MouseWheelEvent.getWheelRotation方法的典型用法代碼示例。如果您正苦於以下問題:Java MouseWheelEvent.getWheelRotation方法的具體用法?Java MouseWheelEvent.getWheelRotation怎麽用?Java MouseWheelEvent.getWheelRotation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.event.MouseWheelEvent的用法示例。


在下文中一共展示了MouseWheelEvent.getWheelRotation方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: mouseWheelMoved

import java.awt.event.MouseWheelEvent; //導入方法依賴的package包/類
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    synchronized (lock) {
        int d = e.getWheelRotation(); 
        
        if (d < 0) {
            curDir = ScrollDirection.UP; 
        }
        else if (d > 0) {
            curDir = ScrollDirection.DOWN; 
        }
        else {
            curDir = ScrollDirection.NONE; 
        }
    }
}
 
開發者ID:HuskyGameDev,項目名稱:2017-TeamEngine,代碼行數:17,代碼來源:Jogl3Mouse.java

示例2: mouseWheelMoved

import java.awt.event.MouseWheelEvent; //導入方法依賴的package包/類
public final void mouseWheelMoved(MouseWheelEvent e)
{
	int notches = e.getWheelRotation();
	int button = 0;
	if (notches < 0)
	{
		button = 4;
	}
	else
	{
		button = 5;
	}

	game.gameQueue.add(new MousePressEvent(SparkEvents.E_MOUSEDOWN,
			button, e.getX(), e.getY()));
}
 
開發者ID:TheRemote,項目名稱:Spark,代碼行數:17,代碼來源:Java2DFrame.java

示例3: mouseWheelMoved

import java.awt.event.MouseWheelEvent; //導入方法依賴的package包/類
public void mouseWheelMoved(MouseWheelEvent e) {
  JScrollPane parent = getParentScrollPane();
  if (parent != null) {
        /*
         * Only dispatch if we have reached top/bottom on previous scroll
         */
    if (e.getWheelRotation() < 0) {
      if (bar.getValue() == 0 && previousValue == 0) {
        parent.dispatchEvent(cloneEvent(e));
      }
    } else {
      if (bar.getValue() == getMax() && previousValue == getMax()) {
        parent.dispatchEvent(cloneEvent(e));
      }
    }
    previousValue = bar.getValue();
  }
    /*
     * If parent scrollpane doesn't exist, remove this as a listener.
     * We have to defer this till now (vs doing it in constructor)
     * because in the constructor this item has no parent yet.
     */
  else {
    PDControlScrollPane.this.removeMouseWheelListener(this);
  }
}
 
開發者ID:nccgroup,項目名稱:Decoder-Improved,代碼行數:27,代碼來源:PDControlScrollPane.java

示例4: getIncrementFromAdjustable

import java.awt.event.MouseWheelEvent; //導入方法依賴的package包/類
public static int getIncrementFromAdjustable(Adjustable adj,
                                             MouseWheelEvent e) {
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (adj == null) {
            log.fine("Assertion (adj != null) failed");
        }
    }

    int increment = 0;

    if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
        increment = e.getUnitsToScroll() * adj.getUnitIncrement();
    }
    else if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
        increment = adj.getBlockIncrement() * e.getWheelRotation();
    }
    return increment;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:ScrollPaneWheelScroller.java

示例5: mouseWheelMoved

import java.awt.event.MouseWheelEvent; //導入方法依賴的package包/類
/**
 * Pass mouse events into the event queue.
 *
 * @param mouse mouse event received
 */
public void mouseWheelMoved(final MouseWheelEvent mouse) {
    int modifiers = mouse.getModifiersEx();
    boolean eventMouse1 = false;
    boolean eventMouse2 = false;
    boolean eventMouse3 = false;
    boolean mouseWheelUp = false;
    boolean mouseWheelDown = false;
    if ((modifiers & MouseEvent.BUTTON1_DOWN_MASK) != 0) {
        eventMouse1 = true;
    }
    if ((modifiers & MouseEvent.BUTTON2_DOWN_MASK) != 0) {
        eventMouse2 = true;
    }
    if ((modifiers & MouseEvent.BUTTON3_DOWN_MASK) != 0) {
        eventMouse3 = true;
    }
    mouse1 = eventMouse1;
    mouse2 = eventMouse2;
    mouse3 = eventMouse3;
    int x = screen.textColumn(mouse.getX());
    int y = screen.textRow(mouse.getY());
    if (mouse.getWheelRotation() > 0) {
        mouseWheelDown = true;
    }
    if (mouse.getWheelRotation() < 0) {
        mouseWheelUp = true;
    }

    TMouseEvent mouseEvent = new TMouseEvent(TMouseEvent.Type.MOUSE_DOWN,
        x, y, x, y, mouse1, mouse2, mouse3, mouseWheelUp, mouseWheelDown);

    synchronized (eventQueue) {
        eventQueue.add(mouseEvent);
    }
    synchronized (listener) {
        listener.notifyAll();
    }
}
 
開發者ID:klamonte,項目名稱:jermit,代碼行數:44,代碼來源:SwingTerminal.java

示例6: mouseWheelMoved

import java.awt.event.MouseWheelEvent; //導入方法依賴的package包/類
@Override
public void mouseWheelMoved( MouseWheelEvent e ) {
    if( !isEnabled() )
        return;
    int rotation = e.getWheelRotation();
    if( (rotation < 0 && isScrollLeft)
            || (rotation > 0 && !isScrollLeft ) ) {
        int increment = getDefaultIncrement();
        increment *= Math.abs( rotation );
        scroll( increment );
        e.consume();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:ScrollAction.java

示例7: doWheelScroll

import java.awt.event.MouseWheelEvent; //導入方法依賴的package包/類
static boolean doWheelScroll(XVerticalScrollbar vsb,
                                 XHorizontalScrollbar hsb,
                                 MouseWheelEvent e) {
    XScrollbar scroll = null;
    int wheelRotation;

    // Determine which, if any, sb to scroll
    if (vsb != null) {
        scroll = vsb;
    }
    else if (hsb != null) {
        scroll = hsb;
    }
    else { // Neither scrollbar is showing
        return false;
    }

    wheelRotation = e.getWheelRotation();

    // Check if scroll is necessary
    if ((wheelRotation < 0 && scroll.getValue() > scroll.getMinimum()) ||
        (wheelRotation > 0 && scroll.getValue() < scroll.getMaximum()) ||
        wheelRotation != 0) {

        int type = e.getScrollType();
        int incr;
        if (type == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
            incr = wheelRotation * scroll.getBlockIncrement();
        }
        else { // type is WHEEL_UNIT_SCROLL
            incr = e.getUnitsToScroll() * scroll.getUnitIncrement();
        }
        scroll.setValue(scroll.getValue() + incr);
        return true;
    }
    return false;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:38,代碼來源:ListHelper.java

示例8: mouseWheelMoved

import java.awt.event.MouseWheelEvent; //導入方法依賴的package包/類
@Override
public void mouseWheelMoved(MouseWheelEvent event) {
	if (react) {
		int amount = event.getWheelRotation();
		if (amount > 0) {
			model.setVerticalOffset(Math.min(model.getVerticalOffset() + amount * 5,
					(model.getAmountVoters() - 1) * model.getElementHeight() * 2));
			view.update();
		} else {
			model.setVerticalOffset(Math.max(model.getVerticalOffset() + amount * 5, 0));
			view.update();
		}
	}
}
 
開發者ID:Skypr,項目名稱:BEAST,代碼行數:15,代碼來源:ElectionSimulation.java

示例9: mouseWheelMoved

import java.awt.event.MouseWheelEvent; //導入方法依賴的package包/類
public void mouseWheelMoved(MouseWheelEvent e) {
      //System.out.println("PlotCanvas.mouseWheelMoved");
/*
       * System.out.println("PlotCanvas.mouseWheelMoved");
       * System.out.println(" mouseClick = [" + mouseClick[0] + " " +
       * mouseClick[1] + "]"); System.out.println(" mouseCurent = [" +
       * mouseCurent[0] + " " + mouseCurent[1] + "]");
       */
      mouseCurent[0] = e.getX();
      mouseCurent[1] = e.getY();
      e.consume();
      int[] origin;
      double[] ratio;
      // double factor = 1.5;
      //switch (ActionMode) {
      //    case ZOOM:
      if (e.getWheelRotation() == -1) {
          if (Array.max(((AWTDrawer) draw).projection.totalScreenRatio) > .01) {
              origin = new int[]{(int) (mouseCurent[0] - getWidth() / 3/* (2*factor) */),
                                 (int) (mouseCurent[1] - getHeight() / 3/* (2*factor) */)};
              ratio = new double[]{0.666/* 1/factor, 1/factor */, 0.666};
              draw.dilate(origin, ratio);
          }
      } else {
          if (Array.max(((AWTDrawer) draw).projection.totalScreenRatio) < 1) {
              origin = new int[]{(int) (mouseCurent[0] - getWidth() / 1.333/* (2/factor) */),
                                 (int) (mouseCurent[1] - getHeight() / 1.333/* (2/factor) */)
              };
              ratio = new double[]{1.5, 1.5 /* factor, factor */};
              draw.dilate(origin, ratio);
          } else /* (Array.max(((AWTDrawer) draw).projection.totalScreenRatio) >= 1)*/ {
              ((AWTDrawer) draw).projection.initBaseCoordsProjection(true);
          }
      }
      repaint();
      //       break;
      //}
  }
 
開發者ID:Cvarier,項目名稱:2D-Elliptic-Mesh-Generator,代碼行數:39,代碼來源:PlotCanvas.java

示例10: mouseWheelMoved

import java.awt.event.MouseWheelEvent; //導入方法依賴的package包/類
public void mouseWheelMoved(MouseWheelEvent e) {
    int notches = e.getWheelRotation();
    double z = node.getZ() - 2 * notches;
    if (z > .8 * camheight)
        z = .8 * camheight;
    if (z < 0)
        z = 0;
    node.setLocation(node.getX(), node.getY(), z);
}
 
開發者ID:acasteigts,項目名稱:JBotSim,代碼行數:10,代碼來源:JNode.java

示例11: mouseWheelMoved

import java.awt.event.MouseWheelEvent; //導入方法依賴的package包/類
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    if (wheelZoomEnabled) {
        int rotation = JMapViewer.zoomReverseWheel ? -e.getWheelRotation() : e.getWheelRotation();
        map.setZoom(map.getZoom() - rotation, e.getPoint());
    }
}
 
開發者ID:berniejenny,項目名稱:MapAnalyst,代碼行數:8,代碼來源:DefaultMapController.java

示例12: mouseWheelMoved

import java.awt.event.MouseWheelEvent; //導入方法依賴的package包/類
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    int rotations = e.getWheelRotation();
    Point2D.Double loc = mapComponent.userToWorldSpace(e.getPoint());
    for (int i = 0; i < Math.abs(rotations); i++) {
        if (rotations < 0) {
            mapComponent.zoomIn(loc);
        } else {
            mapComponent.zoomOut(loc);
        }
    }
}
 
開發者ID:berniejenny,項目名稱:MapAnalyst,代碼行數:13,代碼來源:MapEventHandler.java

示例13: mouseWheelMoved

import java.awt.event.MouseWheelEvent; //導入方法依賴的package包/類
public void mouseWheelMoved(MouseWheelEvent e) {
    if (e.isControlDown()) {
        if (e.getWheelRotation() < 0) {
            getEditor().ZoomMais();
        } else {
            getEditor().ZoomMenos();
        }
        e.consume();
    }
}
 
開發者ID:chcandido,項目名稱:brModelo,代碼行數:11,代碼來源:Diagrama.java

示例14: PrintPreviewComponent

import java.awt.event.MouseWheelEvent; //導入方法依賴的package包/類
public PrintPreviewComponent(RamusPrintable printable, int columnCount,
                             GUIFramework framework) {
    this.printable = printable;
    this.columnCount = columnCount;
    this.framework = framework;
    MouseWheelListener l = new MouseWheelListener() {

        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
            if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
                if (e.getModifiers() == KeyEvent.CTRL_MASK) {
                    double r = e.getWheelRotation();
                    double zoom = getZoom() - 0.2 * r;
                    setCurrentZoom(zoom);
                } else {
                    Rectangle rect = getVisibleRect();
                    scrollRectToVisible(new Rectangle(rect.x, rect.y
                            + e.getWheelRotation() * 150, rect.width,
                            rect.height));
                }
            }
        }
    };
    this.addMouseWheelListener(l);
    layout = Options.getInteger("PREVIW_LAYOUT", PREV_LAYOUT_GRID);
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            setCurrentZoom(Options.getDouble("PREV_ZOOM", 1d));
        }
    });
    setCurrentZoom(Options.getDouble("PREV_ZOOM", 1d));
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:35,代碼來源:PrintPreviewComponent.java

示例15: mouseWheelMoved

import java.awt.event.MouseWheelEvent; //導入方法依賴的package包/類
@Override
public void mouseWheelMoved(final MouseWheelEvent mwe) {
	final JSpinner spinner = (JSpinner) mwe.getSource();
	if (mwe.getScrollType() != MouseWheelEvent.WHEEL_UNIT_SCROLL) {
		return;
	}
	try {
		int value = (Integer) spinner.getValue();

		int i = 0;
		for (i = 0; i < vals.length; i++) {
			if (value < vals[i]) {
				break;
			}
		}
		if (i >= vals.length) {
			i = vals.length - 1;
		}
		final int mult = mults[i];
		value -= mult * mwe.getWheelRotation();
		if (value < 0) {
			value = 0;
		}
		spinner.setValue(value);
	}
	catch (final Exception e) {
		DavisUserControlPanel.log.warning(e.toString());
		return;
	}
}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:31,代碼來源:DavisUserControlPanel.java


注:本文中的java.awt.event.MouseWheelEvent.getWheelRotation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。