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

Java PInputEvent类代码示例

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

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



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

示例1: CalendarNode

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
public CalendarNode() {
    for (int week = 0; week < numWeeks; week++) {
        for (int day = 0; day < numDays; day++) {
            addChild(new DayNode(week, day));
        }
    }

    CalendarNode.this.addInputEventListener(new PBasicInputEventHandler() {
        public void mouseReleased(PInputEvent event) {
            DayNode pickedDay = (DayNode) event.getPickedNode();
            if (pickedDay.hasWidthFocus && pickedDay.hasHeightFocus) {
                setFocusDay(null, true);
            }
            else {
                setFocusDay(pickedDay, true);
            }
        }
    });
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:20,代码来源:CalendarNode.java


示例2: initialize

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
/** {@inheritDoc} */
public void initialize() {

    curve.moveTo(100.0d, 100.0d);
    curve.curveTo(150.0d, 135.0d, 250.0d, 155.0d, 300.0d, 300.0d);
    curve.closePath();

    curve.setPaint(PAINT);
    curve.setStrokePaint(STROKE_PAINT);

    PInputEventListener animateCurve = new PBasicInputEventHandler() {
            /** {@inheritDoc} */
            public void mousePressed(final PInputEvent event) {
                animateCurve();
            }
        };

    curve.addInputEventListener(animateCurve);

    getCanvas().getLayer().addChild(curve);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:22,代码来源:AnimatePathExample.java


示例3: drag

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
public void drag(final PInputEvent e) {
    final PNode node = e.getPickedNode();
    node.translate(e.getDelta().width, e.getDelta().height);

    final ArrayList edges = (ArrayList) e.getPickedNode().getAttribute("edges");

    int i;
    for (i = 0; i < edges.size(); i++) {
        final PPath edge = (PPath) edges.get(i);
        final ArrayList nodes = (ArrayList) edge.getAttribute("nodes");
        final PNode node1 = (PNode) nodes.get(0);
        final PNode node2 = (PNode) nodes.get(1);

        edge.reset();
        // Note that the node's "FullBounds" must be used (instead of
        // just the "Bound") because the nodes have non-identity
        // transforms which must be included when determining their
        // position.
        final Point2D.Double bound1 = (Point2D.Double) node1.getFullBounds().getCenter2D();
        final Point2D.Double bound2 = (Point2D.Double) node2.getFullBounds().getCenter2D();

        edge.moveTo((float) bound1.getX(), (float) bound1.getY());
        edge.lineTo((float) bound2.getX(), (float) bound2.getY());
    }
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:26,代码来源:GraphEditorExample.java


示例4: mousePressed

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
/**
 * A callback that is invoked any time the mouse is pressed on the canvas.
 * If the press occurs directly on the canvas, it create a new PStyledText
 * instance and puts it in editing mode. If the click is on a node, it marks
 * changes it to editing mode.
 * 
 * @param event mouse click event that can be queried
 */
public void mousePressed(final PInputEvent event) {
    final PNode pickedNode = event.getPickedNode();

    stopEditing(event);

    if (event.getButton() != MouseEvent.BUTTON1) {
        return;
    }

    if (pickedNode instanceof PStyledText) {
        startEditing(event, (PStyledText) pickedNode);
    }
    else if (pickedNode instanceof PCamera) {
        final PStyledText newText = createText();
        final Insets pInsets = newText.getInsets();
        newText.translate(event.getPosition().getX() - pInsets.left, event.getPosition().getY() - pInsets.top);
        startEditing(event, newText);
    }
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:28,代码来源:PStyledTextEventHandler.java


示例5: startEditing

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
/**
 * Begins editing the provided text node as a result of the provided event.
 * Will swap out the text node for an editor.
 * 
 * @param event the event responsible for starting the editing
 * @param text text node being edited
 */
public void startEditing(final PInputEvent event, final PStyledText text) {
    // Get the node's top right hand corner
    final Insets pInsets = text.getInsets();
    final Point2D nodePt = new Point2D.Double(text.getX() + pInsets.left, text.getY() + pInsets.top);
    text.localToGlobal(nodePt);
    event.getTopCamera().viewToLocal(nodePt);

    // Update the editor to edit the specified node
    editor.setDocument(text.getDocument());
    editor.setVisible(true);

    final Insets bInsets = editor.getBorder().getBorderInsets(editor);
    editor.setLocation((int) nodePt.getX() - bInsets.left, (int) nodePt.getY() - bInsets.top);
    reshapeEditorLater();

    dispatchEventToEditor(event);
    canvas.repaint();

    text.setEditing(true);
    text.getDocument().addDocumentListener(docListener);
    editedText = text;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:30,代码来源:PStyledTextEventHandler.java


示例6: stopEditing

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
/**
 * Stops editing the current text node.
 * 
 * @param event the event responsible for stopping the editing
 */
public void stopEditing(final PInputEvent event) {
    if (editedText == null) {
        return;
    }

    editedText.getDocument().removeDocumentListener(docListener);
    editedText.setEditing(false);

    if (editedText.getDocument().getLength() == 0) {
        editedText.removeFromParent();
    }
    else {
        editedText.syncWithDocument();
    }

    if (editedText.getParent() == null) {
        editedText.setScale(1.0 / event.getCamera().getViewScale());
        canvas.getLayer().addChild(editedText);
    }
    editor.setVisible(false);
    canvas.repaint();

    editedText = null;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:30,代码来源:PStyledTextEventHandler.java


示例7: dispatchEventToEditor

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
/**
 * Intercepts Piccolo2D events and dispatches the underlying swing one to
 * the current editor.
 * 
 * @param event the swing event being intercepted
 */
public void dispatchEventToEditor(final PInputEvent event) {
    // We have to nest the mouse press in two invoke laters so that it is
    // fired so that the component has been completely validated at the new
    // size and the mouse event has the correct offset
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    final MouseEvent me = new MouseEvent(editor, MouseEvent.MOUSE_PRESSED, event.getWhen(), event
                            .getModifiers()
                            | InputEvent.BUTTON1_MASK, (int) (event.getCanvasPosition().getX() - editor.getX()),
                            (int) (event.getCanvasPosition().getY() - editor.getY()), 1, false);
                    editor.dispatchEvent(me);
                }
            });
        }
    });
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:25,代码来源:PStyledTextEventHandler.java


示例8: startDrag

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
/**
 * Overrides method in PDragSequenceEventHandler so that, selections have
 * marquees.
 * 
 * @param e the event that started the drag
 */
protected void startDrag(final PInputEvent e) {
    super.startDrag(e);

    initializeSelection(e);

    if (isMarqueeSelection(e)) {
        initializeMarquee(e);

        if (!isOptionSelection(e)) {
            startMarqueeSelection(e);
        }
        else {
            startOptionMarqueeSelection(e);
        }
    }
    else {
        if (!isOptionSelection(e)) {
            startStandardSelection(e);
        }
        else {
            startStandardOptionSelection(e);
        }
    }
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:31,代码来源:PSelectionEventHandler.java


示例9: drag

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
/**
 * Updates the marquee to the new bounds caused by the drag.
 * 
 * @param event drag event
 */
protected void drag(final PInputEvent event) {
    super.drag(event);

    if (isMarqueeSelection(event)) {
        updateMarquee(event);

        if (!isOptionSelection(event)) {
            computeMarqueeSelection(event);
        }
        else {
            computeOptionMarqueeSelection(event);
        }
    }
    else {
        dragStandardSelection(event);
    }
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:23,代码来源:PSelectionEventHandler.java


示例10: testKeyboardDeleteFiresSelectionChange

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
/**
 * {@link http://code.google.com/p/piccolo2d/issues/detail?id=177}
 */
public void testKeyboardDeleteFiresSelectionChange()
{
    PCanvas canvas = new PCanvas();
    PLayer layer = canvas.getLayer();
    PNode node = new PNode();
    layer.addChild(node);

    PSelectionEventHandler selectionHandler = new PSelectionEventHandler(layer, layer);
    selectionHandler.setDeleteKeyActive(true);
    selectionHandler.select(node);
    assertTrue(selectionHandler.getSelectionReference().contains(node));

    PNotificationCenter notificationCenter = PNotificationCenter.defaultCenter();
    notificationCenter.addListener(this, "selectionChanged", PSelectionEventHandler.SELECTION_CHANGED_NOTIFICATION, null);

    KeyEvent keyEvent = new KeyEvent(canvas, -1, System.currentTimeMillis(), 0, KeyEvent.VK_DELETE);
    PInputEvent event = new PInputEvent(null, keyEvent);
    selectionHandler.keyPressed(event);
    assertTrue(selectionHandler.getSelectionReference().isEmpty());
    assertTrue(selectionChanged);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:25,代码来源:PSelectionEventHandlerTest.java


示例11: testKeyboardDeleteInactive

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
public void testKeyboardDeleteInactive()
{
    PCanvas canvas = new PCanvas();
    PLayer layer = canvas.getLayer();
    PNode node = new PNode();
    layer.addChild(node);

    PSelectionEventHandler selectionHandler = new PSelectionEventHandler(layer, layer);
    selectionHandler.setDeleteKeyActive(false);
    selectionHandler.select(node);
    assertTrue(selectionHandler.getSelectionReference().contains(node));

    PNotificationCenter notificationCenter = PNotificationCenter.defaultCenter();
    notificationCenter.addListener(this, "selectionChanged", PSelectionEventHandler.SELECTION_CHANGED_NOTIFICATION, null);

    KeyEvent keyEvent = new KeyEvent(canvas, -1, System.currentTimeMillis(), 0, KeyEvent.VK_DELETE);
    PInputEvent event = new PInputEvent(null, keyEvent);
    selectionHandler.keyPressed(event);
    assertTrue(selectionHandler.getSelectionReference().contains(node));
    assertFalse(selectionChanged);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:22,代码来源:PSelectionEventHandlerTest.java


示例12: testKeyboardDeleteEmptySelection

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
public void testKeyboardDeleteEmptySelection()
{
    PCanvas canvas = new PCanvas();
    PLayer layer = canvas.getLayer();

    PSelectionEventHandler selectionHandler = new PSelectionEventHandler(layer, layer);
    selectionHandler.setDeleteKeyActive(true);
    assertTrue(selectionHandler.getSelectionReference().isEmpty());

    PNotificationCenter notificationCenter = PNotificationCenter.defaultCenter();
    notificationCenter.addListener(this, "selectionChanged", PSelectionEventHandler.SELECTION_CHANGED_NOTIFICATION, null);

    KeyEvent keyEvent = new KeyEvent(canvas, -1, System.currentTimeMillis(), 0, KeyEvent.VK_DELETE);
    PInputEvent event = new PInputEvent(null, keyEvent);
    selectionHandler.keyPressed(event);
    assertTrue(selectionHandler.getSelectionReference().isEmpty());
    assertFalse(selectionChanged);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:19,代码来源:PSelectionEventHandlerTest.java


示例13: processEvent

import org.piccolo2d.event.PInputEvent; //导入依赖的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:piccolo2d,项目名称:piccolo2d.java,代码行数:29,代码来源:PPickPath.java


示例14: initialize

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
public void initialize() {

        PPath eacha = PPath.createRectangle(50, 50, 300, 300);
        eacha.setPaint(Color.red);
        getCanvas().getLayer().addChild(eacha);

        eacha = PPath.createRectangle(-50, -50, 100, 100);
        eacha.setPaint(Color.green);
        getCanvas().getLayer().addChild(eacha);

        eacha = PPath.createRectangle(350, 350, 100, 100);
        eacha.setPaint(Color.green);
        getCanvas().getLayer().addChild(eacha);

        getCanvas().getCamera().addInputEventListener(new PBasicInputEventHandler() {
            public void mousePressed(final PInputEvent event) {
                if (!(event.getPickedNode() instanceof PCamera)) {
                    event.setHandled(true);
                    getCanvas().getCamera().animateViewToPanToBounds(event.getPickedNode().getGlobalFullBounds(), 500);
                }
            }
        });

        final PLayer layer = getCanvas().getLayer();

        final Random random = new Random();
        for (int i = 0; i < 1000; i++) {
            final PPath each = PPath.createRectangle(0, 0, 100, 80);
            each.scale(random.nextFloat() * 2);
            each.offset(random.nextFloat() * 10000, random.nextFloat() * 10000);
            each.setPaint(new Color(random.nextFloat(), random.nextFloat(), random.nextFloat()));
            each.setStroke(new BasicStroke(1 + 10 * random.nextFloat()));
            each.setStrokePaint(new Color(random.nextFloat(), random.nextFloat(), random.nextFloat()));
            layer.addChild(each);
        }

        getCanvas().removeInputEventListener(getCanvas().getZoomEventHandler());
    }
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:39,代码来源:PanToExample.java


示例15: initialize

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
public void initialize() {
    final PNode root = createHierarchy(10);
    getCanvas().getLayer().addChild(root);
    getCanvas().removeInputEventListener(getCanvas().getPanEventHandler());
    getCanvas().addInputEventListener(new PBasicInputEventHandler() {
        public void mousePressed(final PInputEvent event) {
            getCanvas().getCamera().animateViewToCenterBounds(event.getPickedNode().getGlobalBounds(), true, 500);
        }
    });
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:11,代码来源:HierarchyZoomExample.java


示例16: startDrag

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
public void startDrag(final PInputEvent e) {
    super.startDrag(e);

    final Point2D p = e.getPosition();

    // Create a new squiggle and add it to the canvas.
    squiggle = new PPath.Float();
    squiggle.moveTo((float) p.getX(), (float) p.getY());
    squiggle.setStroke(new BasicStroke((float) (1 / e.getCamera().getViewScale())));
    canvas.getLayer().addChild(squiggle);

    // Reset the keydboard focus.
    e.getInputManager().setKeyboardFocus(null);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:15,代码来源:UserInteraction.java


示例17: checkForMouseEnteredAndExited

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
/**
 * Fires events whenever the mouse moves from PNode to PNode.
 * 
 * @param event to check to see if the top node has changed.
 */
protected void checkForMouseEnteredAndExited(final PInputEvent event) {
    final PNode currentNode = getPickedNode(mouseOver);
    final PNode previousNode = getPickedNode(previousMouseOver);

    if (currentNode != previousNode) {
        dispatchEventToListener(event, MouseEvent.MOUSE_EXITED, previousMouseOver);
        dispatchEventToListener(event, MouseEvent.MOUSE_ENTERED, mouseOver);
        previousMouseOver = mouseOver;
    }
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:16,代码来源:PInputManager.java


示例18: drag

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
protected void drag(final PInputEvent event) {
    super.drag(event);
    final PDimension aDelta = event.getDeltaRelativeTo(PSWTHandle.this);
    if (aDelta.getWidth() != 0 || aDelta.getHeight() != 0) {
        dragHandle(aDelta, event);
    }
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:8,代码来源:PSWTHandle.java


示例19: testRejectsEventsUnlessModifiersContainOneOfOrMask

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
public void testRejectsEventsUnlessModifiersContainOneOfOrMask() {
    final PInputEvent event = buildTestEvent();
    filter.setOrMask(InputEvent.CTRL_MASK | InputEvent.ALT_MASK);
    assertRejectsEvent(event);
    assertRejectsEvent(buildTestEvent(InputEvent.META_MASK));
    assertAcceptsEvent(buildTestEvent(InputEvent.CTRL_MASK));
    assertAcceptsEvent(buildTestEvent(InputEvent.ALT_MASK));
    assertAcceptsEvent(buildTestEvent(InputEvent.CTRL_MASK | InputEvent.ALT_MASK));
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:10,代码来源:PInputEventFilterTest.java


示例20: testKeyPressedDispatchesToCurrentFocus

import org.piccolo2d.event.PInputEvent; //导入依赖的package包/类
public void testKeyPressedDispatchesToCurrentFocus() {
    manager.setKeyboardFocus(mockListener);
    final PInputEvent event = new PInputEvent(manager, null);
    manager.keyPressed(event);
    assertEquals(2, mockListener.getNotificationCount());
    assertEquals(KeyEvent.KEY_PRESSED, mockListener.getNotification(1).type);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:8,代码来源:PInputManagerTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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