本文整理汇总了Java中com.sun.j3d.utils.picking.PickResult.getNode方法的典型用法代码示例。如果您正苦于以下问题:Java PickResult.getNode方法的具体用法?Java PickResult.getNode怎么用?Java PickResult.getNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.j3d.utils.picking.PickResult
的用法示例。
在下文中一共展示了PickResult.getNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mouseClicked
import com.sun.j3d.utils.picking.PickResult; //导入方法依赖的package包/类
private void mouseClicked(MouseEvent e) {
lastMouseDragLocation = null;
pickCanvas.setShapeLocation(e);
PickResult[] thePickResult = pickCanvas.pickAllSorted();
if (thePickResult != null) {
for (PickResult theResult : thePickResult) {
if (theResult != null) {
Primitive p = (Primitive) theResult.getNode(PickResult.PRIMITIVE);
if (p != null) {
if (p.getUserData() instanceof UserObjectInfo) {
UserObjectInfo theItem = (UserObjectInfo) p.getUserData();
if (!SwingUtilities.isRightMouseButton(e)) {
if (e.getClickCount() == 2) {
editModelItem(theItem.item);
} else {
OutlineComponent.getDefault().setSelectedItem(theItem.item);
}
// We only handle the first found object
return;
} else {
DefaultPopupMenu theMenu = new DefaultPopupMenu(ResourceHelper
.getResourceHelper(ERDesignerBundle.BUNDLE_NAME));
List<ModelItem> theItems = new ArrayList<>();
theItems.add(theItem.item);
ContextMenuFactory.addActionsToMenu(Java3DEditor.this, theMenu, theItems);
UIInitializer.getInstance().initialize(theMenu);
theMenu.show(mainPanel, e.getX(), e.getY());
// We only handle the first found object
return;
}
}
}
}
}
}
}
示例2: mouseMoved
import com.sun.j3d.utils.picking.PickResult; //导入方法依赖的package包/类
private void mouseMoved(MouseEvent e) {
currentElement.setText("");
UserObjectInfo pickedObject = null;
pickCanvas.setShapeLocation(e);
// We have to use pickAll because of transparency
PickResult[] thePickResult = pickCanvas.pickAllSorted();
if (thePickResult != null) {
for (PickResult theResult : thePickResult) {
if (theResult != null) {
Primitive p = (Primitive) theResult.getNode(PickResult.PRIMITIVE);
if (p != null) {
if (p.getUserData() instanceof UserObjectInfo && pickedObject == null) {
UserObjectInfo theItem = (UserObjectInfo) p.getUserData();
pickedObject = theItem;
}
}
}
}
}
if (pickedObject != null) {
currentElement.setText(pickedObject.item.getName());
if (pickedObject != fadingComponent) {
fadingHelper.setComponentToHighlightFadeOut(fadingHelper.getComponentToHighlight() != null);
fadingHelper.setComponentToHighlightNext(getHighlightComponentFor(pickedObject));
}
} else {
fadingHelper.setComponentToHighlightFadeOut(true);
fadingHelper.setComponentToHighlightNext(null);
}
fadingComponent = pickedObject;
fadingHelper.startWaitTimer();
// Repaint triggern
Transform3D theTransform = new Transform3D();
modelGroup.getTransform(theTransform);
modelGroup.setTransform(theTransform);
}
示例3: mouseClicked
import com.sun.j3d.utils.picking.PickResult; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
pickCanvas.setShapeLocation(e);
PickResult result = pickCanvas.pickClosest();
// If nothing is selected, restore all data points
if (result == null) {
for (int i = 0; i < N; i++) {
spheres[i].getAppearance().getMaterial()
.setDiffuseColor(colors[i]);
TransparencyAttributes t_attr = new TransparencyAttributes(
TransparencyAttributes.NONE, 0.0f);
spheres[i].getAppearance()
.setTransparencyAttributes(t_attr);
}
ScatterPlot3DGUI.detailTextArea.append("Nothing selected.\n\n");
} else {
Primitive p = (Primitive) result.getNode(PickResult.PRIMITIVE);
Shape3D s = (Shape3D) result.getNode(PickResult.SHAPE3D);
if (p != null) {
int index = Integer.parseInt(p.getUserData().toString());
if (index == -1) {
ScatterPlot3DGUI.detailTextArea
.append("Axis selected.\n");
} else {
for (int i = 0; i < totalCol; i++) {
ScatterPlot3DGUI.detailTextArea
.append(ScatterPlot3DGUI.headers[i] + ": "
+ data.data[index][i] + "\n");
}
}
// Adjust label
ScatterPlot3DGUI.detailTextArea.append("\n");
ScatterPlot3DGUI.detailTextArea
.setCaretPosition(ScatterPlot3DGUI.detailTextArea
.getDocument().getLength());
} else if (s != null) {
System.out.print("s: ");
System.out.println(s.getClass().getName());
} else {
System.out.println("null");
}
}
} else if (e.getButton() == MouseEvent.BUTTON3) {
saveMenu.show(e.getComponent(), e.getX(), e.getY());
}
}