本文整理汇总了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;
}
}
}
示例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()));
}
示例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);
}
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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();
}
}
}
示例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;
//}
}
示例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);
}
示例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());
}
}
示例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);
}
}
}
示例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();
}
}
示例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));
}
示例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;
}
}