本文整理汇总了Java中javafx.scene.input.PickResult类的典型用法代码示例。如果您正苦于以下问题:Java PickResult类的具体用法?Java PickResult怎么用?Java PickResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PickResult类属于javafx.scene.input包,在下文中一共展示了PickResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: click
import javafx.scene.input.PickResult; //导入依赖的package包/类
@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]);
}
示例2: click
import javafx.scene.input.PickResult; //导入依赖的package包/类
@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]);
}
示例3: getText
import javafx.scene.input.PickResult; //导入依赖的package包/类
@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));
}
示例4: MonthSheetView
import javafx.scene.input.PickResult; //导入依赖的package包/类
/**
* 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()));
}
示例5: GoogleTrendChartEvent
import javafx.scene.input.PickResult; //导入依赖的package包/类
/**
* @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;
}
示例6: DockEvent
import javafx.scene.input.PickResult; //导入依赖的package包/类
/**
* 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;
}
示例7: isEqualsPickResults
import javafx.scene.input.PickResult; //导入依赖的package包/类
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;
}
示例8: click
import javafx.scene.input.PickResult; //导入依赖的package包/类
@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());
}
示例9: extremumTest
import javafx.scene.input.PickResult; //导入依赖的package包/类
@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;
}
}
示例10: genMouseClick
import javafx.scene.input.PickResult; //导入依赖的package包/类
/**
* 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)
);
}
示例11: genRightClick
import javafx.scene.input.PickResult; //导入依赖的package包/类
/**
* 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)
);
}
示例12: genMouseDrag
import javafx.scene.input.PickResult; //导入依赖的package包/类
/**
* 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
);
}
示例13: backingTest
import javafx.scene.input.PickResult; //导入依赖的package包/类
@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());
}
示例14: backingTest
import javafx.scene.input.PickResult; //导入依赖的package包/类
@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());
}
示例15: addVolumeInteraction
import javafx.scene.input.PickResult; //导入依赖的package包/类
/**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());
}
});
}