當前位置: 首頁>>代碼示例>>Java>>正文


Java PSelectionEventHandler類代碼示例

本文整理匯總了Java中edu.umd.cs.piccolox.event.PSelectionEventHandler的典型用法代碼示例。如果您正苦於以下問題:Java PSelectionEventHandler類的具體用法?Java PSelectionEventHandler怎麽用?Java PSelectionEventHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PSelectionEventHandler類屬於edu.umd.cs.piccolox.event包,在下文中一共展示了PSelectionEventHandler類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initialize

import edu.umd.cs.piccolox.event.PSelectionEventHandler; //導入依賴的package包/類
public void initialize() {
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {
            final PNode rect = PPath.createRectangle(i * 60, j * 60, 50, 50);
            rect.setPaint(Color.blue);
            getCanvas().getLayer().addChild(rect);
        }
    }

    // Turn off default navigation event handlers
    getCanvas().removeInputEventListener(getCanvas().getPanEventHandler());
    getCanvas().removeInputEventListener(getCanvas().getZoomEventHandler());

    // Create a selection event handler
    final PSelectionEventHandler selectionEventHandler = new PSelectionEventHandler(getCanvas().getLayer(),
            getCanvas().getLayer());
    getCanvas().addInputEventListener(selectionEventHandler);
    getCanvas().getRoot().getDefaultInputManager().setKeyboardFocus(selectionEventHandler);

    PNotificationCenter.defaultCenter().addListener(this, "selectionChanged",
            PSelectionEventHandler.SELECTION_CHANGED_NOTIFICATION, selectionEventHandler);
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:23,代碼來源:SelectionExample.java

示例2: initialize

import edu.umd.cs.piccolox.event.PSelectionEventHandler; //導入依賴的package包/類
public void initialize() {
    super.initialize();

    getCanvas().removeInputEventListener(getCanvas().getPanEventHandler());

    // Create a decorator group that is NOT volatile
    final DecoratorGroup dg = new DecoratorGroup();
    dg.setPaint(Color.magenta);

    // Put some nodes under the group for it to decorate
    final PPath p1 = PPath.createEllipse(25, 25, 75, 75);
    p1.setPaint(Color.red);
    final PPath p2 = PPath.createRectangle(125, 75, 50, 50);
    p2.setPaint(Color.blue);

    // Add everything to the Piccolo hierarchy
    dg.addChild(p1);
    dg.addChild(p2);
    getCanvas().getLayer().addChild(dg);

    // Create a decorator group that IS volatile
    final VolatileDecoratorGroup vdg = new VolatileDecoratorGroup(getCanvas().getCamera());
    vdg.setPaint(Color.cyan);

    // Put some nodes under the group for it to decorate
    final PPath p3 = PPath.createEllipse(275, 175, 50, 50);
    p3.setPaint(Color.blue);
    final PPath p4 = PPath.createRectangle(175, 175, 75, 75);
    p4.setPaint(Color.green);

    // Add everything to the Piccolo hierarchy
    vdg.addChild(p3);
    vdg.addChild(p4);
    getCanvas().getLayer().addChild(vdg);

    // Create a selection handler so we can see that the decorator actually
    // works
    final ArrayList selectableParents = new ArrayList();
    selectableParents.add(dg);
    selectableParents.add(vdg);

    final PSelectionEventHandler ps = new PSelectionEventHandler(getCanvas().getLayer(), selectableParents);
    getCanvas().addInputEventListener(ps);
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:45,代碼來源:GroupExample.java


注:本文中的edu.umd.cs.piccolox.event.PSelectionEventHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。