javafx.scene.layout.Region.getWidth()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(95)

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

Region.getWidth介绍

暂无

代码示例

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

/**
 * 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());
  }
}

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

if (child.getWidth() != blockWidth || child.getHeight() != blockHeight) {
  child.setOpacity(0);
  child.setPrefSize(blockWidth, blockHeight);

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

errorHideTransition.setOnFinished(finish -> {
  showError(newVal);
  final double w = control.getWidth();
  double errorContainerHeight = computeErrorHeight(computeErrorWidth(w));
  if (errorLabel.isWrapText()) {

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

Region toggleNode = getToggleNode();
newVal.layoutXProperty()
  .bind(Bindings.createDoubleBinding(() -> toggleNode.getLayoutX() + toggleNode.getWidth() / 2,
    toggleNode.widthProperty(),
    toggleNode.layoutXProperty()));

代码示例来源:origin: torakiki/pdfsam

@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);
    }
  }
}

代码示例来源:origin: org.gillius/jfxutils

private Rectangle2D getComponentArea( Region childRegion ) {
    double xStart = getXShift( childRegion, referenceNode );
    double yStart = getYShift( childRegion, referenceNode );

    return new Rectangle2D( xStart, yStart, childRegion.getWidth(), childRegion.getHeight() );
  }
}

代码示例来源:origin: com.powsybl/powsybl-gse-spi

public static Image createImage(Region node) {
  // WORKAROUND to convert a node to a JavaFX image
  // https://stackoverflow.com/questions/41029931/snapshot-image-cant-be-used-as-stage-icon
  int width = (int) node.getWidth();
  int height = (int) node.getHeight();
  BufferedImage bimg = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  SnapshotParameters snapshotParameters = new SnapshotParameters();
  snapshotParameters.setFill(Color.TRANSPARENT);
  SwingFXUtils.fromFXImage(node.snapshot(snapshotParameters, new WritableImage(width, height)), bimg);
  return SwingFXUtils.toFXImage(bimg, new WritableImage(width, height));
}

代码示例来源:origin: com.intuit.karate/karate-core

protected boolean isInDraggableZone(MouseEvent event) {
  zone = Zone.NONE;
  if(allowWidthResize) {
    if ((event.getY() < RESIZE_MARGIN) && (event.getX() < RESIZE_MARGIN)) {
      zone = Zone.NW;
    } else if ((event.getY() < RESIZE_MARGIN) && (event.getX() > (region.getWidth() - RESIZE_MARGIN))) {
      zone = Zone.NE;
    } else if ((event.getY() > (region.getHeight() - RESIZE_MARGIN)) && (event.getX() > (region.getWidth() - RESIZE_MARGIN))) {
      zone = Zone.SE;
    } else if ((event.getY() > (region.getHeight() - RESIZE_MARGIN)) && (event.getX() < RESIZE_MARGIN)) {
      zone = Zone.SW;
    } else if (event.getX() < RESIZE_MARGIN) {
      zone = Zone.W;
    } else if (event.getX() > (region.getWidth() - RESIZE_MARGIN)) {
      zone = Zone.E;
    }
  } else if (allowHeightResize) {
    if (event.getY() > (region.getHeight() - RESIZE_MARGIN)) {
      zone = Zone.S;
    } else if (event.getY() < RESIZE_MARGIN) {
      zone = Zone.N;
    }
  } else if (allowMove) {
      zone = Zone.C;
  }
  return !Zone.NONE.equals(zone);
}

代码示例来源:origin: com.intuit.karate/karate-core

protected void mousePressed(MouseEvent event) {
  // ignore clicks outside of the draggable margin
  if (!isInDraggableZone(event)) {
    return;
  }
  dragging = true;
  // make sure that the minimum height is set to the current height once,
  // setting a min height that is smaller than the current height will
  // have no effect
  if (!initMinHeight) {
    region.setMinHeight(region.getHeight());
    initMinHeight = true;
  }
  y = event.getSceneY();
  if (!initMinWidth) {
    region.setMinWidth(region.getWidth());
    initMinWidth = true;
  }
  x = event.getSceneX();
}

代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay

@Subscribe
public void handleGameStateChange(GameStateChange stateChange) {
  if (stateChange.getStatusChange() == EGameStatusChange.GAME_INITIALISATION_COMPLETE) {
    logger.info("Load and replace the game");
    gameOptions.load(lodableGames.getSelectedValue());
  }
  if (stateChange.getStatusChange() == EGameStatusChange.GAME_LOADED) {
    uiFactory.invalidate();
    final MainGameScene mainGameScene1 = uiFactory.getMainGameScene(getRoot().getWidth(), getRoot().getHeight());
    mainGameScene1.initializeGameView(null);
    Platform.runLater(() ->
      getBackEvent().handle(null)
    );
  }
}

代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay

@Subscribe
public void handleGameStateChange(GameStateChange stateChange) {
  if (stateChange.getStatusChange() == EGameStatusChange.GAME_INITIALISATION_COMPLETE) {
    logger.info("Load and replace the game");
     gameOptions.load(lodableGames.getSelectedValue());
  }
  if (stateChange.getStatusChange() == EGameStatusChange.GAME_LOADED) {
    uiFactory.invalidate();
    final MainGameScene mainGameScene1 = uiFactory.getMainGameScene(getRoot().getWidth(), getRoot().getHeight());
    mainGameScene1.initializeGameView(null);
    Platform.runLater(() ->
      changeScene(mainGameScene1)
    );
    timerEventBus.post(new ResumeGame());
  }
}

代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay

private EventHandler<MouseEvent> getBackEvent() {
  return event -> {
    try {
      EGameSpeed gameSpeed = EGameSpeed.values()[speed.getSelectedIndex()];
      EGameSpeed currentSpeed = game.getGameSpeed();
      if (gameSpeed != currentSpeed) {
        game.setGameSpeed(gameSpeed);
      }
      MainGameScene mainGame = uiFactory.getMainGameScene(getRoot().getWidth(), getRoot().getHeight());
      getSceneChangeable().changeScene(mainGame);
      soundPlayer.play();
      newSaveGame.setText("");
      timerEventBus.post(new ResumeGame());
    } catch (RuntimeException e) {
      logger.error("Failed to go back to game", e);
    }
  };
}

代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay

final double width = getRoot().getWidth();
final double height = getRoot().getHeight();
logger.debug("Change into main game scene with dimensions: {}x{}", width, height);

代码示例来源:origin: org.jrebirth.af/component

/**
 * {@inheritDoc}
 */
@Override
public void dragOver(final DragEvent dragEvent) {
  if (dragEvent.getSource() instanceof Region) {
    if (dragEvent.getX() > 100
        && dragEvent.getX() < ((Region) dragEvent.getSource()).getWidth() - 100
        || dragEvent.getY() > 100
        && dragEvent.getY() < ((Region) dragEvent.getSource()).getHeight() - 100) {
      System.out.println("drag OVER on => " + controller().model().key());
      controller().view().drawMarker(dragEvent.getX(), dragEvent.getY());
      dragEvent.consume();
    } else {
      controller().view().removeMarker();
    }
  }
}

代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay

final double width = getRoot().getWidth();
final double height = getRoot().getHeight();
sceneChanger.changeScene(sceneChangeable, uiFactory.getMainGameScene(width, height));

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

/**
 * 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());
  }
}

代码示例来源:origin: com.bitplan.radolan/com.bitplan.radolan

/**
 * show the sizes of stage, scene, and the given other nodes
 * 
 * @param region
 *          - the regions to show
 */
public void showSizes(Region... regions) {
 System.out.println("Sizes: ");
 ObservableList<Screen> screens = Screen.getScreensForRectangle(stage.getX(),
   stage.getY(), stage.getWidth(), stage.getHeight());
 for (Screen screen : screens) {
  Rectangle2D s = screen.getVisualBounds();
  showSize(screen, s.getWidth(), s.getHeight());
 }
 showSize(stage, stage.getWidth(), stage.getHeight());
 showSize(getScene(), getScene().getWidth(), getScene().getHeight());
 ImageView imageView = mapView.getImageView();
 showSize(imageView, imageView.getFitWidth(), imageView.getFitHeight());
 Image image = mapView.getImage();
 showSize(image, image.getWidth(), image.getHeight());
 for (Region region : regions) {
  showSize(region, region.getWidth(), region.getHeight());
 }
}

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

if (child.getWidth() != blockWidth || child.getHeight() != blockHeight) {
  child.setOpacity(0);
  child.setPrefSize(blockWidth, blockHeight);

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

errorHideTransition.setOnFinished(finish -> {
  showError(newVal);
  final double w = control.getWidth();
  double errorContainerHeight = computeErrorHeight(computeErrorWidth(w));
  if (errorLabel.isWrapText()) {

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

Region toggleNode = getToggleNode();
newVal.layoutXProperty()
  .bind(Bindings.createDoubleBinding(() -> toggleNode.getLayoutX() + toggleNode.getWidth() / 2,
    toggleNode.widthProperty(),
    toggleNode.layoutXProperty()));

相关文章

微信公众号

最新文章

更多