javafx.scene.text.Text#setWrappingWidth ( )源码实例Demo

下面列出了javafx.scene.text.Text#setWrappingWidth ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jace   文件: ConfigurationUIController.java
private Node buildKeyShortcutRow(ConfigNode node, String actionName, String[] values) {
    InvokableAction actionInfo = Configuration.getInvokableActionInfo(node.subject, actionName);
    if (actionInfo == null) {
        return null;
    }
    HBox row = new HBox();
    row.getStyleClass().add("setting-row");
    Label label = new Label(actionInfo.name());
    label.getStyleClass().add("setting-keyboard-shortcut");
    label.setMinWidth(150.0);
    String value = Arrays.stream(values).collect(Collectors.joining(" or "));
    Text widget = new Text(value);
    widget.setWrappingWidth(180.0);
    widget.getStyleClass().add("setting-keyboard-value");
    widget.setOnMouseClicked((event) -> {
        editKeyboardShortcut(node, actionName, widget);
    });
    label.setLabelFor(widget);
    row.getChildren().add(label);
    row.getChildren().add(widget);
    return row;
}
 
源代码2 项目: Open-Lowcode   文件: CTextField.java
/**
 * compute the height of the text with the current font
 * 
 * @param text  text payload
 * @param width width of the widget in pixel
 * @return the height in pixel
 */
public static double computeTextHeight(String text, double width) {
	Text textfield = new Text(text);
	textfield.setWrappingWidth(width - 8);
	new Scene(new Group(textfield));
	textfield.applyCss();
	textfield.setStyle("");
	double height = textfield.getLayoutBounds().getHeight();
	return height * 1.07 + 2;
}
 
源代码3 项目: WorkbenchFX   文件: FridayFunSkin.java
private Text createCenteredText(double cx, double cy, String styleClass) {
  Text text = new Text();
  text.getStyleClass().add(styleClass);
  text.setTextOrigin(VPos.CENTER);
  text.setTextAlignment(TextAlignment.CENTER);
  double width = cx > ARTBOARD_SIZE * 0.5 ? ((ARTBOARD_SIZE - cx) * 2.0) : cx * 2.0;
  text.setWrappingWidth(width);
  text.setBoundsType(TextBoundsType.VISUAL);
  text.setY(cy);
  text.setX(cx - (width / 2.0));

  return text;
}
 
源代码4 项目: WorkbenchFX   文件: LinearSkin.java
@Override
public void initializeParts() {
  value = new Text(0, ARTBOARD_HEIGHT * 0.5, String.format(FORMAT, getSkinnable().getValue()));
  value.getStyleClass().add("value");
  value.setTextOrigin(VPos.CENTER);
  value.setTextAlignment(TextAlignment.CENTER);
  value.setMouseTransparent(true);
  value.setWrappingWidth(ARTBOARD_HEIGHT);
  value.setBoundsType(TextBoundsType.VISUAL);

  thumb = new Circle(ARTBOARD_HEIGHT * 0.5, ARTBOARD_HEIGHT * 0.5, ARTBOARD_HEIGHT * 0.5);
  thumb.getStyleClass().add("thumb");

  thumbGroup = new Group(thumb, value);

  valueBar = new Line();
  valueBar.getStyleClass().add("valueBar");
  valueBar.setStrokeLineCap(StrokeLineCap.ROUND);
  applyCss(valueBar);
  strokeWidthFromCSS = valueBar.getStrokeWidth();

  scale = new Line();
  scale.getStyleClass().add("scale");
  scale.setStrokeLineCap(StrokeLineCap.ROUND);

  // always needed
  drawingPane = new Pane();
}
 
源代码5 项目: WorkbenchFX   文件: SlimSkin.java
private Text createCenteredText(double cx, double cy, String styleClass) {
  Text text = new Text();
  text.getStyleClass().add(styleClass);
  text.setTextOrigin(VPos.CENTER);
  text.setTextAlignment(TextAlignment.CENTER);
  double width = cx > ARTBOARD_WIDTH * 0.5 ? ((ARTBOARD_WIDTH - cx) * 2.0) : cx * 2.0;
  text.setWrappingWidth(width);
  text.setBoundsType(TextBoundsType.VISUAL);
  text.setY(cy);

  return text;
}
 
源代码6 项目: trex-stateless-gui   文件: TrexAlertBuilder.java
public TrexAlertBuilder setContent(String content) {
    Text text = new Text(content);
    text.setWrappingWidth(WRAPPING_WIDTH);
    text.getStyleClass().add("alert-text");
    text.setFontSmoothingType(FontSmoothingType.LCD);

    HBox container = new HBox();
    container.getChildren().add(text);
    alert.getDialogPane().setContent(container);
    return this;
}
 
源代码7 项目: phoenicis   文件: ConsoleTab.java
public void appendTextToConsole(String text, ConsoleTextType textType) {
    final Text commandText = new Text(text);
    commandText.setWrappingWidth(console.getWidth());
    commandText.getStyleClass().addAll("consoleText", textType.getCssName());

    Platform.runLater(() -> {
        forceScroll = true;
        console.getChildren().add(commandText);
        console.layout();
        consolePane.vvalueProperty().setValue(1.0);
    });
}
 
源代码8 项目: TweetwallFX   文件: TweetsToTori.java
private static Parent createTweetInfoBox(Tweet info) {
    HBox hbox = new HBox(20);
    hbox.setStyle("-fx-padding: 20px;");

    HBox hImage = new HBox();
    hImage.setPadding(new Insets(10));
    Image image = new Image(info.getUser().getProfileImageUrl(), 48, 48, true, false);
    ImageView imageView = new ImageView(image);
    Rectangle clip = new Rectangle(48, 48);
    clip.setArcWidth(10);
    clip.setArcHeight(10);
    imageView.setClip(clip);
    hImage.getChildren().add(imageView);

    HBox hName = new HBox(20);
    Label name = new Label(info.getUser().getName());
    name.setStyle("-fx-font: 32px \"Andalus\"; -fx-text-fill: #292F33; -fx-font-weight: bold;");
    DateFormat df = new SimpleDateFormat("HH:mm:ss");
    Label handle = new Label("@" + info.getUser().getScreenName() + " · " + df.format(info.getCreatedAt()));
    handle.setStyle("-fx-font: 28px \"Andalus\"; -fx-text-fill: #8899A6;");
    hName.getChildren().addAll(name, handle);

    Text text = new Text(info.getText());
    text.setWrappingWidth(550);
    text.setStyle("-fx-font: 24px \"Andalus\"; -fx-fill: #292F33;");
    VBox vbox = new VBox(20);
    vbox.getChildren().addAll(hName, text);
    hbox.getChildren().addAll(hImage, vbox);

    return hbox;
}
 
源代码9 项目: HubTurbo   文件: PanelMenuBar.java
private HBox createNameArea() {
    HBox nameArea = new HBox();

    nameText = new Text(panelName);
    nameText.setId(IdGenerator.getPanelNameAreaId(panel.panelIndex));
    nameText.setWrappingWidth(NAME_DISPLAY_WIDTH);

    nameBox = new HBox();
    nameBox.getChildren().add(nameText);
    nameBox.setMinWidth(NAME_DISPLAY_WIDTH);
    nameBox.setMaxWidth(NAME_DISPLAY_WIDTH);
    nameBox.setAlignment(Pos.CENTER_LEFT);

    nameBox.setOnMouseClicked(mouseEvent -> {
        if (mouseEvent.getButton().equals(MouseButton.PRIMARY)
                && mouseEvent.getClickCount() == 2) {

            mouseEvent.consume();
            activateInplaceRename();
        }
    });
    Tooltip.install(nameArea, new Tooltip("Double click to edit the name of this panel"));

    nameArea.getChildren().add(nameBox);
    nameArea.setMinWidth(NAME_AREA_WIDTH);
    nameArea.setMaxWidth(NAME_AREA_WIDTH);
    nameArea.setPadding(new Insets(0, 10, 0, 5));
    return nameArea;
}
 
源代码10 项目: stagedisplayviewer   文件: FxUtils.java
public Text createLowerKey() {
    Text lowerKey = new Text();
    lowerKey.setFont(Font.font(FONT_FAMILY.toString(), FontWeight.MEDIUM, MAX_FONT_SIZE.toInt()));
    lowerKey.setFill(Color.WHITE);
    lowerKey.setWrappingWidth(getWrappingWidth());
    lowerKey.setTextAlignment(getAlignment());
    DropShadow ds = new DropShadow();
    ds.setOffsetY(0.0);
    ds.setOffsetX(0.0);
    ds.setColor(Color.BLACK);
    ds.setSpread(0.5);
    lowerKey.setEffect(ds);
    return lowerKey;
}
 
源代码11 项目: MyBox   文件: ImagesBrowserController.java
private void makeImagePopup(VBox imageBox, ImageInformation imageInfo,
        ImageView iView) {
    try {
        File file = imageInfo.getImageFileInformation().getFile();
        final Image iImage = imageInfo.getImage();
        imagePop = new Popup();
        imagePop.setWidth(popSize + 40);
        imagePop.setHeight(popSize + 40);
        imagePop.setAutoHide(true);

        VBox vbox = new VBox();
        VBox.setVgrow(vbox, Priority.ALWAYS);
        HBox.setHgrow(vbox, Priority.ALWAYS);
        vbox.setMaxWidth(Double.MAX_VALUE);
        vbox.setMaxHeight(Double.MAX_VALUE);
        vbox.setStyle("-fx-background-color: white;");
        imagePop.getContent().add(vbox);

        popView = new ImageView();
        popView.setImage(iImage);
        if (iImage.getWidth() > iImage.getHeight()) {
            popView.setFitWidth(popSize);
        } else {
            popView.setFitHeight(popSize);
        }
        popView.setPreserveRatio(true);
        vbox.getChildren().add(popView);

        popText = new Text();
        popText.setStyle("-fx-font-size: 1.0em;");

        vbox.getChildren().add(popText);
        vbox.setPadding(new Insets(15, 15, 15, 15));

        String info = imageInfo.getFileName() + "\n"
                + AppVariables.message("Format") + ":" + imageInfo.getImageFormat() + "  "
                + AppVariables.message("ModifyTime") + ":" + DateTools.datetimeToString(file.lastModified()) + "\n"
                + AppVariables.message("Size") + ":" + FileTools.showFileSize(file.length()) + "  "
                + AppVariables.message("Pixels") + ":" + imageInfo.getWidth() + "x" + imageInfo.getHeight() + "\n"
                + AppVariables.message("LoadedSize") + ":"
                + (int) iView.getImage().getWidth() + "x" + (int) iView.getImage().getHeight() + "  "
                + AppVariables.message("DisplayedSize") + ":"
                + (int) iView.getFitWidth() + "x" + (int) iView.getFitHeight();
        popText.setText(info);
        popText.setWrappingWidth(popSize);
        Bounds bounds = imageBox.localToScreen(imageBox.getBoundsInLocal());
        imagePop.show(imageBox, bounds.getMinX() + bounds.getWidth() / 2, bounds.getMinY());

    } catch (Exception e) {
        logger.debug(e.toString());
    }
}
 
源代码12 项目: DeskChan   文件: CharacterBalloon.java
protected CharacterBalloon() {
	super();
	instance = this;
	setId("character-balloon");

	positionMode = CharacterBalloon.PositionMode.valueOf(
			Main.getProperties().getString("balloon_position_mode", positionMode.toString())
	);
	directionMode = CharacterBalloon.DirectionMode.valueOf(
			Main.getProperties().getString("balloon_direction_mode", directionMode.toString())
	);

	Text label = new Text("");
	label.setFont(defaultFont);
	if (defaultFont != null) {
		label.setFont(defaultFont);
	} else {
		label.setFont(LocalFont.defaultFont);
	}

	content = label;
	bubblePane = sprite;
	sprite.setSpriteContent(content);
	getChildren().add(bubblePane);

	label.setWrappingWidth(bubblePane.getContentWidth());

	setBalloonScaleFactor(Main.getProperties().getFloat("balloon.scale_factor", 100));
	setBalloonOpacity(Main.getProperties().getFloat("balloon.opacity", 100));

	setOnMousePressed(event -> {
		lastClick = System.currentTimeMillis();
		if (event.isSecondaryButtonDown()){
			UserBalloon.show(null);
			return;
		}
		if ((positionMode != PositionMode.AUTO) && event.getButton().equals(MouseButton.PRIMARY)) {
			startDrag(event);
		}
	});
	setOnMouseReleased(event -> {
		if(!isDragging() && event.getButton().equals(MouseButton.PRIMARY) && (System.currentTimeMillis()-lastClick)<200) {
			if (symbolsAdder.isDone()) {
				if (character != null) {
					character.say(null);
				} else {
					hide();
				}
			} else {
				symbolsAdder.stop();
			}
		}
	});

	setOnMouseEntered(event -> {
		if (character != null && timeoutTimeline != null) {
			timeoutTimeline.stop();
		}
	});
	setOnMouseExited(event -> {
		if (character != null && timeoutTimeline != null) {
			timeoutTimeline.play();
		}
	});

	mouseEventNotificator
			.setOnClickListener()
			.setOnMovedListener()
			.setOnScrollListener(event -> true);

	if (positionMode != PositionMode.ABSOLUTE) {
		positionRelativeToDesktopSize = false;
	}
}
 
源代码13 项目: NLIDB   文件: UserView.java
@Override
public void start(Stage primaryStage) throws Exception {
	
	stage = primaryStage;
	stage.setTitle("Window for NLIDB");
	
	Label label1 = new Label("Welcome to Natural Language Interface to DataBase!");
	
	Label lblInput = new Label("Natural Language Input:");
	TextArea fieldIn = new TextArea();
	fieldIn.setPrefHeight(100);
	fieldIn.setPrefWidth(100);
	fieldIn.setWrapText(true);
	fieldIn.setText(TEST_TEXT);
	
	btnTranslate = new Button("translate");
	
	// Define action of the translate button.
	btnTranslate.setOnAction(e -> {
		ctrl.processNaturalLanguage(fieldIn.getText());
	});
	
	display = new Text();
	display.setWrappingWidth(500);
	display.prefHeight(300);
	display.setText("Default display text");

	// choices and button for nodes mapping
	choiceBox = new ComboBox<NodeInfo>();
	choiceBox.setVisibleRowCount(6);
	btnConfirmChoice = new Button("confirm choice");
	btnConfirmChoice.setOnAction(e -> {
		ctrl.chooseNode(getChoice());
	});
	
	// choices and button for tree selection
	treeChoice = new ComboBox<Integer>(); // ! only show 3 choices now
	treeChoice.setItems(FXCollections.observableArrayList(0,1,2));
	treeChoice.getSelectionModel().selectedIndexProperty().addListener((ov, oldV, newV) -> {
		ctrl.showTree(treeChoice.getItems().get((Integer) newV));
	});
	btnTreeConfirm = new Button("confirm tree choice");
	btnTreeConfirm.setOnAction(e -> {
		ctrl.chooseTree(treeChoice.getValue());
	});
	
	vb1 = new VBox();
	vb1.setSpacing(10);
	vb1.getChildren().addAll(
			label1,
			lblInput,fieldIn,
			btnTranslate
			);
	
	vb2 = new VBox();
	vb2.setSpacing(20);
	vb2.getChildren().addAll(display);
	
	hb = new HBox();
	hb.setPadding(new Insets(15, 12, 15, 12));
	hb.setSpacing(10);
	hb.getChildren().addAll(vb1, vb2);
	
	scene = new Scene(hb, 800, 450);
	
	stage.setScene(scene);
	ctrl = new Controller(this);
	stage.show();
	
}
 
源代码14 项目: FXGLGames   文件: CardViewComponent.java
SkillView(Skill skill) {
    this.skill = skill;

    var texture = texture("skills/" + skill.getImageName(), SKILL_IMAGE_WIDTH, SKILL_IMAGE_HEIGHT);

    var rect = new Rectangle(SKILL_IMAGE_WIDTH, SKILL_IMAGE_HEIGHT, null);
    rect.setStroke(Color.DARKBLUE);

    String tooltipMessage = skill.getName() + "\n" + skill.getDescription();

    Text text = getUIFactoryService().newText(tooltipMessage, Color.WHITE, FontType.TEXT, 14);
    text.setWrappingWidth(CARD_WIDTH * 0.7);

    var bg = new Rectangle(CARD_WIDTH * 0.8, text.getLayoutBounds().getHeight() * 1.2, Color.color(0, 0, 0, 0.85));
    bg.setStroke(Color.WHITE);

    var imageStack = new StackPane(texture, rect);

    imageStack.scaleXProperty().bind(
            Bindings.when(imageStack.hoverProperty()).then(1.2).otherwise(1.0)
    );

    imageStack.scaleYProperty().bind(
            Bindings.when(imageStack.hoverProperty()).then(1.2).otherwise(1.0)
    );

    var tooltipStack = new StackPane(bg, text);
    tooltipStack.setTranslateX(-10);
    tooltipStack.setTranslateY(-SKILL_IMAGE_HEIGHT * 2);

    tooltipStack.visibleProperty().bind(imageStack.hoverProperty());

    getChildren().addAll(imageStack, tooltipStack);
}
 
源代码15 项目: FXGLGames   文件: Level1.java
@Override
public void playInCutscene(Runnable onFinished) {

    boolean doNotPlayCutscene = true;
    if (doNotPlayCutscene) {
        onFinished.run();
        return;
    }

    placeGenerals();

    showStoryPane();

    Text text = getUIFactoryService().newText("HQ: Attention, V.I.T. generals! Your mission is to find and destroy the alien invaders...", Color.WHITE, 24.0);
    text.setWrappingWidth(getAppWidth() - 50);

    updateStoryText(text);

    runOnce(() -> {
        text.setText("HQ: Wait a sec... we are reading alien signals.");
    }, Duration.seconds(3));

    runOnce(() -> {

        placeBoss();

    }, Duration.seconds(6));

    runOnce(() -> {
        hideStoryPane();
        onFinished.run();

    }, Duration.seconds(26));
}
 
源代码16 项目: FXGLGames   文件: CardViewComponent.java
SkillView(Skill skill) {
    this.skill = skill;

    var texture = texture("skills/" + skill.getImageName(), SKILL_IMAGE_WIDTH, SKILL_IMAGE_HEIGHT);

    var rect = new Rectangle(SKILL_IMAGE_WIDTH, SKILL_IMAGE_HEIGHT, null);
    rect.setStroke(Color.DARKBLUE);

    String tooltipMessage = skill.getName() + "\n" + skill.getDescription();

    Text text = getUIFactoryService().newText(tooltipMessage, Color.WHITE, FontType.TEXT, 14);
    text.setWrappingWidth(CARD_WIDTH * 0.7);

    var bg = new Rectangle(CARD_WIDTH * 0.8, text.getLayoutBounds().getHeight() * 1.2, Color.color(0, 0, 0, 0.85));
    bg.setStroke(Color.WHITE);

    var imageStack = new StackPane(texture, rect);

    imageStack.scaleXProperty().bind(
            Bindings.when(imageStack.hoverProperty()).then(1.2).otherwise(1.0)
    );

    imageStack.scaleYProperty().bind(
            Bindings.when(imageStack.hoverProperty()).then(1.2).otherwise(1.0)
    );

    var tooltipStack = new StackPane(bg, text);
    tooltipStack.setTranslateX(-10);
    tooltipStack.setTranslateY(-SKILL_IMAGE_HEIGHT * 2);

    tooltipStack.visibleProperty().bind(imageStack.hoverProperty());

    getChildren().addAll(imageStack, tooltipStack);
}
 
源代码17 项目: FXGLGames   文件: Level1.java
@Override
public void playInCutscene(Runnable onFinished) {

    boolean doNotPlayCutscene = true;
    if (doNotPlayCutscene) {
        onFinished.run();
        return;
    }

    placeGenerals();

    showStoryPane();

    Text text = getUIFactoryService().newText("HQ: Attention, V.I.T. generals! Your mission is to find and destroy the alien invaders...", Color.WHITE, 24.0);
    text.setWrappingWidth(getAppWidth() - 50);

    updateStoryText(text);

    runOnce(() -> {
        text.setText("HQ: Wait a sec... we are reading alien signals.");
    }, Duration.seconds(3));

    runOnce(() -> {

        placeBoss();

    }, Duration.seconds(6));

    runOnce(() -> {
        hideStoryPane();
        onFinished.run();

    }, Duration.seconds(26));
}