本文整理汇总了Java中javafx.geometry.Point2D类的典型用法代码示例。如果您正苦于以下问题:Java Point2D类的具体用法?Java Point2D怎么用?Java Point2D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Point2D类属于javafx.geometry包,在下文中一共展示了Point2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPoint
import javafx.geometry.Point2D; //导入依赖的package包/类
public Point2D getPoint(TableView<?> tableView, int columnIndex, int rowIndex) {
Set<Node> tableRowCell = tableView.lookupAll(".table-row-cell");
TableRow<?> row = null;
for (Node tableRow : tableRowCell) {
TableRow<?> r = (TableRow<?>) tableRow;
if (r.getIndex() == rowIndex) {
row = r;
break;
}
}
Set<Node> cells = row.lookupAll(".table-cell");
for (Node node : cells) {
TableCell<?, ?> cell = (TableCell<?, ?>) node;
if (tableView.getColumns().indexOf(cell.getTableColumn()) == columnIndex) {
Bounds bounds = cell.getBoundsInParent();
Point2D localToParent = cell.localToParent(bounds.getWidth() / 2, bounds.getHeight() / 2);
Point2D rowLocal = row.localToScene(localToParent, true);
return rowLocal;
}
}
return null;
}
示例2: scrollToRow
import javafx.geometry.Point2D; //导入依赖的package包/类
@Test public void scrollToRow() throws Throwable {
Stage primaryStage = getPrimaryStage();
primaryStage.setWidth(250);
primaryStage.setHeight(250);
TableView<?> tableViewNode = (TableView<?>) primaryStage.getScene().getRoot().lookup(".table-view");
Platform.runLater(() -> {
tableView.marathon_select("{\"rows\":[10]}");
});
new Wait("Wating for rows to be select.") {
@Override public boolean until() {
return tableViewNode.getSelectionModel().getSelectedIndex() == 10;
}
};
new Wait("Waiting for the point to be in viewport") {
@Override public boolean until() {
Point2D point = getPoint(tableViewNode, 1, 10);
return tableViewNode.getBoundsInLocal().contains(point);
}
};
}
示例3: select
import javafx.geometry.Point2D; //导入依赖的package包/类
@Test public void select() {
TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(() -> {
Point2D point = getPoint(tableView, 1, 1);
TableCellFactorySample.EditingCell tf = (EditingCell) getCellAt(tableView, 1, 1);
RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
rfxTableView.focusGained(null);
tf.startEdit();
tf.updateItem("Cell Modified", false);
rfxTableView.focusLost(null);
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("Cell Modified", recording.getParameters()[0]);
}
示例4: selectACell
import javafx.geometry.Point2D; //导入依赖的package包/类
@SuppressWarnings("unchecked") @Test public void selectACell() {
TreeTableView<?> treeTableView = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(() -> {
TreeTableViewSelectionModel<?> selectionModel = treeTableView.getSelectionModel();
selectionModel.setCellSelectionEnabled(true);
Point2D point = getPoint(treeTableView, 1, 0);
RFXTreeTableView rfxTreeTableView = new RFXTreeTableView(treeTableView, null, point, lr);
rfxTreeTableView.focusGained(null);
@SuppressWarnings("rawtypes")
TreeTableColumn column = getTreeTableColumnAt(treeTableView, 0);
selectionModel.select(1, column);
rfxTreeTableView.focusLost(null);
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("{\"cells\":[[\"/Sales Department/Ethan Williams\",\"Employee\"]]}", recording.getParameters()[0]);
}
示例5: click
import javafx.geometry.Point2D; //导入依赖的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]);
}
示例6: select
import javafx.geometry.Point2D; //导入依赖的package包/类
@Test public void select() {
TreeView<?> treeView = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(new Runnable() {
@Override public void run() {
Point2D point = getPoint(treeView, 1);
RFXTreeView rfxListView = new RFXTreeView(treeView, null, point, lr);
rfxListView.focusGained(rfxListView);
CheckBoxTreeItem<?> treeItem = (CheckBoxTreeItem<?>) treeView.getTreeItem(1);
treeItem.setSelected(true);
rfxListView.focusLost(rfxListView);
}
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("Child Node 1:checked", recording.getParameters()[0]);
}
示例7: selectEditable
import javafx.geometry.Point2D; //导入依赖的package包/类
@Test public void selectEditable() {
@SuppressWarnings("unchecked")
TreeView<String> treeView = (TreeView<String>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(() -> {
@SuppressWarnings("unchecked")
ComboBoxTreeCell<String> cell = (ComboBoxTreeCell<String>) getCellAt(treeView, 1);
cell.setComboBoxEditable(true);
Point2D point = getPoint(treeView, 1);
RFXTreeView rfxtreeView = new RFXTreeView(treeView, null, point, lr);
rfxtreeView.focusGained(rfxtreeView);
cell.startEdit();
cell.updateItem("Option 5", false);
cell.commitEdit("Option 5");
rfxtreeView.focusLost(rfxtreeView);
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("Option 5", recording.getParameters()[0]);
}
示例8: selectSelectedTreeItemCheckBox
import javafx.geometry.Point2D; //导入依赖的package包/类
@Test public void selectSelectedTreeItemCheckBox() {
TreeView<?> treeView = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(new Runnable() {
@Override public void run() {
Point2D point = getPoint(treeView, 1);
RFXTreeView rfxListView = new RFXTreeView(treeView, null, point, lr);
CheckBoxTreeItem<?> treeItem = (CheckBoxTreeItem<?>) treeView.getTreeItem(1);
treeItem.setSelected(true);
rfxListView.focusGained(rfxListView);
treeItem.setSelected(false);
rfxListView.focusLost(rfxListView);
}
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("Child Node 1:unchecked", recording.getParameters()[0]);
}
示例9: selectListItemCheckBox
import javafx.geometry.Point2D; //导入依赖的package包/类
@Test public void selectListItemCheckBox() {
ListView<?> listView = (ListView<?>) getPrimaryStage().getScene().getRoot().lookup(".list-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(new Runnable() {
@Override public void run() {
Point2D point = getPoint(listView, 5);
RFXListView rfxListView = new RFXListView(listView, null, point, lr);
rfxListView.focusGained(rfxListView);
Item x = (Item) listView.getItems().get(5);
x.setOn(true);
rfxListView.focusLost(rfxListView);
}
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("Item 6:checked", recording.getParameters()[0]);
}
示例10: getIndexAt
import javafx.geometry.Point2D; //导入依赖的package包/类
protected int getIndexAt(ListView<?> listView, Point2D point) {
if (point == null) {
return listView.getSelectionModel().getSelectedIndex();
}
point = listView.localToScene(point);
Set<Node> lookupAll = getListCells(listView);
ListCell<?> selected = null;
for (Node cellNode : lookupAll) {
Bounds boundsInScene = cellNode.localToScene(cellNode.getBoundsInLocal(), true);
if (boundsInScene.contains(point)) {
selected = (ListCell<?>) cellNode;
break;
}
}
if (selected == null) {
return -1;
}
return selected.getIndex();
}
示例11: getMask
import javafx.geometry.Point2D; //导入依赖的package包/类
@Override
public Set<Point2D> getMask(Image image, Color color) {
PixelReader pixelReader = image.getPixelReader();
Set<Point2D> mask = new HashSet<>();
int pixel;
boolean isTransparent, isBackgroundColor;
for(int i =0; i < image.getWidth(); i++){
for(int j = 0; j < image.getHeight(); j++){
pixel = pixelReader.getArgb(i, j);
//check the transparency of the pixel at (i,j)
isTransparent = (pixel >> 24) == 0x00;
Color backgroundColor = pixelReader.getColor(i, j);
isBackgroundColor = (color.equals(backgroundColor));
if(!isTransparent && !isBackgroundColor){
Point2D p = new Point2D(i,j);
mask.add(p);
}
}
}
return mask;
}
示例12: buttonup
import javafx.geometry.Point2D; //导入依赖的package包/类
public void buttonup(JSONObject query, JSONObject uriParams, Session session) {
int button = 0;
if (query.has("button")) {
button = query.getInt("button");
}
IJavaFXElement element = null;
double xoffset;
double yoffset;
if (lastComponenet.element != null) {
element = lastComponenet.element;
xoffset = lastComponenet.x;
yoffset = lastComponenet.y;
} else {
element = session.getActiveElement();
Point2D p = element.getMidpoint();
xoffset = p.getX();
yoffset = p.getY();
}
element.buttonUp(button, xoffset, yoffset);
}
示例13: loadPositionFromStorage
import javafx.geometry.Point2D; //导入依赖的package包/类
protected void loadPositionFromStorage() {
try {
final String key = getCurrentPositionStorageKey();
if (key != null) {
final String value = Main.getProperties().getString(key);
if (value != null) {
String[] coords = value.split(";");
if (coords.length == 2) {
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
Rectangle2D desktop = OverlayStage.getDesktopSize();
if(desktop.getWidth() == 0 || desktop.getHeight() == 0) return;
if (x + getHeight() > desktop.getMaxX() || x < -getHeight())
x = desktop.getMaxX() - getHeight();
if (y + getWidth() > desktop.getMaxY() || y < -getWidth()) y = desktop.getMaxY() - getWidth();
setPosition(new Point2D(x, y));
return;
}
}
}
} catch (Exception e){ Main.log(e); }
setDefaultPosition();
}
示例14: testGraph
import javafx.geometry.Point2D; //导入依赖的package包/类
@Test
public void testGraph() {
Graph graph = new Graph();
PackageNode packageNode = new PackageNode(0, 0 ,150, 150);
ClassNode c1 = new ClassNode(0, 0, 25, 25);
ClassNode c2 = new ClassNode(50, 50, 25, 25);
EnumerationNode e1 = new EnumerationNode(100, 100, 25, 25);
packageNode.addChild(c1);
packageNode.addChild(c2);
packageNode.addChild(e1);
Point2D p1 = new Point2D(12, 12);
Point2D p2 = new Point2D(70, 70);
Point2D p3 = new Point2D(112, 112);
Point2D p4 = new Point2D(140, 140);
graph.addNode(packageNode, false);
graph.addNode(c1, false);
graph.addNode(c2, false);
graph.addNode(e1, false);
assertEquals(graph.findNode(p1), c1);
assertEquals(graph.findNode(p2), c2);
assertEquals(graph.findNode(p3), e1);
assertEquals(graph.findNode(p4), packageNode);
}
示例15: select
import javafx.geometry.Point2D; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void select() {
TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(() -> {
Point2D point = getPoint(tableView, 2, 1);
ChoiceBoxTableCell cell = (ChoiceBoxTableCell) getCellAt(tableView, 1, 2);
RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
rfxTableView.focusGained(null);
cell.startEdit();
tableView.edit(1, (TableColumn) tableView.getColumns().get(2));
Person person = (Person) tableView.getItems().get(1);
person.setLastName("Jones");
cell.commitEdit("Jones");
rfxTableView.focusLost(null);
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("Jones", recording.getParameters()[0]);
}