Java 类javafx.scene.input.PickResult 实例源码
项目:marathonv5
文件:RFXHyperlinkButtonTest.java
@Test public void click() {
Hyperlink button = (Hyperlink) getPrimaryStage().getScene().getRoot().lookup(".hyperlink");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(new Runnable() {
@Override public void run() {
RFXButtonBase rfxButtonBase = new RFXButtonBase(button, null, null, lr);
Point2D sceneXY = button.localToScene(new Point2D(3, 3));
PickResult pickResult = new PickResult(button, sceneXY.getX(), sceneXY.getY());
Point2D screenXY = button.localToScreen(new Point2D(3, 3));
MouseEvent me = new MouseEvent(button, button, MouseEvent.MOUSE_PRESSED, 3, 3, sceneXY.getX(), screenXY.getY(),
MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, pickResult);
rfxButtonBase.mouseButton1Pressed(me);
}
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording select = recordings.get(0);
AssertJUnit.assertEquals("click", select.getCall());
AssertJUnit.assertEquals("", select.getParameters()[0]);
}
项目:marathonv5
文件:RFXButtonBaseTest.java
@Test public void click() {
Button button = (Button) getPrimaryStage().getScene().getRoot().lookup(".button");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(new Runnable() {
@Override public void run() {
RFXButtonBase rfxButtonBase = new RFXButtonBase(button, null, null, lr);
Point2D sceneXY = button.localToScene(new Point2D(3, 3));
PickResult pickResult = new PickResult(button, sceneXY.getX(), sceneXY.getY());
Point2D screenXY = button.localToScreen(new Point2D(3, 3));
MouseEvent me = new MouseEvent(button, button, MouseEvent.MOUSE_PRESSED, 3, 3, sceneXY.getX(), screenXY.getY(),
MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, pickResult);
rfxButtonBase.mouseButton1Pressed(me);
}
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording select = recordings.get(0);
AssertJUnit.assertEquals("click", select.getCall());
AssertJUnit.assertEquals("", select.getParameters()[0]);
}
项目:marathonv5
文件:RFXButtonBaseTest.java
@Test public void getText() {
Button button = (Button) getPrimaryStage().getScene().getRoot().lookup(".button");
LoggingRecorder lr = new LoggingRecorder();
List<String> text = new ArrayList<>();
Platform.runLater(new Runnable() {
@Override public void run() {
RFXButtonBase rfxButtonBase = new RFXButtonBase(button, null, null, lr);
Point2D sceneXY = button.localToScene(new Point2D(3, 3));
PickResult pickResult = new PickResult(button, sceneXY.getX(), sceneXY.getY());
Point2D screenXY = button.localToScreen(new Point2D(3, 3));
MouseEvent me = new MouseEvent(button, button, MouseEvent.MOUSE_PRESSED, 3, 3, sceneXY.getX(), screenXY.getY(),
MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, pickResult);
rfxButtonBase.mouseButton1Pressed(me);
text.add(rfxButtonBase.getAttribute("text"));
}
});
new Wait("Waiting for button text.") {
@Override public boolean until() {
return text.size() > 0;
}
};
AssertJUnit.assertEquals("Color", text.get(0));
}
项目:CalendarFX
文件:MonthSheetView.java
/**
* Constructs a new month sheet view that is using the {@link SimpleDateCell}.
*/
public MonthSheetView() {
getStyleClass().add(DEFAULT_STYLE_CLASS);
setHeaderCellFactory(param -> new MonthHeaderCell(param.getView(), param.getYearMonth()));
/*
* This view has its own context menu.
*/
setContextMenu(createContextMenu());
addEventHandler(ContextMenuEvent.CONTEXT_MENU_REQUESTED, evt -> {
final PickResult pickResult = evt.getPickResult();
final Node intersectedNode = pickResult.getIntersectedNode();
if (intersectedNode != null && intersectedNode instanceof DateCell) {
this.dateCell = (DateCell) intersectedNode;
} else {
this.dateCell = null;
}
ctxMenuScreenX = evt.getScreenX();
ctxMenuScreenY = evt.getScreenY();
});
// Set the factory AFTER the context menu has been created or the cell factory
// will be overridden again.
setCellFactory(param -> new SimpleDateCell(param.getView(), param.getDate()));
}
项目:Gargoyle
文件:GoogleTrendChartEvent.java
/**
* @param source
* @param target
* @param eventType
* @param x
* @param y
* @param screenX
* @param screenY
* @param pickResult
* @param clickCount
* @param contents
*/
public GoogleTrendChartEvent(Object source, EventTarget target, EventType<? extends GoogleTrendChartEvent> eventType, double x,
double y, double screenX, double screenY, PickResult pickResult, int clickCount, List<Node> contents) {
super(source, target, eventType);
this.x = x;
this.y = y;
this.screenX = screenX;
this.screenY = screenY;
this.sceneX = x;
this.sceneY = y;
this.pickResult = pickResult != null ? pickResult : new PickResult(target, x, y);
final Point3D p = InputEventUtils.recomputeCoordinates(this.pickResult, null);
this.x = p.getX();
this.y = p.getY();
this.z = p.getZ();
this.clickCount = clickCount;
this.contents = contents;
}
项目:Gargoyle
文件:DockEvent.java
/**
* Constructs new DockEvent event..
*
* @param source the source of the event. Can be null.
* @param target the target of the event. Can be null.
* @param eventType The type of the event.
* @param x The x with respect to the source. Should be in scene coordinates if source == null or
* source is not a Node.
* @param y The y with respect to the source. Should be in scene coordinates if source == null or
* source is not a Node.
* @param screenX The x coordinate relative to screen.
* @param screenY The y coordinate relative to screen.
* @param pickResult pick result. Can be null, in this case a 2D pick result without any further
* values is constructed based on the scene coordinates
* @param contents The contents being dragged during this event.
*/
public DockEvent(Object source, EventTarget target, EventType<? extends DockEvent> eventType,
double x, double y, double screenX, double screenY, PickResult pickResult, Node contents) {
super(source, target, eventType);
this.x = x;
this.y = y;
this.screenX = screenX;
this.screenY = screenY;
this.sceneX = x;
this.sceneY = y;
this.pickResult = pickResult != null ? pickResult : new PickResult(target, x, y);
final Point3D p = InputEventUtils.recomputeCoordinates(this.pickResult, null);
this.x = p.getX();
this.y = p.getY();
this.z = p.getZ();
this.contents = contents;
}
项目:openjfx-8u-dev-tests
文件:PickingTestOverall.java
private static boolean isEqualsPickResults(PickResult pr1, PickResult pr2) {
if (pr1.getIntersectedDistance() != pr2.getIntersectedDistance()
|| pr1.getIntersectedFace() != pr2.getIntersectedFace()
|| pr1.getIntersectedNode() != pr2.getIntersectedNode()) {
return false;
}
if (pr1.getIntersectedPoint() != null) {
if (!pr1.getIntersectedPoint().equals(pr2.getIntersectedPoint())) {
return false;
}
} else if (pr2.getIntersectedPoint() != null) {
return false;
}
if (pr1.getIntersectedTexCoord() != null) {
if (!pr1.getIntersectedTexCoord().equals(pr2.getIntersectedTexCoord())) {
return false;
}
} else if (pr2.getIntersectedTexCoord() != null) {
return false;
}
return true;
}
项目:openjfx-8u-dev-tests
文件:PickingTestFunctions.java
@Override
public PickResult click(Point pt) {
final int count = getResultsCount();
mouse().click(1, pt);
new Waiter(Wrap.WAIT_STATE_TIMEOUT).ensureValue(Boolean.TRUE, new State<Boolean>() {
@Override
public Boolean reached() {
if (count < getResultsCount()) {
return Boolean.TRUE;
} else {
return null;
}
}
});
return new GetAction<PickResult>() {
@Override
public void run(Object... os) throws Exception {
setResult(app.getLastResult().getPickResult());
}
}.dispatch(Root.ROOT.getEnvironment());
}
项目:openjfx-8u-dev-tests
文件:MeshPickingTests.java
@Test(timeout = 20000)
public void extremumTest() {
int leftX = getLeftX();
int topY = getTopY();
int delta = getDelta();
Rectangle rect = getAppRectangle();
double e = 1;
for (int dx = 0; dx < 2 * delta; dx += delta) {
for (int dy = 0; dy < 2 * delta; dy += delta) {
PickResult pr = click(new Point(rect.x + leftX + dx, rect.y + topY + dy));
Assert.assertTrue("Extremum is not " + e + " in " + pr.getIntersectedPoint(),
Math.abs(e - pr.getIntersectedPoint().getZ()) < eps);
e = -e;
}
e = -e;
}
}
项目:DockFX
文件:DockEvent.java
/**
* Constructs new DockEvent event..
*
* @param source the source of the event. Can be null.
* @param target the target of the event. Can be null.
* @param eventType The type of the event.
* @param x The x with respect to the source. Should be in scene coordinates if source == null or
* source is not a Node.
* @param y The y with respect to the source. Should be in scene coordinates if source == null or
* source is not a Node.
* @param screenX The x coordinate relative to screen.
* @param screenY The y coordinate relative to screen.
* @param pickResult pick result. Can be null, in this case a 2D pick result without any further
* values is constructed based on the scene coordinates
* @param contents The contents being dragged during this event.
*/
public DockEvent(Object source, EventTarget target, EventType<? extends DockEvent> eventType,
double x, double y, double screenX, double screenY, PickResult pickResult, Node contents) {
super(source, target, eventType);
this.x = x;
this.y = y;
this.screenX = screenX;
this.screenY = screenY;
this.sceneX = x;
this.sceneY = y;
this.pickResult = pickResult != null ? pickResult : new PickResult(target, x, y);
final Point3D p = InputEventUtils.recomputeCoordinates(this.pickResult, null);
this.x = p.getX();
this.y = p.getY();
this.z = p.getZ();
this.contents = contents;
}
项目:minesim
文件:MouseHandlerTest.java
/**
* create a click mouse event
*/
private MouseEvent genMouseClick(EventType<? extends MouseEvent> type, double x, double y) {
return new MouseEvent(
type,
x,
y,
x,
y,
MouseButton.PRIMARY,
1,
false,
false,
false,
false,
true, //left click down
false,
false,
false,
false,
false,
new PickResult(null, x, y)
);
}
项目:minesim
文件:MouseHandlerTest.java
/**
* create a right click mouseEvent
*/
private MouseEvent genRightClick(EventType<? extends MouseEvent> type, double x, double y) {
return new MouseEvent(
type,
x,
y,
x,
y,
MouseButton.SECONDARY,
1,
false,
false,
false,
false,
false,
false,
true, //right click down
false,
false,
false,
new PickResult(null, x, y)
);
}
项目:minesim
文件:MouseHandlerTest.java
/**
* create a drag mouseEvent
*/
private MouseDragEvent genMouseDrag(double x, double y) {
return new MouseDragEvent(
MouseDragEvent.MOUSE_DRAG_ENTERED,
x,
y,
x,
y,
MouseButton.PRIMARY,
1,
false,
false,
false,
false,
true, //left click down
false,
false,
false,
false,
new PickResult(null, x, y),
genMouseClick(MouseEvent.MOUSE_PRESSED, 0, 0) //drag from origin
);
}
项目:minesim
文件:BuildingMenuTest.java
@Test
public void backingTest() throws InterruptedException {
BuildingMenu.resetAll();
StackPane menuPane = new StackPane();
BuildingMenu.init(menuPane);
waitForRunLater();
Pane hascorrectStyle = new Pane();
hascorrectStyle.setStyle("-fx-background-color: #191d22; -fx-border-color: darkred; -fx-opacity: 0.8;");
StackPane initialOuterPane = BuildingMenu.getPane();
assertEquals(initialOuterPane.getChildren().get(0).getStyle(), hascorrectStyle.getStyle());
assertEquals("menu pane should have backing and menu", 2, initialOuterPane.getChildren().size());
BuildingMenu.showMenu();
assertTrue(BuildingMenu.isVisible());
initialOuterPane.getChildren().get(0).fireEvent(new MouseEvent(MOUSE_CLICKED, 0, 0, 0, 0, MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, new PickResult(null, 0, 0)));
assertFalse(BuildingMenu.isVisible());
}
项目:minesim
文件:eMenuHandlerTests.java
@Test
public void backingTest() throws InterruptedException {
eMenuHandler.resetAll();
Pane testPane = new Pane();
eMenuHandler.init(testPane);
waitForRunLater();
Pane hascorrectStyle = new Pane();
hascorrectStyle.setStyle("-fx-background-color: #191d22; -fx-border-color: darkred; -fx-opacity: 0.8;");
StackPane generatedAssembly = eMenuHandler.getAssembly();
assertEquals("backing should be the only child", 1, generatedAssembly.getChildren().size());
assertEquals(generatedAssembly.getChildren().get(0).getStyle(), hascorrectStyle.getStyle());
eMenuHandler.showMenu();
assertTrue(eMenuHandler.isVisible());
generatedAssembly.getChildren().get(0).fireEvent(new MouseEvent(MOUSE_CLICKED, 0, 0, 0, 0, MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, new PickResult(null, 0, 0)));
assertFalse(eMenuHandler.isVisible());
}
项目:VRL-JFXVis
文件:UGXReader.java
/**Adds the high resolution volume interaction to a group, that consists of meshView objects.
* Do not use this on the low resolution model.
* @param volumeMeshView the group of meshViews (volumes) that should be selectable
**/
private void addVolumeInteraction(MeshView volumeMeshView) {
volumeMeshView.addEventHandler(MouseEvent.MOUSE_CLICKED, mouseClick -> {
if (mouseClick.getButton().toString().matches("SECONDARY")) {
Node pickedNode = mouseClick.getPickResult().getIntersectedNode();
PickResult res = mouseClick.getPickResult();
if (debugMode) {
System.out.println("Selected node is a volume!");
System.out.println(newFaceMap.get(pickedNode));
}
handleSelection(faceNodeSelection, faceNodeSelectionMaterial, pickedNode, new MeshView());
}
});
}
项目:marathonv5
文件:FXEventQueueDevice.java
private void dispatchMouseEvent(Node node, Node target, PickResult pickResult, boolean popupTrigger, int clickCount,
MouseButton buttons, double x, double y) {
ensureVisible(node);
Point2D screenXY = node.localToScreen(new Point2D(x, y));
if (node != deviceState.getNode()) {
if (deviceState.getNode() != null) {
dispatchEvent(createMouseEvent(MouseEvent.MOUSE_EXITED, target, pickResult, x, y, screenXY.getX(), screenXY.getY(),
buttons, clickCount, deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed,
deviceState.metaPressed, false, false, false, false, popupTrigger, false, node));
}
dispatchEvent(createMouseEvent(MouseEvent.MOUSE_ENTERED, target, pickResult, x, y, screenXY.getX(), screenXY.getY(),
buttons, clickCount, deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed,
deviceState.metaPressed, false, false, false, false, popupTrigger, false, node));
}
for (int n = 1; n <= clickCount; n++) {
dispatchEvent(createMouseEvent(MouseEvent.MOUSE_PRESSED, target, pickResult, x, y, screenXY.getX(), screenXY.getY(),
buttons, n, deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed, deviceState.metaPressed,
buttons == MouseButton.PRIMARY, buttons == MouseButton.MIDDLE, buttons == MouseButton.SECONDARY, false,
popupTrigger, false, node));
dispatchEvent(createMouseEvent(MouseEvent.MOUSE_RELEASED, target, pickResult, x, y, screenXY.getX(), screenXY.getY(),
buttons, n, deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed, deviceState.metaPressed,
buttons == MouseButton.PRIMARY, buttons == MouseButton.MIDDLE, buttons == MouseButton.SECONDARY, false,
popupTrigger, false, node));
dispatchEvent(createMouseEvent(MouseEvent.MOUSE_CLICKED, target, pickResult, x, y, screenXY.getX(), screenXY.getY(),
buttons, n, deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed, deviceState.metaPressed,
buttons == MouseButton.PRIMARY, buttons == MouseButton.MIDDLE, buttons == MouseButton.SECONDARY, false,
popupTrigger, false, node));
}
}
项目:marathonv5
文件:JavaFXElement.java
@Override public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) {
verifyCanInteractWithElement();
EventQueueWait.requestFocus(node);
IDevice mouse = driver.getDevices();
mouse.click(node, target, pickResult, Buttons.getButtonFor(button), clickCount, xoffset, yoffset);
}
项目:marathonv5
文件:JavaFXTableCellElement.java
@Override public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) {
Node cell = getPseudoComponent();
target = getTextObj((TableCell<?, ?>) cell);
Point2D targetXY = target.localToParent(xoffset, yoffset);
targetXY = node.localToScene(targetXY);
super.click(button, target, new PickResult(target, targetXY.getX(), targetXY.getY()), clickCount, xoffset, yoffset);
}
项目:marathonv5
文件:JavaFXTreeTableViewCellElement.java
@Override public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) {
Node cell = getPseudoComponent();
target = getTextObj((TreeTableCell<?, ?>) cell);
Point2D targetXY = target.localToParent(xoffset, yoffset);
targetXY = node.localToScene(targetXY);
super.click(button, target, new PickResult(target, targetXY.getX(), targetXY.getY()), clickCount, xoffset, yoffset);
}
项目:openjfx-8u-dev-tests
文件:ShapesPickingTests.java
private void distanceTestCase(Point[] clickPoints) {
for (int i = 0; i < clickPoints.length; i++) {
PickResult pr = click(clickPoints[i]);
// Assert.fail("rewrite");
Rectangle rect = getAppRectangle();
double expected = getDistanceExpectedValue(100, Math.abs(rect.x + rect.width / 2 - clickPoints[i].x), Math.abs(rect.y + rect.height / 2 - clickPoints[i].y));
Assert.assertTrue("Intersected Distance error: expected "
+ expected + ", but was " + pr.getIntersectedDistance()
+ " in point " + clickPoints[i],
Math.abs(expected - pr.getIntersectedDistance()) <= eps);
//System.out.println(pr.getIntersectedDistance());
//System.out.println(application.getZTranslation() + cameraFixedEyePositionCorrection + SCALE + eps);
}
}
项目:openjfx-8u-dev-tests
文件:ShapesPickingTests.java
private void centerTestCase() {
Point3D expected = new Point3D(0, 0, -1.0);
Rectangle rect = getAppRectangle();
PickResult pr = click(new Point(rect.x + rect.width / 2 - 1, rect.y + rect.height / 2 - 1));
if (!isEqualsPoints(expected, pr.getIntersectedPoint())) {
Assert.fail("expected " + expected + "but was " + pr.getIntersectedPoint());
}
}
项目:openjfx-8u-dev-tests
文件:PickingTestOverall.java
/**
* Test check that PickResult not save last result.
*/
@Test(timeout = 10000)
public void pickResultTest() {
click(getNotNullClickPoint());
PickResult pr = click(getNullClickPoint());
Assert.assertNull("MouseEvent save last result", pr.getIntersectedNode());
}
项目:openjfx-8u-dev-tests
文件:PickingTestOverall.java
/**
* Test check that picking works with any fill.
*/
@Test(timeout = 10000)
public void fillTest() {
PickResult pr[][] = new PickResult[2][2];
pr[0][0] = click(getNotNullClickPoint());
pr[0][1] = click(getNullClickPoint());
setFill(Color.RED);
pr[1][0] = click(getNotNullClickPoint());
pr[1][1] = click(getNullClickPoint());
Assert.assertTrue("PickResult is differs in Not Null Popint!", isEqualsPickResults(pr[0][0], pr[1][0]));
Assert.assertTrue("PickResult is differs in Null Popint!", isEqualsPickResults(pr[0][1], pr[1][1]));
}
项目:openjfx-8u-dev-tests
文件:MeshPickingTests.java
private void fillPathPointsArray(int startX, int startY, double dx, double dy, Point3D points[], int start, int iterations) {
for (int i = 0; i < iterations; i++) {
Point clickPoint = new Point(startX + (i * dx), startY + (i * dy));
PickResult pr = click(clickPoint);
points[start + i] = pr.getIntersectedPoint();
}
}
项目:openjfx-8u-dev-tests
文件:MeshPickingTests.java
private void fillPathDistanceArray(int startX, int startY, double dx, double dy, double dist[][], int start, int iterations) {
Rectangle rect = getAppRectangle();
for (int i = 0; i < iterations; i++) {
Point clickPoint = new Point(startX + (i * dx), startY + (i * dy));
PickResult pr = click(clickPoint);
dist[start + i][0] = pr.getIntersectedDistance();
// dist[start + i][1] = pr.getIntersectedPoint().getX();
// dist[start + i][2] = pr.getIntersectedPoint().getY();
// dist[start + i][3] = pr.getIntersectedPoint().getZ();
dist[start + i][1] = Math.abs(clickPoint.x - rect.width / 2);
dist[start + i][2] = Math.abs(clickPoint.y - rect.height / 2);
}
}
项目:marathonv5
文件:FXEventQueueDevice.java
@Override public void click(Node node, Node target, PickResult pickResult, Buttons button, int clickCount, double xoffset,
double yoffset) {
MouseButton b = button.getMouseButton();
dispatchMouseEvent(node, target, pickResult, button == Buttons.RIGHT, clickCount, b, xoffset, yoffset);
deviceState.setNode(node);
}
项目:marathonv5
文件:JavaFXTreeViewNodeElement.java
@Override public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) {
Node cell = getPseudoComponent();
target = getTextObj((TreeCell<?>) cell);
Point2D targetXY = node.localToScene(xoffset, yoffset);
super.click(button, target, new PickResult(target, targetXY.getX(), targetXY.getY()), clickCount, xoffset, yoffset);
}
项目:marathonv5
文件:JavaFXListViewItemElement.java
@Override public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) {
Node cell = getPseudoComponent();
target = getTextObj((ListCell<?>) cell);
Point2D targetXY = node.localToScene(xoffset, yoffset);
super.click(button, target, new PickResult(target, targetXY.getX(), targetXY.getY()), clickCount, xoffset, yoffset);
}
项目:eavp
文件:FXViewer.java
/**
* <p>
* Hooks up JavaFX picking with JFace selections.
* </p>
*/
protected void wireSelectionHandling() {
scene.setOnMousePressed(new EventHandler<MouseEvent>() {
Group lastSelection = null;
@Override
public void handle(MouseEvent event) {
// Pick
PickResult pickResult = event.getPickResult();
Node intersectedNode = pickResult.getIntersectedNode();
if (intersectedNode == null) {
return;
}
if (!(intersectedNode instanceof Shape3D)) {
return;
}
// Resolve the parent
Group nodeParent = (Group) intersectedNode.getParent();
if (nodeParent == lastSelection) {
return;
}
// Resolve the shape
IRenderElement modelShape = (IRenderElement) nodeParent
.getProperties().get(ShapeController.class);
if (modelShape == null) {
return;
}
// Create and set the viewer selection
// (event gets fired in parent class)
FXSelection selection = new FXSelection(modelShape);
setSelection(selection);
lastSelection = nodeParent;
}
});
}
项目:eavp
文件:FXGeometryAttachment.java
/**
* The default constructor.
*
* @param manager
* The manager which will oversee this attachment
*/
public FXGeometryAttachment(FXGeometryAttachmentManager manager) {
super(manager);
selectMultiple = false;
// Add block to run when the mouse is clicked on the geometry
// canvas. This will allow for selection in the Editor.
super.fxAttachmentNode.setOnMouseClicked((event) -> {
selectMultiple = event.isControlDown();
// Get the pick result, see if we are selecting a node
PickResult pick = event.getPickResult();
// Get the node
Node selected = pick.getIntersectedNode();
// The render to select
IRenderElement selectedRender = null;
// All geometry editor objects in the root are now TriangleMeshViews
if (selected instanceof MeshView) {
MeshView view = (MeshView) selected;
// Go through the rendered nodes and find the node that
// corresponds
// to the selected MeshView
for (IRenderElement element : renderedNodes) {
Object mesh = element.getMesh();
// Test each mesh with the selected one
if (element.getMesh().equals(view)) {
selectedRender = element;
// If the mesh is a group node, check each child node
} else if (mesh instanceof Group) {
Group group = (Group) mesh;
for (Node node : group.getChildren()) {
if (node.equals(view)) {
// Finally set the render element
selectedRender = element;
break;
}
}
}
// If we found the selected render, break out of the loop
if (selectedRender != null) {
break;
}
}
}
// Set the selection in the tree view, which also sets the
// transformation view
IViewPart treeView = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage()
.findView(ShapeTreeView.ID);
if (selectMultiple) {
((ShapeTreeView) treeView).toggleSelected(selectedRender);
} else {
((ShapeTreeView) treeView).setSelected(selectedRender);
}
});
}
项目:eavp
文件:FXMeshViewer.java
/**
* The function called whenever the user clicks the mouse while in Edit
* mode.
*
* @param event
* The event that prompted the invocation of this function.
*/
private void handleEditModeClick(MouseEvent event) {
// Get the mouse position
mousePosX = event.getSceneX();
mousePosY = event.getSceneY();
mouseOldX = event.getSceneX();
mouseOldY = event.getSceneY();
// Get the user's selection
PickResult pickResult = event.getPickResult();
Node intersectedNode = pickResult.getIntersectedNode();
if (intersectedNode instanceof Shape3D) {
// Resolve the parent
Group nodeParent = (Group) intersectedNode.getParent();
// Resolve the shape
IController modelShape = (IController) nodeParent.getProperties()
.get(IController.class);
// If the user clicked a vertex, handle it
if (modelShape instanceof VertexController) {
// If shift is down, add the vertex to the selection
if (event.isShiftDown()) {
selectedVertices.add(modelShape);
modelShape.setProperty(MeshProperty.SELECTED, "True");
}
// If shift is not down and control is, either add the
// vertex to the selection if it is not present already
// or remove it if it is.
else if (event.isControlDown()) {
if (selectedVertices.contains(modelShape)) {
selectedVertices.remove(modelShape);
modelShape.setProperty(MeshProperty.SELECTED, "False");
}
else {
selectedVertices.add(modelShape);
modelShape.setProperty(MeshProperty.SELECTED, "True");
}
}
// If nothing is pressed, select that vertex and nothing
// else
else {
clearSelection();
selectedVertices.add(modelShape);
modelShape.setProperty(MeshProperty.SELECTED, "True");
}
}
}
}
项目:VRL-JFXVis
文件:UGXReader.java
/**Adds the high resolution face interaction to a group, that consists of meshView objects.
* Do not use this on the low resolution model.
* @param faceMeshView the group of meshViews (faces) that should be selectable
**/
private void addFaceInteraction(Group faceMeshView) {
faceMeshView.addEventHandler(MouseEvent.MOUSE_CLICKED, mouseClick -> {
if (mouseClick.getButton().toString().matches("SECONDARY")) {
Node pickedNode = mouseClick.getPickResult().getIntersectedNode();
PickResult res = mouseClick.getPickResult();
if (debugMode) {
System.out.println(newFaceMap.get(pickedNode));
}
handleSelection(faceNodeSelection, faceNodeSelectionMaterial, pickedNode, new MeshView());
}
});
}
项目:Gargoyle
文件:GoogleTrendChartEvent.java
/**
* @작성자 : KYJ
* @작성일 : 2016. 11. 4.
* @return
*/
public final PickResult getPickResult() {
return pickResult;
}
项目:Gargoyle
文件:GoogleTrendChartEvent.java
/**
* @param eventType
* @param x
* @param y
* @param screenX
* @param screenY
* @param pickResult
*/
public GoogleTrendChartEvent(EventType<? extends GoogleTrendChartEvent> eventType, double x, double y, double screenX, double screenY,
PickResult pickResult) {
this(null, null, eventType, x, y, screenX, screenY, pickResult);
}
项目:Gargoyle
文件:GoogleTrendChartEvent.java
/**
* @param source
* @param target
* @param eventType
* @param x
* @param y
* @param screenX
* @param screenY
* @param pickResult
*/
public GoogleTrendChartEvent(Object source, EventTarget target, EventType<? extends GoogleTrendChartEvent> eventType, double x,
double y, double screenX, double screenY, PickResult pickResult) {
this(source, target, eventType, x, y, screenX, screenY, pickResult, 0, null);
}
项目:Gargoyle
文件:DockEvent.java
/**
* Returns information about the pick.
*
* @return new PickResult object that contains information about the pick
*/
public final PickResult getPickResult() {
return pickResult;
}
项目:Gargoyle
文件:DockEvent.java
/**
* Constructs new DockEvent event..
*
* @param eventType The type of the event.
* @param x The x with respect to the source. Should be in scene coordinates if source == null or
* source is not a Node.
* @param y The y with respect to the source. Should be in scene coordinates if source == null or
* source is not a Node.
* @param screenX The x coordinate relative to screen.
* @param screenY The y coordinate relative to screen.
* @param pickResult pick result. Can be null, in this case a 2D pick result without any further
* values is constructed based on the scene coordinates
*/
public DockEvent(EventType<? extends DockEvent> eventType, double x, double y, double screenX,
double screenY, PickResult pickResult) {
this(null, null, eventType, x, y, screenX, screenY, pickResult);
}
项目:Gargoyle
文件:DockEvent.java
/**
* Constructs new DockEvent event..
*
* @param source the source of the event. Can be null.
* @param target the target of the event. Can be null.
* @param eventType The type of the event.
* @param x The x with respect to the source. Should be in scene coordinates if source == null or
* source is not a Node.
* @param y The y with respect to the source. Should be in scene coordinates if source == null or
* source is not a Node.
* @param screenX The x coordinate relative to screen.
* @param screenY The y coordinate relative to screen.
* @param pickResult pick result. Can be null, in this case a 2D pick result without any further
* values is constructed based on the scene coordinates
*/
public DockEvent(Object source, EventTarget target, EventType<? extends DockEvent> eventType,
double x, double y, double screenX, double screenY, PickResult pickResult) {
this(source, target, eventType, x, y, screenX, screenY, pickResult, null);
}
项目:DockFX
文件:DockEvent.java
/**
* Returns information about the pick.
*
* @return new PickResult object that contains information about the pick
*/
public final PickResult getPickResult() {
return pickResult;
}