Java Code Examples for javafx.scene.text.FontWeight

The following examples show how to use javafx.scene.text.FontWeight. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: constellation   Source File: AttributeCalculatorPane.java    License: Apache License 2.0 6 votes vote down vote up
private void updateTemplateObjectHelp(final String itemName, final String itemDescription) {

        templateObjectHelp.getChildren().clear();

        final Text objectNameText = new Text(itemName + ":\n");
        objectNameText.setFont(Font.font(FONT_FAMILY, FontWeight.NORMAL, 16));
        objectNameText.setFill(Color.web(TEXT_COLOR));
        templateObjectHelp.getChildren().add(objectNameText);

        String objDescrip = "   " + itemDescription + "\n";
        final Text objectDescripText = new Text(objDescrip + "\n");
        objectDescripText.setFont(Font.font(FONT_FAMILY, FontWeight.BOLD, 12));
        objectDescripText.setFill(Color.WHITE);
        objectDescripText.setFontSmoothingType(FontSmoothingType.LCD);
        templateObjectHelp.getChildren().add(objectDescripText);

    }
 
Example 2
Source Project: constellation   Source File: AttributeCalculatorPane.java    License: Apache License 2.0 6 votes vote down vote up
private void updateAttributeDescriptionHelp(String attributeName, String attributeDescription, String attributeType) {
    Platform.runLater(() -> {
        attributeDescriptionHelp.getChildren().clear();
        final Text attributeHeadingText = new Text("Attribute to set:\n");
        attributeHeadingText.setFont(Font.font(FONT_FAMILY, FontWeight.NORMAL, 16));
        attributeHeadingText.setFill(Color.web(TEXT_COLOR));
        final Text attributeLabelText = new Text(attributeName);
        attributeLabelText.setFont(Font.font(FONT_FAMILY, FontWeight.BOLD, 12));
        attributeLabelText.setFill(Color.WHITE);
        final Text attributeSpacingText = new Text("  -  ");
        attributeSpacingText.setFont(Font.font(FONT_FAMILY, FontWeight.NORMAL, 12));
        attributeSpacingText.setFill(Color.WHITE);
        final Text attributeDescriptionText = new Text(attributeDescription);
        attributeDescriptionText.setFont(Font.font(FONT_FAMILY, FontPosture.ITALIC, 12));
        attributeDescriptionText.setFill(Color.WHITE);
        final Text attributeTypeText = new Text("    (type:  " + attributeType + ")");
        attributeTypeText.setFont(Font.font(FONT_FAMILY, FontWeight.NORMAL, 12));
        attributeTypeText.setFill(Color.WHITE);
        attributeDescriptionHelp.getChildren().addAll(attributeHeadingText, attributeLabelText, attributeSpacingText, attributeDescriptionText, attributeTypeText);
    });
}
 
Example 3
Source Project: marathonv5   Source File: HTMLEditorSample.java    License: Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {

        Text htmlStart = new Text("<html>");
        Text htmlEnd = new Text("</html>");
        htmlStart.setFont(Font.font(null, FontWeight.BOLD, 20));
        htmlStart.setStyle("-fx-font-size: 20px;");
        htmlStart.setTextOrigin(VPos.TOP);
        htmlStart.setLayoutY(11);
        htmlStart.setLayoutX(20);

        htmlEnd.setFont(Font.font(null, FontWeight.BOLD, 20));
        htmlEnd.setStyle("-fx-font-size: 20px;");
        htmlEnd.setTextOrigin(VPos.TOP);
        htmlEnd.setLayoutY(31);
        htmlEnd.setLayoutX(20);

        return new Group(htmlStart, htmlEnd);
    }
 
Example 4
Source Project: marathonv5   Source File: DropShadowSample.java    License: Apache License 2.0 6 votes vote down vote up
public DropShadowSample() {
    Text sample = new Text(0,40,"DropShadow Effect");
    sample.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD,36));
    final DropShadow dropShadow = new DropShadow();
    sample.setEffect(dropShadow);
    getChildren().add(sample);
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Radius", dropShadow.radiusProperty(), 0d, 20d),
            new SimplePropertySheet.PropDesc("Offset X", dropShadow.offsetXProperty(), -10d, 10d),
            new SimplePropertySheet.PropDesc("Offset Y", dropShadow.offsetYProperty(), -10d, 10d),
            new SimplePropertySheet.PropDesc("Spread", dropShadow.spreadProperty(), 0d, 1d),
            new SimplePropertySheet.PropDesc("Color", dropShadow.colorProperty())
    );
    // END REMOVE ME
}
 
Example 5
Source Project: marathonv5   Source File: StringBindingSample.java    License: Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    Text text = new Text("abc");
    text.setTextOrigin(VPos.TOP);
    text.setLayoutX(10);
    text.setLayoutY(11);
    text.setFill(Color.BLACK);
    text.setOpacity(0.5);
    text.setFont(Font.font(null, FontWeight.BOLD, 20));
    text.setStyle("-fx-font-size: 20px;");

    Text text2 = new Text("abc");
    text2.setTextOrigin(VPos.TOP);
    text2.setLayoutX(28);
    text2.setLayoutY(51);
    text2.setFill(Color.BLACK);
    text2.setFont(javafx.scene.text.Font.font(null, FontWeight.BOLD, 20));
    text2.setStyle("-fx-font-size: 20px;");
            
    Line line = new Line(30, 32, 45, 57);
    line.setStroke(Color.DARKMAGENTA);

    return new javafx.scene.Group(text, line, text2);
}
 
Example 6
Source Project: marathonv5   Source File: ImagePanel.java    License: Apache License 2.0 6 votes vote down vote up
private void drawGraphics() {
    graphics.clearRect(0, 0, canvas.getWidth(), canvas.getHeight());
    graphics.drawImage(image, 0, 0);
    if (annotations.size() > 0) {
        for (int i = 0; i < annotations.size(); i++) {
            Annotation annotationFX = annotations.get(i);
            double x = annotationFX.getX();
            double y = annotationFX.getY();
            graphics.setFill(ANNOTATION_COLOR);
            graphics.fillRect(x, y, annotationFX.getWidth(), annotationFX.getHeight());
            graphics.setFill(Color.RED);
            graphics.fillArc(x - 25, y - 25, 50, 50, 270, 90, ArcType.ROUND);
            graphics.setFill(Color.WHITE);
            graphics.setFont(Font.font(null, FontWeight.EXTRA_BOLD, 14));
            if (i > 8) {
                graphics.fillText(Integer.toString(i + 1), x + 5, y + 15);
            } else {
                graphics.fillText(Integer.toString(i + 1), x + 5, y + 15);
            }
        }
    }
}
 
Example 7
Source Project: marathonv5   Source File: ResultPane.java    License: Apache License 2.0 6 votes vote down vote up
private void setLabel() {
    String text;
    if (failuresList == null) {
        text = "";
    } else if (failuresList.size() > 0) {
        String errorString = failuresList.size() == 1 ? " error" : " errors";
        text = failuresList.size() + errorString;
        tableLabel.setTextFill(Color.RED);
    } else {
        text = "No Errors";
        tableLabel.setTextFill(Color.GREEN);
    }

    tableLabel.setText(text);
    tableLabel.setFont(Font.font(tableLabel.getFont().toString(), FontWeight.BOLD, 12));
    tableLabel.setLabelFor(resultTable);
}
 
Example 8
Source Project: marathonv5   Source File: StatusBar.java    License: Apache License 2.0 6 votes vote down vote up
public StatusBar() {
    setId("status-bar");
    msgLabel = createLabel("");
    extraLabel = createLabel("               ");
    extraLabel.setFont(Font.font("System", FontPosture.ITALIC, 12.0));
    fixtureLabel = createLabel("       ");
    fixtureLabel.setFont(Font.font("System", FontWeight.BOLD, 12.0));
    rowLabel = createLabel("       ");
    columnLabel = createLabel("       ");
    insertLabel = createLabel("               ");
    Region region = new Region();
    getChildren().addAll(msgLabel, region, createSeparator(), extraLabel, createSeparator(), fixtureLabel, createSeparator(),
            rowLabel, createSeparator(), columnLabel, createSeparator(), insertLabel, createSeparator());
    HBox.setHgrow(region, Priority.ALWAYS);
    getStylesheets().add(ModalDialog.class.getClassLoader().getResource("net/sourceforge/marathon/fx/api/css/marathon.css")
            .toExternalForm());
}
 
Example 9
Source Project: marathonv5   Source File: HTMLEditorSample.java    License: Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {

        Text htmlStart = new Text("<html>");
        Text htmlEnd = new Text("</html>");
        htmlStart.setFont(Font.font(null, FontWeight.BOLD, 20));
        htmlStart.setStyle("-fx-font-size: 20px;");
        htmlStart.setTextOrigin(VPos.TOP);
        htmlStart.setLayoutY(11);
        htmlStart.setLayoutX(20);

        htmlEnd.setFont(Font.font(null, FontWeight.BOLD, 20));
        htmlEnd.setStyle("-fx-font-size: 20px;");
        htmlEnd.setTextOrigin(VPos.TOP);
        htmlEnd.setLayoutY(31);
        htmlEnd.setLayoutX(20);

        return new Group(htmlStart, htmlEnd);
    }
 
Example 10
Source Project: marathonv5   Source File: DropShadowSample.java    License: Apache License 2.0 6 votes vote down vote up
public DropShadowSample() {
    Text sample = new Text(0,40,"DropShadow Effect");
    sample.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD,36));
    final DropShadow dropShadow = new DropShadow();
    sample.setEffect(dropShadow);
    getChildren().add(sample);
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Radius", dropShadow.radiusProperty(), 0d, 20d),
            new SimplePropertySheet.PropDesc("Offset X", dropShadow.offsetXProperty(), -10d, 10d),
            new SimplePropertySheet.PropDesc("Offset Y", dropShadow.offsetYProperty(), -10d, 10d),
            new SimplePropertySheet.PropDesc("Spread", dropShadow.spreadProperty(), 0d, 1d),
            new SimplePropertySheet.PropDesc("Color", dropShadow.colorProperty())
    );
    // END REMOVE ME
}
 
Example 11
Source Project: marathonv5   Source File: StringBindingSample.java    License: Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    Text text = new Text("abc");
    text.setTextOrigin(VPos.TOP);
    text.setLayoutX(10);
    text.setLayoutY(11);
    text.setFill(Color.BLACK);
    text.setOpacity(0.5);
    text.setFont(Font.font(null, FontWeight.BOLD, 20));
    text.setStyle("-fx-font-size: 20px;");

    Text text2 = new Text("abc");
    text2.setTextOrigin(VPos.TOP);
    text2.setLayoutX(28);
    text2.setLayoutY(51);
    text2.setFill(Color.BLACK);
    text2.setFont(javafx.scene.text.Font.font(null, FontWeight.BOLD, 20));
    text2.setStyle("-fx-font-size: 20px;");
            
    Line line = new Line(30, 32, 45, 57);
    line.setStroke(Color.DARKMAGENTA);

    return new javafx.scene.Group(text, line, text2);
}
 
Example 12
Source Project: java-ml-projects   Source File: App.java    License: Apache License 2.0 6 votes vote down vote up
private Parent buildUI() {
	fc = new FileChooser();
	fc.getExtensionFilters().clear();
	ExtensionFilter jpgFilter = new ExtensionFilter("JPG, JPEG images", "*.jpg", "*.jpeg", "*.JPG", ".JPEG");
	fc.getExtensionFilters().add(jpgFilter);
	fc.setSelectedExtensionFilter(jpgFilter);
	fc.setTitle("Select a JPG image");
	lstLabels = new ListView<>();
	lstLabels.setPrefHeight(200);
	Button btnLoad = new Button("Select an Image");
	btnLoad.setOnAction(e -> validateUrlAndLoadImg());

	HBox hbBottom = new HBox(10, btnLoad);
	hbBottom.setAlignment(Pos.CENTER);

	loadedImage = new ImageView();
	loadedImage.setFitWidth(300);
	loadedImage.setFitHeight(250);
	
	Label lblTitle = new Label("Label image using TensorFlow");
	lblTitle.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD, 40));
	VBox root = new VBox(10,lblTitle, loadedImage, new Label("Results:"), lstLabels, hbBottom);
	root.setAlignment(Pos.TOP_CENTER);
	return root;
}
 
Example 13
Source Project: arma-dialog-creator   Source File: HistoryListPopup.java    License: MIT License 6 votes vote down vote up
public HistoryListItemNode(@NotNull HistoryListItem item) {
	super(5);
	final VBox vboxTitle = new VBox(5);
	final Label lblTitle = new Label(item.getItemTitle());
	lblTitle.setFont(Font.font(15));
	vboxTitle.getChildren().add(lblTitle);

	Font subInfoLabelFont = Font.font(Font.getDefault().getFamily(), FontWeight.BOLD, 10);
	Font subInfoTextFont = Font.font(subInfoLabelFont.getSize());
	for (HistoryListItemSubInfo subInfo : item.getSubInfo()) {
		final Label lbl = new Label(subInfo.getLabel());
		lbl.setFont(subInfoLabelFont);
		final Label lblInfo = new Label(subInfo.getInfo());
		lblInfo.setFont(subInfoTextFont);
		vboxTitle.getChildren().add(new HBox(5, lbl, lblInfo));
	}

	getChildren().add(vboxTitle);
	final Label lblMainInfo = new Label(item.getInformation());
	lblMainInfo.setWrapText(true);
	getChildren().add(lblMainInfo);
}
 
Example 14
Source Project: youtube-comment-suite   Source File: LetterAvatar.java    License: MIT License 6 votes vote down vote up
private void draw() {
    Canvas canvas = new Canvas(scale, scale);
    GraphicsContext gc = canvas.getGraphicsContext2D();

    gc.setFill(Color.TRANSPARENT);
    gc.fillRect(0, 0, scale, scale);

    gc.setFill(background);
    gc.fillRect(0, 0, scale, scale);

    gc.setFill(Color.WHITE);
    gc.setTextAlign(TextAlignment.CENTER);
    gc.setTextBaseline(VPos.CENTER);
    gc.setFont(Font.font("Tahoma", FontWeight.SEMI_BOLD, scale * 0.6));

    gc.fillText(String.valueOf(character), Math.round(scale / 2.0), Math.round(scale / 2.0));
    Platform.runLater(() -> canvas.snapshot(null, this));
}
 
Example 15
Source Project: FXMaps   Source File: MapPane.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Called internally to configure size, position and style of the overlay.
 */
private void configureOverlay() {
    dimmer = new StackPane();
    dimmer.setManaged(false);
    dimmerMessage = new Label(DEFAULT_OVERLAY_MESSAGE);
    dimmerMessage.setFont(Font.font(dimmerMessage.getFont().getFamily(), FontWeight.BOLD, 18));
    dimmerMessage.setTextFill(Color.WHITE);
    dimmer.getChildren().add(dimmerMessage);
    dimmer.setStyle("-fx-background-color: rgba(0, 0, 0, 0.6);");
    getChildren().add(dimmer);
    
    layoutBoundsProperty().addListener((v, o, n) -> {
        Platform.runLater(() -> {
            if(MapPane.this.getScene().getWindow() == null) return;
            Point2D mapPoint = contentPane.localToParent(0, 0);
            double topHeight = contentPane.getTop() == null ? 0 : contentPane.getTop().getLayoutBounds().getHeight();
            dimmer.resizeRelocate(mapPoint.getX(), mapPoint.getY() + topHeight, 
                contentPane.getWidth(), contentPane.getHeight() - topHeight);
        });
    });
}
 
Example 16
@Override
public void start(Stage theStage) 
{
    theStage.setTitle( "Canvas Example" );
    
    Group root = new Group();
    Scene theScene = new Scene( root );
    theStage.setScene( theScene );
    
    Canvas canvas = new Canvas( 400, 200 );
    root.getChildren().add( canvas );
    
    GraphicsContext gc = canvas.getGraphicsContext2D();
    
    gc.setFill( Color.RED );
    gc.setStroke( Color.BLACK );
    gc.setLineWidth(2);
    Font theFont = Font.font( "Times New Roman", FontWeight.BOLD, 48 );
    gc.setFont( theFont );
    gc.fillText( "Hello, World!", 60, 50 );
    gc.strokeText( "Hello, World!", 60, 50 );
    
    Image earth = new Image( "earth.png" );
    gc.drawImage( earth, 180, 100 );
    
    theStage.show();
}
 
Example 17
Source Project: openstock   Source File: FXGraphics2D.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the font to be used for drawing text.
 * 
 * @param font  the font ({@code null} is permitted but ignored).
 * 
 * @see #getFont() 
 */
@Override
public void setFont(Font font) {
    if (font == null) {
        return;
    }
    this.font = font;
    FontWeight weight = font.isBold() ? FontWeight.BOLD : FontWeight.NORMAL;
    FontPosture posture = font.isItalic() 
            ? FontPosture.ITALIC : FontPosture.REGULAR;
    this.gc.setFont(javafx.scene.text.Font.font(font.getFamily(), 
            weight, posture, font.getSize()));
}
 
Example 18
Source Project: mzmine3   Source File: FontParameter.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void loadValueFromXML(Element xmlElement) {
  NodeList colorNodes = xmlElement.getElementsByTagName("color");
  if (colorNodes.getLength() != 1)
    return;
  NodeList fontNodes = xmlElement.getElementsByTagName("font");
  if (fontNodes.getLength() != 1)
    return;
  String scolor = colorNodes.item(0).getTextContent();
  String sfont = fontNodes.item(0).getTextContent();

  try {
    // font
    String[] s = sfont.split(",");
    String name = s[0];
    FontWeight style = FontWeight.findByName(s[1]);
    double size = Double.valueOf(s[2]);
    Font f = Font.font(name, style, size);

    // color
    s = scolor.split(",");
    double r = Double.valueOf(s[0]);
    double g = Double.valueOf(s[1]);
    double b = Double.valueOf(s[2]);
    double a = Double.valueOf(s[3]);
    Color c = new Color(r, g, b, a);

    value = new FontSpecs(c, f);
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
Example 19
Source Project: img2latex-mathpix   Source File: CopiedButton.java    License: Apache License 2.0 5 votes vote down vote up
public CopiedButton() {

        setText("COPIED");
        setPrefHeight(20);
        // white text colour
        setTextFill(Color.WHITE);
        setFont(Font.font("Arial Black", FontWeight.BOLD, 10));
        // blue background
        setBackground(new Background(new BackgroundFill(UIUtils.LIGHT_BLUE, RADII, Insets.EMPTY)));

    }
 
Example 20
Source Project: PDF4Teachers   Source File: TextTreeItem.java    License: Apache License 2.0 5 votes vote down vote up
public LinkedHashMap<Object, Object> getYAMLData(){
	LinkedHashMap<Object, Object> data = new LinkedHashMap<>();
	data.put("color", color.get().toString());
	data.put("font", font.get().getFamily());
	data.put("size", font.get().getSize());
	data.put("bold", FontUtils.getFontWeight(font.get()) == FontWeight.BOLD);
	data.put("italic", FontUtils.getFontPosture(font.get()) == FontPosture.ITALIC);
	data.put("uses", uses);
	data.put("date", creationDate);
	data.put("text", text);

	return data;
}
 
Example 21
Source Project: PDF4Teachers   Source File: FontUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static FontWeight getFontWeight(Font font) {

        String[] style = font.getStyle().split(" ");
        if(style.length >= 1){
            if(style[0].equals("Bold")){
                return FontWeight.BOLD;
            }
        }

        return FontWeight.NORMAL;
    }
 
Example 22
Source Project: Quelea   Source File: BibleSearchTreeView.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void trigger(Event t) {
    BibleSearchTreeView tv = (BibleSearchTreeView) t.getSource();
    TreeItem<BibleInterface> ti = tv.getSelectionModel().getSelectedItem();
    if (ti != null) {
        if (ti.getValue() instanceof BibleVerse) {
            textPane.getChildren().clear();
            BibleChapter chapter = (BibleChapter) ti.getValue().getParent();
            BibleVerse[] verses = chapter.getVerses();
            BibleVerse selected = (BibleVerse) ti.getValue();

            int x = selected.getNum() - 1;
            for (int i = 0; i < verses.length; i++) {
                Text text = new Text(verses[i].toString() + " ");
                text.getStyleClass().add("text");
                if (i == x) {
                    text.setFont(Font.font("Sans", FontWeight.BOLD, 14));
                } else {
                    text.setFont(Font.font("Sans", 14));
                }
                textPane.getChildren().add(text);
                text.wrappingWidthProperty().bind(sp.widthProperty().subtract(20)); //-20 to account for scroll bar width
            }
        } else {
            ti.setExpanded(!ti.isExpanded());
        }
    } else {
        tv.selectionModelProperty().get().selectFirst();
    }
}
 
Example 23
Source Project: JFoenix   Source File: JFXDatePickerContent.java    License: Apache License 2.0 5 votes vote down vote up
protected BorderPane createCalendarMonthLabelPane() {
    monthYearLabel = new Label();
    monthYearLabel.getStyleClass().add(SPINNER_LABEL);
    monthYearLabel.setFont(Font.font(ROBOTO, FontWeight.BOLD, 13));
    monthYearLabel.setTextFill(DEFAULT_COLOR);

    BorderPane monthContainer = new BorderPane();
    monthContainer.setMinHeight(50);
    monthContainer.setCenter(monthYearLabel);
    monthContainer.setPadding(new Insets(2, 12, 2, 12));
    return monthContainer;
}
 
Example 24
Source Project: Quelea   Source File: Timer.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void setFontSize(double pickFontSize) {
    setFont(Font.font(theme.getFont().getFamily(),
            theme.isBold() ? FontWeight.BOLD : FontWeight.NORMAL,
            theme.isItalic() ? FontPosture.ITALIC : FontPosture.REGULAR,
            pickFontSize));

}
 
Example 25
Source Project: Quelea   Source File: FontOptionsDialog.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get the font represented on this dialog.
 *
 * @return the font.
 */
public SerializableFont getTranslateFont() {
    return new SerializableFont(Font.font(fontSelection.getSelectionModel().getSelectedItem(),
            boldButton.isSelected() ? FontWeight.BOLD : FontWeight.NORMAL,
            italicButton.isSelected() ? FontPosture.ITALIC : FontPosture.REGULAR,
            QueleaProperties.get().getMaxFontSize()));
}
 
Example 26
Source Project: Quelea   Source File: StageDrawer.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Determine the largest font size we can safely use for every section of a
 * text displayable.
 * <p>
 * @param displayable the displayable to check.
 * @return the font size to use
 */
private double getUniformFontSize(TextDisplayable displayable) {
    if (!QueleaProperties.get().getUseUniformFontSize()) {
        return -1;
    }
    Font font = theme.getFont();
    font = Font.font(font.getName(),
            theme.isBold() ? FontWeight.BOLD : FontWeight.NORMAL,
            theme.isItalic() ? FontPosture.ITALIC : FontPosture.REGULAR,
            QueleaProperties.get().getMaxFontSize());
    double fontSize = Double.POSITIVE_INFINITY;
    for (TextSection section : displayable.getSections()) {
        String[] textArr;
        if (QueleaProperties.get().getShowChords()) {
            textArr = section.getText(true, false);
        } else {
            textArr = section.getText(false, false);
        }
        double newSize;
        List<LyricLine> newText;
        if (displayable instanceof BiblePassage) {
            newText = new ArrayList<>();
            for (String str : section.getText(false, false)) {
                for (String line : str.split("\n")) {
                    newText.add(new LyricLine(line));
                }
            }
        } else {
            newText = sanctifyText(textArr);
        }
        newSize = pickFontSize(font, newText, getCanvas().getWidth() * 0.92, getCanvas().getHeight() * 0.9);
        if (newSize < fontSize) {
            fontSize = newSize;
        }
    }
    if (fontSize == Double.POSITIVE_INFINITY) {
        fontSize = -1;
    }
    return fontSize;
}
 
Example 27
Source Project: buffer_bci   Source File: FXGraphics2D.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the font to be used for drawing text.
 * 
 * @param font  the font ({@code null} is permitted but ignored).
 * 
 * @see #getFont() 
 */
@Override
public void setFont(Font font) {
    if (font == null) {
        return;
    }
    this.font = font;
    FontWeight weight = font.isBold() ? FontWeight.BOLD : FontWeight.NORMAL;
    FontPosture posture = font.isItalic() 
            ? FontPosture.ITALIC : FontPosture.REGULAR;
    this.gc.setFont(javafx.scene.text.Font.font(font.getFamily(), 
            weight, posture, font.getSize()));
}
 
Example 28
Source Project: Enzo   Source File: LcdSkin.java    License: Apache License 2.0 5 votes vote down vote up
private void updateFonts() {
    digitalFontSizeFactor = 1.0;
    switch(getSkinnable().getValueFont()) {
        case LCD:
            valueFont = Font.font("Digital-7", (0.6 * height));
            digitalFontSizeFactor = 1.4;
            break;
        case DIGITAL:
            valueFont = Font.font("Digital Readout Upright", (0.5833333333 * height));
            break;
        case DIGITAL_BOLD:
            valueFont = Font.font("Digital Readout Thick Upright", (0.5833333333 * height));
            break;
        case ELEKTRA:
            valueFont = Font.font("Elektra", (0.62 * height));
            break;
        case STANDARD:
        default:
            valueFont = Font.font("Open Sans", FontWeight.NORMAL, (0.5 * height));
            break;
    }
    backgroundText.setFont(valueFont);
    backgroundText.setOpacity((Lcd.LcdFont.LCD == getSkinnable().getValueFont() ||
                               Lcd.LcdFont.DIGITAL == getSkinnable().getValueFont() ||
                               Lcd.LcdFont.DIGITAL_BOLD == getSkinnable().getValueFont() ||
                               Lcd.LcdFont.ELEKTRA == getSkinnable().getValueFont()) &&
                               !getSkinnable().isTextMode() ? 1 : 0);
    text.setFont(valueFont);
    unitFont  = Font.font(getSkinnable().getUnitFont(), FontWeight.NORMAL, (0.26 * height));
    titleFont = Font.font(getSkinnable().getTitleFont(), FontWeight.BOLD, (0.1666666667 * height));
    smallFont = Font.font(getSkinnable().getSmallFont(), FontWeight.NORMAL, (0.1666666667 * height));
}
 
Example 29
Source Project: marathonv5   Source File: InnerShadowSample.java    License: Apache License 2.0 5 votes vote down vote up
public static Node createIconContent() {
    Text sample = new Text("FX");
    sample.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD,80));
    sample.setStyle("-fx-font-size: 80px;");
    sample.setFill(Color.web("#aaaaaa"));
    final InnerShadow innerShadow = new InnerShadow();
    innerShadow.setRadius(4);
    innerShadow.setOffsetX(1);
    innerShadow.setOffsetY(1);
    innerShadow.setColor(Color.web("#333333"));
    sample.setEffect(innerShadow);
    return sample;
}
 
Example 30
Source Project: marathonv5   Source File: GaussianBlurSample.java    License: Apache License 2.0 5 votes vote down vote up
public static Node createIconContent() {

        Text sample = new Text("FX");
        sample.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD,80));
        sample.setStyle("-fx-font-size: 80px;");
        sample.setFill(Color.web("#333333"));
        final GaussianBlur GaussianBlur = new GaussianBlur();
        GaussianBlur.setRadius(15);
        sample.setEffect(GaussianBlur);
        return sample;
    }