本文整理了Java中javafx.scene.text.Text.getLayoutBounds()
方法的一些代码示例,展示了Text.getLayoutBounds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Text.getLayoutBounds()
方法的具体详情如下:
包路径:javafx.scene.text.Text
类名称:Text
方法名:getLayoutBounds
暂无
代码示例来源:origin: jfoenixadmin/JFoenix
temp.setFont(text.getFont());
temp.applyCss();
double width = temp.getLayoutBounds().getWidth();
temp.setText(lineText.substring(0, beginIndex + queryLength));
temp.applyCss();
double maxX = temp.getLayoutBounds().getMaxX();
double startX = maxX - width;
width, temp.getLayoutBounds().getHeight()));
代码示例来源:origin: jfoenixadmin/JFoenix
private double computeTextContentWidth(TextInputControl editor) {
Text text = new Text(editor.getText());
text.setFont(editor.getFont());
text.applyCss();
return text.getLayoutBounds().getWidth();
}
代码示例来源:origin: jfoenixadmin/JFoenix
/**
* {@inheritDoc}
*/
@Override
protected void layoutChildren(double contentX, double contentY, double contentWidth, double contentHeight) {
final double strokeWidth = arc.getStrokeWidth();
final double radius = Math.min(contentWidth, contentHeight) / 2 - strokeWidth / 2;
final double arcSize = snapSize(radius * 2 + strokeWidth);
arcPane.resizeRelocate((contentWidth - arcSize) / 2 + 1, (contentHeight - arcSize) / 2 + 1, arcSize, arcSize);
updateArcLayout(radius, arcSize);
fillRect.setWidth(arcSize);
fillRect.setHeight(arcSize);
if (!isValid) {
initialize();
isValid = true;
}
if (!getSkinnable().isIndeterminate()) {
arc.setLength(arcLength);
if (text.isVisible()) {
final double progress = control.getProgress();
int intProgress = (int) Math.round(progress * 100.0);
Font font = text.getFont();
text.setFont(Font.font(font.getFamily(), radius / 1.7));
text.setText((progress > 1 ? 100 : intProgress) + "%");
text.relocate((arcSize - text.getLayoutBounds().getWidth()) / 2, (arcSize - text.getLayoutBounds().getHeight()) / 2);
}
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
private void updateTextPos() {
double textWidth = textNode.getLayoutBounds().getWidth();
final double promptWidth = promptText == null ? 0 : promptText.getLayoutBounds().getWidth();
switch (getHAlignment()) {
case CENTER:
linesWrapper.promptTextScale.setPivotX(promptWidth / 2);
double midPoint = textRight.get() / 2;
double newX = midPoint - textWidth / 2;
if (newX + textWidth <= textRight.get()) {
textTranslateX.set(newX);
}
break;
case LEFT:
linesWrapper.promptTextScale.setPivotX(0);
break;
case RIGHT:
linesWrapper.promptTextScale.setPivotX(promptWidth);
break;
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
private void updateTextPos() {
double textWidth = textNode.getLayoutBounds().getWidth();
final double promptWidth = promptText == null ? 0 : promptText.getLayoutBounds().getWidth();
switch (getHAlignment()) {
case CENTER:
linesWrapper.promptTextScale.setPivotX(promptWidth / 2);
double midPoint = textRight.get() / 2;
double newX = midPoint - textWidth / 2;
if (newX + textWidth <= textRight.get()) {
textTranslateX.set(newX);
}
break;
case LEFT:
linesWrapper.promptTextScale.setPivotX(0);
break;
case RIGHT:
linesWrapper.promptTextScale.setPivotX(promptWidth);
break;
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
/***************************************************************************
* *
* Public API *
* *
**************************************************************************/
@Override
protected void layoutChildren(final double x, final double y,
final double w, final double h) {
super.layoutChildren(x, y, w, h);
final double height = getSkinnable().getHeight();
linesWrapper.layoutLines(x, y, w, h, height,
promptText == null ? 0 : snapPosition(promptText.getBaselineOffset() + promptText.getLayoutBounds().getHeight() * .36));
errorContainer.layoutPane(x, height + linesWrapper.focusedLine.getHeight(), w, h);
linesWrapper.updateLabelFloatLayout();
if (invalid) {
invalid = false;
// update validation container
errorContainer.invalid(w);
// focus
linesWrapper.invalid();
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
private void createPromptNode() {
if (promptText != null || !linesWrapper.usePromptText.get()) {
return;
}
promptText = new Text();
StackPane.setAlignment(promptText, Pos.CENTER_LEFT);
// create my custom pane for the prompt node
promptText.textProperty().bind(getSkinnable().promptTextProperty());
promptText.fillProperty().bind(linesWrapper.animatedPromptTextFill);
promptText.getStyleClass().addAll("text");
promptText.getTransforms().add(linesWrapper.promptTextScale);
promptText.visibleProperty().bind(linesWrapper.usePromptText);
promptText.setTranslateX(1);
linesWrapper.promptContainer.getChildren().add(promptText);
if (getSkinnable().isFocused() && ((JFXComboBox<T>) getSkinnable()).isLabelFloat()) {
promptText.setTranslateY(-snapPosition(promptText.getBaselineOffset() + promptText.getLayoutBounds().getHeight() * .36));
linesWrapper.promptTextScale.setX(0.85);
linesWrapper.promptTextScale.setY(0.85);
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
@Override
protected void layoutChildren(final double x, final double y, final double w, final double h) {
super.layoutChildren(x, y, w, h);
final double height = getSkinnable().getHeight();
linesWrapper.layoutLines(x, y, w, h, height, promptText == null ? 0 : promptText.getLayoutBounds().getHeight() + 3);
errorContainer.layoutPane(x, height + linesWrapper.focusedLine.getHeight(), w, h);
linesWrapper.updateLabelFloatLayout();
if (invalid) {
invalid = false;
// set the default background of text area viewport to white
Region viewPort = (Region) scrollPane.getChildrenUnmodifiable().get(0);
viewPort.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
CornerRadii.EMPTY,
Insets.EMPTY)));
// reapply css of scroll pane in case set by the user
viewPort.applyCss();
errorContainer.invalid(w);
// focus
linesWrapper.invalid();
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
@Override
protected void layoutChildren(final double x, final double y, final double w, final double h) {
super.layoutChildren(x, y, w, h);
final double height = getSkinnable().getHeight();
linesWrapper.layoutLines(x, y, w, h, height, promptText == null ? 0 : promptText.getLayoutBounds().getHeight() + 3);
errorContainer.layoutPane(x, height + linesWrapper.focusedLine.getHeight(), w, h);
linesWrapper.updateLabelFloatLayout();
if (invalid) {
invalid = false;
// set the default background of text area viewport to white
Region viewPort = (Region) scrollPane.getChildrenUnmodifiable().get(0);
viewPort.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
CornerRadii.EMPTY,
Insets.EMPTY)));
// reapply css of scroll pane in case set by the user
viewPort.applyCss();
errorContainer.invalid(w);
// focus
linesWrapper.invalid();
}
}
代码示例来源:origin: torakiki/pdfsam
private static Text helpIcon(HelpPopup popup) {
Text icon = MaterialDesignIconFactory.get().createIcon(MaterialDesignIcon.HELP_CIRCLE, "1.1em");
icon.setOnMouseEntered(e -> {
Point2D p = icon.localToScreen(icon.getLayoutBounds().getMaxX(), icon.getLayoutBounds().getMaxY());
popup.show(icon, p.getX(), p.getY());
});
icon.setOnMouseExited(e -> popup.hide());
return icon;
}
}
代码示例来源:origin: org.processing/core
@Override
protected float textWidthImpl(char[] buffer, int start, int stop) {
if (textFont == null) {
defaultFontOrDeath("textWidth");
}
if (textFontInfo.font == null) {
return super.textWidthImpl(buffer, start, stop);
}
fontCache.measuringText.setFont(textFontInfo.font);
fontCache.measuringText.setText(new String(buffer, start, stop - start));
return (float) fontCache.measuringText.getLayoutBounds().getWidth();
}
代码示例来源: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: com.github.almasb/fxgl-extra
@Override
protected Node createVersionView(String version) {
Text view = FXGL.getUIFactory().newText(version, 16);
view.setTranslateX(app.getWidth() - view.getLayoutBounds().getWidth());
view.setTranslateY(20);
return view;
}
代码示例来源:origin: ch.sahits.game/OpenPatricianJavaFX
double computeTextHeight(Font font, String text, double wrappingWidth, double lineSpacing) {
Text helper = new Text();
helper.setFont(font);
helper.setText(text);
helper.setWrappingWidth((int)wrappingWidth);
helper.setLineSpacing(lineSpacing);
return helper.getLayoutBounds().getHeight();
}
/**
代码示例来源:origin: com.github.almasb/fxgl-extra
@Override
protected Node createVersionView(String version) {
Text view = FXGL.getUIFactory().newText(version, 16);
view.setTranslateX(app.getWidth() - view.getLayoutBounds().getWidth());
view.setTranslateY(20);
return view;
}
代码示例来源:origin: com.github.almasb/fxgl-extra
@Override
protected Node createProfileView(String profileName) {
Text view = FXGL.getUIFactory().newText(profileName, 24);
view.setTranslateX(app.getWidth() - view.getLayoutBounds().getWidth());
view.setTranslateY(50);
return view;
}
代码示例来源:origin: com.github.almasb/fxgl-extra
@Override
protected Node createProfileView(String profileName) {
Text view = FXGL.getUIFactory().newText(profileName, 24);
view.setTranslateX(app.getWidth() - view.getLayoutBounds().getWidth());
view.setTranslateY(50);
return view;
}
代码示例来源:origin: com.jfoenix/jfoenix
private double computeTextContentWidth(TextInputControl editor) {
Text text = new Text(editor.getText());
text.setFont(editor.getFont());
text.applyCss();
return text.getLayoutBounds().getWidth();
}
代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.controls
public static double getTextHeight(String text, Font font, double fontZoomFactor) {
Text t = new Text(text);
t.setFont(Font.font(font.getName(), font.getSize() * fontZoomFactor));
return t.getLayoutBounds().getHeight();
}
代码示例来源:origin: com.github.almasb/fxgl-base
@Override
protected Node createProfileView(String profileName) {
Text view = FXGL.getUIFactory().newText(profileName);
view.setTranslateY(app.getHeight() - 2);
view.setTranslateX(app.getWidth() - view.getLayoutBounds().getWidth());
return view;
}
内容来源于网络,如有侵权,请联系作者删除!