• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PInputEventListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中edu.umd.cs.piccolo.event.PInputEventListener的典型用法代码示例。如果您正苦于以下问题:Java PInputEventListener类的具体用法?Java PInputEventListener怎么用?Java PInputEventListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PInputEventListener类属于edu.umd.cs.piccolo.event包,在下文中一共展示了PInputEventListener类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: StarButton

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
private StarButton( double innerRadius, double outerRadius, boolean initialEnabledState, PInputEventListener inputEventHandler ) {
    super( ENABLED_FILL_COLOR, STROKE, Color.BLACK );
    DoubleGeneralPath starPath = new DoubleGeneralPath();
    double angle = -Math.PI / 2;
    starPath.moveTo( Math.cos( angle ) * outerRadius, Math.sin( angle ) * outerRadius );
    for ( int i = 0; i < NUM_POINTS * 2; i++ ) {
        angle += Math.PI / NUM_POINTS;
        double length = i % 2 == 0 ? innerRadius : outerRadius;
        starPath.lineTo( Math.cos( angle ) * length, Math.sin( angle ) * length );
    }
    starPath.closePath();
    setPathTo( starPath.getGeneralPath() );
    setEnabled( initialEnabledState );
    addInputEventListener( inputEventHandler );
    addInputEventListener( new CursorHandler() );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:BalanceLabCanvas.java


示例2: MoleculeBucketNode

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
public MoleculeBucketNode( final MoleculeBucket bucket ) {
    super( bucket, MODEL_VIEW_TRANSFORM );

    addLabelToContainer( new ZeroOffsetNode( new PNode() {{
        final HTMLNode label = new HTMLNode( ChemUtils.toSubscript( bucket.getShape().name ),
                                             Color.BLACK, new PhetFont( 18, true ) ) {{
            setOffset( 0, -getFullBounds().getHeight() / 2 );
        }};
        final MoleculeNode exampleMoleculeNode = new MoleculeNode( new Molecule( bucket.getShape() ) );
        MoleculeNode icon = new MoleculeNode( new Molecule( bucket.getShape() ) {{
            setPosition( MODEL_VIEW_TRANSFORM.viewToModel( new Vector2D( 0, 0 ) ) );
        }} ) {{
            setLabelVisible( false );
            scale( 0.5 );

            // don't show the mouse hand over it
            for ( PInputEventListener listener : Arrays.asList( getInputEventListeners() ) ) {
                removeInputEventListener( listener );
            }
        }};
        addChild( label );
        addChild( new ZeroOffsetNode( icon ) {{
            setOffset( -getFullBounds().getWidth() - 10, -getFullBounds().getHeight() / 2 );
        }} );
    }} ) );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:MoleculeBucketNode.java


示例3: processEvent

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
/**
 * Process Events - Give each node in the pick path, starting at the bottom
 * most one, a chance to handle the event.
 * 
 * @param event event to be processed
 * @param eventType the type of event being processed
 */
public void processEvent(final PInputEvent event, final int eventType) {
    event.setPath(this);

    for (int i = nodeStack.size() - 1; i >= 0; i--) {
        final PNode each = (PNode) nodeStack.get(i);

        final EventListenerList list = each.getListenerList();

        if (list != null) {
            final Object[] listeners = list.getListeners(PInputEventListener.class);

            for (int j = 0; j < listeners.length; j++) {
                final PInputEventListener listener = (PInputEventListener) listeners[j];
                listener.processEvent(event, eventType);
                if (event.isHandled()) {
                    return;
                }
            }
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:29,代码来源:PPickPath.java


示例4: testCursorHandlerIsInstalledByDefault

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
public void testCursorHandlerIsInstalledByDefault() {
    PSWTBoundsHandle handle = new PSWTBoundsHandle(PBoundsLocator.createEastLocator(node));
    PInputEventListener dragHandler = handle.getHandleDraggerHandler();
    PInputEventListener cursorHandler = handle.getHandleCursorEventHandler();
    assertNotNull(cursorHandler);
    PInputEventListener[] listeners = handle.getInputEventListeners();
    assertEquals(2, listeners.length);
    assertTrue(cursorHandler == listeners[0] || cursorHandler == listeners[1]);
    assertTrue(dragHandler == listeners[0] || dragHandler == listeners[1]);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:PSWTBoundsHandleTest.java


示例5: getHandlerIndex

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
private int getHandlerIndex(PInputEventListener handler) {
    PInputEventListener[] listeners = canvas.getCamera().getInputEventListeners();
    int handlerIndex = -1;
    for (int i = 0; i < listeners.length; i++) {
        if (listeners[i] == handler) {
            handlerIndex = i;
        }
    }
    return handlerIndex;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:PSWTCanvasTest.java


示例6: testHandleHasDragHandlerInstalled

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
public void testHandleHasDragHandlerInstalled() {
    PInputEventListener dragHandler = handle.getHandleDraggerHandler();
    assertNotNull(dragHandler);

    PInputEventListener[] installedListeners = handle.getInputEventListeners();
    assertEquals(1, installedListeners.length);
    assertSame(dragHandler, installedListeners[0]);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:PSWTHandleTest.java


示例7: setKeyboardFocus

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
/**
 * Set the node that should receive key events.
 * 
 * @param eventHandler sets the keyboard event focus, may be null
 */
public void setKeyboardFocus(final PInputEventListener eventHandler) {
    final PInputEvent focusEvent = new PInputEvent(this, null);

    if (keyboardFocus != null) {
        dispatchEventToListener(focusEvent, FocusEvent.FOCUS_LOST, keyboardFocus);
    }

    keyboardFocus = eventHandler;

    if (keyboardFocus != null) {
        dispatchEventToListener(focusEvent, FocusEvent.FOCUS_GAINED, keyboardFocus);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:PInputManager.java


示例8: dispatchEventToListener

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
/**
 * Dispatches the given event to the listener, or does nothing if listener
 * is null.
 * 
 * @param event event to be dispatched
 * @param type type of event to dispatch
 * @param listener target of dispatch
 */
private void dispatchEventToListener(final PInputEvent event, final int type, final PInputEventListener listener) {
    if (listener != null) {
        // clear the handled bit since the same event object is used to send
        // multiple events such as mouseEntered/mouseExited and mouseMove.
        event.setHandled(false);
        listener.processEvent(event, type);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:PInputManager.java


示例9: removeInputEventListener

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
/**
 * Removes the specified input event listener so that it no longer receives
 * input events from this node.
 * 
 * @param listener the input listener to remove
 */
public void removeInputEventListener(final PInputEventListener listener) {
    if (listenerList == null) {
        return;
    }
    getListenerList().remove(PInputEventListener.class, listener);
    if (listenerList.getListenerCount() == 0) {
        listenerList = null;
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:16,代码来源:PNode.java


示例10: getInputEventListeners

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
/**
 * Returns an array of input event listeners that are attached to this node.
 * 
 * @since 1.3
 * @return event listeners attached to this node
 */
public PInputEventListener[] getInputEventListeners() {
    if (listenerList == null || listenerList.getListenerCount() == 0) {
        return new PInputEventListener[] {};
    }

    final EventListener[] listeners = listenerList.getListeners(PInputEventListener.class);

    final PInputEventListener[] result = new PInputEventListener[listeners.length];
    for (int i = 0; i < listeners.length; i++) {
        result[i] = (PInputEventListener) listeners[i];
    }
    return result;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:PNode.java


示例11: testAddInputEventListenersIsHonoured

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
public void testAddInputEventListenersIsHonoured() {
    canvas.addInputEventListener(mockListener);
    final PInputEventListener[] listeners = canvas.getInputEventListeners();
    assertNotNull(listeners);
    assertEquals(3, listeners.length); // zoom + pan + mockListener
    // by default
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:PCanvasTest.java


示例12: testRemoveInputEventListenersIsHonoured

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
public void testRemoveInputEventListenersIsHonoured() {
    canvas.addInputEventListener(mockListener);
    canvas.removeInputEventListener(mockListener);
    final PInputEventListener[] listeners = canvas.getInputEventListeners();
    assertNotNull(listeners);
    assertEquals(2, listeners.length); // zoom + pan + mockListener
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:PCanvasTest.java


示例13: containsListener

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
private boolean containsListener( PInputEventListener listener ) {
    return asList( getInputEventListeners() ).contains( listener );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:4,代码来源:CompoundListNode.java


示例14: addInputEventListener

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
public synchronized void addInputEventListener( PInputEventListener l ) {
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:3,代码来源:GlassPaneCanvas.java


示例15: testDefaultNumberOfEventListenersIs2

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
public void testDefaultNumberOfEventListenersIs2() {
    final PInputEventListener[] listeners = canvas.getInputEventListeners();
    assertNotNull(listeners);
    assertEquals(2, listeners.length);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:6,代码来源:PCanvasTest.java


示例16: getKeyboardListener

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
public PInputEventListener getKeyboardListener() {
    if (swingRenderer != null) {
        return swingRenderer;
    }
	return inputHandler;
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:7,代码来源:ContentBoxNode.java


示例17: addThumbListener

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
/**
 * Adds a listener to the thumb, so we tell when we're dragging it.
 *
 * @param listener
 */
public void addThumbListener( PInputEventListener listener ) {
    thumb.addInputEventListener( listener );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:WavelengthControl.java


示例18: addInputEventListener

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
/**
 * Add an input listener to the camera associated with this canvas.
 * 
 * @param listener listener to add to to the camera
 */
public void addInputEventListener(final PInputEventListener listener) {
    getCamera().addInputEventListener(listener);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:PSWTCanvas.java


示例19: removeInputEventListener

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
/**
 * Remove an input listener to the camera associated with this canvas. Does
 * nothign is the listener is not found.
 * 
 * @param listener listener to remove from the set of event listeners
 *            attached to this canvas.
 */
public void removeInputEventListener(final PInputEventListener listener) {
    getCamera().removeInputEventListener(listener);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:PSWTCanvas.java


示例20: getKeyboardFocus

import edu.umd.cs.piccolo.event.PInputEventListener; //导入依赖的package包/类
/**
 * Return the node that currently has the keyboard focus. This node receives
 * the key events.
 * 
 * @return the current keyboard focus
 */
public PInputEventListener getKeyboardFocus() {
    return keyboardFocus;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:PInputManager.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NotFilter类代码示例发布时间:2022-05-15
下一篇:
Java Labels类代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap