javafx.scene.Node.setTranslateX()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(219)

本文整理了Java中javafx.scene.Node.setTranslateX()方法的一些代码示例,展示了Node.setTranslateX()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.setTranslateX()方法的具体详情如下:
包路径:javafx.scene.Node
类名称:Node
方法名:setTranslateX

Node.setTranslateX介绍

暂无

代码示例

代码示例来源:origin: jfoenixadmin/JFoenix

  1. @Override
  2. public void initAnimation(Node contentContainer, Node overlay) {
  3. overlay.setOpacity(0);
  4. contentContainer.setTranslateX(-(contentContainer.getLayoutX()
  5. + contentContainer.getLayoutBounds().getMaxX()));
  6. }

代码示例来源:origin: jfoenixadmin/JFoenix

  1. @Override
  2. public void initAnimation(Node contentContainer, Node overlay) {
  3. overlay.setOpacity(0);
  4. contentContainer.setTranslateX(contentContainer.getLayoutX()
  5. + contentContainer.getLayoutBounds().getMaxX());
  6. }

代码示例来源:origin: jfoenixadmin/JFoenix

  1. public void reset(PopupVPosition vAlign, PopupHPosition hAlign, double offsetX, double offsetY) {
  2. // postion the popup according to its animation
  3. scale.setPivotX(hAlign == PopupHPosition.RIGHT ? container.getWidth() : 0);
  4. scale.setPivotY(vAlign == PopupVPosition.BOTTOM ? container.getHeight() : 0);
  5. root.setTranslateX(hAlign == PopupHPosition.RIGHT ? -container.getWidth() + offsetX : offsetX);
  6. root.setTranslateY(vAlign == PopupVPosition.BOTTOM ? -container.getHeight() + offsetY : offsetY);
  7. }

代码示例来源:origin: speedment/speedment

  1. @Override
  2. public void changed(ObservableValue<? extends Number> ov, Number oldValue, Number newValue) {
  3. final double delta = newValue.doubleValue() - oldValue.doubleValue();
  4. final DoubleProperty doubleProperty = (DoubleProperty) ov;
  5. final Node node = (Node) doubleProperty.getBean();
  6. TranslateTransition t;
  7. switch (doubleProperty.getName()) {
  8. case "layoutX":
  9. t = nodeXTransitions.get(node);
  10. if (t == null) {
  11. t = new TranslateTransition(Duration.millis(150), node);
  12. t.setToX(0);
  13. nodeXTransitions.put(node, t);
  14. }
  15. t.setFromX(node.getTranslateX() - delta);
  16. node.setTranslateX(node.getTranslateX() - delta);
  17. break;
  18. default: // "layoutY"
  19. t = nodeYTransitions.get(node);
  20. if (t == null) {
  21. t = new TranslateTransition(Duration.millis(150), node);
  22. t.setToY(0);
  23. nodeYTransitions.put(node, t);
  24. }
  25. t.setFromY(node.getTranslateY() - delta);
  26. node.setTranslateY(node.getTranslateY() - delta);
  27. }
  28. t.playFromStart();
  29. }

代码示例来源:origin: jfoenixadmin/JFoenix

  1. alignedWidth = alignedWidth/2 + alignedX - childWidth / 2;
  2. child.setTranslateX(-alignedWidth * Math.cos(Math.toRadians(rotate)));
  3. child.setTranslateY(alignedWidth * Math.cos(Math.toRadians(90 - rotate)));

代码示例来源:origin: com.jfoenix/jfoenix

  1. @Override
  2. public void initAnimation(Node contentContainer, Node overlay) {
  3. overlay.setOpacity(0);
  4. contentContainer.setTranslateX(contentContainer.getLayoutX()
  5. + contentContainer.getLayoutBounds().getMaxX());
  6. }

代码示例来源:origin: com.jfoenix/jfoenix

  1. @Override
  2. public void initAnimation(Node contentContainer, Node overlay) {
  3. overlay.setOpacity(0);
  4. contentContainer.setTranslateX(-(contentContainer.getLayoutX()
  5. + contentContainer.getLayoutBounds().getMaxX()));
  6. }

代码示例来源:origin: stackoverflow.com

  1. node.setTranslateX(x); node.setTranslateY(y);

代码示例来源:origin: stackoverflow.com

  1. EventHandler<MouseEvent> onMouseReleasedEventHandler = new EventHandler<MouseEvent>() {
  2. @Override
  3. public void handle(MouseEvent t) {
  4. fixPosition((Node) t.getSource());
  5. }
  6. };
  7. resource.setOnMouseReleased(onMouseReleasedEventHandler);
  8. private void fixPosition( Node node) {
  9. double x = node.getTranslateX();
  10. double y = node.getTranslateY();
  11. node.relocate(node.getLayoutX() + x, node.getLayoutY() + y);
  12. node.setTranslateX(0);
  13. node.setTranslateY(0);
  14. }

代码示例来源:origin: org.refcodes/refcodes-graphical-ext-javafx

  1. @Override
  2. public void handle( MouseEvent aEvent ) {
  3. Node theSprite = (Node) (aEvent.getSource());
  4. double theSceneOffsetX = aEvent.getSceneX() - _sceneX;
  5. double theSceneOffsetY = aEvent.getSceneY() - _sceneY;
  6. double theTranslateX = _posX + theSceneOffsetX;
  7. double theTranslateY = _posY + theSceneOffsetY;
  8. switch ( _moveMode ) {
  9. case SMOOTH:
  10. theTranslateX = toBoundsX( theTranslateX, theSprite );
  11. theTranslateY = toBoundsY( theTranslateY, theSprite );
  12. break;
  13. case JUMPY:
  14. theTranslateX = toSnapX( theTranslateX, theSprite );
  15. theTranslateY = toSnapY( theTranslateY, theSprite );
  16. break;
  17. }
  18. theSprite.setTranslateX( theTranslateX );
  19. theSprite.setTranslateY( theTranslateY );
  20. _offsetX = (int) Math.round( theTranslateX / (getFieldWidth() + getFieldGap()) );
  21. _offsetY = (int) Math.round( theTranslateY / (getFieldHeight() + getFieldGap()) );
  22. aEvent.consume();
  23. }
  24. };

代码示例来源:origin: com.jfoenix/jfoenix

  1. public void reset(PopupVPosition vAlign, PopupHPosition hAlign, double offsetX, double offsetY) {
  2. // postion the popup according to its animation
  3. scale.setPivotX(hAlign == PopupHPosition.RIGHT ? container.getWidth() : 0);
  4. scale.setPivotY(vAlign == PopupVPosition.BOTTOM ? container.getHeight() : 0);
  5. root.setTranslateX(hAlign == PopupHPosition.RIGHT ? -container.getWidth() + offsetX : offsetX);
  6. root.setTranslateY(vAlign == PopupVPosition.BOTTOM ? -container.getHeight() + offsetY : offsetY);
  7. }

代码示例来源:origin: us.ihmc/robot-environment-awareness-visualizers

  1. public static void translateNode(Node nodeToTranslate, Tuple3DBasics translation)
  2. {
  3. nodeToTranslate.setTranslateX(nodeToTranslate.getTranslateX() + translation.getX());
  4. nodeToTranslate.setTranslateY(nodeToTranslate.getTranslateY() + translation.getY());
  5. nodeToTranslate.setTranslateZ(nodeToTranslate.getTranslateZ() + translation.getZ());
  6. }

代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.ui.controls

  1. private void updateSize() {
  2. @Nullable
  3. Node content = this.contentProperty.get();
  4. if (content != null) {
  5. double width = content.getLayoutBounds().getWidth();
  6. double height = content.getLayoutBounds().getHeight();
  7. double depth = content.getLayoutBounds().getDepth();
  8. content.setTranslateX(+7.8 - width / 2);
  9. content.setTranslateY(height / 2);
  10. content.setTranslateZ(+7.8 - depth / 2);
  11. this.cameraPosition.setX(getWidth() / -2);
  12. this.cameraPosition.setY(getHeight() / -2);
  13. }
  14. }

代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.controls

  1. private void updateSize() {
  2. @Nullable
  3. Node content = this.contentProperty.get();
  4. if (content != null) {
  5. double width = content.getLayoutBounds().getWidth();
  6. double height = content.getLayoutBounds().getHeight();
  7. double depth = content.getLayoutBounds().getDepth();
  8. content.setTranslateX(+7.8 - width / 2);
  9. content.setTranslateY(height / 2);
  10. content.setTranslateZ(+7.8 - depth / 2);
  11. this.cameraPosition.setX(getWidth() / -2);
  12. this.cameraPosition.setY(getHeight() / -2);
  13. }
  14. }

代码示例来源:origin: org.refcodes/refcodes-checkerboard-alt-javafx

  1. theSprite.setLayoutX( -(thePoint.getX()) );
  2. theSprite.setLayoutY( -(thePoint.getY()) );
  3. theSprite.setTranslateX( toPixelPositionX( aPlayer ) );
  4. theSprite.setTranslateY( toPixelPositionY( aPlayer ) );
  5. _checkers.getChildren().add( theSprite );

代码示例来源:origin: org.refcodes/refcodes-checkerboard-alt-javafx

  1. @Override
  2. public void run() {
  3. if ( _checkers.getChildren().remove( theSprite ) ) {
  4. _checkers.getChildren().add( theSprite );
  5. if ( getMoveMode() == MoveMode.SMOOTH ) {
  6. TranslateTransition theTransition = new TranslateTransition( Duration.millis( aDurationInMillis ), theSprite );
  7. theTransition.setByX( toPixelPositionX( aPlayer ) - theSprite.getTranslateX() );
  8. theTransition.setByY( toPixelPositionY( aPlayer ) - theSprite.getTranslateY() );
  9. theTransition.setCycleCount( 1 );
  10. theTransition.setAutoReverse( false );
  11. theTransition.play();
  12. }
  13. else {
  14. theSprite.setTranslateX( toPixelPositionX( aPlayer ) );
  15. theSprite.setTranslateY( toPixelPositionY( aPlayer ) );
  16. }
  17. }
  18. }
  19. };

代码示例来源:origin: com.github.almasb/fxgl-extra

  1. protected Node createMenuBodyGameMenu() {
  2. double midY = app.getHeight() / 2;
  3. double distance = midY - 50;
  4. Button btnContinue = createActionButton("RESUME", this::fireResume);
  5. Button btn1 = createActionButton("SAVE", this::fireSave);
  6. Button btn2 = createContentButton("LOAD", this::createContentLoad);
  7. Button btn3 = createContentButton("OPTIONS", () -> new MenuContent(makeOptionsMenu()));
  8. Button btn4 = createContentButton("EXTRA", () -> new MenuContent(makeExtraMenu()));
  9. Button btn5 = createActionButton("MAIN MENU", this::fireExitToMainMenu);
  10. Group group = new Group(btnContinue, btn1, btn2, btn3, btn4, btn5);
  11. double dtheta = Math.PI / (group.getChildren().size() - 1);
  12. double angle = Math.PI / 2;
  13. int i = 0;
  14. for (Node n : group.getChildren()) {
  15. Point2D vector = new Point2D(Math.cos(angle), -Math.sin(angle))
  16. .normalize()
  17. .multiply(distance)
  18. .add(0, midY);
  19. n.setTranslateX(vector.getX() - (i == 0 || i == 5 ? 0 : 100));
  20. n.setTranslateY(vector.getY());
  21. angle -= dtheta;
  22. i++;
  23. }
  24. return group;
  25. }

代码示例来源:origin: org.refcodes/refcodes-checkerboard-alt-javafx

  1. /**
  2. * Fx scale player.
  3. *
  4. * @param aPlayer the player
  5. * @param aFieldDimension the field dimension
  6. * @param aPrecedingFieldDimension the preceding field dimension
  7. */
  8. private void fxScalePlayer( P aPlayer, FieldDimension aFieldDimension, FieldDimension aPrecedingFieldDimension ) {
  9. Node theSprite;
  10. synchronized ( _playerToSprite ) {
  11. theSprite = _playerToSprite.get( aPlayer );
  12. }
  13. theSprite.setScaleX( aFieldDimension.getFieldWidth() / theSprite.getBoundsInLocal().getWidth() );
  14. theSprite.setScaleY( aFieldDimension.getFieldHeight() / theSprite.getBoundsInLocal().getHeight() );
  15. double theLayoutX = (aFieldDimension.getFieldWidth() - theSprite.getBoundsInLocal().getWidth()) / 2;
  16. double theLayoutY = (aFieldDimension.getFieldHeight() - theSprite.getBoundsInLocal().getHeight()) / 2;
  17. theSprite.setLayoutX( theLayoutX );
  18. theSprite.setLayoutY( theLayoutY );
  19. theSprite.setTranslateX( toPixelPositionX( aPlayer ) );
  20. theSprite.setTranslateY( toPixelPositionY( aPlayer ) );
  21. }

代码示例来源:origin: org.refcodes/refcodes-graphical-ext-javafx

  1. theSprite.setTranslateX( theToX );
  2. theSprite.setTranslateY( theToY );
  3. break;

代码示例来源:origin: com.github.almasb/fxgl-extra

  1. .add(0, midY);
  2. n.setTranslateX(vector.getX() - (i == 0 || i == 7 ? 0 : 100));
  3. n.setTranslateY(vector.getY());

相关文章

Node类方法