当前位置: 首页>>代码示例>>Java>>正文


Java MouseWheelEvent类代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:UIUtils.java

示例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);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:InteractiveCanvasComponent.java

示例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();
	
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:25,代码来源:GraphEnvironmentMousePlugin.java

示例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();
}
 
开发者ID:onprom,项目名称:onprom,代码行数:19,代码来源:UMLDiagramPanel.java

示例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; 
        }
    }
}
 
开发者ID:HuskyGameDev,项目名称:2017-TeamEngine,代码行数:17,代码来源:Jogl3Mouse.java

示例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()));
}
 
开发者ID:TheRemote,项目名称:Spark,代码行数:17,代码来源:Java2DFrame.java

示例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);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:ScrollPaneWheelScroller.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:ScrollPaneWheelScroller.java

示例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();
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:27,代码来源:Editor.java

示例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())
			+ "%");
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:19,代码来源:BasicGraphEditor.java

示例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");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:bug7170657.java

示例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!");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:bug8049533.java

示例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();
    }
}
 
开发者ID:klamonte,项目名称:jermit,代码行数:44,代码来源:SwingTerminal.java

示例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);
	}
}
 
开发者ID:mgropp,项目名称:pdfjumbler,代码行数:11,代码来源:PdfList.java

示例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 ();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:WidgetAction.java


注:本文中的java.awt.event.MouseWheelEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。