javafx.scene.text.Text.prefWidth()方法的使用及代码示例

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

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

Text.prefWidth介绍

暂无

代码示例

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

double computeTextWidth(Font font, String text, double wrappingWidth) {
  Text helper = new Text();
  helper.setFont(font);
  helper.setText(text);
  // Note that the wrapping width needs to be set to zero before
  // getting the text's real preferred width.
  helper.setWrappingWidth(0);
  helper.setLineSpacing(0);
  double w = Math.min(helper.prefWidth(-1), wrappingWidth);
  helper.setWrappingWidth((int)Math.ceil(w));
  return Math.ceil(helper.getLayoutBounds().getWidth());
}

代码示例来源:origin: no.tornado/tornadofx-controls

protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
  double w = text.prefWidth(height);
  if (getSkinnable().getGraphic() != null && iconPosition().isVertical())
    w += Math.max(getSkinnable().getGraphic().prefWidth(-1), graphicFixedSize());
  return w + leftInset + rightInset;
}

代码示例来源:origin: no.tornado/tornadofx-controls

double centeredX = x + (w / 2) - text.prefWidth(-1) / 2;
text.resizeRelocate(centeredX, y, text.prefWidth(-1), text.prefHeight(-1));
break;
double centeredX = x + (w / 2) - text.prefWidth(-1) / 2;
text.resizeRelocate(centeredX, y, text.prefWidth(-1), text.prefHeight(-1));
text.resizeRelocate(x, centeredY, text.prefWidth(-1), text.prefHeight(-1));
text.resizeRelocate(x, centeredY, text.prefWidth(-1), text.prefHeight(-1));
break;

相关文章