本文整理匯總了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);
}
示例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);
}