javafx.scene.text.FontPosture Java Examples

The following examples show how to use javafx.scene.text.FontPosture. 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: PluginParametersPane.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
public Pane getParamPane(final PluginParametersNode node) {
    if (node.getChildren().isEmpty()) {
        return null;
    }
    if (currentChild == -1) {
        titleLabel = new Label(title);
        titleLabel.setFont(Font.font(Font.getDefault().getFamily(), FontPosture.ITALIC, fontSize));
        final Separator separator = new Separator();
        separator.setStyle("-fx-background-color:#444444;");
        HBox separatorBox = new HBox(separator);
        HBox.setHgrow(separator, Priority.ALWAYS);
        HBox.setMargin(separator, new Insets(PADDING, 0, 0, 0));
        return new VBox(titleLabel, separatorBox);
    }
    final Pane paramPane = super.getParamPane(node);
    final SimpleDoubleProperty updated = new SimpleDoubleProperty();
    updated.bind(Bindings.max(maxParamWidth, paramPane.widthProperty()));
    maxParamWidth = updated;
    if (titleLabel != null) {
        titleLabel.prefWidthProperty().bind(maxParamWidth);
    }
    return paramPane;
}
 
Example #2
Source File: FXGraphics2D.java    From buffer_bci with GNU General Public License v3.0 6 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 #3
Source File: FXGraphics2D.java    From buffer_bci with GNU General Public License v3.0 6 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 #4
Source File: FXGraphics2D.java    From ECG-Viewer with GNU General Public License v2.0 6 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 #5
Source File: Exercise_16_14.java    From Intro-to-Java-Programming with MIT License 6 votes vote down vote up
private FontPosture getPosture() {
	return chkItalic.isSelected() ? FontPosture.ITALIC : FontPosture.REGULAR;
}
 
Example #6
Source File: GeneralOptionsPane.java    From markdown-writer-fx with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Return a list of all the mono-spaced fonts on the system.
 *
 * @author David D. Clark http://clarkonium.net/2015/07/finding-mono-spaced-fonts-in-javafx/
 */
private static Collection<String> getMonospacedFonts() {

	// Compare the layout widths of two strings. One string is composed
	// of "thin" characters, the other of "wide" characters. In mono-spaced
	// fonts the widths should be the same.

	final Text thinTxt = new Text("1 l"); // note the space
	final Text thikTxt = new Text("MWX");

	List<String> fontFamilyList = Font.getFamilies();
	List<String> monospacedFonts = new ArrayList<>();

	for (String fontFamilyName : fontFamilyList) {
		Font font = Font.font(fontFamilyName, FontWeight.NORMAL, FontPosture.REGULAR, 14.0d);
		thinTxt.setFont(font);
		thikTxt.setFont(font);
		if (thinTxt.getLayoutBounds().getWidth() == thikTxt.getLayoutBounds().getWidth())
			monospacedFonts.add(fontFamilyName);
	}

	return monospacedFonts;
}
 
Example #7
Source File: FXGraphics2D.java    From SIMVA-SoS with Apache License 2.0 6 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 #8
Source File: FXGraphics2D.java    From ccu-historian with GNU General Public License v3.0 6 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 #9
Source File: XMLPersistence.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** Load font from XML document
 *  @param node Parent node of the color
 *  @param font_tag Name of tag that contains the font
 *  @return {@link Font}
 */
public static Optional<Font> loadFontFromDocument(final Element node, final String font_tag)
{
    final String desc = XMLUtil.getChildString(node, font_tag).orElse("");
    if (desc.isEmpty())
        return Optional.empty();

    String family = DEFAULT_FONT_FAMILY;
    FontPosture posture = FontPosture.REGULAR;
    FontWeight weight = FontWeight.NORMAL;
    double size = DEFAULT_FONT_SIZE;

    // Legacy format was "Liberation Sans|20|1"
    final String[] items = desc.split("\\|");
    if (items.length == 3)
    {
        family = items[0];
        size = Double.parseDouble(items[1]);
        switch (items[2])
        {
        case "1": // SWT.BOLD
            weight = FontWeight.BOLD;
            break;
        case "2": // SWT.ITALIC
            posture = FontPosture.ITALIC;
            break;
        case "3": // SWT.BOLD | SWT.ITALIC
            weight = FontWeight.BOLD;
            posture = FontPosture.ITALIC;
            break;
        }
    }
    return Optional.of(Font.font(family, weight, posture, size ));
}
 
Example #10
Source File: GraphicsUtils.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** Convert font
 *  @param font AWT font
 *  @return JFX font
 */
public static Font convert(final java.awt.Font font)
{
    final FontWeight weight = font.isBold() ? FontWeight.BOLD : FontWeight.NORMAL;
    final FontPosture posture = font.isItalic() ? FontPosture.ITALIC : FontPosture.REGULAR;
    return Font.font(font.getFamily(), weight, posture, font.getSize());
}
 
Example #11
Source File: JFXUtil.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** Convert model font into JFX font
 *  @param font {@link WidgetFont}
 *  @return {@link Font}
 */
public static Font convert(final WidgetFont font)
{
    return fontCache.computeIfAbsent(font, f ->
    {
        final double calibrated = f.getSize() * font_calibration;
        switch (f.getStyle())
        {
        case BOLD:
            return Font.font(f.getFamily(), FontWeight.BOLD,   FontPosture.REGULAR, calibrated);
        case ITALIC:
            return Font.font(f.getFamily(), FontWeight.NORMAL, FontPosture.ITALIC,  calibrated);
        case BOLD_ITALIC:
            return Font.font(f.getFamily(), FontWeight.BOLD,   FontPosture.ITALIC,  calibrated);
        default:
            return Font.font(f.getFamily(), FontWeight.NORMAL, FontPosture.REGULAR, calibrated);
        }
    });
}
 
Example #12
Source File: StatusBar.java    From marathonv5 with 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 #13
Source File: SerializableFont.java    From Quelea with GNU General Public License v3.0 6 votes vote down vote up
public Font getFont() {
    Font ret;
    if(isBold() && isItalic()) {
        ret = Font.font(family, FontWeight.BOLD, FontPosture.ITALIC, size);
    }
    else if(isBold()) {
        ret = Font.font(family, FontWeight.BOLD, FontPosture.REGULAR, size);
    }
    else if(isItalic()) {
        ret = Font.font(family, FontWeight.NORMAL, FontPosture.ITALIC, size);
    }
    else {
        ret = Font.font(family, size);
    }
    return ret;
}
 
Example #14
Source File: FontUtils.java    From PDF4Teachers with Apache License 2.0 6 votes vote down vote up
public static FontPosture getFontPosture(Font font) {

        String[] style = font.getStyle().split(" ");
        if(style.length == 1){
            if(style[0].equals("Italic")){
                return FontPosture.ITALIC;
            }
        }else if(style.length == 2){
            if(style[1].equals("Italic")){
                return FontPosture.ITALIC;
            }
        }
        return FontPosture.REGULAR;
    }
 
Example #15
Source File: FXGraphics2D.java    From openstock with GNU General Public License v3.0 6 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 #16
Source File: AttributeCalculatorPane.java    From constellation with 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 #17
Source File: PluginParametersPane.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
public Pane getParamPane(final PluginParametersNode node) {
    if (node.getChildren().isEmpty()) {
        return null;
    }
    if (currentChild == -1) {
        warningLabel = new Label(message);
        warningLabel.setFont(Font.font(Font.getDefault().getFamily(), FontPosture.ITALIC, fontSize));
        warningLabel.setWrapText(true);
        warningLabel.setAlignment(Pos.CENTER);
        final HBox warning = new HBox(warningIcon, warningLabel);
        warning.setStyle("-fx-border-color: red");
        return new VBox(warning);
    }
    final Pane paramPane = super.getParamPane(node);
    final SimpleDoubleProperty updated = new SimpleDoubleProperty();
    updated.bind(Bindings.max(maxParamWidth, paramPane.widthProperty()));
    maxParamWidth = updated;
    warningLabel.prefWidthProperty().bind(maxParamWidth);
    return paramPane;
}
 
Example #18
Source File: CFileChooser.java    From Open-Lowcode with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Node getNode(
		PageActionManager actionmanager,
		CPageData inputdata,
		Window parentwindow,
		TabPane[] parenttabpanes,
		CollapsibleNode nodetocollapsewhenactiontriggered) {

	FlowPane thispane = new FlowPane();
	Label thislabel = new Label(title);
	thislabel.setFont(Font.font(thislabel.getFont().getName(), FontPosture.ITALIC, thislabel.getFont().getSize()));
	thislabel.setMinWidth(120);
	thislabel.setWrapText(true);
	thislabel.setMaxWidth(120);
	thispane.setRowValignment(VPos.TOP);
	thispane.getChildren().add(thislabel);

	filepathfield = new TextField();
	Button loadfromfile = new Button("Select");
	loadfromfile.setStyle("-fx-base: #ffffff; -fx-hover-base: #ddeeff;");
	thispane.getChildren().add(filepathfield);
	thispane.getChildren().add(loadfromfile);
	loadfromfile.setOnAction(new EventHandler<ActionEvent>() {

		@Override
		public void handle(ActionEvent arg0) {
			FileChooser fileChooser = new FileChooser();
			selectedfile = fileChooser.showOpenDialog(null);
			if (selectedfile != null)
				filepathfield.setText(selectedfile.getAbsolutePath());
		}
	});

	return thispane;
}
 
Example #19
Source File: FontButtonDemo.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void start(final Stage stage) throws Exception
{
    final Font initial_font = Font.font("Liberation Sans", FontWeight.BOLD, FontPosture.ITALIC, 12.0);
    final FontButton button = new FontButton(initial_font, font ->
    {
        System.out.println("Selected " + font);
    });
    final BorderPane layout = new BorderPane(button);
    final Scene scene = new Scene(layout, 300, 300);
    stage.setScene(scene);
    stage.show();
}
 
Example #20
Source File: GradeElementRenderer.java    From PDF4Teachers with Apache License 2.0 5 votes vote down vote up
public void renderElement(GradeElement element, PDPageContentStream contentStream, PDPage page, float pageWidth, float pageHeight, float pageRealWidth, float pageRealHeight, float startX, float startY) throws IOException {

        if(!element.isVisible()) return;

        // COLOR
        Color color = element.getColor();
        contentStream.setNonStrokingColor(new java.awt.Color((float) color.getRed(), (float) color.getGreen(), (float) color.getBlue(), (float) color.getOpacity()));

        // FONT
        boolean bold = false;
        if (FontUtils.getFontWeight(element.getFont()) == FontWeight.BOLD) bold = true;
        boolean italic = false;
        if (FontUtils.getFontPosture(element.getFont()) == FontPosture.ITALIC) italic = true;
        InputStream fontFile = FontUtils.getFontFile(element.getFont().getFamily(), italic, bold);
        element.setFont(FontUtils.getFont(element.getFont().getFamily(), italic, bold, element.getFont().getSize() / 596.0 * pageWidth));

        contentStream.beginText();

        // CUSTOM STREAM

        Map.Entry<String, String> entry = Map.entry(element.getFont().getFamily(), FontUtils.getFontFileName(italic, bold));

        if(!fonts.containsKey(entry)){
            PDType0Font font = PDType0Font.load(doc, fontFile);
            contentStream.setFont(font, (float) element.getFont().getSize());
            fonts.put(entry, font);
        }else{
            contentStream.setFont(fonts.get(entry), (float) element.getFont().getSize());
        }

        float bottomMargin = pageRealHeight-pageHeight-startY;
        contentStream.newLineAtOffset(startX + element.getRealX() / Element.GRID_WIDTH * pageWidth, bottomMargin + pageRealHeight - element.getBaseLineY() - element.getRealY() / Element.GRID_HEIGHT * pageHeight);
        try{
            contentStream.showText(element.getText());
        }catch(IllegalArgumentException e){
            e.printStackTrace();
            System.err.println("Erreur : impossible d'écrire la note : \"" + element.getText() + "\" avec la police " + element.getFont().getFamily());
            System.err.println("Message d'erreur : " + e.getMessage());
        }
        contentStream.endText();

    }
 
Example #21
Source File: TemplateManager.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void initialize(final URL location, final ResourceBundle resources) {
	mainPane.managedProperty().bind(mainPane.visibleProperty());
	emptyLabel.managedProperty().bind(emptyLabel.visibleProperty());
	emptyLabel.visibleProperty().bind(Bindings.createBooleanBinding(() -> templatePane.getChildren().isEmpty(), templatePane.getChildren()));
	emptyLabel.setFont(Font.font(emptyLabel.getFont().getFamily(), FontPosture.ITALIC, emptyLabel.getFont().getSize()));

	Command.executeAndFlush(new UpdateTemplates(templatePane, svgGen, false));

	setActivated(true);
	templatePane.setCursor(Cursor.MOVE);
}
 
Example #22
Source File: IconSwitchSkin.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private void resize() {
    width  = getSkinnable().getWidth();
    height = getSkinnable().getHeight();
    size   = width < height ? width : height;

    if (width > 0 && height > 0) {
        if (aspectRatio * width > height) {
            width = 1 / (aspectRatio / height);
        } else if (1 / (aspectRatio / height) > width) {
            height = aspectRatio * width;
        }

        font = Font.font("Open Sans", FontWeight.BOLD, FontPosture.REGULAR, height * 0.5);

        background.setPrefSize(width, height);

        symbol.setPrefSize(height * 0.59375 * getSkinnable().getSymbolType().WIDTH_FACTOR, height * 0.59375 * getSkinnable().getSymbolType().HEIGHT_FACTOR);
        symbol.relocate(height * 0.15 + (height * 0.59375 - height * 0.59375 * getSkinnable().getSymbolType().WIDTH_FACTOR) * 0.5,
                        height * 0.18 + (height * 0.59375 - height * 0.59375 * getSkinnable().getSymbolType().HEIGHT_FACTOR) * 0.5);

        text.setFont(font);
        text.setVisible(!getSkinnable().getText().isEmpty() && SymbolType.NONE == getSkinnable().getSymbolType());
        text.setPrefSize(height * 0.59375, height * 0.59375);
        text.relocate(height * 0.125, height * 0.15);

        thumb.setPrefSize((height * 0.75), (height * 0.75));
        thumb.setTranslateX(getSkinnable().isSelected() ? height * 1.625 : height * 0.875);
        thumb.setTranslateY(height * 0.125);

        moveToDeselected.setFromX(height * 1.625);
        moveToDeselected.setToX(height * 0.875);

        moveToSelected.setFromX(height * 0.875);
        moveToSelected.setToX(height * 1.625);
    }
}
 
Example #23
Source File: OnOffSwitchSkin.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private void resize() {
    width  = getSkinnable().getWidth();
    height = getSkinnable().getHeight();

    if (width > 0 && height > 0) {
        if (aspectRatio * width > height) {
            width = 1 / (aspectRatio / height);
        } else if (1 / (aspectRatio / height) > width) {
            height = aspectRatio * width;
        }

        font = Font.font("Open Sans", FontWeight.EXTRA_BOLD, FontPosture.REGULAR, 0.5 * height);

        background.setPrefSize(width, height);

        selectedText.setFont(font);
        selectedText.setTextOrigin(VPos.CENTER);
        selectedText.relocate(height * 0.3125, (height - selectedText.getLayoutBounds().getHeight()) * 0.5);

        deselectedText.setFont(font);
        deselectedText.setTextOrigin(VPos.CENTER);
        deselectedText.relocate(width - height * 0.3125 - deselectedText.getLayoutBounds().getWidth(), (height - deselectedText.getLayoutBounds().getHeight()) * 0.5);

        thumb.setPrefSize((height * 0.75), (height * 0.75));
        thumb.setTranslateX(getSkinnable().isSelected() ? height * 1.125 : height * 0.125);
        thumb.setTranslateY(height * 0.125);

        moveToDeselected.setFromX(height * 1.125);
        moveToDeselected.setToX(height * 0.125);

        moveToSelected.setFromX(height * 0.125);
        moveToSelected.setToX(height * 1.125);
    }
}
 
Example #24
Source File: FontButton.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
private void updateFont()
{
    if (size.getValue() == null)
        return;
    final double s = Double.parseDouble(size.getValue());
    font = Font.font(families.getValue(),
                     bold.isSelected() ? FontWeight.BOLD : FontWeight.NORMAL,
                     italic.isSelected() ? FontPosture.ITALIC : FontPosture.REGULAR,
                     s);
    example.setFont(font);
}
 
Example #25
Source File: Status.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public Status() {
    super("Ready");
    Font font = getFont();
    double size = font.getSize();
    setFont(Font.font("Arial", FontWeight.BOLD, FontPosture.ITALIC, size - 1));
    setPrefHeight(size + 14);
    setAlignment(Pos.CENTER);
}
 
Example #26
Source File: TextListItem.java    From PDF4Teachers with 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.toString());
    data.put("font", font.getFamily());
    data.put("size", font.getSize());
    data.put("bold", FontUtils.getFontWeight(font) == FontWeight.BOLD);
    data.put("italic", FontUtils.getFontPosture(font) == FontPosture.ITALIC);
    data.put("uses", uses);
    data.put("date", creationDate);
    data.put("text", text);

    return data;
}
 
Example #27
Source File: Timer.java    From Quelea with 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 #28
Source File: FontOptionsDialog.java    From Quelea with 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 #29
Source File: StageDrawer.java    From Quelea with 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 #30
Source File: TextTreeItem.java    From PDF4Teachers with 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;
}