@Override public void initAnimation(Node contentContainer, Node overlay) { overlay.setOpacity(0); contentContainer.setTranslateX(-(contentContainer.getLayoutX() + contentContainer.getLayoutBounds().getMaxX())); }
@Override public void initAnimation(Node contentContainer, Node overlay) { overlay.setOpacity(0); contentContainer.setTranslateX(contentContainer.getLayoutX() + contentContainer.getLayoutBounds().getMaxX()); }
public void reset(PopupVPosition vAlign, PopupHPosition hAlign, double offsetX, double offsetY) { // postion the popup according to its animation scale.setPivotX(hAlign == PopupHPosition.RIGHT ? container.getWidth() : 0); scale.setPivotY(vAlign == PopupVPosition.BOTTOM ? container.getHeight() : 0); root.setTranslateX(hAlign == PopupHPosition.RIGHT ? -container.getWidth() + offsetX : offsetX); root.setTranslateY(vAlign == PopupVPosition.BOTTOM ? -container.getHeight() + offsetY : offsetY); }
@Override public void changed(ObservableValue<? extends Number> ov, Number oldValue, Number newValue) { final double delta = newValue.doubleValue() - oldValue.doubleValue(); final DoubleProperty doubleProperty = (DoubleProperty) ov; final Node node = (Node) doubleProperty.getBean(); TranslateTransition t; switch (doubleProperty.getName()) { case "layoutX": t = nodeXTransitions.get(node); if (t == null) { t = new TranslateTransition(Duration.millis(150), node); t.setToX(0); nodeXTransitions.put(node, t); } t.setFromX(node.getTranslateX() - delta); node.setTranslateX(node.getTranslateX() - delta); break; default: // "layoutY" t = nodeYTransitions.get(node); if (t == null) { t = new TranslateTransition(Duration.millis(150), node); t.setToY(0); nodeYTransitions.put(node, t); } t.setFromY(node.getTranslateY() - delta); node.setTranslateY(node.getTranslateY() - delta); } t.playFromStart(); }
alignedWidth = alignedWidth/2 + alignedX - childWidth / 2; child.setTranslateX(-alignedWidth * Math.cos(Math.toRadians(rotate))); child.setTranslateY(alignedWidth * Math.cos(Math.toRadians(90 - rotate)));
@Override public void initAnimation(Node contentContainer, Node overlay) { overlay.setOpacity(0); contentContainer.setTranslateX(contentContainer.getLayoutX() + contentContainer.getLayoutBounds().getMaxX()); }
@Override public void initAnimation(Node contentContainer, Node overlay) { overlay.setOpacity(0); contentContainer.setTranslateX(-(contentContainer.getLayoutX() + contentContainer.getLayoutBounds().getMaxX())); }
node.setTranslateX(x); node.setTranslateY(y);
EventHandler<MouseEvent> onMouseReleasedEventHandler = new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { fixPosition((Node) t.getSource()); } }; resource.setOnMouseReleased(onMouseReleasedEventHandler); private void fixPosition( Node node) { double x = node.getTranslateX(); double y = node.getTranslateY(); node.relocate(node.getLayoutX() + x, node.getLayoutY() + y); node.setTranslateX(0); node.setTranslateY(0); }
@Override public void handle( MouseEvent aEvent ) { Node theSprite = (Node) (aEvent.getSource()); double theSceneOffsetX = aEvent.getSceneX() - _sceneX; double theSceneOffsetY = aEvent.getSceneY() - _sceneY; double theTranslateX = _posX + theSceneOffsetX; double theTranslateY = _posY + theSceneOffsetY; switch ( _moveMode ) { case SMOOTH: theTranslateX = toBoundsX( theTranslateX, theSprite ); theTranslateY = toBoundsY( theTranslateY, theSprite ); break; case JUMPY: theTranslateX = toSnapX( theTranslateX, theSprite ); theTranslateY = toSnapY( theTranslateY, theSprite ); break; } theSprite.setTranslateX( theTranslateX ); theSprite.setTranslateY( theTranslateY ); _offsetX = (int) Math.round( theTranslateX / (getFieldWidth() + getFieldGap()) ); _offsetY = (int) Math.round( theTranslateY / (getFieldHeight() + getFieldGap()) ); aEvent.consume(); } };
public void reset(PopupVPosition vAlign, PopupHPosition hAlign, double offsetX, double offsetY) { // postion the popup according to its animation scale.setPivotX(hAlign == PopupHPosition.RIGHT ? container.getWidth() : 0); scale.setPivotY(vAlign == PopupVPosition.BOTTOM ? container.getHeight() : 0); root.setTranslateX(hAlign == PopupHPosition.RIGHT ? -container.getWidth() + offsetX : offsetX); root.setTranslateY(vAlign == PopupVPosition.BOTTOM ? -container.getHeight() + offsetY : offsetY); }
public static void translateNode(Node nodeToTranslate, Tuple3DBasics translation) { nodeToTranslate.setTranslateX(nodeToTranslate.getTranslateX() + translation.getX()); nodeToTranslate.setTranslateY(nodeToTranslate.getTranslateY() + translation.getY()); nodeToTranslate.setTranslateZ(nodeToTranslate.getTranslateZ() + translation.getZ()); }
private void updateSize() { @Nullable Node content = this.contentProperty.get(); if (content != null) { double width = content.getLayoutBounds().getWidth(); double height = content.getLayoutBounds().getHeight(); double depth = content.getLayoutBounds().getDepth(); content.setTranslateX(+7.8 - width / 2); content.setTranslateY(height / 2); content.setTranslateZ(+7.8 - depth / 2); this.cameraPosition.setX(getWidth() / -2); this.cameraPosition.setY(getHeight() / -2); } }
private void updateSize() { @Nullable Node content = this.contentProperty.get(); if (content != null) { double width = content.getLayoutBounds().getWidth(); double height = content.getLayoutBounds().getHeight(); double depth = content.getLayoutBounds().getDepth(); content.setTranslateX(+7.8 - width / 2); content.setTranslateY(height / 2); content.setTranslateZ(+7.8 - depth / 2); this.cameraPosition.setX(getWidth() / -2); this.cameraPosition.setY(getHeight() / -2); } }
theSprite.setLayoutX( -(thePoint.getX()) ); theSprite.setLayoutY( -(thePoint.getY()) ); theSprite.setTranslateX( toPixelPositionX( aPlayer ) ); theSprite.setTranslateY( toPixelPositionY( aPlayer ) ); _checkers.getChildren().add( theSprite );
@Override public void run() { if ( _checkers.getChildren().remove( theSprite ) ) { _checkers.getChildren().add( theSprite ); if ( getMoveMode() == MoveMode.SMOOTH ) { TranslateTransition theTransition = new TranslateTransition( Duration.millis( aDurationInMillis ), theSprite ); theTransition.setByX( toPixelPositionX( aPlayer ) - theSprite.getTranslateX() ); theTransition.setByY( toPixelPositionY( aPlayer ) - theSprite.getTranslateY() ); theTransition.setCycleCount( 1 ); theTransition.setAutoReverse( false ); theTransition.play(); } else { theSprite.setTranslateX( toPixelPositionX( aPlayer ) ); theSprite.setTranslateY( toPixelPositionY( aPlayer ) ); } } } };
protected Node createMenuBodyGameMenu() { double midY = app.getHeight() / 2; double distance = midY - 50; Button btnContinue = createActionButton("RESUME", this::fireResume); Button btn1 = createActionButton("SAVE", this::fireSave); Button btn2 = createContentButton("LOAD", this::createContentLoad); Button btn3 = createContentButton("OPTIONS", () -> new MenuContent(makeOptionsMenu())); Button btn4 = createContentButton("EXTRA", () -> new MenuContent(makeExtraMenu())); Button btn5 = createActionButton("MAIN MENU", this::fireExitToMainMenu); Group group = new Group(btnContinue, btn1, btn2, btn3, btn4, btn5); double dtheta = Math.PI / (group.getChildren().size() - 1); double angle = Math.PI / 2; int i = 0; for (Node n : group.getChildren()) { Point2D vector = new Point2D(Math.cos(angle), -Math.sin(angle)) .normalize() .multiply(distance) .add(0, midY); n.setTranslateX(vector.getX() - (i == 0 || i == 5 ? 0 : 100)); n.setTranslateY(vector.getY()); angle -= dtheta; i++; } return group; }
/** * Fx scale player. * * @param aPlayer the player * @param aFieldDimension the field dimension * @param aPrecedingFieldDimension the preceding field dimension */ private void fxScalePlayer( P aPlayer, FieldDimension aFieldDimension, FieldDimension aPrecedingFieldDimension ) { Node theSprite; synchronized ( _playerToSprite ) { theSprite = _playerToSprite.get( aPlayer ); } theSprite.setScaleX( aFieldDimension.getFieldWidth() / theSprite.getBoundsInLocal().getWidth() ); theSprite.setScaleY( aFieldDimension.getFieldHeight() / theSprite.getBoundsInLocal().getHeight() ); double theLayoutX = (aFieldDimension.getFieldWidth() - theSprite.getBoundsInLocal().getWidth()) / 2; double theLayoutY = (aFieldDimension.getFieldHeight() - theSprite.getBoundsInLocal().getHeight()) / 2; theSprite.setLayoutX( theLayoutX ); theSprite.setLayoutY( theLayoutY ); theSprite.setTranslateX( toPixelPositionX( aPlayer ) ); theSprite.setTranslateY( toPixelPositionY( aPlayer ) ); }
theSprite.setTranslateX( theToX ); theSprite.setTranslateY( theToY ); break;
.add(0, midY); n.setTranslateX(vector.getX() - (i == 0 || i == 7 ? 0 : 100)); n.setTranslateY(vector.getY());