public void moveCircle(Circle circle, Scene scene) { Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { Platform.runLater(() -> { circle.setCenterX(random((int) scene.getX())); circle.setCenterY(random((int) scene.getY())); }); } }, 1000, 1000); }
private void updateY() { Window stage = getOwner(); setY(stage.getY() + stage.getScene().getY()); }
public void moveCircle(Circle circle, Scene scene) { Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), ev -> { circle.setCenterX(random((int) scene.getX())); circle.setCenterY(random((int) scene.getY())); })); timeline.setCycleCount(Animation.INDEFINITE); timeline.play(); }
public void show(Node node){ if(!isShowing()){ if(node.getScene() == null || node.getScene().getWindow() == null) throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window."); Window parent = node.getScene().getWindow(); this.show(parent, parent.getX() + node.localToScene(0, 0).getX() + node.getScene().getX(), parent.getY() + node.localToScene(0, 0).getY() + node.getScene().getY() + ((Region)node).getHeight()); ((JFXAutoCompletePopupSkin<T>)getSkin()).animate(); } }
/** * show the popup according to the specified position with a certain offset * * @param vAlign can be TOP/BOTTOM * @param hAlign can be LEFT/RIGHT * @param initOffsetX on the x axis * @param initOffsetY on the y axis */ public void show(Node node, PopupVPosition vAlign, PopupHPosition hAlign, double initOffsetX, double initOffsetY) { if (!isShowing()) { if (node.getScene() == null || node.getScene().getWindow() == null) { throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window."); } Window parent = node.getScene().getWindow(); final Point2D origin = node.localToScene(0, 0); final double anchorX = parent.getX() + origin.getX() + node.getScene().getX() + (hAlign == PopupHPosition.RIGHT ? ((Region) node).getWidth() : 0); final double anchorY = parent.getY() + origin.getY() + node.getScene() .getY() + (vAlign == PopupVPosition.BOTTOM ? ((Region) node).getHeight() : 0); this.show(parent, anchorX, anchorY); ((JFXPopupSkin) getSkin()).reset(vAlign, hAlign, initOffsetX, initOffsetY); Platform.runLater(() -> ((JFXPopupSkin) getSkin()).animate()); } }
public void show(Node node) { if (text == null) { text = (Text) node.lookup(".text"); } node = text; if (!isShowing()) { if (node.getScene() == null || node.getScene().getWindow() == null) { throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window."); } Window parent = node.getScene().getWindow(); this.show(parent, parent.getX() + node.localToScene(0, 0).getX() + node.getScene().getX(), parent.getY() + node.localToScene(0, 0).getY() + node.getScene().getY() + node.getLayoutBounds().getHeight() + shift); ((JFXAutoCompletePopupSkin<T>) getSkin()).animate(); } else { // if already showing update location if needed Window parent = node.getScene().getWindow(); this.show(parent, parent.getX() + node.localToScene(0, 0).getX() + node.getScene().getX(), parent.getY() + node.localToScene(0, 0).getY() + node.getScene().getY() + node.getLayoutBounds().getHeight() + shift); } } }
private Point2D getDisplayCoordiantes(Window owner, Scene scene) { Point2D nodeCoord = ValidableTextField.this.localToScene(0.0, ValidableTextField.this.getHeight()); double anchorX = Math.round(owner.getX() + scene.getX() + nodeCoord.getX() + 2); double anchorY = Math.round(owner.getY() + scene.getY() + nodeCoord.getY() - 2); return new Point2D(anchorX, anchorY); } }
private void showPasswordFieldPopup() { Scene scene = this.getScene(); if (scene != null) { Window owner = scene.getWindow(); if (owner != null && owner.isShowing()) { Point2D nodeCoord = encryptionIndicator.localToScene(encryptionIndicator.getWidth() / 2, encryptionIndicator.getHeight() / 1.5); double anchorX = Math.round(owner.getX() + scene.getX() + nodeCoord.getX() + 2); double anchorY = Math.round(owner.getY() + scene.getY() + nodeCoord.getY() + 2); passwordPopup.showFor(this, descriptor, anchorX, anchorY); } } }
@EventListener public void showPasswordFieldPopup(ShowPasswordFieldPopupRequest request) { Scene scene = this.getScene(); if (scene != null) { Window owner = scene.getWindow(); if (owner != null && owner.isShowing()) { Point2D nodeCoord = request.getRequestingNode().localToScene(request.getRequestingNode().getWidth() / 2, request.getRequestingNode().getHeight() / 1.5); double anchorX = Math.round(owner.getX() + scene.getX() + nodeCoord.getX() + 2); double anchorY = Math.round(owner.getY() + scene.getY() + nodeCoord.getY() + 2); passwordPopup.showFor(this, request.getPdfDescriptor(), anchorX, anchorY); } } }
import org.controlsfx.control.PopOver; import org.controlsfx.control.PopOver.ArrowLocation; private PopOver item; final Scene scene = addItemButton.getScene(); final Point2D windowCoord = new Point2D(scene.getWindow() .getX(), scene.getWindow().getY()); final Point2D sceneCoord = new Point2D(scene.getX(), scene. getY()); final Point2D nodeCoord = addItemButton.localToScene(0.0, 0.0); final double clickX = Math.round(windowCoord.getX() + sceneCoord.getY() + nodeCoord.getX()); final double clickY = Math.round(windowCoord.getY() + sceneCoord.getY() + nodeCoord.getY()); item.setContentNode(addItemScreen); item.setArrowLocation(ArrowLocation.BOTTOM_LEFT); item.setCornerRadius(4); item.setDetachedTitle("Add New Item"); item.show(addItemButton.getParent(), clickX, clickY);
private void updateY() { Window stage = getOwner(); setY(stage.getY() + stage.getScene().getY()); }
/** * * @param node * @return The Y scene coordinate of the node. */ static public double sceneY(Node node) { return node.localToScene(node.getBoundsInLocal()).getMinY() + node.getScene().getY(); }
/** * * @param node * @return The Y screen coordinate of the node. */ static public double screenY(Node node) { return node.localToScene(node.getBoundsInLocal()).getMinY() + node.getScene().getY() + node.getScene().getWindow().getY(); }
/** * * @param node * @return The Y screen coordinate of the node. */ static public double screenY(Node node) { return node.localToScene(node.getBoundsInLocal()).getMinY() + node.getScene().getY() + node.getScene().getWindow().getY(); }
@Override public Point2D getScenePosition() { Scene scene; if(source instanceof Node) { scene = ((Node) source).getScene(); } else if(source instanceof Scene) { scene = (Scene) source; } else { return null; } return screenPos.subtract( scene.getX() + scene.getWindow().getX(), scene.getY() + scene.getWindow().getY()); }
@Override public Point2D getScenePosition() { Scene scene; if(source instanceof Node) { scene = ((Node) source).getScene(); } else if(source instanceof Scene) { scene = (Scene) source; } else { return null; } return screenPos.subtract( scene.getX() + scene.getWindow().getX(), scene.getY() + scene.getWindow().getY()); }
private static Bounds sceneBoundsToScreenBounds( Bounds sceneBounds, Scene scene ) { Window window = targetWindow( scene.getWindow() ); BoundingBox b = new BoundingBox( window.getX() + scene.getX() + sceneBounds.getMinX(), window.getY() + scene.getY() + sceneBounds.getMinY(), sceneBounds.getWidth(), sceneBounds.getHeight() ); return b; }
public void show(Node node){ if(!isShowing()){ if(node.getScene() == null || node.getScene().getWindow() == null) throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window."); Window parent = node.getScene().getWindow(); this.show(parent, parent.getX() + node.localToScene(0, 0).getX() + node.getScene().getX(), parent.getY() + node.localToScene(0, 0).getY() + node.getScene().getY() + ((Region)node).getHeight()); ((JFXAutoCompletePopupSkin<T>)getSkin()).animate(); } }
/** * Show this popup right below the given Node * * @param node */ public void show(Node node) { if (node.getScene() == null || node.getScene().getWindow() == null) { throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window."); } // $NON-NLS-1$ if (isShowing()) { return; } final Window parent = node.getScene().getWindow(); this.show(parent, parent.getX() + node.localToScene(0, 0).getX() + node.getScene().getX(), parent.getY() + node.localToScene(0, 0).getY() + node.getScene().getY() + control.getHeight()); }
/** * Show this popup right below the given Node * @param node */ public void show(Node node){ if(node.getScene() == null || node.getScene().getWindow() == null) throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window."); //$NON-NLS-1$ if(isShowing()){ return; } Window parent = node.getScene().getWindow(); this.show( parent, parent.getX() + node.localToScene(0, 0).getX() + node.getScene().getX(), parent.getY() + node.localToScene(0, 0).getY() + node.getScene().getY() + TITLE_HEIGHT); }