javafx.scene.text.TextFlow Java Examples

The following examples show how to use javafx.scene.text.TextFlow. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StringMatchUtil.java    From pmd-designer with BSD 2-Clause "Simplified" License 7 votes vote down vote up
/**
 * Selects the best {@link MatchResult} given a list of candidates and a query.
 *
 * <p>The results are useless unless you provide the {@link MatchSelector} that
 * suits your use case (limiter).
 *
 * @param candidates     List of stuff to sort
 * @param matchExtractor Extracts the searchable text from an item
 * @param limiter        Selects the best candidates, may process them further to break ties
 * @param query          Text to search for
 */
public static <T> Stream<MatchResult<T>> filterResults(List<? extends T> candidates,
                                                       Function<? super T, String> matchExtractor,
                                                       String query,
                                                       MatchSelector<T> limiter) {
    if (query.length() < MIN_QUERY_LENGTH) {
        return Stream.empty();
    }

    Stream<MatchResult<T>> base = candidates.stream()
                                            .map(it -> {
                                                String cand = matchExtractor.apply(it);
                                                return new MatchResult<>(0, it, cand, query, new TextFlow(makeNormalText(cand)));
                                            });
    return limiter.selectBest(base);
}
 
Example #2
Source File: GoogleCloudCredentialsAlert.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
public void show()
{
	final Hyperlink hyperlink = new Hyperlink("Google Cloud SDK");
	hyperlink.setOnAction(e -> Paintera.getApplication().getHostServices().showDocument(googleCloudSdkLink));

	final TextArea area = new TextArea(googleCloudAuthCmd);
	area.setFont(Font.font("monospace"));
	area.setEditable(false);
	area.setMaxHeight(24);

	final TextFlow textFlow = new TextFlow(
			new Text("Please install "),
			hyperlink,
			new Text(" and then run this command to initialize the credentials:"),
			new Text(System.lineSeparator() + System.lineSeparator()),
			area);

	final Alert alert = PainteraAlerts.alert(Alert.AlertType.INFORMATION);
	alert.setHeaderText("Could not find Google Cloud credentials.");
	alert.getDialogPane().contentProperty().set(textFlow);
	alert.show();
}
 
Example #3
Source File: ThreadListCellFactory.java    From jstackfx with Apache License 2.0 6 votes vote down vote up
protected TextFlow buildThreadListGraphic(final TableCell<ThreadElement, Set<ThreadElement>> cell, final Set<ThreadElement> threads) {
    final TextFlow threadsGraphic = new TextFlow();
    threadsGraphic.setPrefHeight(20);

    final Iterator<ThreadElement> threadIterator = threads.iterator();
    while (threadIterator.hasNext()) {
        final ThreadElement thread = threadIterator.next();

        threadsGraphic.getChildren().add(buildThreadLink(cell, thread));

        if (threadIterator.hasNext()) {
            threadsGraphic.getChildren().add(buildThreadSeparator());
        }
    }
    return threadsGraphic;
}
 
Example #4
Source File: CalibratePatchesBase.java    From testing-video with GNU General Public License v3.0 6 votes vote down vote up
protected Parent overlay(Args args) {
    Color fill = getTextFill(args);

    TextFlow topLeft = text(fill, getTopLeftText(args), LEFT);
    TextFlow topCenter = text(fill, getTopCenterText(args), CENTER);
    TextFlow topRight = text(fill, getTopRightText(args), RIGHT);
    TextFlow bottomLeft = text(fill, getBottomLeftText(args), LEFT);
    TextFlow bottomCenter = text(fill, getBottomCenterText(args), CENTER);
    TextFlow bottomRight = text(fill, getBottomRightText(args), RIGHT);

    StackPane top = new StackPane(topLeft, topCenter, topRight);
    StackPane bottom = new StackPane(bottomLeft, bottomCenter, bottomRight);

    BorderPane.setMargin(top, new Insets(20));
    BorderPane.setMargin(bottom, new Insets(20));

    BorderPane layout = new BorderPane();
    layout.setBackground(EMPTY);
    layout.setTop(top);
    layout.setBottom(bottom);

    return layout;
}
 
Example #5
Source File: PrefixPane.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
public PrefixPane(String ownerModule, UserContext userContext) {
    this.ownerModule = defaultString(ownerModule);
    this.field = new PrefixField(userContext.getDefaultPrefix(this.ownerModule));
    getStyleClass().addAll(Style.CONTAINER.css());
    getStyleClass().addAll(Style.HCONTAINER.css());
    I18nContext ctx = DefaultI18nContext.getInstance();
    getChildren().addAll(new Label(DefaultI18nContext.getInstance().i18n("Generated PDF documents name prefix:")),
            field,
                    helpIcon(new TextFlow(
                            new Text(ctx.i18n("Prefix for the output files name.") + System.lineSeparator()),
                            new Text(ctx.i18n("Some special keywords are replaced with runtime values.")
                                    + System.lineSeparator()),
                    new Text(ctx.i18n("Right click to add these keywords.")))));
    eventStudio().add(TaskExecutionRequestEvent.class, e -> {
        if (ownerModule.equals(e.getModuleId())) {
            userContext.setDefaultPrefix(this.ownerModule, field.getText());
        }
    });
}
 
Example #6
Source File: StepRepresentationPresentation.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void drawStepContent() {
    final String title = this.getParentWizardTitle();

    VBox contentPane = new VBox();
    contentPane.setId("presentationBackground");

    Label titleWidget = new Label(title + "\n\n");
    titleWidget.setId("presentationTextTitle");

    Text textWidget = new Text(textToShow);
    textWidget.setId("presentationText");

    TextFlow flow = new TextFlow();
    flow.getChildren().add(textWidget);

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setId("presentationScrollPane");
    scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    scrollPane.setFitToWidth(true);
    scrollPane.setContent(flow);
    VBox.setVgrow(scrollPane, Priority.ALWAYS);

    contentPane.getChildren().add(scrollPane);
    getParent().getRoot().setCenter(contentPane);
}
 
Example #7
Source File: TopicsTemplate.java    From helloiot with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void updateItem(TemplateInfo item, boolean empty) {
    super.updateItem(item, empty);
    if (item == null) {
        setGraphic(null);
        setText(null);
    } else {               
        Text t = IconBuilder.create(IconFontGlyph.valueOf(item.icon), 18.0).build();
        t.setFill(Color.WHITE);
        TextFlow tf = new TextFlow(t);
        tf.setTextAlignment(TextAlignment.CENTER);
        tf.setPadding(new Insets(5, 5, 5, 5));
        tf.setStyle("-fx-background-color: #505050; -fx-background-radius: 5px;");
        tf.setPrefWidth(30.0);      
        
        setGraphic(tf);
        setText(item.name);
    }
}
 
Example #8
Source File: ClientLoginNode.java    From helloiot with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void updateItem(TopicInfo item, boolean empty) {
    super.updateItem(item, empty);
    if (item == null) {
        setGraphic(null);
        setText(null);
    } else {
        Text t = IconBuilder.create(item.getFactory().getGlyph(), 18.0).build();
        t.setFill(Color.WHITE);
        TextFlow tf = new TextFlow(t);
        tf.setTextAlignment(TextAlignment.CENTER);
        tf.setPadding(new Insets(5, 5, 5, 5));
        tf.setStyle("-fx-background-color: #505050; -fx-background-radius: 5px;");
        tf.setPrefWidth(30.0);              
        setGraphic(tf);
        
        String label = item.getLabel().getValue();
        setText(item.getFactory().getTypeName() + ((label == null || label.isEmpty()) ? "" : " : " + label));
    }
}
 
Example #9
Source File: News.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
News(NewsData data) {
    this.getStyleClass().add("news-box");
    TextFlow flow = new TextFlow();
    if (data.isImportant()) {
        Text megaphone = FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.BULLHORN, "1.2em");
        megaphone.getStyleClass().clear();
        megaphone.getStyleClass().add("news-box-title-important");
        flow.getChildren().addAll(megaphone, new Text(" "));
    }

    Text titleText = new Text(data.getTitle() + System.lineSeparator());
    titleText.setOnMouseClicked(e -> eventStudio().broadcast(new OpenUrlRequest(data.getLink())));
    titleText.getStyleClass().add("news-box-title");

    Text contentText = new Text(data.getContent());
    contentText.setTextAlignment(TextAlignment.JUSTIFY);
    contentText.getStyleClass().add("news-content");

    flow.getChildren().addAll(titleText, contentText);
    flow.setTextAlignment(TextAlignment.JUSTIFY);
    Label labelDate = new Label(FORMATTER.format(data.getDate()),
            MaterialDesignIconFactory.get().createIcon(MaterialDesignIcon.CLOCK));
    labelDate.setPrefWidth(Integer.MAX_VALUE);
    HBox.setHgrow(labelDate, Priority.ALWAYS);
    HBox bottom = new HBox(labelDate);
    bottom.setAlignment(Pos.CENTER_LEFT);
    bottom.getStyleClass().add("news-box-footer");
    if (isNotBlank(data.getLink())) {
        Button link = UrlButton.urlButton(null, data.getLink(), FontAwesomeIcon.EXTERNAL_LINK_SQUARE,
                "pdfsam-toolbar-button");
        bottom.getChildren().add(link);
    }
    getChildren().addAll(flow, bottom);
}
 
Example #10
Source File: LoginPane.java    From pattypan with MIT License 6 votes vote down vote up
private void setContent() {
  TextFlow flow = new TextFlow(new Text(Util.text("login-intro")), link);
  flow.setTextAlignment(TextAlignment.CENTER);
  addElement(flow);

  addElement(loginText);
  addElement(passwordText);
  addElement(loginButton);
  addElement(loginStatus);

  if (!Settings.getSetting("user").isEmpty()) {
    loginText.setText(Settings.getSetting("user"));
    Platform.runLater(() -> {
      passwordText.requestFocus();
    });
  }
}
 
Example #11
Source File: TimeTileSkin.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    text = new Text(tile.getText());
    text.setFill(tile.getUnitColor());
    Helper.enableNode(text, tile.isTextVisible());

    LocalTime duration = tile.getDuration();

    leftText = new Text(Integer.toString(duration.getHour() > 0 ? duration.getHour() : duration.getMinute()));
    leftText.setFill(tile.getValueColor());
    leftUnit = new Text(duration.getHour() > 0 ? "h" : "m");
    leftUnit.setFill(tile.getValueColor());

    rightText = new Text(Integer.toString(duration.getHour() > 0 ? duration.getMinute() : duration.getSecond()));
    rightText.setFill(tile.getValueColor());
    rightUnit = new Text(duration.getHour() > 0 ? "m" : "s");
    rightUnit.setFill(tile.getValueColor());

    timeText = new TextFlow(leftText, leftUnit, rightText, rightUnit);
    timeText.setTextAlignment(TextAlignment.RIGHT);
    timeText.setPrefWidth(PREFERRED_WIDTH * 0.9);

    description = new Label(tile.getDescription());
    description.setAlignment(Pos.TOP_RIGHT);
    description.setWrapText(true);
    description.setTextFill(tile.getDescriptionColor());
    Helper.enableNode(description, !tile.getDescription().isEmpty());

    getPane().getChildren().addAll(titleText, text, timeText, description);
}
 
Example #12
Source File: ThreadListCellFactory.java    From jstackfx with Apache License 2.0 5 votes vote down vote up
@Override
public TableCell<ThreadElement, Set<ThreadElement>> call(TableColumn<ThreadElement, Set<ThreadElement>> param) {
    final TableCell<ThreadElement, Set<ThreadElement>> cell = new TableCell<ThreadElement, Set<ThreadElement>>() {
        @Override
        protected void updateItem(Set<ThreadElement> item, boolean empty) {
            super.updateItem(item, empty);

            if (item != null && !item.isEmpty() && !empty) {
                final TextFlow threadList = buildThreadListGraphic(this, item);

                if (this.prefHeightProperty().isBound()) {
                    this.prefHeightProperty().unbind();
                }

                this.prefHeightProperty().bind(threadList.heightProperty());
                threadList.prefWidthProperty().bind(this.widthProperty().subtract(-5));

                this.setGraphic(threadList);
                this.layout();
            } else {
                this.setGraphic(null);
            }
        }
    };

    return cell;
}
 
Example #13
Source File: StartPane.java    From pattypan with MIT License 5 votes vote down vote up
private GridPane setContent() {
  this.getStylesheets().add(css);
  this.setAlignment(Pos.CENTER);
  this.setHgap(20);
  this.setVgap(5);
  this.getStyleClass().add("background");

  this.getColumnConstraints().add(Util.newColumn(400, "px"));

  this.addRow(0, new WikiLabel("pattypan").setClass("title"));
  this.addRow(1, new WikiLabel("v. " + Settings.VERSION));
  if (!Session.WIKI.getDomain().equals("commons.wikimedia.org")) {
    this.addRow(3, new WikiLabel(Session.WIKI.getDomain()));
  }

  this.addRow(20, new HBox(20,
          new WikiButton("start-generate-button", "primary")
                  .setWidth(300)
                  .linkTo("ChooseDirectoryPane", stage),
          new WikiButton("start-validate-button")
                  .setWidth(300)
                  .linkTo("LoadPane", stage)));

  this.addRow(22, new HBox(20,
          new WikiLabel("start-generate-description").setWidth(300),
          new WikiLabel("start-validate-description").setWidth(300)));

  String year = new SimpleDateFormat("yyyy").format(new Date());
  this.addRow(40, new WikiLabel(year + " // Pawel Marynowski").setClass("muted"));

  TextFlow flow = new TextFlow(
          new Text(Util.text("start-bug-found")), bugLink,
          new Text(" • "), logFile);
  flow.setTextAlignment(TextAlignment.CENTER);

  this.addRow(41, flow);
  return this;
}
 
Example #14
Source File: SceneGraphTests.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * @param index The index of the desired paragraph box
 * @return The ParagraphText (protected subclass of TextFlow) for the paragraph at the specified index
 */
protected TextFlow getParagraphText(int index) {
    // get the ParagraphBox (protected subclass of Region) 
    Region paragraphBox = getParagraphBox(index);

    // get the ParagraphText (protected subclass of TextFlow)
    return (TextFlow) paragraphBox.getChildrenUnmodifiable().stream()
            .filter(n -> n instanceof TextFlow)
            .findFirst()
            .orElseThrow(() -> new IllegalArgumentException("No TextFlow node found in area at index: " + index));
}
 
Example #15
Source File: LabeledHorizontalBarChart.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@Override
protected void layoutPlotChildren() {
    super.layoutPlotChildren();
    if (labelType == null || labelType == LabelType.NotDisplay || labelType == LabelType.Pop) {
        return;
    }
    for (Node bar : nodeMap.keySet()) {
        TextFlow textFlow = nodeMap.get(bar);
        textFlow.relocate(bar.getBoundsInParent().getMaxX() + 10, bar.getBoundsInParent().getMinY());
    }
}
 
Example #16
Source File: SplitOptionsPane.java    From pdfsam with GNU Affero General Public License v3.0 5 votes vote down vote up
SplitOptionsPane() {
    super(Style.DEFAULT_SPACING);
    getStyleClass().addAll(Style.CONTAINER.css());
    I18nContext ctx = DefaultI18nContext.getInstance();
    levelCombo.setId("bookmarksLevel");
    regexpField.setId("bookmarksRegexp");
    regexpField.setPromptText(ctx.i18n("Regular expression the bookmark has to match"));
    regexpField.setPrefWidth(350);
    getChildren().addAll(createLine(new Label(ctx.i18n("Split at this bookmark level:")), levelCombo),
            createLine(new Label(ctx.i18n("Matching regular expression:")), regexpField, helpIcon(new TextFlow(
                    new Text(ctx.i18n("A regular expression the bookmark text has to match")
                            + System.lineSeparator()),
                    new Text(ctx.i18n(
                            "Example: use .*Chapter.* to match bookmarks containing the word \"Chapter\""))))));
}
 
Example #17
Source File: AutocompleteMenu.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** @param field Field where user entered text
 *  @param text Text entered by user
 *  @param proposal Matching proposal
 *  @return AutocompleteItem that will apply the proposal
 */
private AutocompleteItem createItem(final TextInputControl field,
                                    final String text, final Proposal proposal)
{
    final TextFlow markup = new TextFlow();
    for (MatchSegment seg: proposal.getMatch(text))
    {
        final Label match = new Label(seg.getDescription());
        switch (seg.getType())
        {
        case MATCH:
            match.setTextFill(Color.BLUE);
            match.setFont(highlight_font);
            break;
        case COMMENT:
            match.setTextFill(Color.GRAY);
            match.setFont(highlight_font);
            break;
        case NORMAL:
        default:
        }
        markup.getChildren().add(match);
    }

    return new AutocompleteItem(markup, () ->
    {
        final String value = proposal.apply(text);
        field.setText(value);
        field.positionCaret(value.length());
        invokeAction(field);
    });
}
 
Example #18
Source File: CodeEditor.java    From ARMStrong with Mozilla Public License 2.0 5 votes vote down vote up
/**
   * Creates a new instance of a code editor
   * @param armSimulator the simulator
   */
  public CodeEditor(ArmSimulator armSimulator) {

      mainPane = new AnchorPane();

      this.armSimulator = armSimulator;
      this.textArea = new TextArea();
      this.textFlow = new TextFlow();
      this.scrollPane = new ScrollPane(this.textFlow);
      
      visibleNodes = FXCollections.observableArrayList();
      
      dockNode = new DockNode(mainPane, "Editor");
      dockNode.setPrefSize(300, 100);
      dockNode.setClosable(false);
      
      AnchorPane.setBottomAnchor(this.textArea, 0D);
      AnchorPane.setLeftAnchor(this.textArea, 0D);
      AnchorPane.setRightAnchor(this.textArea, 0D);
      AnchorPane.setTopAnchor(this.textArea, 0D);
      this.mainPane.setMinSize(300, 300);
      
      AnchorPane.setBottomAnchor(this.scrollPane, 0D);
      AnchorPane.setLeftAnchor(this.scrollPane, 0D);
      AnchorPane.setRightAnchor(this.scrollPane, 0D);
      AnchorPane.setTopAnchor(this.scrollPane, 0D);
      
      this.mainPane.getChildren().addAll(this.scrollPane, this.textFlow, this.textArea);
      this.dockNode.getStylesheets().add("/resources/style.css");
      mainPane.setMaxHeight(Double.MAX_VALUE);
      mainPane.setMaxWidth(Double.MAX_VALUE);
      
      scrollPane.vvalueProperty().addListener((obs) -> {
	checkVisible(scrollPane);
});
      scrollPane.hvalueProperty().addListener((obs) -> {
	checkVisible(scrollPane);
});
  }
 
Example #19
Source File: ASTTreeItem.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
TextFlow styledPresentableText(Node node) {
    DesignerBindings bindings = languageBindingsProperty().getOrElse(DefaultDesignerBindings.getInstance());

    Attribute attr = bindings.getMainAttribute(node);

    TextFlow flow = new TextFlow(makeStyledText(node.getXPathNodeName(), NODE_XPATH_NAME_CSS));
    if (attr != null && attr.getStringValue() != null) {
        flow.getChildren().add(makeStyledText(" [", NODE_XPATH_PUNCT_CSS));
        flow.getChildren().add(makeStyledText("@" + attr.getName(), NODE_XPATH_MAIN_ATTR_NAME_CSS));
        flow.getChildren().add(makeStyledText(" = ", NODE_XPATH_PUNCT_CSS));
        flow.getChildren().add(makeStyledText(attrToXpathString(attr), NODE_XPATH_MAIN_ATTR_VALUE_CSS));
        flow.getChildren().add(makeStyledText("]", NODE_XPATH_PUNCT_CSS));
    }
    return flow;
}
 
Example #20
Source File: StyledTextArea.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public StyledTextArea(@NamedArg("initialParagraphStyle") PS initialParagraphStyle,
                      @NamedArg("applyParagraphStyle")   BiConsumer<TextFlow, PS> applyParagraphStyle,
                      @NamedArg("initialTextStyle")      S initialTextStyle,
                      @NamedArg("applyStyle")            BiConsumer<? super TextExt, S> applyStyle,
                      @NamedArg("document")              EditableStyledDocument<PS, String, S> document) {
    this(initialParagraphStyle, applyParagraphStyle,
         initialTextStyle, applyStyle, document, true);
}
 
Example #21
Source File: StyledTextArea.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public StyledTextArea(@NamedArg("initialParagraphStyle") PS initialParagraphStyle,
                      @NamedArg("applyParagraphStyle")   BiConsumer<TextFlow, PS> applyParagraphStyle,
                      @NamedArg("initialTextStyle")      S initialTextStyle,
                      @NamedArg("applyStyle")            BiConsumer<? super TextExt, S> applyStyle,
                      @NamedArg("preserveStyle")         boolean preserveStyle) {
    this(
            initialParagraphStyle,
            applyParagraphStyle,
            initialTextStyle,
            applyStyle,
            new SimpleEditableStyledDocument<>(initialParagraphStyle, initialTextStyle),
            preserveStyle);
}
 
Example #22
Source File: FxHacksJava9.java    From FxDock with Apache License 2.0 5 votes vote down vote up
public CHitInfo getHit(TextFlow t, double x, double y)
{
	HitInfo h = getHitInfo(t, x, y);
	int ix = h.getCharIndex();
	boolean leading = h.isLeading();
	return new CHitInfo(ix, leading);
}
 
Example #23
Source File: DemoHPane.java    From FxDock with Apache License 2.0 5 votes vote down vote up
public DemoHPane()
	{
		super(DemoGenerator.HPANE);
		setTitle("DemoHPane.java");

		String info = "HPane is a horizontal Pane with a single row layout similar to CPane.";

		infoField = new TextFlow(new Text(info));

		p = new CPane();
		p.setGaps(10, 7);
		p.setPadding(10);
		p.addColumns
		(
			CPane.FILL
		);
		p.addRows
		(
			CPane.PREF,
			CPane.PREF,
			CPane.PREF,
			CPane.PREF,
			CPane.PREF,
			CPane.PREF,
			CPane.PREF,
			CPane.PREF,
			CPane.PREF
		);
		int r = 0;
		p.add(0, r++, infoField);
		p.add(0, r++, p(HPane.FILL));
//		p.add(0, r++, p(1.0));
//		p.add(0, r++, p(0.1, HPane.FILL, HPane.FILL, 0.1));
		p.add(0, r++, p(0.1, HPane.FILL));
//		p.add(0, r++, p(HPane.FILL, HPane.FILL));
//		p.add(0, r++, p(HPane.PREF, HPane.PREF, HPane.PREF));
		
		setContent(p);
	}
 
Example #24
Source File: StyledTextArea.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public StyledTextArea(@NamedArg("initialParagraphStyle") PS initialParagraphStyle,
                      @NamedArg("applyParagraphStyle")   BiConsumer<TextFlow, PS> applyParagraphStyle,
                      @NamedArg("initialTextStyle")      S initialTextStyle,
                      @NamedArg("applyStyle")            BiConsumer<? super TextExt, S> applyStyle) {
    this(initialParagraphStyle, applyParagraphStyle,
         initialTextStyle, applyStyle, true);
}
 
Example #25
Source File: StyledTextArea.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public StyledTextArea(@NamedArg("initialParagraphStyle") PS initialParagraphStyle,
                      @NamedArg("applyParagraphStyle")   BiConsumer<TextFlow, PS> applyParagraphStyle,
                      @NamedArg("initialTextStyle")      S initialTextStyle,
                      @NamedArg("applyStyle")            BiConsumer<? super TextExt, S> applyStyle,
                      @NamedArg("document")              EditableStyledDocument<PS, String, S> document,
                      @NamedArg("segmentOps")            TextOps<String, S> segmentOps,
                      @NamedArg("preserveStyle")         boolean preserveStyle) {
    super(initialParagraphStyle, applyParagraphStyle,
            initialTextStyle, document, segmentOps, preserveStyle,
            seg -> createStyledTextNode(seg, applyStyle)
    );
}
 
Example #26
Source File: StepRepresentationMessage.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void drawStepContent() {
    Text textWidget = new Text(textToShow);
    textWidget.setId("stepText");

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setId("stepScrollPane");
    scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    scrollPane.setFitToWidth(true);
    scrollPane.setContent(new TextFlow(textWidget));

    this.addToContentPane(scrollPane);

    VBox.setVgrow(scrollPane, Priority.ALWAYS);
}
 
Example #27
Source File: TweetLayout.java    From TweetwallFX with MIT License 5 votes vote down vote up
private List<TweetWord> recalcTweetLayout() {
    TextFlow flow = new TextFlow();
    flow.setMaxWidth(300);
    pattern.splitAsStream(configuration.tweet.getDisplayEnhancedText())
            .forEach(w -> {
                Text textWord = wordNodeFactory.createTextNode(w.concat(" "));
                fontSizeAdaption(textWord, configuration.tweetFontSize);
                textWord.getStyleClass().setAll("tag");
                flow.getChildren().add(textWord);
            });
    flow.requestLayout();
    return flow.getChildren().stream().map(node -> new TweetWord(node.getBoundsInParent(), ((Text) node).getText())).collect(Collectors.toList());
}
 
Example #28
Source File: SetupDialog.java    From archivo with GNU General Public License v3.0 5 votes vote down vote up
private void initDialog() {
    dialog.setHeaderText("Welcome to Archivo");

    GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);

    List<Text> text = buildExplanationText();
    TextFlow explanation = new TextFlow(text.toArray(new Text[text.size()]));
    explanation.setPrefWidth(EXPLANATION_WIDTH);
    explanation.setLineSpacing(3);
    grid.add(explanation, 0, 0, 2, 1);

    grid.add(new Label("Media access key"), 0, 1);
    TextField mak = new TextField();
    grid.add(mak, 1, 1);

    dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

    // Only enable the OK button after the user has entered the MAK
    Node okButton = dialog.getDialogPane().lookupButton(ButtonType.OK);
    okButton.setDisable(true);
    mak.textProperty().addListener(((observable, oldValue, newValue) -> {
        okButton.setDisable(newValue.trim().isEmpty());
    }));

    dialog.getDialogPane().setContent(grid);

    Platform.runLater(mak::requestFocus);

    dialog.setResultConverter(button -> {
        if (button == ButtonType.OK) {
            return mak.getText().trim();
        }
        return null;
    });
}
 
Example #29
Source File: Controller.java    From game-of-life-java with MIT License 5 votes vote down vote up
@FXML
private void onAbout(Event evt) {
    // TEXT //
    Text text1 = new Text("Conway's Game of Life\n");
    text1.setFont(Font.font(30));
    Text text2 = new Text(
            "\nThe Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.\n"
                    + "The game is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input. One interacts with the Game of Life by creating an initial configuration and observing how it evolves or, for advanced players, by creating patterns with particular properties."
            );
    Text text3 = new Text("\n\nRules\n");
    text3.setFont(Font.font(20));
    Text text4 = new Text(
            "\nThe universe of the Game of Life is a two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead. Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:\n"
                    +"\n1) Any live cell with fewer than two live neighbours dies, as if caused by under-population.\n"
                    +"2) Any live cell with two or three live neighbours lives on to the next generation.\n"
                    +"3) Any live cell with more than three live neighbours dies, as if by overcrowding.\n"
                    +"4) Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.\n\nMore on Wikipedia:\n"
            );

    Hyperlink link = new Hyperlink("http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life <-------not working");
    TextFlow tf = new TextFlow(text1,text2,text3,text4,link);
    tf.setPadding(new Insets(10, 10, 10, 10));
    tf.setTextAlignment(TextAlignment.JUSTIFY);
    // END TEXT, START WINDOW //
    final Stage dialog = new Stage();
    dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.initOwner(new Stage());
    VBox dialogVbox = new VBox(20);
    dialogVbox.getChildren().add(tf);
    Scene dialogScene = new Scene(dialogVbox, 450, 500);
    dialog.setScene(dialogScene);
    dialog.show();
    // END WINDOW //
}
 
Example #30
Source File: DirectionsStepPane.java    From FXMaps with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Parses the text and returns a {@link TextFlow} node containing the proper
 * icon and the directions text which is used to display the 
 * directions information.
 *  
 * @return  the constructed {@link TextFlow}
 */
private TextFlow parseText() {
    String testText = excludeDestinationStatement(text);
    
    TextFlow tf = new TextFlow();
    List<Text> tList = new ArrayList<Text>();
    int len = testText.length();
    int start = 0;
    int idx = 0;
    boolean isBold = false;
    
    while((idx = testText.indexOf("<", start)) != len) {
        if(idx == -1) {
            idx = len;
        }
        Text segment = new Text(testText.substring(start, idx));
        if(isBold) {
            segment.setFont(Font.font(
                segment.getFont().getFamily(), FontWeight.BOLD, segment.getFont().getSize()));
            isBold = false;
        }
        tList.add(segment);
        
        start = testText.indexOf(">", idx) + 1;
        
        if(idx < len && text.substring(idx, idx + 2).indexOf("<b") != -1) {
            isBold = true;
        }
        
        if(idx == len) break;
    }
    
    if(text.length() != testText.length()) {
        tList.add(new Text(" " + text.indexOf("Destination")));
    }
    
    tf.getChildren().addAll(tList);
    
    return tf;
}