当前位置: 首页>>代码示例>>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;未经允许,请勿转载。