本文整理汇总了Java中java.awt.event.MouseWheelEvent类的典型用法代码示例。如果您正苦于以下问题:Java MouseWheelEvent类的具体用法?Java MouseWheelEvent怎么用?Java MouseWheelEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MouseWheelEvent类属于java.awt.event包,在下文中一共展示了MouseWheelEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: issue163946Hack
import java.awt.event.MouseWheelEvent; //导入依赖的package包/类
public static void issue163946Hack(final JScrollPane scrollPane) {
MouseWheelListener listener = new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (scrollPane.getVerticalScrollBar().isShowing()) {
if (e.getSource() != scrollPane) {
e.setSource(scrollPane);
scrollPane.dispatchEvent(e);
}
} else {
scrollPane.getParent().dispatchEvent(e);
}
}
};
scrollPane.addMouseWheelListener(listener);
scrollPane.getViewport().getView().addMouseWheelListener(listener);
}
示例2: mouseWheelMoved
import java.awt.event.MouseWheelEvent; //导入依赖的package包/类
public void mouseWheelMoved(MouseWheelEvent e) {
// Mouse wheel zooming takes precedence over scrolling
if (isMouseZoomingEnabled() &&
e.getSource() == InteractiveCanvasComponent.this) return;
// Change the ScrollBar value
if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
int unitsToScroll = e.getUnitsToScroll();
int direction = unitsToScroll < 0 ? -1 : 1;
if (unitsToScroll != 0) {
int increment = scrollBar.getUnitIncrement(direction);
int oldValue = scrollBar.getValue();
int newValue = oldValue + increment * unitsToScroll;
newValue = Math.max(Math.min(newValue, scrollBar.getMaximum() -
scrollBar.getVisibleAmount()), scrollBar.getMinimum());
if (oldValue != newValue) scrollBar.setValue(newValue);
}
}
}
示例3: mouseWheelMoved
import java.awt.event.MouseWheelEvent; //导入依赖的package包/类
@Override
public void mouseWheelMoved(MouseWheelEvent me) {
Point2D mouse = me.getPoint();
Point2D center = this.getVisViewer().getCenter();
int amount = me.getWheelRotation();
if(zoomAtMouse) {
if(amount > 0) {
scaler.scale(this.getVisViewer(), out, mouse);
} else if(amount < 0) {
scaler.scale(this.getVisViewer(), in, mouse);
}
} else {
if(amount > 0) {
scaler.scale(this.getVisViewer(), out, center);
} else if(amount < 0) {
scaler.scale(this.getVisViewer(), in, center);
}
}
me.consume();
}
示例4: mouseWheelMoved
import java.awt.event.MouseWheelEvent; //导入依赖的package包/类
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (e.isControlDown()) {
ZoomUtility.changeZoom(e.getPreciseWheelRotation());
//TODO position according mouse location
JViewport viewPort = (JViewport) SwingUtilities
.getAncestorOfClass(JViewport.class, this);
if (viewPort != null) {
Rectangle view = viewPort.getViewRect();
view.x = ZoomUtility.get(e.getX());
view.y = ZoomUtility.get(e.getY());
this.scrollRectToVisible(view);
}
} else if (getParent() != null) {
getParent().dispatchEvent(e);
}
repaint();
}
示例5: 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;
}
}
}
示例6: 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()));
}
示例7: handleWheelScrolling
import java.awt.event.MouseWheelEvent; //导入依赖的package包/类
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) {
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource());
}
int increment = 0;
if (sp != null && e.getScrollAmount() != 0) {
Adjustable adj = getAdjustableToScroll(sp);
if (adj != null) {
increment = getIncrementFromAdjustable(adj, e);
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment);
}
scrollAdjustable(adj, increment);
}
}
}
示例8: 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;
}
示例9: ScrollMove
import java.awt.event.MouseWheelEvent; //导入依赖的package包/类
/**
* Recebe o evento de MouseWheel do quadro de edição se não consumido.
*
* @param e
*/
public void ScrollMove(MouseWheelEvent e) {
int x = parente.getHorizontalScrollBar().getValue();
int y = parente.getVerticalScrollBar().getValue();
int vpw = parente.getViewport().getWidth() - getMargem();
int vph = parente.getViewport().getHeight() - getMargem();
int p1 = e.getX() + getMargem() - x;
int p2 = e.getY() + getMargem() - y;
boolean ambos = (p2 > vph && p1 > vpw);
p1 = vpw - (p1);
p2 = vph - (p2);
if (p1 < p2 || ambos) {
parente.getVerticalScrollBar().setValue(y + 2 * e.getUnitsToScroll());
}
if (p2 < p1 || ambos) {
parente.getHorizontalScrollBar().setValue(x + 2 * e.getUnitsToScroll());
}
e.consume();
}
示例10: mouseWheelMoved
import java.awt.event.MouseWheelEvent; //导入依赖的package包/类
/**
*
*/
protected void mouseWheelMoved(MouseWheelEvent e)
{
if (e.getWheelRotation() < 0)
{
graphComponent.zoomIn();
}
else
{
graphComponent.zoomOut();
}
status(mxResources.get("scale") + ": "
+ (int) (100 * graphComponent.getGraph().getView().getScale())
+ "%");
}
示例11: main
import java.awt.event.MouseWheelEvent; //导入依赖的package包/类
public static void main(final String[] args) {
final int mask = InputEvent.META_DOWN_MASK | InputEvent.CTRL_MASK;
Frame f = new Frame();
MouseEvent mwe = new MouseWheelEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
1, 1, 1);
MouseEvent mdme = new MenuDragMouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1,
true, null, null);
MouseEvent me = new MouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
MouseEvent.NOBUTTON);
test(f, mwe);
test(f, mdme);
test(f, me);
if (FAILED) {
throw new RuntimeException("Wrong mouse event");
}
}
示例12: main
import java.awt.event.MouseWheelEvent; //导入依赖的package包/类
public static void main(String[] args) {
Frame frame = new Frame();
Panel panel = new Panel();
frame.add(panel);
MouseWheelEvent event = new MouseWheelEvent(panel,
0, 0, 0, 0, 0, 0, 0, 0, false, 0, 0,
2, // wheelRotation
PRECISE_WHEEL_ROTATION); // preciseWheelRotation
MouseWheelEvent convertedEvent = (MouseWheelEvent) SwingUtilities.
convertMouseEvent(event.getComponent(), event, null);
if (convertedEvent.getPreciseWheelRotation() != PRECISE_WHEEL_ROTATION) {
throw new RuntimeException("PreciseWheelRotation field is not copied!");
}
}
示例13: 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();
}
}
示例14: mouseWheelMoved
import java.awt.event.MouseWheelEvent; //导入依赖的package包/类
@Override
public void mouseWheelMoved(MouseWheelEvent event) {
if (event.isControlDown() && (getCellRenderer() instanceof PdfCellRenderer)) {
setThumbnailSize(
Math.max(10, getThumbnailSize() - zoomSpeed * event.getWheelRotation())
);
} else if (getParent() != null) {
getParent().dispatchEvent(event);
}
}
示例15: WidgetMouseWheelEvent
import java.awt.event.MouseWheelEvent; //导入依赖的package包/类
/**
* Creates a mouse wheel event.
* @param id the event id
* @param event the Swing event
*/
public WidgetMouseWheelEvent(long id, MouseWheelEvent event) {
this.id = id;
this.event = event;
x = event.getX ();
y = event.getY ();
}