當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。