javafx.scene.text.Text Java Examples

The following examples show how to use javafx.scene.text.Text. 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: KeyStrokeMotion.java    From marathonv5 with Apache License 2.0 7 votes vote down vote up
private void createLetter(String c) {
    final Text letter = new Text(c);
    letter.setFill(Color.BLACK);
    letter.setFont(FONT_DEFAULT);
    letter.setTextOrigin(VPos.TOP);
    letter.setTranslateX((getWidth() - letter.getBoundsInLocal().getWidth()) / 2);
    letter.setTranslateY((getHeight() - letter.getBoundsInLocal().getHeight()) / 2);
    getChildren().add(letter);
    // over 3 seconds move letter to random position and fade it out
    final Timeline timeline = new Timeline();
    timeline.getKeyFrames().add(
            new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
                @Override public void handle(ActionEvent event) {
                    // we are done remove us from scene
                    getChildren().remove(letter);
                }
            },
            new KeyValue(letter.translateXProperty(), getRandom(0.0f, getWidth() - letter.getBoundsInLocal().getWidth()),INTERPOLATOR),
            new KeyValue(letter.translateYProperty(), getRandom(0.0f, getHeight() - letter.getBoundsInLocal().getHeight()),INTERPOLATOR),
            new KeyValue(letter.opacityProperty(), 0f)
    ));
    timeline.play();
}
 
Example #2
Source File: TabIndicatorSkin.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void initialise() {
    final Region circle = new Region();
    circle.getStyleClass().add("indicator-circle");

    final Text text = new Text();
    text.getStyleClass().add("indicator-information");
    text.textProperty().bind(getControl().textProperty());

    final StackPane container = new StackPane(circle, text);
    container.getStyleClass().add("indicator-container");

    final StackPane tabIndicator = new StackPane(container);
    tabIndicator.getStyleClass().add("tab-indicator");

    getChildren().add(tabIndicator);
}
 
Example #3
Source File: Main.java    From stagedisplayviewer with MIT License 6 votes vote down vote up
@Override
public void start(final Stage primaryStage) throws IOException {
    log.info("Starting program");
    final FxUtils fxUtils = new FxUtils();

    Property.loadProperties();

    Text lowerKey = fxUtils.createLowerKey();
    midiModule = new MidiModule();
    lowerKeyHandler = new LowerKeyHandler(lowerKey, midiModule);
    thread = new Thread(lowerKeyHandler);

    primaryStage.setTitle(PROGRAM_TITLE);
    Scene scene = fxUtils.createScene(lowerKey);
    scene.setOnKeyTyped(new SceneKeyTypedHandler(primaryStage));
    primaryStage.setScene(scene);
    fxUtils.startOnCorrectScreen(primaryStage);
    primaryStage.setOnCloseRequest(getEventHandler());
    primaryStage.setFullScreen(Property.START_IN_FULLSCREEN.isTrue());
    primaryStage.show();
    thread.start();
}
 
Example #4
Source File: CycleStepTileSkin.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    chartItems = new ArrayList<>();
    double sum = tile.getChartData().stream().mapToDouble(chartData -> chartData.getValue()).sum();
    tile.getChartData().forEach(chartData -> chartItems.add(new ChartItem(chartData, sum)));

    chartBox = new VBox(0);
    chartBox.setFillWidth(true);
    chartBox.getChildren().addAll(chartItems);

    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());

    getPane().getChildren().addAll(titleText, text, chartBox);
}
 
Example #5
Source File: ParticlesClockApp.java    From FXTutorials with MIT License 6 votes vote down vote up
private void populateDigits() {
    for (int i = 0; i < digits.length; i++) {
        digits[i] = new Digit();

        Text text = new Text(i + "");
        text.setFont(Font.font(144));
        text.setFill(Color.BLACK);

        Image snapshot = text.snapshot(null, null);

        for (int y = 0; y < snapshot.getHeight(); y++) {
            for (int x = 0; x < snapshot.getWidth(); x++) {
                if (snapshot.getPixelReader().getColor(x, y).equals(Color.BLACK)) {
                    digits[i].positions.add(new Point2D(x, y));
                }
            }
        }

        if (digits[i].positions.size() > maxParticles) {
            maxParticles = digits[i].positions.size();
        }
    }
}
 
Example #6
Source File: Main.java    From JFX-Browser with MIT License 6 votes vote down vote up
public static void setDialouge(JFXButton applyButton , String heading , String text , Node ob) {
	
	JFXButton button = applyButton;
	
	content.setHeading(new Text(heading));
	content.setBody(new Text(text));
	
	JFXDialog dialoge = new JFXDialog(pane, content, JFXDialog.DialogTransition.CENTER);
	button.addEventHandler(MouseEvent.MOUSE_CLICKED, (e6) -> {
		dialoge.close();
	});
	
	content.setActions(ob, button);
	
	// To show overlay dialougge box
	dialoge.show();
}
 
Example #7
Source File: TableFileSizeCell.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public TableCell<T, Long> call(TableColumn<T, Long> param) {
    TableCell<T, Long> cell = new TableCell<T, Long>() {
        private final Text text = new Text();

        @Override
        protected void updateItem(final Long item, boolean empty) {
            super.updateItem(item, empty);
            if (empty || item == null || (long) item <= 0) {
                setText(null);
                setGraphic(null);
                return;
            }
            text.setText(FileTools.showFileSize((long) item));
            setGraphic(text);
        }
    };
    return cell;
}
 
Example #8
Source File: ErrorCell.java    From Recaf with MIT License 6 votes vote down vote up
@Override
public void updateItem(Pair<Integer, String> item, boolean empty) {
	super.updateItem(item, empty);
	if(empty) {
		setText(null);
		setGraphic(null);
	} else {
		setText(item.getValue());
		int index = item.getKey();
		Node g = new Text(String.valueOf(index + 1));
		g.getStyleClass().addAll("bold", "error-cell");
		setGraphic(g);
		// on-click: go to line
		if(index >= 0) {
			setOnMouseClicked(me -> {
				codeArea.moveTo(index, 0);
				codeArea.requestFollowCaret();
				codeArea.requestFocus();
			});
		} else {
			setText(getText() + "\n(Cannot resolve line number from error)");
		}
	}
}
 
Example #9
Source File: Exercise_15_08a.java    From Intro-to-Java-Programming with MIT License 6 votes vote down vote up
@Override // Override the start method on the Application class
public void start(Stage primaryStage) {
	// Create a pane
	Pane pane = new Pane();

	// Create and register the handler
	pane.setOnMouseClicked(e -> {
		pane.getChildren().clear();
		pane.getChildren().add(new Text(e.getX(), e.getY(),
			"(" + e.getX() + ", " + e.getY() + ")"));
	});

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 200, 200);
	primaryStage.setTitle("Exercise_15_08a"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example #10
Source File: SVGGrid.java    From latexdraw with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates the SVG element corresponding to the labels of the grid.
 */
private void createSVGGridLabels(final SVGDocument document, final SVGElement elt, final String prefix, final double minX, final double maxX, final double
	minY, final double maxY, final double tlx, final double tly, final double xStep, final double yStep, final double gridWidth, final double absStep) {
	final Color gridLabelsColor = shape.getGridLabelsColour();
	final SVGElement texts = new SVGGElement(document);
	final double originX = shape.getOriginX();
	final double originY = shape.getOriginY();
	final double xorigin = xStep * originX;
	final Text fooText = new Text(String.valueOf((int) maxX));
	fooText.setFont(new Font(null, shape.getLabelsSize()));
	final double labelHeight = fooText.getBaselineOffset();
	final double labelWidth = fooText.getBoundsInLocal().getWidth();
	final double yorigin = shape.isXLabelSouth() ? yStep * originY + labelHeight : yStep * originY - 2d;

	texts.setAttribute(SVGAttributes.SVG_FONT_SIZE, String.valueOf(shape.getLabelsSize()));
	texts.setAttribute(SVGAttributes.SVG_STROKE, CSSColors.INSTANCE.getColorName(gridLabelsColor, true));
	texts.setAttribute(prefix + LNamespace.XML_TYPE, LNamespace.XML_TYPE_TEXT);

	if(gridLabelsColor.getO() < 1d) {
		texts.setAttribute(SVGAttributes.SVG_OPACITY, MathUtils.INST.format.format(gridLabelsColor.getO()));
	}

	produceSVGGridLabelsTexts(document, texts, gridWidth, xorigin, yorigin, fooText, minX, maxX, minY, maxY, tlx, tly, labelWidth, labelHeight, absStep);

	elt.appendChild(texts);
}
 
Example #11
Source File: guiCollector.java    From SeedSearcherStandaloneTool with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Some Biomes come back as null. No idea. The Names match each other so it
 * should work (Apparently it works like 1 in 10 times...)
 *
 * @return
 */
private List<String> comboBoxManager(GridPane pane, String inORex) {
    List<String> checkedTexts = new ArrayList<String>();
    int k = 0;
    for(int i = 0; i < (pane.getChildren().size() / 3) + 1; i++) {
        for(int j =0; j < 3; j++) {
            //Adding an empty pane to the grid to fill in blanks check based on visiblity because its the only object going to be invisible
            if(pane.getChildren().get(k).isVisible()){
                VBox tempVbox = (VBox) pane.getChildren().get(k);
                Text tempText = (Text) tempVbox.getChildren().get(0);
                ComboBox tempCombo = (ComboBox) tempVbox.getChildren().get(1);
                if (tempCombo.getValue() != null && tempCombo.getValue().equals(inORex)) {
                    checkedTexts.add(tempText.getText());
                }
                k++;
            }
        }
    }

   return checkedTexts;
}
 
Example #12
Source File: ParetoInfoPopup.java    From charts with Apache License 2.0 6 votes vote down vote up
private void addLine(String title, String value) {
    rowCount++;
    Text titleText = new Text(title);
    titleText.setFill(_textColor);
    titleText.setFont(regularFont);

    Text valueText = new Text(value);
    valueText.setFill(_textColor);
    valueText.setFont(regularFont);

    vBoxTitles.getChildren().add(titleText);
    vBoxValues.getChildren().add(valueText);

    Helper.enableNode(titleText, true);
    Helper.enableNode(valueText, true);
}
 
Example #13
Source File: TextTileSkin.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

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

    description = new Label(tile.getDescription());
    description.setAlignment(tile.getDescriptionAlignment());
    description.setTextAlignment(TextAlignment.RIGHT);
    description.setWrapText(true);
    description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS);
    description.setTextFill(tile.getTextColor());
    description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795);
    Helper.enableNode(description, tile.isTextVisible());

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

    getPane().getChildren().addAll(titleText, text, description);
}
 
Example #14
Source File: Text3DHelper.java    From FXyzLib with GNU General Public License v3.0 6 votes vote down vote up
public Text3DHelper(String text, String font, int size){
    this.text=text;
    list=new ArrayList<>();
    
    Text textNode = new Text(text);
    textNode.setFont(new Font(font,size));
    
    // Convert Text to Path
    Path subtract = (Path)(Shape.subtract(textNode, new Rectangle(0, 0)));
    // Convert Path elements into lists of points defining the perimeter (exterior or interior)
    subtract.getElements().forEach(this::getPoints);
    
    // Group exterior polygons with their interior polygons
    polis.stream().filter(LineSegment::isHole).forEach(hole->{
        polis.stream().filter(poly->!poly.isHole())
                .filter(poly->!((Path)Shape.intersect(poly.getPath(), hole.getPath())).getElements().isEmpty())
                .filter(poly->poly.getPath().contains(new Point2D(hole.getOrigen().x,hole.getOrigen().y)))
                .forEach(poly->poly.addHole(hole));
    });        
    polis.removeIf(LineSegment::isHole);                
}
 
Example #15
Source File: SpaceInvadersFactory.java    From FXGLGames with MIT License 6 votes vote down vote up
@Spawns("LevelInfo")
public Entity newLevelInfo(SpawnData data) {
    Text levelText = getUIFactoryService().newText("Level " + geti("level"), Color.AQUAMARINE, 44);

    Entity levelInfo = entityBuilder()
            .view(levelText)
            .with(new ExpireCleanComponent(Duration.seconds(LEVEL_START_DELAY)))
            .build();

    animationBuilder()
            .interpolator(Interpolators.BOUNCE.EASE_OUT())
            .duration(Duration.seconds(LEVEL_START_DELAY - 0.1))
            .translate(levelInfo)
            .from(new Point2D(getAppWidth() / 2 - levelText.getLayoutBounds().getWidth() / 2, 0))
            .to(new Point2D(getAppWidth() / 2 - levelText.getLayoutBounds().getWidth() / 2, getAppHeight() / 2))
            .buildAndPlay();

    return levelInfo;
}
 
Example #16
Source File: TextClockSkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
@Override protected void initGraphics() {
    // Set initial size
    if (Double.compare(clock.getPrefWidth(), 0.0) <= 0 || Double.compare(clock.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(clock.getWidth(), 0.0) <= 0 || Double.compare(clock.getHeight(), 0.0) <= 0) {
        if (clock.getPrefWidth() > 0 && clock.getPrefHeight() > 0) {
            clock.setPrefSize(clock.getPrefWidth(), clock.getPrefHeight());
        } else {
            clock.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    timeText = new Text();
    timeText.setTextOrigin(VPos.CENTER);
    timeText.setFill(textColor);

    dateText = new Text();
    dateText.setTextOrigin(VPos.CENTER);
    dateText.setFill(dateColor);

    pane = new Pane(timeText, dateText);
    pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(clock.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example #17
Source File: MKXMenuApp.java    From FXTutorials with MIT License 6 votes vote down vote up
private Node createRightContent() {
    String title = "Please Subscribe :)";
    HBox letters = new HBox(0);
    letters.setAlignment(Pos.CENTER);
    for (int i = 0; i < title.length(); i++) {
        Text letter = new Text(title.charAt(i) + "");
        letter.setFont(FONT);
        letter.setFill(Color.WHITE);
        letter.setOpacity(0);
        letters.getChildren().add(letter);

        FadeTransition ft = new FadeTransition(Duration.seconds(2), letter);
        ft.setDelay(Duration.millis(i * 50));
        ft.setToValue(1);
        ft.setAutoReverse(true);
        ft.setCycleCount(TranslateTransition.INDEFINITE);
        ft.play();
    }

    return letters;
}
 
Example #18
Source File: Gui.java    From ARMStrong with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * display a warning popup
 * @param message the message to display
 * @param okEvent an event fired when the user presses the ok button
 */
public static void warningPopup(String message, EventHandler<ActionEvent> okEvent) {
	final Stage warningStage = new Stage();
	warningStage.setTitle("Warning");

	warningStage.initModality(Modality.APPLICATION_MODAL);
	warningStage.setResizable(false);

	try {
		Pane main = FXMLLoader.load(Gui.class.getResource("/resources/warning.fxml"));
		warningStage.setScene(new Scene(main, 500, 280));

		Text messageText = (Text) main.lookup("#message");
		messageText.setText(message);

		ImageView image = (ImageView) main.lookup("#image");
		image.setImage(new Image(Gui.class.getResource("/resources/warning.png").toExternalForm()));

		Button okButton = (Button) main.lookup("#ok");
		Button cancelButton = (Button) main.lookup("#cancel");
		okButton.setOnAction(okEvent);
		okButton.setOnMouseReleased(mouseEvent -> warningStage.close());
		okButton.setOnKeyPressed(keyEvent -> warningStage.close());

		cancelButton.setOnAction(actionEvent1 -> warningStage.close());

	} catch (IOException e) {
		e.printStackTrace();
	}
	warningStage.show();
}
 
Example #19
Source File: SettingsDialog.java    From mdict-java with GNU General Public License v3.0 5 votes vote down vote up
static HBox make_simple_switcher(ResourceBundle bundle, ChangeListener<? super Boolean> listener, String message, boolean enabled) {
	ToggleSwitch switcher = new ToggleSwitch();
	switcher.setId(message);
	switcher.selectedProperty().addListener(listener);
	switcher.setSelected(enabled);
	HBox vb1 = new HBox(switcher, new Text(bundle.getString(message)));
	vb1.setPadding(padding);
	return vb1;
}
 
Example #20
Source File: SpaceRunnerFactory.java    From FXGLGames with MIT License 5 votes vote down vote up
@Spawns("ai_point")
public Entity newAIPoint(SpawnData data) {
    return entityBuilder()
            .from(data)
            .type(SpaceRunnerType.AI_POINT)
            .bbox(new HitBox("MAIN", new Point2D(-400, 0), BoundingShape.box(400, 30)))
            .view(new Text())
            .with("collisions", new ArrayList<Entity>())
            .with("enemies", 0)
            .with(new AIPointComponent())
            .with(new CollidableComponent(true), new MoveComponent())
            .build();
}
 
Example #21
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 A list of text nodes which render the text in the ParagraphBox 
 *         specified by the given index.
 */
protected List<Text> getTextNodes(int index) {
    TextFlow tf = getParagraphText(index);

    List<Text> result = new ArrayList<>();
    tf.getChildrenUnmodifiable().filtered(n -> n instanceof Text).forEach(n -> result.add((Text) n));
    return result;
}
 
Example #22
Source File: LogInViewController.java    From Corendon-LostLuggage with MIT License 5 votes vote down vote up
private void showAlertMessage() {
    stackPane.setVisible(true);
    MESSAGE_FLOW.getChildren().clear();

    //Customize header
    Text header = new Text(alertHeader);
    header.setFont(new Font("System", 18));
    header.setFill(Paint.valueOf(headerColor));

    JFXButton hideMessageButton = new JFXButton(buttonText);
    //Customize button
    hideMessageButton.setStyle("-fx-background-color: #4dadf7");
    hideMessageButton.setTextFill(Paint.valueOf("#FFFFFF"));
    hideMessageButton.setRipplerFill(Paint.valueOf("#FFFFFF"));
    hideMessageButton.setButtonType(JFXButton.ButtonType.RAISED);

    MESSAGE_FLOW.getChildren().add(new Text(alert));
    DIALOG_LAYOUT.setHeading(header);
    DIALOG_LAYOUT.setBody(MESSAGE_FLOW);
    DIALOG_LAYOUT.setActions(hideMessageButton);
    JFXDialog alertView = new JFXDialog(stackPane, DIALOG_LAYOUT, JFXDialog.DialogTransition.CENTER);
    alertView.setOverlayClose(false);
    hideMessageButton.setOnAction(e -> {
        alertView.close();
        stackPane.setVisible(false);
    });

    alertView.show();
}
 
Example #23
Source File: EdgeLabelPart.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Group doCreateVisual() {
	Text text = createText();
	Group g = new Group();
	g.getStyleClass().add(EdgePart.CSS_CLASS);
	g.getChildren().add(text);
	return g;
}
 
Example #24
Source File: LinearSkin.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #25
Source File: Alarm.java    From FXTutorials with MIT License 5 votes vote down vote up
public Alarm(LocalTime time) {
    this.time = time;

    getStyleClass().add("alarm");

    Text text = new Text(time.toString());
    text.getStyleClass().add("alarm_text");

    getChildren().add(text);
    setAlignment(Pos.CENTER_LEFT);
}
 
Example #26
Source File: SlimSkin.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #27
Source File: FxUtils.java    From stagedisplayviewer with MIT License 5 votes vote down vote up
public Scene createScene(Text lowerKey) {
    Rectangle2D bounds = getScreenBounds();
    Scene scene = new Scene(createRoot(lowerKey), bounds.getWidth(), bounds.getHeight());
    scene.getStylesheets().add("styles.css");
    try {
        scene.getStylesheets().add(new File("styles.css").toURI().toURL().toString());
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    return scene;
}
 
Example #28
Source File: ClockTileSkin.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    currentValueListener = o -> {
        if (tile.isRunning()) { return; } // Update time only if clock is not already running
        updateTime(ZonedDateTime.ofInstant(Instant.ofEpochSecond(tile.getCurrentTime()), ZoneId.of(ZoneId.systemDefault().getId())));
    };
    timeListener         = o -> updateTime(tile.getTime());

    timeFormatter      = DateTimeFormatter.ofPattern("HH:mm", tile.getLocale());
    dateFormatter      = DateTimeFormatter.ofPattern("dd MMM YYYY", tile.getLocale());
    dayOfWeekFormatter = DateTimeFormatter.ofPattern("EEEE", tile.getLocale());

    titleText = new Text("");
    titleText.setTextOrigin(VPos.TOP);
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

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

    timeRect = new Rectangle();

    timeText = new Text(timeFormatter.format(tile.getTime()));
    timeText.setTextOrigin(VPos.CENTER);

    dateText = new Text(dateFormatter.format(tile.getTime()));

    dayOfWeekText = new Text(dayOfWeekFormatter.format(tile.getTime()));

    getPane().getChildren().addAll(titleText, text, timeRect, timeText, dateText, dayOfWeekText);
}
 
Example #29
Source File: CustomNodeExample.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Group doCreateVisual() {
	ImageView ian = new ImageView(new javafx.scene.image.Image(
			getClass().getResource("ibull.jpg").toExternalForm()));
	Polyline body = new Polyline(0, 0, 0, 60, 25, 90, 0, 60, -25, 90, 0,
			60, 0, 25, 25, 0, 0, 25, -25, 0);
	body.setTranslateX(ian.getLayoutBounds().getWidth() / 2
			- body.getLayoutBounds().getWidth() / 2 - 5);
	body.setTranslateY(-15);
	labelText = new Text();
	vbox = new VBox();
	vbox.getChildren().addAll(ian, body, labelText);
	return new Group(vbox);
}
 
Example #30
Source File: Helper.java    From Medusa with Apache License 2.0 5 votes vote down vote up
public static final void adjustTextSize(final Text TEXT, final double MAX_WIDTH, final double FONT_SIZE) {
    final String FONT_NAME          = TEXT.getFont().getName();
    double       adjustableFontSize = FONT_SIZE;
    while (TEXT.getLayoutBounds().getWidth() > MAX_WIDTH && adjustableFontSize > MIN_FONT_SIZE) {
        adjustableFontSize -= 0.1;
        TEXT.setFont(new Font(FONT_NAME, adjustableFontSize));
    }
}